Make Wrappable a template class

This commit is contained in:
Cheng Zhao 2016-04-25 10:17:54 +09:00
parent a8f08e1fab
commit 2ae52d0ff4
52 changed files with 367 additions and 349 deletions

View file

@ -194,10 +194,11 @@ int ImportIntoCertStore(
} // namespace } // namespace
App::App() { App::App(v8::Isolate* isolate) {
static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(this); static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())->set_delegate(this);
Browser::Get()->AddObserver(this); Browser::Get()->AddObserver(this);
content::GpuDataManager::GetInstance()->AddObserver(this); content::GpuDataManager::GetInstance()->AddObserver(this);
Init(isolate);
} }
App::~App() { App::~App() {
@ -439,10 +440,16 @@ void App::OnCertificateManagerModelCreated(
} }
#endif #endif
mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( // static
v8::Isolate* isolate) { mate::Handle<App> App::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new App(isolate));
}
// static
void App::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
auto browser = base::Unretained(Browser::Get()); auto browser = base::Unretained(Browser::Get());
return mate::ObjectTemplateBuilder(isolate) mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("quit", base::Bind(&Browser::Quit, browser)) .SetMethod("quit", base::Bind(&Browser::Quit, browser))
.SetMethod("exit", base::Bind(&Browser::Exit, browser)) .SetMethod("exit", base::Bind(&Browser::Exit, browser))
.SetMethod("focus", base::Bind(&Browser::Focus, browser)) .SetMethod("focus", base::Bind(&Browser::Focus, browser))
@ -484,11 +491,6 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder(
.SetMethod("makeSingleInstance", &App::MakeSingleInstance); .SetMethod("makeSingleInstance", &App::MakeSingleInstance);
} }
// static
mate::Handle<App> App::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new App);
}
} // namespace api } // namespace api
} // namespace atom } // namespace atom

View file

@ -33,12 +33,15 @@ namespace atom {
namespace api { namespace api {
class App : public AtomBrowserClient::Delegate, class App : public AtomBrowserClient::Delegate,
public mate::EventEmitter, public mate::EventEmitter<App>,
public BrowserObserver, public BrowserObserver,
public content::GpuDataManagerObserver { public content::GpuDataManagerObserver {
public: public:
static mate::Handle<App> Create(v8::Isolate* isolate); static mate::Handle<App> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
// Called when window with disposition needs to be created. // Called when window with disposition needs to be created.
void OnCreateWindow(const GURL& target_url, void OnCreateWindow(const GURL& target_url,
const std::string& frame_name, const std::string& frame_name,
@ -54,8 +57,8 @@ class App : public AtomBrowserClient::Delegate,
#endif #endif
protected: protected:
App(); explicit App(v8::Isolate* isolate);
virtual ~App(); ~App() override;
// BrowserObserver: // BrowserObserver:
void OnBeforeQuit(bool* prevent_default) override; void OnBeforeQuit(bool* prevent_default) override;
@ -93,10 +96,6 @@ class App : public AtomBrowserClient::Delegate,
void OnPlatformThemeChanged() override; void OnPlatformThemeChanged() override;
#endif #endif
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
private: private:
// Get/Set the pre-defined path in PathService. // Get/Set the pre-defined path in PathService.
base::FilePath GetPath(mate::Arguments* args, const std::string& name); base::FilePath GetPath(mate::Arguments* args, const std::string& name);

View file

@ -34,8 +34,9 @@ namespace atom {
namespace api { namespace api {
AutoUpdater::AutoUpdater() { AutoUpdater::AutoUpdater(v8::Isolate* isolate) {
auto_updater::AutoUpdater::SetDelegate(this); auto_updater::AutoUpdater::SetDelegate(this);
Init(isolate);
} }
AutoUpdater::~AutoUpdater() { AutoUpdater::~AutoUpdater() {
@ -78,14 +79,6 @@ void AutoUpdater::OnWindowAllClosed() {
QuitAndInstall(); QuitAndInstall();
} }
mate::ObjectTemplateBuilder AutoUpdater::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("setFeedURL", &auto_updater::AutoUpdater::SetFeedURL)
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
}
void AutoUpdater::QuitAndInstall() { void AutoUpdater::QuitAndInstall() {
// If we don't have any window then quitAndInstall immediately. // If we don't have any window then quitAndInstall immediately.
WindowList* window_list = WindowList::GetInstance(); WindowList* window_list = WindowList::GetInstance();
@ -102,7 +95,16 @@ void AutoUpdater::QuitAndInstall() {
// static // static
mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) { mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new AutoUpdater); return CreateHandle(isolate, new AutoUpdater(isolate));
}
// static
void AutoUpdater::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("setFeedURL", &auto_updater::AutoUpdater::SetFeedURL)
.SetMethod("checkForUpdates", &auto_updater::AutoUpdater::CheckForUpdates)
.SetMethod("quitAndInstall", &AutoUpdater::QuitAndInstall);
} }
} // namespace api } // namespace api

View file

@ -16,15 +16,18 @@ namespace atom {
namespace api { namespace api {
class AutoUpdater : public mate::EventEmitter, class AutoUpdater : public mate::EventEmitter<AutoUpdater>,
public auto_updater::Delegate, public auto_updater::Delegate,
public WindowListObserver { public WindowListObserver {
public: public:
static mate::Handle<AutoUpdater> Create(v8::Isolate* isolate); static mate::Handle<AutoUpdater> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
AutoUpdater(); explicit AutoUpdater(v8::Isolate* isolate);
virtual ~AutoUpdater(); ~AutoUpdater() override;
// Delegate implementations. // Delegate implementations.
void OnError(const std::string& error) override; void OnError(const std::string& error) override;
@ -39,10 +42,6 @@ class AutoUpdater : public mate::EventEmitter,
// WindowListObserver: // WindowListObserver:
void OnWindowAllClosed() override; void OnWindowAllClosed() override;
// mate::Wrappable implementations:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
private: private:
void QuitAndInstall(); void QuitAndInstall();

View file

@ -186,8 +186,10 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
} // namespace } // namespace
Cookies::Cookies(content::BrowserContext* browser_context) Cookies::Cookies(v8::Isolate* isolate,
content::BrowserContext* browser_context)
: request_context_getter_(browser_context->GetRequestContext()) { : request_context_getter_(browser_context->GetRequestContext()) {
Init(isolate);
} }
Cookies::~Cookies() { Cookies::~Cookies() {
@ -223,7 +225,7 @@ void Cookies::Set(const base::DictionaryValue& details,
mate::Handle<Cookies> Cookies::Create( mate::Handle<Cookies> Cookies::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
content::BrowserContext* browser_context) { content::BrowserContext* browser_context) {
return mate::CreateHandle(isolate, new Cookies(browser_context)); return mate::CreateHandle(isolate, new Cookies(isolate, browser_context));
} }
// static // static

View file

@ -46,8 +46,8 @@ class Cookies : public mate::TrackableObject<Cookies> {
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit Cookies(content::BrowserContext* browser_context); Cookies(v8::Isolate* isolate, content::BrowserContext* browser_context);
~Cookies(); ~Cookies() override;
void Get(const base::DictionaryValue& filter, const GetCallback& callback); void Get(const base::DictionaryValue& filter, const GetCallback& callback);
void Remove(const GURL& url, const std::string& name, void Remove(const GURL& url, const std::string& name,

View file

@ -31,9 +31,10 @@ WrapDebuggerCallback g_wrap_debugger;
} // namespace } // namespace
Debugger::Debugger(content::WebContents* web_contents) Debugger::Debugger(v8::Isolate* isolate, content::WebContents* web_contents)
: web_contents_(web_contents), : web_contents_(web_contents),
previous_request_id_(0) { previous_request_id_(0) {
Init(isolate);
} }
Debugger::~Debugger() { Debugger::~Debugger() {
@ -150,7 +151,8 @@ void Debugger::SendCommand(mate::Arguments* args) {
mate::Handle<Debugger> Debugger::Create( mate::Handle<Debugger> Debugger::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
content::WebContents* web_contents) { content::WebContents* web_contents) {
auto handle = mate::CreateHandle(isolate, new Debugger(web_contents)); auto handle = mate::CreateHandle(
isolate, new Debugger(isolate, web_contents));
g_wrap_debugger.Run(handle.ToV8()); g_wrap_debugger.Run(handle.ToV8());
return handle; return handle;
} }

View file

@ -42,8 +42,8 @@ class Debugger: public mate::TrackableObject<Debugger>,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit Debugger(content::WebContents* web_contents); Debugger(v8::Isolate* isolate, content::WebContents* web_contents);
~Debugger(); ~Debugger() override;
// content::DevToolsAgentHostClient: // content::DevToolsAgentHostClient:
void AgentHostClosed(content::DevToolsAgentHost* agent_host, void AgentHostClosed(content::DevToolsAgentHost* agent_host,

View file

@ -38,7 +38,8 @@ namespace atom {
namespace api { namespace api {
DesktopCapturer::DesktopCapturer() { DesktopCapturer::DesktopCapturer(v8::Isolate* isolate) {
Init(isolate);
} }
DesktopCapturer::~DesktopCapturer() { DesktopCapturer::~DesktopCapturer() {
@ -92,15 +93,16 @@ bool DesktopCapturer::OnRefreshFinished() {
return false; return false;
} }
mate::ObjectTemplateBuilder DesktopCapturer::GetObjectTemplateBuilder( // static
v8::Isolate* isolate) { mate::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate) return mate::CreateHandle(isolate, new DesktopCapturer(isolate));
.SetMethod("startHandling", &DesktopCapturer::StartHandling);
} }
// static // static
mate::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) { void DesktopCapturer::BuildPrototype(
return mate::CreateHandle(isolate, new DesktopCapturer); v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("startHandling", &DesktopCapturer::StartHandling);
} }
} // namespace api } // namespace api

View file

@ -14,18 +14,21 @@ namespace atom {
namespace api { namespace api {
class DesktopCapturer: public mate::EventEmitter, class DesktopCapturer: public mate::EventEmitter<DesktopCapturer>,
public DesktopMediaListObserver { public DesktopMediaListObserver {
public: public:
static mate::Handle<DesktopCapturer> Create(v8::Isolate* isolate); static mate::Handle<DesktopCapturer> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
void StartHandling(bool capture_window, void StartHandling(bool capture_window,
bool capture_screen, bool capture_screen,
const gfx::Size& thumbnail_size); const gfx::Size& thumbnail_size);
protected: protected:
DesktopCapturer(); explicit DesktopCapturer(v8::Isolate* isolate);
~DesktopCapturer(); ~DesktopCapturer() override;
// DesktopMediaListObserver overrides. // DesktopMediaListObserver overrides.
void OnSourceAdded(int index) override; void OnSourceAdded(int index) override;
@ -36,10 +39,6 @@ class DesktopCapturer: public mate::EventEmitter,
bool OnRefreshFinished() override; bool OnRefreshFinished() override;
private: private:
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
scoped_ptr<DesktopMediaList> media_list_; scoped_ptr<DesktopMediaList> media_list_;
DISALLOW_COPY_AND_ASSIGN(DesktopCapturer); DISALLOW_COPY_AND_ASSIGN(DesktopCapturer);

View file

@ -57,9 +57,11 @@ std::map<uint32_t, linked_ptr<v8::Global<v8::Value>>> g_download_item_objects;
} // namespace } // namespace
DownloadItem::DownloadItem(content::DownloadItem* download_item) DownloadItem::DownloadItem(v8::Isolate* isolate,
content::DownloadItem* download_item)
: download_item_(download_item) { : download_item_(download_item) {
download_item_->AddObserver(this); download_item_->AddObserver(this);
Init(isolate);
AttachAsUserData(download_item); AttachAsUserData(download_item);
} }
@ -173,7 +175,7 @@ mate::Handle<DownloadItem> DownloadItem::Create(
if (existing) if (existing)
return mate::CreateHandle(isolate, static_cast<DownloadItem*>(existing)); return mate::CreateHandle(isolate, static_cast<DownloadItem*>(existing));
auto handle = mate::CreateHandle(isolate, new DownloadItem(item)); auto handle = mate::CreateHandle(isolate, new DownloadItem(isolate, item));
g_wrap_download_item.Run(handle.ToV8()); g_wrap_download_item.Run(handle.ToV8());
// Reference this object in case it got garbage collected. // Reference this object in case it got garbage collected.

View file

@ -23,7 +23,6 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
static mate::Handle<DownloadItem> Create(v8::Isolate* isolate, static mate::Handle<DownloadItem> Create(v8::Isolate* isolate,
content::DownloadItem* item); content::DownloadItem* item);
// mate::TrackableObject:
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
@ -41,7 +40,7 @@ class DownloadItem : public mate::TrackableObject<DownloadItem>,
base::FilePath GetSavePath() const; base::FilePath GetSavePath() const;
protected: protected:
explicit DownloadItem(content::DownloadItem* download_item); DownloadItem(v8::Isolate* isolate, content::DownloadItem* download_item);
~DownloadItem(); ~DownloadItem();
// Override content::DownloadItem::Observer methods // Override content::DownloadItem::Observer methods

View file

@ -19,7 +19,8 @@ namespace atom {
namespace api { namespace api {
GlobalShortcut::GlobalShortcut() { GlobalShortcut::GlobalShortcut(v8::Isolate* isolate) {
Init(isolate);
} }
GlobalShortcut::~GlobalShortcut() { GlobalShortcut::~GlobalShortcut() {
@ -66,20 +67,21 @@ void GlobalShortcut::UnregisterAll() {
GlobalShortcutListener::GetInstance()->UnregisterAccelerators(this); GlobalShortcutListener::GetInstance()->UnregisterAccelerators(this);
} }
mate::ObjectTemplateBuilder GlobalShortcut::GetObjectTemplateBuilder( // static
v8::Isolate* isolate) { mate::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate) return CreateHandle(isolate, new GlobalShortcut(isolate));
}
// static
void GlobalShortcut::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("register", &GlobalShortcut::Register) .SetMethod("register", &GlobalShortcut::Register)
.SetMethod("isRegistered", &GlobalShortcut::IsRegistered) .SetMethod("isRegistered", &GlobalShortcut::IsRegistered)
.SetMethod("unregister", &GlobalShortcut::Unregister) .SetMethod("unregister", &GlobalShortcut::Unregister)
.SetMethod("unregisterAll", &GlobalShortcut::UnregisterAll); .SetMethod("unregisterAll", &GlobalShortcut::UnregisterAll);
} }
// static
mate::Handle<GlobalShortcut> GlobalShortcut::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new GlobalShortcut);
}
} // namespace api } // namespace api
} // namespace atom } // namespace atom

View file

@ -23,13 +23,12 @@ class GlobalShortcut : public extensions::GlobalShortcutListener::Observer,
public: public:
static mate::Handle<GlobalShortcut> Create(v8::Isolate* isolate); static mate::Handle<GlobalShortcut> Create(v8::Isolate* isolate);
protected: static void BuildPrototype(v8::Isolate* isolate,
GlobalShortcut(); v8::Local<v8::ObjectTemplate> prototype);
~GlobalShortcut() override;
// mate::Wrappable implementations: protected:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder( explicit GlobalShortcut(v8::Isolate* isolate);
v8::Isolate* isolate) override; ~GlobalShortcut() override;
private: private:
typedef std::map<ui::Accelerator, base::Closure> AcceleratorCallbackMap; typedef std::map<ui::Accelerator, base::Closure> AcceleratorCallbackMap;

View file

@ -19,7 +19,7 @@ namespace atom {
namespace api { namespace api {
Menu::Menu() Menu::Menu(v8::Isolate* isolate)
: model_(new AtomMenuModel(this)), : model_(new AtomMenuModel(this)),
parent_(NULL) { parent_(NULL) {
} }

View file

@ -20,7 +20,7 @@ namespace api {
class Menu : public mate::TrackableObject<Menu>, class Menu : public mate::TrackableObject<Menu>,
public AtomMenuModel::Delegate { public AtomMenuModel::Delegate {
public: public:
static mate::Wrappable* Create(); static mate::WrappableBase* Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
@ -36,7 +36,7 @@ class Menu : public mate::TrackableObject<Menu>,
AtomMenuModel* model() const { return model_.get(); } AtomMenuModel* model() const { return model_.get(); }
protected: protected:
Menu(); explicit Menu(v8::Isolate* isolate);
~Menu() override; ~Menu() override;
// mate::Wrappable: // mate::Wrappable:

View file

@ -17,7 +17,7 @@ namespace api {
class MenuMac : public Menu { class MenuMac : public Menu {
protected: protected:
MenuMac(); explicit MenuMac(v8::Isolate* isolate);
void PopupAt(Window* window, int x, int y, int positioning_item = 0) override; void PopupAt(Window* window, int x, int y, int positioning_item = 0) override;

View file

@ -15,7 +15,7 @@ namespace atom {
namespace api { namespace api {
MenuMac::MenuMac() { MenuMac::MenuMac(v8::Isolate* isolate) : Menu(isolate) {
} }
void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) { void MenuMac::PopupAt(Window* window, int x, int y, int positioning_item) {
@ -68,8 +68,8 @@ void Menu::SendActionToFirstResponder(const std::string& action) {
} }
// static // static
mate::Wrappable* Menu::Create() { mate::WrappableBase* Menu::Create(v8::Isolate* isolate) {
return new MenuMac(); return new MenuMac(isolate);
} }
} // namespace api } // namespace api

View file

@ -13,7 +13,7 @@ namespace atom {
namespace api { namespace api {
MenuViews::MenuViews() { MenuViews::MenuViews(v8::Isolate* isolate) : Menu(isolate) {
} }
void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) { void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
@ -49,7 +49,7 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) {
} }
// static // static
mate::Wrappable* Menu::Create() { mate::WrappableBase* Menu::Create() {
return new MenuViews(); return new MenuViews();
} }

View file

@ -14,7 +14,7 @@ namespace api {
class MenuViews : public Menu { class MenuViews : public Menu {
public: public:
MenuViews(); explicit MenuViews(v8::Isolate* isolate);
protected: protected:
void PopupAt(Window* window, int x, int y, int positioning_item = 0) override; void PopupAt(Window* window, int x, int y, int positioning_item = 0) override;

View file

@ -14,8 +14,9 @@ namespace atom {
namespace api { namespace api {
PowerMonitor::PowerMonitor() { PowerMonitor::PowerMonitor(v8::Isolate* isolate) {
base::PowerMonitor::Get()->AddObserver(this); base::PowerMonitor::Get()->AddObserver(this);
Init(isolate);
} }
PowerMonitor::~PowerMonitor() { PowerMonitor::~PowerMonitor() {
@ -46,7 +47,12 @@ v8::Local<v8::Value> PowerMonitor::Create(v8::Isolate* isolate) {
return v8::Null(isolate); return v8::Null(isolate);
} }
return CreateHandle(isolate, new PowerMonitor).ToV8(); return CreateHandle(isolate, new PowerMonitor(isolate)).ToV8();
}
// static
void PowerMonitor::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
} }
} // namespace api } // namespace api

View file

@ -19,8 +19,11 @@ class PowerMonitor : public mate::TrackableObject<PowerMonitor>,
public: public:
static v8::Local<v8::Value> Create(v8::Isolate* isolate); static v8::Local<v8::Value> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
PowerMonitor(); explicit PowerMonitor(v8::Isolate* isolate);
~PowerMonitor() override; ~PowerMonitor() override;
// base::PowerObserver implementations: // base::PowerObserver implementations:

View file

@ -37,9 +37,10 @@ namespace atom {
namespace api { namespace api {
PowerSaveBlocker::PowerSaveBlocker() PowerSaveBlocker::PowerSaveBlocker(v8::Isolate* isolate)
: current_blocker_type_( : current_blocker_type_(
content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) { content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) {
Init(isolate);
} }
PowerSaveBlocker::~PowerSaveBlocker() { PowerSaveBlocker::~PowerSaveBlocker() {
@ -97,17 +98,18 @@ bool PowerSaveBlocker::IsStarted(int id) {
return power_save_blocker_types_.find(id) != power_save_blocker_types_.end(); return power_save_blocker_types_.find(id) != power_save_blocker_types_.end();
} }
mate::ObjectTemplateBuilder PowerSaveBlocker::GetObjectTemplateBuilder( // static
v8::Isolate* isolate) { mate::Handle<PowerSaveBlocker> PowerSaveBlocker::Create(v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate) return CreateHandle(isolate, new PowerSaveBlocker(isolate));
.SetMethod("start", &PowerSaveBlocker::Start)
.SetMethod("stop", &PowerSaveBlocker::Stop)
.SetMethod("isStarted", &PowerSaveBlocker::IsStarted);
} }
// static // static
mate::Handle<PowerSaveBlocker> PowerSaveBlocker::Create(v8::Isolate* isolate) { void PowerSaveBlocker::BuildPrototype(
return CreateHandle(isolate, new PowerSaveBlocker); v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("start", &PowerSaveBlocker::Start)
.SetMethod("stop", &PowerSaveBlocker::Stop)
.SetMethod("isStarted", &PowerSaveBlocker::IsStarted);
} }
} // namespace api } // namespace api

View file

@ -24,13 +24,12 @@ class PowerSaveBlocker : public mate::TrackableObject<PowerSaveBlocker> {
public: public:
static mate::Handle<PowerSaveBlocker> Create(v8::Isolate* isolate); static mate::Handle<PowerSaveBlocker> Create(v8::Isolate* isolate);
protected: static void BuildPrototype(v8::Isolate* isolate,
PowerSaveBlocker(); v8::Local<v8::ObjectTemplate> prototype);
~PowerSaveBlocker() override;
// mate::Wrappable implementations: protected:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder( explicit PowerSaveBlocker(v8::Isolate* isolate);
v8::Isolate* isolate) override; ~PowerSaveBlocker() override;
private: private:
void UpdatePowerSaveBlocker(); void UpdatePowerSaveBlocker();

View file

@ -22,37 +22,11 @@ namespace atom {
namespace api { namespace api {
Protocol::Protocol(AtomBrowserContext* browser_context) Protocol::Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context)
: request_context_getter_(browser_context->GetRequestContext()), : request_context_getter_(browser_context->GetRequestContext()),
job_factory_(browser_context->job_factory()) { job_factory_(browser_context->job_factory()) {
CHECK(job_factory_); CHECK(job_factory_);
} Init(isolate);
mate::ObjectTemplateBuilder Protocol::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("registerStandardSchemes", &Protocol::RegisterStandardSchemes)
.SetMethod("registerServiceWorkerSchemes",
&Protocol::RegisterServiceWorkerSchemes)
.SetMethod("registerStringProtocol",
&Protocol::RegisterProtocol<URLRequestStringJob>)
.SetMethod("registerBufferProtocol",
&Protocol::RegisterProtocol<URLRequestBufferJob>)
.SetMethod("registerFileProtocol",
&Protocol::RegisterProtocol<URLRequestAsyncAsarJob>)
.SetMethod("registerHttpProtocol",
&Protocol::RegisterProtocol<URLRequestFetchJob>)
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol)
.SetMethod("isProtocolHandled", &Protocol::IsProtocolHandled)
.SetMethod("interceptStringProtocol",
&Protocol::InterceptProtocol<URLRequestStringJob>)
.SetMethod("interceptBufferProtocol",
&Protocol::InterceptProtocol<URLRequestBufferJob>)
.SetMethod("interceptFileProtocol",
&Protocol::InterceptProtocol<URLRequestAsyncAsarJob>)
.SetMethod("interceptHttpProtocol",
&Protocol::InterceptProtocol<URLRequestFetchJob>)
.SetMethod("uninterceptProtocol", &Protocol::UninterceptProtocol);
} }
void Protocol::RegisterStandardSchemes( void Protocol::RegisterStandardSchemes(
@ -150,7 +124,35 @@ std::string Protocol::ErrorCodeToString(ProtocolError error) {
// static // static
mate::Handle<Protocol> Protocol::Create( mate::Handle<Protocol> Protocol::Create(
v8::Isolate* isolate, AtomBrowserContext* browser_context) { v8::Isolate* isolate, AtomBrowserContext* browser_context) {
return mate::CreateHandle(isolate, new Protocol(browser_context)); return mate::CreateHandle(isolate, new Protocol(isolate, browser_context));
}
// static
void Protocol::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("registerStandardSchemes", &Protocol::RegisterStandardSchemes)
.SetMethod("registerServiceWorkerSchemes",
&Protocol::RegisterServiceWorkerSchemes)
.SetMethod("registerStringProtocol",
&Protocol::RegisterProtocol<URLRequestStringJob>)
.SetMethod("registerBufferProtocol",
&Protocol::RegisterProtocol<URLRequestBufferJob>)
.SetMethod("registerFileProtocol",
&Protocol::RegisterProtocol<URLRequestAsyncAsarJob>)
.SetMethod("registerHttpProtocol",
&Protocol::RegisterProtocol<URLRequestFetchJob>)
.SetMethod("unregisterProtocol", &Protocol::UnregisterProtocol)
.SetMethod("isProtocolHandled", &Protocol::IsProtocolHandled)
.SetMethod("interceptStringProtocol",
&Protocol::InterceptProtocol<URLRequestStringJob>)
.SetMethod("interceptBufferProtocol",
&Protocol::InterceptProtocol<URLRequestBufferJob>)
.SetMethod("interceptFileProtocol",
&Protocol::InterceptProtocol<URLRequestAsyncAsarJob>)
.SetMethod("interceptHttpProtocol",
&Protocol::InterceptProtocol<URLRequestFetchJob>)
.SetMethod("uninterceptProtocol", &Protocol::UninterceptProtocol);
} }
} // namespace api } // namespace api

View file

@ -30,7 +30,7 @@ class AtomURLRequestJobFactory;
namespace api { namespace api {
class Protocol : public mate::Wrappable { class Protocol : public mate::Wrappable<Protocol> {
public: public:
using Handler = using Handler =
base::Callback<void(const net::URLRequest*, v8::Local<v8::Value>)>; base::Callback<void(const net::URLRequest*, v8::Local<v8::Value>)>;
@ -40,12 +40,11 @@ class Protocol : public mate::Wrappable {
static mate::Handle<Protocol> Create( static mate::Handle<Protocol> Create(
v8::Isolate* isolate, AtomBrowserContext* browser_context); v8::Isolate* isolate, AtomBrowserContext* browser_context);
protected: static void BuildPrototype(v8::Isolate* isolate,
explicit Protocol(AtomBrowserContext* browser_context); v8::Local<v8::ObjectTemplate> prototype);
// mate::Wrappable implementations: protected:
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder( Protocol(v8::Isolate* isolate, AtomBrowserContext* browser_context);
v8::Isolate* isolate);
private: private:
// Possible errors. // Possible errors.

View file

@ -47,9 +47,11 @@ std::vector<std::string> MetricsToArray(uint32_t metrics) {
} // namespace } // namespace
Screen::Screen(gfx::Screen* screen) : screen_(screen) { Screen::Screen(v8::Isolate* isolate, gfx::Screen* screen)
: screen_(screen) {
displays_ = screen_->GetAllDisplays(); displays_ = screen_->GetAllDisplays();
screen_->AddObserver(this); screen_->AddObserver(this);
Init(isolate);
} }
Screen::~Screen() { Screen::~Screen() {
@ -100,16 +102,6 @@ void Screen::OnDisplayMetricsChanged(const gfx::Display& display,
Emit("display-metrics-changed", display, MetricsToArray(changed_metrics)); Emit("display-metrics-changed", display, MetricsToArray(changed_metrics));
} }
mate::ObjectTemplateBuilder Screen::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate)
.SetMethod("getCursorScreenPoint", &Screen::GetCursorScreenPoint)
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
}
// static // static
v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) { v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
if (!Browser::Get()->is_ready()) { if (!Browser::Get()->is_ready()) {
@ -126,7 +118,18 @@ v8::Local<v8::Value> Screen::Create(v8::Isolate* isolate) {
return v8::Null(isolate); return v8::Null(isolate);
} }
return mate::CreateHandle(isolate, new Screen(screen)).ToV8(); return mate::CreateHandle(isolate, new Screen(isolate, screen)).ToV8();
}
// static
void Screen::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("getCursorScreenPoint", &Screen::GetCursorScreenPoint)
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
} }
} // namespace api } // namespace api

View file

@ -21,14 +21,17 @@ namespace atom {
namespace api { namespace api {
class Screen : public mate::EventEmitter, class Screen : public mate::EventEmitter<Screen>,
public gfx::DisplayObserver { public gfx::DisplayObserver {
public: public:
static v8::Local<v8::Value> Create(v8::Isolate* isolate); static v8::Local<v8::Value> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit Screen(gfx::Screen* screen); Screen(v8::Isolate* isolate, gfx::Screen* screen);
virtual ~Screen(); ~Screen() override;
gfx::Point GetCursorScreenPoint(); gfx::Point GetCursorScreenPoint();
gfx::Display GetPrimaryDisplay(); gfx::Display GetPrimaryDisplay();
@ -42,10 +45,6 @@ class Screen : public mate::EventEmitter,
void OnDisplayMetricsChanged(const gfx::Display& display, void OnDisplayMetricsChanged(const gfx::Display& display,
uint32_t changed_metrics) override; uint32_t changed_metrics) override;
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
private: private:
gfx::Screen* screen_; gfx::Screen* screen_;
std::vector<gfx::Display> displays_; std::vector<gfx::Display> displays_;

View file

@ -288,14 +288,15 @@ void ClearHostResolverCacheInIO(
} // namespace } // namespace
Session::Session(AtomBrowserContext* browser_context) Session::Session(v8::Isolate* isolate, AtomBrowserContext* browser_context)
: devtools_network_emulation_client_id_(base::GenerateGUID()), : devtools_network_emulation_client_id_(base::GenerateGUID()),
browser_context_(browser_context) { browser_context_(browser_context) {
AttachAsUserData(browser_context);
// Observe DownloadManger to get download notifications. // Observe DownloadManger to get download notifications.
content::BrowserContext::GetDownloadManager(browser_context)-> content::BrowserContext::GetDownloadManager(browser_context)->
AddObserver(this); AddObserver(this);
Init(isolate);
AttachAsUserData(browser_context);
} }
Session::~Session() { Session::~Session() {
@ -308,6 +309,9 @@ void Session::OnDownloadCreated(content::DownloadManager* manager,
auto web_contents = item->GetWebContents(); auto web_contents = item->GetWebContents();
if (SavePageHandler::IsSavePageTypes(item->GetMimeType())) if (SavePageHandler::IsSavePageTypes(item->GetMimeType()))
return; return;
v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate());
bool prevent_default = Emit( bool prevent_default = Emit(
"will-download", "will-download",
DownloadItem::Create(isolate(), item), DownloadItem::Create(isolate(), item),
@ -454,7 +458,8 @@ mate::Handle<Session> Session::CreateFrom(
if (existing) if (existing)
return mate::CreateHandle(isolate, static_cast<Session*>(existing)); return mate::CreateHandle(isolate, static_cast<Session*>(existing));
auto handle = mate::CreateHandle(isolate, new Session(browser_context)); auto handle = mate::CreateHandle(
isolate, new Session(isolate, browser_context));
g_wrap_session.Run(handle.ToV8()); g_wrap_session.Run(handle.ToV8());
return handle; return handle;
} }

View file

@ -58,7 +58,7 @@ class Session: public mate::TrackableObject<Session>,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit Session(AtomBrowserContext* browser_context); Session(v8::Isolate* isolate, AtomBrowserContext* browser_context);
~Session(); ~Session();
// content::DownloadManager::Observer: // content::DownloadManager::Observer:

View file

@ -22,7 +22,7 @@ namespace atom {
namespace api { namespace api {
Tray::Tray(const gfx::Image& image) Tray::Tray(v8::Isolate* isolate, const gfx::Image& image)
: tray_icon_(TrayIcon::Create()) { : tray_icon_(TrayIcon::Create()) {
tray_icon_->SetImage(image); tray_icon_->SetImage(image);
tray_icon_->AddObserver(this); tray_icon_->AddObserver(this);
@ -32,13 +32,13 @@ Tray::~Tray() {
} }
// static // static
mate::Wrappable* Tray::New(v8::Isolate* isolate, const gfx::Image& image) { mate::WrappableBase* Tray::New(v8::Isolate* isolate, const gfx::Image& image) {
if (!Browser::Get()->is_ready()) { if (!Browser::Get()->is_ready()) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8( isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Cannot create Tray before app is ready"))); isolate, "Cannot create Tray before app is ready")));
return nullptr; return nullptr;
} }
return new Tray(image); return new Tray(isolate, image);
} }
void Tray::OnClicked(const gfx::Rect& bounds, int modifiers) { void Tray::OnClicked(const gfx::Rect& bounds, int modifiers) {

View file

@ -32,13 +32,14 @@ class Menu;
class Tray : public mate::TrackableObject<Tray>, class Tray : public mate::TrackableObject<Tray>,
public TrayIconObserver { public TrayIconObserver {
public: public:
static mate::Wrappable* New(v8::Isolate* isolate, const gfx::Image& image); static mate::WrappableBase* New(
v8::Isolate* isolate, const gfx::Image& image);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit Tray(const gfx::Image& image); Tray(v8::Isolate* isolate, const gfx::Image& image);
~Tray() override; ~Tray() override;
// TrayIconObserver: // TrayIconObserver:

View file

@ -215,14 +215,17 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
} // namespace } // namespace
WebContents::WebContents(content::WebContents* web_contents) WebContents::WebContents(v8::Isolate* isolate,
content::WebContents* web_contents)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
embedder_(nullptr), embedder_(nullptr),
type_(REMOTE), type_(REMOTE),
request_id_(0), request_id_(0),
background_throttling_(true) { background_throttling_(true) {
AttachAsUserData(web_contents);
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent()); web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
Init(isolate);
AttachAsUserData(web_contents);
} }
WebContents::WebContents(v8::Isolate* isolate, WebContents::WebContents(v8::Isolate* isolate,
@ -270,7 +273,6 @@ WebContents::WebContents(v8::Isolate* isolate,
} }
Observe(web_contents); Observe(web_contents);
AttachAsUserData(web_contents);
InitWithWebContents(web_contents); InitWithWebContents(web_contents);
managed_web_contents()->GetView()->SetDelegate(this); managed_web_contents()->GetView()->SetDelegate(this);
@ -299,6 +301,9 @@ WebContents::WebContents(v8::Isolate* isolate,
if (owner_window) if (owner_window)
SetOwnerWindow(owner_window); SetOwnerWindow(owner_window);
} }
Init(isolate);
AttachAsUserData(web_contents);
} }
WebContents::~WebContents() { WebContents::~WebContents() {
@ -1290,7 +1295,8 @@ mate::Handle<WebContents> WebContents::CreateFrom(
return mate::CreateHandle(isolate, static_cast<WebContents*>(existing)); return mate::CreateHandle(isolate, static_cast<WebContents*>(existing));
// Otherwise create a new WebContents wrapper object. // Otherwise create a new WebContents wrapper object.
auto handle = mate::CreateHandle(isolate, new WebContents(web_contents)); auto handle = mate::CreateHandle(
isolate, new WebContents(isolate, web_contents));
g_wrap_web_contents.Run(handle.ToV8()); g_wrap_web_contents.Run(handle.ToV8());
return handle; return handle;
} }

View file

@ -55,6 +55,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
static mate::Handle<WebContents> Create( static mate::Handle<WebContents> Create(
v8::Isolate* isolate, const mate::Dictionary& options); v8::Isolate* isolate, const mate::Dictionary& options);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
int GetID() const; int GetID() const;
bool Equal(const WebContents* web_contents) const; bool Equal(const WebContents* web_contents) const;
void LoadURL(const GURL& url, const mate::Dictionary& options); void LoadURL(const GURL& url, const mate::Dictionary& options);
@ -156,12 +159,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate); v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
v8::Local<v8::Value> Debugger(v8::Isolate* isolate); v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
// mate::TrackableObject:
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit WebContents(content::WebContents* web_contents); WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
WebContents(v8::Isolate* isolate, const mate::Dictionary& options); WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
~WebContents(); ~WebContents();

View file

@ -36,8 +36,10 @@ namespace atom {
namespace api { namespace api {
WebRequest::WebRequest(AtomBrowserContext* browser_context) WebRequest::WebRequest(v8::Isolate* isolate,
AtomBrowserContext* browser_context)
: browser_context_(browser_context) { : browser_context_(browser_context) {
Init(isolate);
} }
WebRequest::~WebRequest() { WebRequest::~WebRequest() {
@ -81,7 +83,7 @@ void WebRequest::SetListener(Method method, Event type, mate::Arguments* args) {
mate::Handle<WebRequest> WebRequest::Create( mate::Handle<WebRequest> WebRequest::Create(
v8::Isolate* isolate, v8::Isolate* isolate,
AtomBrowserContext* browser_context) { AtomBrowserContext* browser_context) {
return mate::CreateHandle(isolate, new WebRequest(browser_context)); return mate::CreateHandle(isolate, new WebRequest(isolate, browser_context));
} }
// static // static

View file

@ -21,13 +21,12 @@ class WebRequest : public mate::TrackableObject<WebRequest> {
static mate::Handle<WebRequest> Create(v8::Isolate* isolate, static mate::Handle<WebRequest> Create(v8::Isolate* isolate,
AtomBrowserContext* browser_context); AtomBrowserContext* browser_context);
// mate::TrackableObject:
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
explicit WebRequest(AtomBrowserContext* browser_context); WebRequest(v8::Isolate* isolate, AtomBrowserContext* browser_context);
~WebRequest(); ~WebRequest() override;
// C++ can not distinguish overloaded member function. // C++ can not distinguish overloaded member function.
template<AtomNetworkDelegate::SimpleEvent type> template<AtomNetworkDelegate::SimpleEvent type>

View file

@ -287,7 +287,7 @@ void Window::OnWindowMessage(UINT message, WPARAM w_param, LPARAM l_param) {
#endif #endif
// static // static
mate::Wrappable* Window::New(v8::Isolate* isolate, mate::Arguments* args) { mate::WrappableBase* Window::New(v8::Isolate* isolate, mate::Arguments* args) {
if (!Browser::Get()->is_ready()) { if (!Browser::Get()->is_ready()) {
isolate->ThrowException(v8::Exception::Error(mate::StringToV8( isolate->ThrowException(v8::Exception::Error(mate::StringToV8(
isolate, "Cannot create BrowserWindow before app is ready"))); isolate, "Cannot create BrowserWindow before app is ready")));

View file

@ -38,7 +38,7 @@ class WebContents;
class Window : public mate::TrackableObject<Window>, class Window : public mate::TrackableObject<Window>,
public NativeWindowObserver { public NativeWindowObserver {
public: public:
static mate::Wrappable* New(v8::Isolate* isolate, mate::Arguments* args); static mate::WrappableBase* New(v8::Isolate* isolate, mate::Arguments* args);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
@ -51,7 +51,7 @@ class Window : public mate::TrackableObject<Window>,
protected: protected:
Window(v8::Isolate* isolate, const mate::Dictionary& options); Window(v8::Isolate* isolate, const mate::Dictionary& options);
virtual ~Window(); ~Window() override;
// NativeWindowObserver: // NativeWindowObserver:
void WillCloseWindow(bool* prevent_default) override; void WillCloseWindow(bool* prevent_default) override;

View file

@ -11,31 +11,15 @@
namespace mate { namespace mate {
namespace { Event::Event(v8::Isolate* isolate)
v8::Persistent<v8::ObjectTemplate> template_;
} // namespace
Event::Event()
: sender_(NULL), : sender_(NULL),
message_(NULL) { message_(NULL) {
Init(isolate);
} }
Event::~Event() { Event::~Event() {
} }
ObjectTemplateBuilder Event::GetObjectTemplateBuilder(v8::Isolate* isolate) {
if (template_.IsEmpty())
template_.Reset(isolate, ObjectTemplateBuilder(isolate)
.SetMethod("preventDefault", &Event::PreventDefault)
.SetMethod("sendReply", &Event::SendReply)
.Build());
return ObjectTemplateBuilder(
isolate, v8::Local<v8::ObjectTemplate>::New(isolate, template_));
}
void Event::SetSenderAndMessage(content::WebContents* sender, void Event::SetSenderAndMessage(content::WebContents* sender,
IPC::Message* message) { IPC::Message* message) {
DCHECK(!sender_); DCHECK(!sender_);
@ -52,7 +36,7 @@ void Event::WebContentsDestroyed() {
} }
void Event::PreventDefault(v8::Isolate* isolate) { void Event::PreventDefault(v8::Isolate* isolate) {
GetWrapper(isolate)->Set(StringToV8(isolate, "defaultPrevented"), GetWrapper()->Set(StringToV8(isolate, "defaultPrevented"),
v8::True(isolate)); v8::True(isolate));
} }
@ -66,7 +50,15 @@ bool Event::SendReply(const base::string16& json) {
// static // static
Handle<Event> Event::Create(v8::Isolate* isolate) { Handle<Event> Event::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new Event); return CreateHandle(isolate, new Event(isolate));
}
// static
void Event::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("preventDefault", &Event::PreventDefault)
.SetMethod("sendReply", &Event::SendReply);
} }
} // namespace mate } // namespace mate

View file

@ -15,11 +15,14 @@ class Message;
namespace mate { namespace mate {
class Event : public Wrappable, class Event : public Wrappable<Event>,
public content::WebContentsObserver { public content::WebContentsObserver {
public: public:
static Handle<Event> Create(v8::Isolate* isolate); static Handle<Event> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
// Pass the sender and message to be replied. // Pass the sender and message to be replied.
void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message); void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message);
@ -30,11 +33,8 @@ class Event : public Wrappable,
bool SendReply(const base::string16& json); bool SendReply(const base::string16& json);
protected: protected:
Event(); explicit Event(v8::Isolate* isolate);
virtual ~Event(); ~Event() override;
// Wrappable implementations:
ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate) override;
// content::WebContentsObserver implementations: // content::WebContentsObserver implementations:
void WebContentsDestroyed() override; void WebContentsDestroyed() override;

View file

@ -34,11 +34,13 @@ v8::Local<v8::Object> CreateEventObject(v8::Isolate* isolate) {
} // namespace } // namespace
EventEmitter::EventEmitter() { namespace internal {
}
v8::Local<v8::Object> EventEmitter::CreateJSEvent( v8::Local<v8::Object> CreateJSEvent(
v8::Isolate* isolate, content::WebContents* sender, IPC::Message* message) { v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::WebContents* sender,
IPC::Message* message) {
v8::Local<v8::Object> event; v8::Local<v8::Object> event;
bool use_native_event = sender && message; bool use_native_event = sender && message;
@ -49,16 +51,20 @@ v8::Local<v8::Object> EventEmitter::CreateJSEvent(
} else { } else {
event = CreateEventObject(isolate); event = CreateEventObject(isolate);
} }
mate::Dictionary(isolate, event).Set("sender", GetWrapper(isolate)); mate::Dictionary(isolate, event).Set("sender", object);
return event; return event;
} }
v8::Local<v8::Object> EventEmitter::CreateCustomEvent( v8::Local<v8::Object> CreateCustomEvent(
v8::Isolate* isolate, v8::Local<v8::Object> custom_event) { v8::Isolate* isolate,
v8::Local<v8::Object> object,
v8::Local<v8::Object> custom_event) {
v8::Local<v8::Object> event = CreateEventObject(isolate); v8::Local<v8::Object> event = CreateEventObject(isolate);
(void)event->SetPrototype(custom_event->CreationContext(), custom_event); (void)event->SetPrototype(custom_event->CreationContext(), custom_event);
mate::Dictionary(isolate, event).Set("sender", GetWrapper(isolate)); mate::Dictionary(isolate, event).Set("sender", object);
return event; return event;
} }
} // namespace internal
} // namespace mate } // namespace mate

View file

@ -20,17 +20,40 @@ class Message;
namespace mate { namespace mate {
namespace internal {
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
v8::Local<v8::Object> object,
content::WebContents* sender,
IPC::Message* message);
v8::Local<v8::Object> CreateCustomEvent(
v8::Isolate* isolate,
v8::Local<v8::Object> object,
v8::Local<v8::Object> event);
} // namespace internal
// Provide helperers to emit event in JavaScript. // Provide helperers to emit event in JavaScript.
class EventEmitter : public Wrappable { template<typename T>
class EventEmitter : public Wrappable<T> {
public: public:
typedef std::vector<v8::Local<v8::Value>> ValueArray; typedef std::vector<v8::Local<v8::Value>> ValueArray;
// Make the convinient methods visible:
// https://isocpp.org/wiki/faq/templates#nondependent-name-lookup-members
v8::Local<v8::Object> GetWrapper(v8::Isolate* isolate = nullptr) {
return Wrappable<T>::GetWrapper();
}
v8::Isolate* isolate() const { return Wrappable<T>::isolate(); }
// this.emit(name, event, args...); // this.emit(name, event, args...);
template<typename... Args> template<typename... Args>
bool EmitCustomEvent(const base::StringPiece& name, bool EmitCustomEvent(const base::StringPiece& name,
v8::Local<v8::Object> event, v8::Local<v8::Object> event,
const Args&... args) { const Args&... args) {
return EmitWithEvent(name, CreateCustomEvent(isolate(), event), args...); return EmitWithEvent(
name,
internal::CreateCustomEvent(isolate(), GetWrapper(), event), args...);
} }
// this.emit(name, new Event(), args...); // this.emit(name, new Event(), args...);
@ -47,12 +70,13 @@ class EventEmitter : public Wrappable {
const Args&... args) { const Args&... args) {
v8::Locker locker(isolate()); v8::Locker locker(isolate());
v8::HandleScope handle_scope(isolate()); v8::HandleScope handle_scope(isolate());
v8::Local<v8::Object> event = CreateJSEvent(isolate(), sender, message); v8::Local<v8::Object> event = internal::CreateJSEvent(
isolate(), GetWrapper(), sender, message);
return EmitWithEvent(name, event, args...); return EmitWithEvent(name, event, args...);
} }
protected: protected:
EventEmitter(); EventEmitter() {}
private: private:
// this.emit(name, event, args...); // this.emit(name, event, args...);
@ -67,12 +91,6 @@ class EventEmitter : public Wrappable {
StringToV8(isolate(), "defaultPrevented"))->BooleanValue(); StringToV8(isolate(), "defaultPrevented"))->BooleanValue();
} }
v8::Local<v8::Object> CreateJSEvent(v8::Isolate* isolate,
content::WebContents* sender,
IPC::Message* message);
v8::Local<v8::Object> CreateCustomEvent(
v8::Isolate* isolate, v8::Local<v8::Object> event);
DISALLOW_COPY_AND_ASSIGN(EventEmitter); DISALLOW_COPY_AND_ASSIGN(EventEmitter);
}; };

View file

@ -37,15 +37,6 @@ TrackableObjectBase::~TrackableObjectBase() {
cleanup_.Run(); cleanup_.Run();
} }
void TrackableObjectBase::AfterInit(v8::Isolate* isolate) {
if (wrapped_)
AttachAsUserData(wrapped_);
}
void TrackableObjectBase::MarkDestroyed() {
GetWrapper(isolate())->SetAlignedPointerInInternalField(0, nullptr);
}
base::Closure TrackableObjectBase::GetDestroyClosure() { base::Closure TrackableObjectBase::GetDestroyClosure() {
return base::Bind(&TrackableObjectBase::Destroy, weak_factory_.GetWeakPtr()); return base::Bind(&TrackableObjectBase::Destroy, weak_factory_.GetWeakPtr());
} }

View file

@ -21,7 +21,7 @@ class SupportsUserData;
namespace mate { namespace mate {
// Users should use TrackableObject instead. // Users should use TrackableObject instead.
class TrackableObjectBase : public mate::EventEmitter { class TrackableObjectBase {
public: public:
TrackableObjectBase(); TrackableObjectBase();
@ -32,13 +32,7 @@ class TrackableObjectBase : public mate::EventEmitter {
void AttachAsUserData(base::SupportsUserData* wrapped); void AttachAsUserData(base::SupportsUserData* wrapped);
protected: protected:
~TrackableObjectBase() override; virtual ~TrackableObjectBase();
// mate::Wrappable:
void AfterInit(v8::Isolate* isolate) override;
// Mark the JS object as destroyed.
void MarkDestroyed();
// Returns a closure that can destroy the native class. // Returns a closure that can destroy the native class.
base::Closure GetDestroyClosure(); base::Closure GetDestroyClosure();
@ -65,8 +59,14 @@ class TrackableObjectBase : public mate::EventEmitter {
// All instances of TrackableObject will be kept in a weak map and can be got // All instances of TrackableObject will be kept in a weak map and can be got
// from its ID. // from its ID.
template<typename T> template<typename T>
class TrackableObject : public TrackableObjectBase { class TrackableObject : public TrackableObjectBase,
public mate::EventEmitter<T> {
public: public:
// Mark the JS object as destroyed.
void MarkDestroyed() {
Wrappable<T>::GetWrapper()->SetAlignedPointerInInternalField(0, nullptr);
}
// Finds out the TrackableObject from its ID in weak map. // Finds out the TrackableObject from its ID in weak map.
static T* FromWeakMapID(v8::Isolate* isolate, int32_t id) { static T* FromWeakMapID(v8::Isolate* isolate, int32_t id) {
if (!weak_map_) if (!weak_map_)
@ -106,6 +106,7 @@ class TrackableObject : public TrackableObjectBase {
protected: protected:
TrackableObject() {} TrackableObject() {}
~TrackableObject() override { ~TrackableObject() override {
RemoveFromWeakMap(); RemoveFromWeakMap();
} }
@ -116,38 +117,22 @@ class TrackableObject : public TrackableObjectBase {
RegisterDestructionCallback( RegisterDestructionCallback(
base::Bind(&TrackableObject<T>::ReleaseAllWeakReferences)); base::Bind(&TrackableObject<T>::ReleaseAllWeakReferences));
} }
weak_map_id_ = weak_map_->Add(isolate, GetWrapper(isolate)); weak_map_id_ = weak_map_->Add(isolate, Wrappable<T>::GetWrapper());
TrackableObjectBase::AfterInit(isolate); if (wrapped_)
AttachAsUserData(wrapped_);
} }
private: private:
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override {
if (template_.IsEmpty()) {
auto templ = v8::ObjectTemplate::New(isolate);
T::BuildPrototype(isolate, templ);
template_.Reset(isolate, templ);
}
return ObjectTemplateBuilder(
isolate, v8::Local<v8::ObjectTemplate>::New(isolate, template_));
}
// Releases all weak references in weak map, called when app is terminating. // Releases all weak references in weak map, called when app is terminating.
static void ReleaseAllWeakReferences() { static void ReleaseAllWeakReferences() {
weak_map_.reset(); weak_map_.reset();
} }
static v8::Persistent<v8::ObjectTemplate> template_;
static scoped_ptr<atom::IDWeakMap> weak_map_; static scoped_ptr<atom::IDWeakMap> weak_map_;
DISALLOW_COPY_AND_ASSIGN(TrackableObject); DISALLOW_COPY_AND_ASSIGN(TrackableObject);
}; };
template<typename T>
v8::Persistent<v8::ObjectTemplate> TrackableObject<T>::template_;
template<typename T> template<typename T>
scoped_ptr<atom::IDWeakMap> TrackableObject<T>::weak_map_; scoped_ptr<atom::IDWeakMap> TrackableObject<T>::weak_map_;

View file

@ -18,21 +18,39 @@
namespace { namespace {
v8::Persistent<v8::ObjectTemplate> template_; class Archive : public mate::Wrappable<Archive> {
class Archive : public mate::Wrappable {
public: public:
static v8::Local<v8::Value> Create(v8::Isolate* isolate, static v8::Local<v8::Value> Create(v8::Isolate* isolate,
const base::FilePath& path) { const base::FilePath& path) {
scoped_ptr<asar::Archive> archive(new asar::Archive(path)); scoped_ptr<asar::Archive> archive(new asar::Archive(path));
if (!archive->Init()) if (!archive->Init())
return v8::False(isolate); return v8::False(isolate);
return (new Archive(std::move(archive)))->GetWrapper(isolate); return (new Archive(isolate, std::move(archive)))->GetWrapper();
}
static void BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetProperty("path", &Archive::GetPath)
.SetMethod("getFileInfo", &Archive::GetFileInfo)
.SetMethod("stat", &Archive::Stat)
.SetMethod("readdir", &Archive::Readdir)
.SetMethod("realpath", &Archive::Realpath)
.SetMethod("copyFileOut", &Archive::CopyFileOut)
.SetMethod("getFd", &Archive::GetFD)
.SetMethod("destroy", &Archive::Destroy);
} }
protected: protected:
explicit Archive(scoped_ptr<asar::Archive> archive) Archive(v8::Isolate* isolate, scoped_ptr<asar::Archive> archive)
: archive_(std::move(archive)) {} : archive_(std::move(archive)) {
Init(isolate);
}
// Returns the path of the file.
base::FilePath GetPath() {
return archive_->path();
}
// Reads the offset and size of file. // Reads the offset and size of file.
v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate, v8::Local<v8::Value> GetFileInfo(v8::Isolate* isolate,
@ -101,24 +119,6 @@ class Archive : public mate::Wrappable {
archive_.reset(); archive_.reset();
} }
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate) {
if (template_.IsEmpty())
template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
.SetValue("path", archive_->path())
.SetMethod("getFileInfo", &Archive::GetFileInfo)
.SetMethod("stat", &Archive::Stat)
.SetMethod("readdir", &Archive::Readdir)
.SetMethod("realpath", &Archive::Realpath)
.SetMethod("copyFileOut", &Archive::CopyFileOut)
.SetMethod("getFd", &Archive::GetFD)
.SetMethod("destroy", &Archive::Destroy)
.Build());
return mate::ObjectTemplateBuilder(
isolate, v8::Local<v8::ObjectTemplate>::New(isolate, template_));
}
private: private:
scoped_ptr<asar::Archive> archive_; scoped_ptr<asar::Archive> archive_;

View file

@ -12,7 +12,7 @@ namespace atom {
namespace api { namespace api {
IDWeakMap::IDWeakMap() { IDWeakMap::IDWeakMap(v8::Isolate* isolate) {
} }
IDWeakMap::~IDWeakMap() { IDWeakMap::~IDWeakMap() {
@ -52,8 +52,8 @@ void IDWeakMap::BuildPrototype(v8::Isolate* isolate,
} }
// static // static
mate::Wrappable* IDWeakMap::Create(v8::Isolate* isolate) { mate::WrappableBase* IDWeakMap::Create(v8::Isolate* isolate) {
return new IDWeakMap; return new IDWeakMap(isolate);
} }
} // namespace api } // namespace api

View file

@ -13,15 +13,15 @@ namespace atom {
namespace api { namespace api {
class IDWeakMap : public mate::Wrappable { class IDWeakMap : public mate::Wrappable<IDWeakMap> {
public: public:
static mate::Wrappable* Create(v8::Isolate* isolate); static mate::WrappableBase* Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate, static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype); v8::Local<v8::ObjectTemplate> prototype);
protected: protected:
IDWeakMap(); explicit IDWeakMap(v8::Isolate* isolate);
~IDWeakMap(); ~IDWeakMap();
private: private:

View file

@ -168,35 +168,15 @@ bool ReadImageSkiaFromICO(gfx::ImageSkia* image, const base::FilePath& path) {
} }
#endif #endif
v8::Persistent<v8::ObjectTemplate> template_;
} // namespace } // namespace
NativeImage::NativeImage() {} NativeImage::NativeImage(v8::Isolate* isolate, const gfx::Image& image)
: image_(image) {
NativeImage::NativeImage(const gfx::Image& image) : image_(image) {} Init(isolate);
}
NativeImage::~NativeImage() {} NativeImage::~NativeImage() {}
mate::ObjectTemplateBuilder NativeImage::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
if (template_.IsEmpty())
template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
.SetMethod("toPng", &NativeImage::ToPNG)
.SetMethod("toJpeg", &NativeImage::ToJPEG)
.SetMethod("getNativeHandle", &NativeImage::GetNativeHandle)
.SetMethod("toDataURL", &NativeImage::ToDataURL)
.SetMethod("toDataUrl", &NativeImage::ToDataURL) // deprecated.
.SetMethod("isEmpty", &NativeImage::IsEmpty)
.SetMethod("getSize", &NativeImage::GetSize)
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
.SetMethod("isTemplateImage", &NativeImage::IsTemplateImage)
.Build());
return mate::ObjectTemplateBuilder(
isolate, v8::Local<v8::ObjectTemplate>::New(isolate, template_));
}
v8::Local<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) { v8::Local<v8::Value> NativeImage::ToPNG(v8::Isolate* isolate) {
scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes(); scoped_refptr<base::RefCountedMemory> png = image_.As1xPNGBytes();
return node::Buffer::Copy(isolate, return node::Buffer::Copy(isolate,
@ -255,13 +235,13 @@ bool NativeImage::IsTemplateImage() {
// static // static
mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) { mate::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) {
return mate::CreateHandle(isolate, new NativeImage); return mate::CreateHandle(isolate, new NativeImage(isolate, gfx::Image()));
} }
// static // static
mate::Handle<NativeImage> NativeImage::Create( mate::Handle<NativeImage> NativeImage::Create(
v8::Isolate* isolate, const gfx::Image& image) { v8::Isolate* isolate, const gfx::Image& image) {
return mate::CreateHandle(isolate, new NativeImage(image)); return mate::CreateHandle(isolate, new NativeImage(isolate, image));
} }
// static // static
@ -330,6 +310,21 @@ mate::Handle<NativeImage> NativeImage::CreateFromDataURL(
return CreateEmpty(isolate); return CreateEmpty(isolate);
} }
// static
void NativeImage::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("toPng", &NativeImage::ToPNG)
.SetMethod("toJpeg", &NativeImage::ToJPEG)
.SetMethod("getNativeHandle", &NativeImage::GetNativeHandle)
.SetMethod("toDataURL", &NativeImage::ToDataURL)
.SetMethod("toDataUrl", &NativeImage::ToDataURL) // deprecated.
.SetMethod("isEmpty", &NativeImage::IsEmpty)
.SetMethod("getSize", &NativeImage::GetSize)
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)
.SetMethod("isTemplateImage", &NativeImage::IsTemplateImage);
}
} // namespace api } // namespace api
} // namespace atom } // namespace atom

View file

@ -29,7 +29,7 @@ namespace atom {
namespace api { namespace api {
class NativeImage : public mate::Wrappable { class NativeImage : public mate::Wrappable<NativeImage> {
public: public:
static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate); static mate::Handle<NativeImage> CreateEmpty(v8::Isolate* isolate);
static mate::Handle<NativeImage> Create( static mate::Handle<NativeImage> Create(
@ -45,18 +45,14 @@ class NativeImage : public mate::Wrappable {
static mate::Handle<NativeImage> CreateFromDataURL( static mate::Handle<NativeImage> CreateFromDataURL(
v8::Isolate* isolate, const GURL& url); v8::Isolate* isolate, const GURL& url);
// The default constructor should only be used by image_converter.cc. static void BuildPrototype(v8::Isolate* isolate,
NativeImage(); v8::Local<v8::ObjectTemplate> prototype);
const gfx::Image& image() const { return image_; } const gfx::Image& image() const { return image_; }
protected: protected:
explicit NativeImage(const gfx::Image& image); NativeImage(v8::Isolate* isolate, const gfx::Image& image);
virtual ~NativeImage(); ~NativeImage() override;
// mate::Wrappable:
mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate) override;
private: private:
v8::Local<v8::Value> ToPNG(v8::Isolate* isolate); v8::Local<v8::Value> ToPNG(v8::Isolate* isolate);

View file

@ -54,8 +54,9 @@ class ScriptExecutionCallback : public blink::WebScriptExecutionCallback {
} // namespace } // namespace
WebFrame::WebFrame() WebFrame::WebFrame(v8::Isolate* isolate)
: web_frame_(blink::WebLocalFrame::frameForCurrentContext()) { : web_frame_(blink::WebLocalFrame::frameForCurrentContext()) {
Init(isolate);
} }
WebFrame::~WebFrame() { WebFrame::~WebFrame() {
@ -67,7 +68,7 @@ void WebFrame::SetName(const std::string& name) {
double WebFrame::SetZoomLevel(double level) { double WebFrame::SetZoomLevel(double level) {
double ret = web_frame_->view()->setZoomLevel(level); double ret = web_frame_->view()->setZoomLevel(level);
mate::EmitEvent(isolate(), GetWrapper(isolate()), "zoom-level-changed", ret); mate::EmitEvent(isolate(), GetWrapper(), "zoom-level-changed", ret);
return ret; return ret;
} }
@ -162,9 +163,15 @@ void WebFrame::ExecuteJavaScript(const base::string16& code,
callback.release()); callback.release());
} }
mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder( // static
v8::Isolate* isolate) { mate::Handle<WebFrame> WebFrame::Create(v8::Isolate* isolate) {
return mate::ObjectTemplateBuilder(isolate) return CreateHandle(isolate, new WebFrame(isolate));
}
// static
void WebFrame::BuildPrototype(
v8::Isolate* isolate, v8::Local<v8::ObjectTemplate> prototype) {
mate::ObjectTemplateBuilder(isolate, prototype)
.SetMethod("setName", &WebFrame::SetName) .SetMethod("setName", &WebFrame::SetName)
.SetMethod("setZoomLevel", &WebFrame::SetZoomLevel) .SetMethod("setZoomLevel", &WebFrame::SetZoomLevel)
.SetMethod("getZoomLevel", &WebFrame::GetZoomLevel) .SetMethod("getZoomLevel", &WebFrame::GetZoomLevel)
@ -187,11 +194,6 @@ mate::ObjectTemplateBuilder WebFrame::GetObjectTemplateBuilder(
.SetMethod("executeJavaScript", &WebFrame::ExecuteJavaScript); .SetMethod("executeJavaScript", &WebFrame::ExecuteJavaScript);
} }
// static
mate::Handle<WebFrame> WebFrame::Create(v8::Isolate* isolate) {
return CreateHandle(isolate, new WebFrame);
}
} // namespace api } // namespace api
} // namespace atom } // namespace atom

View file

@ -26,13 +26,16 @@ namespace api {
class SpellCheckClient; class SpellCheckClient;
class WebFrame : public mate::Wrappable { class WebFrame : public mate::Wrappable<WebFrame> {
public: public:
static mate::Handle<WebFrame> Create(v8::Isolate* isolate); static mate::Handle<WebFrame> Create(v8::Isolate* isolate);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::ObjectTemplate> prototype);
private: private:
WebFrame(); explicit WebFrame(v8::Isolate* isolate);
virtual ~WebFrame(); ~WebFrame() override;
void SetName(const std::string& name); void SetName(const std::string& name);
@ -66,10 +69,6 @@ class WebFrame : public mate::Wrappable {
// Excecuting scripts. // Excecuting scripts.
void ExecuteJavaScript(const base::string16& code, mate::Arguments* args); void ExecuteJavaScript(const base::string16& code, mate::Arguments* args);
// mate::Wrappable:
virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
v8::Isolate* isolate);
scoped_ptr<SpellCheckClient> spell_check_client_; scoped_ptr<SpellCheckClient> spell_check_client_;
blink::WebLocalFrame* web_frame_; blink::WebLocalFrame* web_frame_;

2
vendor/native_mate vendored

@ -1 +1 @@
Subproject commit 553326b00696fcda106a8866872a8f2ad6caff0d Subproject commit 0df2d882ea2286e6335f206b7002037fce66c4a5