chore: remove native_mate (Part 11) (#20719)

* refactor: convert Menu and globalShortcut to gin

* refactor: convert api::Cookies to gin

* refactor: convert View and WebContentsView to gin

* refactor: convert WebContents related classes to gin

* refactor: convert powerMonitor to gin

* refactor: prepare for header change

* refactor: remove last uses of mate::EventEmitter

* refactor: remove mate::EventEmitter

* refactor: move trackable_object to gin_helper

* fix: custom converter should not use Handle

* fix: no more need to check if icon is empty

It was a bug that the Handle<NativeImage> can be non-empty when the
image file does not exist. The bug was caused by the converter code
writing out the image even when the convertion fails.

The bug was work-arounded by adding an additional check, but since the
original bug had been fixed, the additional check is no longer needed.

* fix: should always set frameId even when callback is null

* fix: do not mix gin/mate handles for NativeImage
This commit is contained in:
Cheng Zhao 2019-10-25 22:03:28 +09:00 committed by GitHub
parent 0e0d4fe990
commit 0fe6767d6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 823 additions and 1087 deletions

View file

@ -11,9 +11,9 @@
#include "base/values.h"
#include "content/public/browser/download_manager.h"
#include "electron/buildflags/buildflags.h"
#include "native_mate/handle.h"
#include "shell/browser/api/trackable_object.h"
#include "gin/handle.h"
#include "shell/browser/net/resolve_proxy_helper.h"
#include "shell/common/gin_helper/trackable_object.h"
#include "shell/common/promise_util.h"
class GURL;
@ -22,10 +22,9 @@ namespace base {
class FilePath;
}
namespace mate {
class Arguments;
namespace gin_helper {
class Dictionary;
} // namespace mate
}
namespace net {
class ProxyConfig;
@ -37,56 +36,58 @@ class AtomBrowserContext;
namespace api {
class Session : public mate::TrackableObject<Session>,
class Session : public gin_helper::TrackableObject<Session>,
public content::DownloadManager::Observer {
public:
// Gets or creates Session from the |browser_context|.
static mate::Handle<Session> CreateFrom(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
static gin::Handle<Session> CreateFrom(v8::Isolate* isolate,
AtomBrowserContext* browser_context);
// Gets the Session of |partition|.
static mate::Handle<Session> FromPartition(
static gin::Handle<Session> FromPartition(
v8::Isolate* isolate,
const std::string& partition,
const base::DictionaryValue& options = base::DictionaryValue());
AtomBrowserContext* browser_context() const { return browser_context_.get(); }
// mate::TrackableObject:
// gin_helper::TrackableObject:
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
// Methods.
v8::Local<v8::Promise> ResolveProxy(mate::Arguments* args);
v8::Local<v8::Promise> ResolveProxy(gin_helper::Arguments* args);
v8::Local<v8::Promise> GetCacheSize();
v8::Local<v8::Promise> ClearCache();
v8::Local<v8::Promise> ClearStorageData(mate::Arguments* args);
v8::Local<v8::Promise> ClearStorageData(gin_helper::Arguments* args);
void FlushStorageData();
v8::Local<v8::Promise> SetProxy(mate::Arguments* args);
v8::Local<v8::Promise> SetProxy(gin_helper::Arguments* args);
void SetDownloadPath(const base::FilePath& path);
void EnableNetworkEmulation(const mate::Dictionary& options);
void EnableNetworkEmulation(const gin_helper::Dictionary& options);
void DisableNetworkEmulation();
void SetCertVerifyProc(v8::Local<v8::Value> proc, mate::Arguments* args);
void SetCertVerifyProc(v8::Local<v8::Value> proc,
gin_helper::Arguments* args);
void SetPermissionRequestHandler(v8::Local<v8::Value> val,
mate::Arguments* args);
gin_helper::Arguments* args);
void SetPermissionCheckHandler(v8::Local<v8::Value> val,
mate::Arguments* args);
v8::Local<v8::Promise> ClearHostResolverCache(mate::Arguments* args);
gin_helper::Arguments* args);
v8::Local<v8::Promise> ClearHostResolverCache(gin_helper::Arguments* args);
v8::Local<v8::Promise> ClearAuthCache();
void AllowNTLMCredentialsForDomains(const std::string& domains);
void SetUserAgent(const std::string& user_agent, mate::Arguments* args);
void SetUserAgent(const std::string& user_agent, gin_helper::Arguments* args);
std::string GetUserAgent();
v8::Local<v8::Promise> GetBlobData(v8::Isolate* isolate,
const std::string& uuid);
void DownloadURL(const GURL& url);
void CreateInterruptedDownload(const mate::Dictionary& options);
void CreateInterruptedDownload(const gin_helper::Dictionary& options);
void SetPreloads(const std::vector<base::FilePath::StringType>& preloads);
std::vector<base::FilePath::StringType> GetPreloads() const;
v8::Local<v8::Value> Cookies(v8::Isolate* isolate);
v8::Local<v8::Value> Protocol(v8::Isolate* isolate);
v8::Local<v8::Value> WebRequest(v8::Isolate* isolate);
v8::Local<v8::Value> NetLog(v8::Isolate* isolate);
void Preconnect(const mate::Dictionary& options, mate::Arguments* args);
void Preconnect(const gin_helper::Dictionary& options,
gin_helper::Arguments* args);
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
void LoadChromeExtension(const base::FilePath extension_path);