зеркало из https://github.com/electron/electron.git
Use new context aware module API in builtin modules.
This commit is contained in:
Родитель
c3301a197e
Коммит
ba46f2c820
|
@ -109,8 +109,9 @@ int DockBounce(const std::string& type) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
Browser* browser = Browser::Get();
|
Browser* browser = Browser::Get();
|
||||||
CommandLine* command_line = CommandLine::ForCurrentProcess();
|
CommandLine* command_line = CommandLine::ForCurrentProcess();
|
||||||
|
|
||||||
|
@ -140,4 +141,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_app, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_app, Initialize)
|
||||||
|
|
|
@ -85,12 +85,13 @@ mate::Handle<AutoUpdater> AutoUpdater::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("autoUpdater", atom::api::AutoUpdater::Create(isolate));
|
dict.Set("autoUpdater", atom::api::AutoUpdater::Create(isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_auto_updater, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_auto_updater, Initialize)
|
||||||
|
|
|
@ -76,8 +76,9 @@ void ShowSaveDialog(const std::string& title,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("showMessageBox", &ShowMessageBox);
|
dict.SetMethod("showMessageBox", &ShowMessageBox);
|
||||||
dict.SetMethod("showOpenDialog", &ShowOpenDialog);
|
dict.SetMethod("showOpenDialog", &ShowOpenDialog);
|
||||||
dict.SetMethod("showSaveDialog", &ShowSaveDialog);
|
dict.SetMethod("showSaveDialog", &ShowSaveDialog);
|
||||||
|
@ -85,4 +86,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_dialog, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_dialog, Initialize)
|
||||||
|
|
|
@ -262,9 +262,10 @@ void Menu::BuildPrototype(v8::Isolate* isolate,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
using atom::api::Menu;
|
using atom::api::Menu;
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
v8::Local<v8::Function> constructor = mate::CreateConstructor<Menu>(
|
v8::Local<v8::Function> constructor = mate::CreateConstructor<Menu>(
|
||||||
isolate, "Menu", base::Bind(&Menu::Create));
|
isolate, "Menu", base::Bind(&Menu::Create));
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
|
@ -278,4 +279,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_menu, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_menu, Initialize)
|
||||||
|
|
|
@ -49,13 +49,14 @@ mate::Handle<PowerMonitor> PowerMonitor::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
|
base::PowerMonitorDeviceSource::AllocateSystemIOPorts();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using atom::api::PowerMonitor;
|
using atom::api::PowerMonitor;
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Handle<PowerMonitor> power_monitor = PowerMonitor::Create(isolate);
|
mate::Handle<PowerMonitor> power_monitor = PowerMonitor::Create(isolate);
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("powerMonitor", power_monitor);
|
dict.Set("powerMonitor", power_monitor);
|
||||||
|
@ -63,4 +64,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_power_monitor, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_power_monitor, Initialize)
|
||||||
|
|
|
@ -322,16 +322,17 @@ mate::Handle<Protocol> Protocol::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
// Make sure the job factory has been created.
|
// Make sure the job factory has been created.
|
||||||
atom::AtomBrowserContext::Get()->url_request_context_getter()->
|
atom::AtomBrowserContext::Get()->url_request_context_getter()->
|
||||||
GetURLRequestContext();
|
GetURLRequestContext();
|
||||||
|
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("protocol", atom::api::Protocol::Create(isolate));
|
dict.Set("protocol", atom::api::Protocol::Create(isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_protocol, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_protocol, Initialize)
|
||||||
|
|
|
@ -69,9 +69,10 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
using atom::api::Tray;
|
using atom::api::Tray;
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
v8::Handle<v8::Function> constructor = mate::CreateConstructor<Tray>(
|
v8::Handle<v8::Function> constructor = mate::CreateConstructor<Tray>(
|
||||||
isolate, "Tray", base::Bind(&Tray::New));
|
isolate, "Tray", base::Bind(&Tray::New));
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
|
@ -80,4 +81,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_tray, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_tray, Initialize)
|
||||||
|
|
|
@ -388,9 +388,10 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
using atom::api::Window;
|
using atom::api::Window;
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
v8::Local<v8::Function> constructor = mate::CreateConstructor<Window>(
|
v8::Local<v8::Function> constructor = mate::CreateConstructor<Window>(
|
||||||
isolate, "BrowserWindow", base::Bind(&Window::New));
|
isolate, "BrowserWindow", base::Bind(&Window::New));
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
|
@ -399,4 +400,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_browser_window, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_browser_window, Initialize)
|
||||||
|
|
|
@ -67,8 +67,9 @@ void Clear(ui::ClipboardType type) {
|
||||||
ui::Clipboard::GetForCurrentThread()->Clear(type);
|
ui::Clipboard::GetForCurrentThread()->Clear(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("_has", &Has);
|
dict.SetMethod("_has", &Has);
|
||||||
dict.SetMethod("_read", &Read);
|
dict.SetMethod("_read", &Read);
|
||||||
dict.SetMethod("_readText", &ReadText);
|
dict.SetMethod("_readText", &ReadText);
|
||||||
|
@ -78,4 +79,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_common_clipboard, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_clipboard, Initialize)
|
||||||
|
|
|
@ -35,9 +35,10 @@ struct Converter<std::map<std::string, std::string> > {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
using crash_reporter::CrashReporter;
|
using crash_reporter::CrashReporter;
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("start",
|
dict.SetMethod("start",
|
||||||
base::Bind(&CrashReporter::Start,
|
base::Bind(&CrashReporter::Start,
|
||||||
base::Unretained(CrashReporter::GetInstance())));
|
base::Unretained(CrashReporter::GetInstance())));
|
||||||
|
@ -45,4 +46,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_common_crash_reporter, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_crash_reporter, Initialize)
|
||||||
|
|
|
@ -91,10 +91,10 @@ void IDWeakMap::WeakCallback(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
using atom::api::IDWeakMap;
|
using atom::api::IDWeakMap;
|
||||||
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
|
||||||
v8::Local<v8::Function> constructor = mate::CreateConstructor<IDWeakMap>(
|
v8::Local<v8::Function> constructor = mate::CreateConstructor<IDWeakMap>(
|
||||||
isolate,
|
isolate,
|
||||||
"IDWeakMap",
|
"IDWeakMap",
|
||||||
|
@ -104,4 +104,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_common_id_weak_map, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_id_weak_map, Initialize)
|
||||||
|
|
|
@ -86,13 +86,14 @@ struct Converter<gfx::Display> {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
#if defined(TOOLKIT_GTK)
|
#if defined(TOOLKIT_GTK)
|
||||||
gfx::GdkInitFromCommandLine(*CommandLine::ForCurrentProcess());
|
gfx::GdkInitFromCommandLine(*CommandLine::ForCurrentProcess());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
gfx::Screen* screen = gfx::Screen::GetNativeScreen();
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("getCursorScreenPoint",
|
dict.SetMethod("getCursorScreenPoint",
|
||||||
base::Bind(&gfx::Screen::GetCursorScreenPoint,
|
base::Bind(&gfx::Screen::GetCursorScreenPoint,
|
||||||
base::Unretained(screen)));
|
base::Unretained(screen)));
|
||||||
|
@ -103,4 +104,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_common_screen, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_screen, Initialize)
|
||||||
|
|
|
@ -13,8 +13,9 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
dict.SetMethod("showItemInFolder", &platform_util::ShowItemInFolder);
|
||||||
dict.SetMethod("openItem", &platform_util::OpenItem);
|
dict.SetMethod("openItem", &platform_util::OpenItem);
|
||||||
dict.SetMethod("openExternal", &platform_util::OpenExternal);
|
dict.SetMethod("openExternal", &platform_util::OpenExternal);
|
||||||
|
@ -24,4 +25,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_common_shell, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_shell, Initialize)
|
||||||
|
|
|
@ -43,8 +43,9 @@ void TakeHeapSnapshot(v8::Isolate* isolate) {
|
||||||
mate::StringToV8(isolate, "test"));
|
mate::StringToV8(isolate, "test"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("createObjectWithName", &CreateObjectWithName);
|
dict.SetMethod("createObjectWithName", &CreateObjectWithName);
|
||||||
dict.SetMethod("getHiddenValue", &GetHiddenValue);
|
dict.SetMethod("getHiddenValue", &GetHiddenValue);
|
||||||
dict.SetMethod("setHiddenValue", &SetHiddenValue);
|
dict.SetMethod("setHiddenValue", &SetHiddenValue);
|
||||||
|
@ -55,4 +56,4 @@ void Initialize(v8::Handle<v8::Object> exports) {
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_common_v8_util, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_common_v8_util, Initialize)
|
||||||
|
|
|
@ -62,12 +62,13 @@ base::string16 SendSync(const base::string16& channel,
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
mate::Dictionary dict(v8::Isolate::GetCurrent(), exports);
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
mate::Dictionary dict(context->GetIsolate(), exports);
|
||||||
dict.SetMethod("send", &Send);
|
dict.SetMethod("send", &Send);
|
||||||
dict.SetMethod("sendSync", &SendSync);
|
dict.SetMethod("sendSync", &SendSync);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_renderer_ipc, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_ipc, Initialize)
|
||||||
|
|
|
@ -69,12 +69,13 @@ mate::Handle<WebView> WebView::Create(v8::Isolate* isolate) {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void Initialize(v8::Handle<v8::Object> exports) {
|
void Initialize(v8::Handle<v8::Object> exports, v8::Handle<v8::Value> unused,
|
||||||
v8::Isolate* isolate = v8::Isolate::GetCurrent();
|
v8::Handle<v8::Context> context, void* priv) {
|
||||||
|
v8::Isolate* isolate = context->GetIsolate();
|
||||||
mate::Dictionary dict(isolate, exports);
|
mate::Dictionary dict(isolate, exports);
|
||||||
dict.Set("webView", atom::api::WebView::Create(isolate));
|
dict.Set("webView", atom::api::WebView::Create(isolate));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
NODE_MODULE_X(atom_renderer_web_view, Initialize, NULL, NM_F_BUILTIN)
|
NODE_MODULE_CONTEXT_AWARE_BUILTIN(atom_renderer_web_view, Initialize)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче