From cd4c5d976b5fe67ed8098dca663305765bf342f0 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 28 Jun 2014 22:33:00 +0800 Subject: [PATCH] Adapt to API changes of Chromium and node. --- atom.gyp | 5 +- atom/app/atom_library_main.cc | 2 +- atom/browser/api/atom_api_app.cc | 2 +- atom/browser/api/atom_api_auto_updater.cc | 2 +- atom/browser/api/atom_api_dialog.cc | 2 +- atom/browser/api/atom_api_menu.cc | 2 +- atom/browser/api/atom_api_power_monitor.cc | 2 +- atom/browser/api/atom_api_protocol.cc | 2 +- atom/browser/api/atom_api_tray.cc | 2 +- atom/browser/api/atom_api_window.cc | 2 +- atom/browser/atom_browser_client.cc | 7 +- atom/browser/atom_browser_client.h | 7 +- atom/browser/atom_browser_main_parts.cc | 2 +- atom/browser/native_window.cc | 20 ++-- atom/browser/native_window.h | 7 +- atom/browser/native_window_gtk.cc | 2 +- atom/browser/native_window_win.cc | 2 +- atom/browser/native_window_win.h | 4 +- .../net/atom_url_request_context_getter.cc | 15 +-- atom/browser/ui/cocoa/atom_menu_controller.mm | 2 +- atom/browser/ui/message_box_win.cc | 4 +- atom/browser/ui/win/native_menu_win.cc | 20 ++-- atom/browser/ui/win/native_menu_win.h | 4 +- atom/common/api/atom_api_clipboard.cc | 36 ++++--- atom/common/api/atom_api_crash_reporter.cc | 2 +- atom/common/api/atom_api_id_weak_map.cc | 21 ++--- atom/common/api/atom_api_id_weak_map.h | 7 +- atom/common/api/atom_api_screen.cc | 2 +- atom/common/api/atom_api_shell.cc | 2 +- atom/common/api/atom_api_v8_util.cc | 18 ++-- atom/common/api/atom_bindings.cc | 60 ++---------- atom/common/api/atom_bindings.h | 4 +- atom/common/api/atom_extensions.cc | 56 ----------- atom/common/api/atom_extensions.h | 35 ------- atom/common/api/object_life_monitor.cc | 26 +++--- atom/common/api/object_life_monitor.h | 8 +- .../crash_reporter/crash_reporter_win.cc | 2 +- .../crash_reporter/win/crash_service_main.cc | 2 +- atom/common/lib/init.coffee | 2 + .../native_mate_converters/image_converter.cc | 1 + .../v8_value_converter.cc | 93 ++++++++++--------- .../v8_value_converter.h | 27 +++--- .../native_mate_converters/value_converter.cc | 8 +- atom/common/node_bindings.cc | 33 +++---- atom/common/node_bindings.h | 6 -- atom/renderer/api/atom_api_renderer_ipc.cc | 13 +-- atom/renderer/api/atom_api_web_view.cc | 12 +-- atom/renderer/api/atom_api_web_view.h | 4 +- atom/renderer/api/atom_renderer_bindings.cc | 21 +++-- atom/renderer/api/atom_renderer_bindings.h | 6 +- atom/renderer/atom_render_view_observer.cc | 14 +-- atom/renderer/atom_render_view_observer.h | 6 +- atom/renderer/atom_renderer_client.cc | 21 +++-- atom/renderer/atom_renderer_client.h | 14 +-- vendor/native_mate | 2 +- 55 files changed, 281 insertions(+), 402 deletions(-) delete mode 100644 atom/common/api/atom_extensions.cc delete mode 100644 atom/common/api/atom_extensions.h diff --git a/atom.gyp b/atom.gyp index fff91713144..0e2b19bf183 100644 --- a/atom.gyp +++ b/atom.gyp @@ -167,8 +167,6 @@ 'atom/common/api/atom_api_v8_util.cc', 'atom/common/api/atom_bindings.cc', 'atom/common/api/atom_bindings.h', - 'atom/common/api/atom_extensions.cc', - 'atom/common/api/atom_extensions.h', 'atom/common/api/object_life_monitor.cc', 'atom/common/api/object_life_monitor.h', 'atom/common/browser_v8_locker.cc', @@ -382,6 +380,7 @@ '<(libchromiumcontent_library_dir)/icudt.dll', '<(libchromiumcontent_library_dir)/libEGL.dll', '<(libchromiumcontent_library_dir)/libGLESv2.dll', + '<(libchromiumcontent_resources_dir)/icudtl.dat', '<(libchromiumcontent_resources_dir)/content_shell.pak', 'external_binaries/d3dcompiler_43.dll', 'external_binaries/xinput1_3.dll', @@ -402,6 +401,7 @@ 'files': [ '<(libchromiumcontent_library_dir)/libchromiumcontent.so', '<(libchromiumcontent_library_dir)/libffmpegsumo.so', + '<(libchromiumcontent_resources_dir)/icudtl.dat', '<(libchromiumcontent_resources_dir)/content_shell.pak', ], }, @@ -663,6 +663,7 @@ 'mac_bundle_resources': [ 'atom/common/resources/mac/MainMenu.xib', '<(libchromiumcontent_resources_dir)/content_shell.pak', + '<(libchromiumcontent_resources_dir)/icudtl.dat', ], 'xcode_settings': { 'INFOPLIST_FILE': 'atom/common/resources/mac/Info.plist', diff --git a/atom/app/atom_library_main.cc b/atom/app/atom_library_main.cc index cf2b8cf1ee1..dcf3ae5e32b 100644 --- a/atom/app/atom_library_main.cc +++ b/atom/app/atom_library_main.cc @@ -10,6 +10,6 @@ #if defined(OS_MACOSX) int AtomMain(int argc, const char* argv[]) { atom::AtomMainDelegate delegate; - return content::ContentMain(argc, argv, &delegate); + return content::ContentMain(content::ContentMainParams(&delegate)); } #endif // OS_MACOSX diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 8966d3ea181..0d06b392b85 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -140,4 +140,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_app, Initialize) +NODE_MODULE_X(atom_browser_app, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_auto_updater.cc b/atom/browser/api/atom_api_auto_updater.cc index 74995a9860c..65842b21e98 100644 --- a/atom/browser/api/atom_api_auto_updater.cc +++ b/atom/browser/api/atom_api_auto_updater.cc @@ -93,4 +93,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_auto_updater, Initialize) +NODE_MODULE_X(atom_browser_auto_updater, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_dialog.cc b/atom/browser/api/atom_api_dialog.cc index 753a2a343af..217aab0c790 100644 --- a/atom/browser/api/atom_api_dialog.cc +++ b/atom/browser/api/atom_api_dialog.cc @@ -85,4 +85,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_dialog, Initialize) +NODE_MODULE_X(atom_browser_dialog, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_menu.cc b/atom/browser/api/atom_api_menu.cc index 322b03e5015..73464456d47 100644 --- a/atom/browser/api/atom_api_menu.cc +++ b/atom/browser/api/atom_api_menu.cc @@ -278,4 +278,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_menu, Initialize) +NODE_MODULE_X(atom_browser_menu, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_power_monitor.cc b/atom/browser/api/atom_api_power_monitor.cc index 88e49db492f..4ceb2a168bd 100644 --- a/atom/browser/api/atom_api_power_monitor.cc +++ b/atom/browser/api/atom_api_power_monitor.cc @@ -63,4 +63,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_power_monitor, Initialize) +NODE_MODULE_X(atom_browser_power_monitor, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index 4c0e3f1b7b8..4eeca5ab9ce 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -334,4 +334,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_protocol, Initialize) +NODE_MODULE_X(atom_browser_protocol, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_tray.cc b/atom/browser/api/atom_api_tray.cc index 49d95402443..32fa4ee6208 100644 --- a/atom/browser/api/atom_api_tray.cc +++ b/atom/browser/api/atom_api_tray.cc @@ -80,4 +80,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_tray, Initialize) +NODE_MODULE_X(atom_browser_tray, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 6a8628d253d..1f87e549daa 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -399,4 +399,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_browser_window, Initialize) +NODE_MODULE_X(atom_browser_window, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index 74b38d6b309..60c1d314be9 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -44,7 +44,8 @@ AtomBrowserClient::~AtomBrowserClient() { net::URLRequestContextGetter* AtomBrowserClient::CreateRequestContext( content::BrowserContext* browser_context, - content::ProtocolHandlerMap* protocol_handlers) { + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors) { return static_cast(browser_context)-> CreateRequestContext(protocol_handlers); } @@ -77,7 +78,7 @@ void AtomBrowserClient::OverrideWebkitPrefs( window->OverrideWebkitPrefs(url, prefs); } -bool AtomBrowserClient::ShouldSwapProcessesForNavigation( +bool AtomBrowserClient::ShouldSwapBrowsingInstancesForNavigation( content::SiteInstance* site_instance, const GURL& current_url, const GURL& new_url) { @@ -94,7 +95,7 @@ std::string AtomBrowserClient::GetApplicationLocale() { } void AtomBrowserClient::AppendExtraCommandLineSwitches( - CommandLine* command_line, + base::CommandLine* command_line, int child_process_id) { WindowList* list = WindowList::GetInstance(); NativeWindow* window = NULL; diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 10ae1b0c7dc..b4b4a08b55e 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -19,16 +19,17 @@ class AtomBrowserClient : public brightray::BrowserClient { protected: net::URLRequestContextGetter* CreateRequestContext( content::BrowserContext* browser_context, - content::ProtocolHandlerMap* protocol_handlers) OVERRIDE; + content::ProtocolHandlerMap* protocol_handlers, + content::ProtocolHandlerScopedVector protocol_interceptors) OVERRIDE; virtual void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, const GURL& url, WebPreferences* prefs) OVERRIDE; - virtual bool ShouldSwapProcessesForNavigation( + virtual bool ShouldSwapBrowsingInstancesForNavigation( content::SiteInstance* site_instance, const GURL& current_url, const GURL& new_url) OVERRIDE; virtual std::string GetApplicationLocale() OVERRIDE; - virtual void AppendExtraCommandLineSwitches(CommandLine* command_line, + virtual void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id) OVERRIDE; private: diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 784b31368e7..2ca497b6496 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -63,7 +63,7 @@ void AtomBrowserMainParts::PostEarlyInitialization() { context->Enter(); // Add atom-shell extended APIs. - atom_bindings_->BindTo(global_env->process_object()); + atom_bindings_->BindTo(isolate, global_env->process_object()); } void AtomBrowserMainParts::PreMainMessageLoopRun() { diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 4f89038366a..19510c878fc 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -34,11 +34,13 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/plugin_service.h" +#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "content/public/browser/web_contents_view.h" #include "content/public/common/renderer_preferences.h" +#include "content/public/common/user_agent.h" #include "ipc/ipc_message_macros.h" #include "native_mate/dictionary.h" #include "ui/gfx/codec/png_codec.h" @@ -49,7 +51,6 @@ #include "ui/gfx/size.h" #include "vendor/brightray/browser/inspectable_web_contents.h" #include "vendor/brightray/browser/inspectable_web_contents_view.h" -#include "webkit/common/user_agent/user_agent_util.h" #include "webkit/common/webpreferences.h" using content::NavigationEntry; @@ -104,7 +105,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents, browser->GetVersion().c_str(), CHROME_VERSION_STRING); web_contents->GetMutableRendererPrefs()->user_agent_override = - webkit_glue::BuildUserAgentFromProduct(product_name); + content::BuildUserAgentFromProduct(product_name); // Get notified of title updated message. registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_TITLE_UPDATED, @@ -271,7 +272,8 @@ void NativeWindow::CapturePage(const gfx::Rect& rect, size, base::Bind(&NativeWindow::OnCapturePageDone, weak_factory_.GetWeakPtr(), - callback)); + callback), + SkBitmap::kARGB_8888_Config); } void NativeWindow::DestroyWebContents() { @@ -305,7 +307,7 @@ void NativeWindow::CloseWebContents() { ScheduleUnresponsiveEvent(5000); if (web_contents->NeedToFireBeforeUnload()) - web_contents->GetRenderViewHost()->FirePageBeforeUnload(false); + web_contents->GetMainFrame()->DispatchBeforeUnload(false); else web_contents->Close(); } @@ -322,8 +324,8 @@ content::WebContents* NativeWindow::GetDevToolsWebContents() const { return inspectable_web_contents()->devtools_web_contents(); } -void NativeWindow::AppendExtraCommandLineSwitches(CommandLine* command_line, - int child_process_id) { +void NativeWindow::AppendExtraCommandLineSwitches( + base::CommandLine* command_line, int child_process_id) { // Append --node-integration to renderer process. command_line->AppendSwitchASCII(switches::kNodeIntegration, node_integration_); @@ -542,7 +544,7 @@ void NativeWindow::DevToolsSaveToFile(const std::string& url, } saved_files_[url] = path; - file_util::WriteFile(path, content.data(), content.size()); + base::WriteFile(path, content.data(), content.size()); // Notify devtools. base::StringValue url_value(url); @@ -557,7 +559,7 @@ void NativeWindow::DevToolsAppendToFile(const std::string& url, PathsMap::iterator it = saved_files_.find(url); if (it == saved_files_.end()) return; - file_util::AppendToFile(it->second, content.data(), content.size()); + base::AppendToFile(it->second, content.data(), content.size()); // Notify devtools. base::StringValue url_value(url); @@ -614,7 +616,7 @@ void NativeWindow::CallDevToolsFunction(const std::string& function_name, } } GetDevToolsWebContents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame( - string16(), base::UTF8ToUTF16(function_name + "(" + params + ");")); + base::string16(), base::UTF8ToUTF16(function_name + "(" + params + ");")); } } // namespace atom diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index a211abdeabd..6929b8d2f9d 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -22,9 +22,12 @@ #include "vendor/brightray/browser/inspectable_web_contents_delegate.h" #include "vendor/brightray/browser/inspectable_web_contents_impl.h" -class CommandLine; struct WebPreferences; +namespace base { +class CommandLine; +} + namespace content { class BrowserContext; class WebContents; @@ -160,7 +163,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate, content::WebContents* GetDevToolsWebContents() const; // Called when renderer process is going to be started. - void AppendExtraCommandLineSwitches(CommandLine* command_line, + void AppendExtraCommandLineSwitches(base::CommandLine* command_line, int child_process_id); void OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs); diff --git a/atom/browser/native_window_gtk.cc b/atom/browser/native_window_gtk.cc index 3b1f6f8d348..b064bb5d4dc 100644 --- a/atom/browser/native_window_gtk.cc +++ b/atom/browser/native_window_gtk.cc @@ -418,7 +418,7 @@ void NativeWindowGtk::UpdateDraggableRegions( void NativeWindowGtk::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { - if (event.type == WebKit::WebInputEvent::RawKeyDown) { + if (event.type == blink::WebInputEvent::RawKeyDown) { GdkEventKey* os_event = reinterpret_cast(event.os_event); ui::Accelerator accelerator = ui::AcceleratorForGdkKeyCodeAndModifier( os_event->keyval, static_cast(os_event->state)); diff --git a/atom/browser/native_window_win.cc b/atom/browser/native_window_win.cc index 3ba3daa91ad..a590b5664d6 100644 --- a/atom/browser/native_window_win.cc +++ b/atom/browser/native_window_win.cc @@ -469,7 +469,7 @@ void NativeWindowWin::UpdateDraggableRegions( void NativeWindowWin::HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent& event) { - if (event.type == WebKit::WebInputEvent::RawKeyDown) { + if (event.type == blink::WebInputEvent::RawKeyDown) { ui::Accelerator accelerator( static_cast(event.windowsKeyCode), content::GetModifiersFromNativeWebKeyboardEvent(event)); diff --git a/atom/browser/native_window_win.h b/atom/browser/native_window_win.h index 0a5047523fa..c0292974440 100644 --- a/atom/browser/native_window_win.h +++ b/atom/browser/native_window_win.h @@ -111,7 +111,7 @@ class NativeWindowWin : public NativeWindow, virtual views::View* GetInitiallyFocusedView() OVERRIDE; virtual bool CanResize() const OVERRIDE; virtual bool CanMaximize() const OVERRIDE; - virtual string16 GetWindowTitle() const OVERRIDE; + virtual base::string16 GetWindowTitle() const OVERRIDE; virtual bool ShouldHandleSystemCommands() const OVERRIDE; virtual gfx::ImageSkia GetWindowAppIcon() OVERRIDE; virtual gfx::ImageSkia GetWindowIcon() OVERRIDE; @@ -150,7 +150,7 @@ class NativeWindowWin : public NativeWindow, bool use_content_size_; bool resizable_; - string16 title_; + base::string16 title_; gfx::Size minimum_size_; gfx::Size maximum_size_; diff --git a/atom/browser/net/atom_url_request_context_getter.cc b/atom/browser/net/atom_url_request_context_getter.cc index d5be00b983b..346a05da77b 100644 --- a/atom/browser/net/atom_url_request_context_getter.cc +++ b/atom/browser/net/atom_url_request_context_getter.cc @@ -32,6 +32,7 @@ #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_storage.h" #include "vendor/brightray/browser/network_delegate.h" +#include "webkit/browser/quota/special_storage_policy.h" namespace atom { @@ -75,18 +76,18 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() { url_request_context_->set_network_delegate(network_delegate_.get()); storage_.reset( new net::URLRequestContextStorage(url_request_context_.get())); - storage_->set_cookie_store(content::CreatePersistentCookieStore( + auto cookie_config = content::CookieStoreConfig( base_path_.Append(FILE_PATH_LITERAL("Cookies")), - false, + content::CookieStoreConfig::EPHEMERAL_SESSION_COOKIES, nullptr, - nullptr, - nullptr)); + nullptr); + storage_->set_cookie_store(content::CreateCookieStore(cookie_config)); storage_->set_server_bound_cert_service(new net::ServerBoundCertService( new net::DefaultServerBoundCertStore(NULL), base::WorkerPool::GetTaskRunner(true))); storage_->set_http_user_agent_settings( new net::StaticHttpUserAgentSettings( - "en-us,en", EmptyString())); + "en-us,en", base::EmptyString())); scoped_ptr host_resolver( net::HostResolver::CreateDefaultResolver(NULL)); @@ -163,9 +164,9 @@ net::URLRequestContext* AtomURLRequestContextGetter::GetURLRequestContext() { content::BrowserThread::GetBlockingPool()-> GetTaskRunnerWithShutdownBehavior( base::SequencedWorkerPool::SKIP_ON_SHUTDOWN))); - job_factory_->SetProtocolHandler(chrome::kDataScheme, + job_factory_->SetProtocolHandler(content::kDataScheme, new net::DataProtocolHandler); - job_factory_->SetProtocolHandler(chrome::kFileScheme, + job_factory_->SetProtocolHandler(content::kFileScheme, file_protocol_handler.release()); storage_->set_job_factory(job_factory_); } diff --git a/atom/browser/ui/cocoa/atom_menu_controller.mm b/atom/browser/ui/cocoa/atom_menu_controller.mm index 249eecc8bc2..05e4b4cc41d 100644 --- a/atom/browser/ui/cocoa/atom_menu_controller.mm +++ b/atom/browser/ui/cocoa/atom_menu_controller.mm @@ -131,7 +131,7 @@ int EventFlagsFromNSEvent(NSEvent* event) { - (void)addItemToMenu:(NSMenu*)menu atIndex:(NSInteger)index fromModel:(ui::MenuModel*)model { - string16 label16 = model->GetLabelAt(index); + base::string16 label16 = model->GetLabelAt(index); NSString* label = l10n_util::FixUpWindowsStyleLabel(label16); base::scoped_nsobject item( [[NSMenuItem alloc] initWithTitle:label diff --git a/atom/browser/ui/message_box_win.cc b/atom/browser/ui/message_box_win.cc index 66b2eb6792a..d180d9edb38 100644 --- a/atom/browser/ui/message_box_win.cc +++ b/atom/browser/ui/message_box_win.cc @@ -53,7 +53,7 @@ class MessageDialog : public base::MessageLoop::Dispatcher, virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; // Overridden from views::WidgetDelegate: - virtual string16 GetWindowTitle() const; + virtual base::string16 GetWindowTitle() const; virtual void WindowClosing() OVERRIDE; virtual views::Widget* GetWidget() OVERRIDE; virtual const views::Widget* GetWidget() const OVERRIDE; @@ -73,7 +73,7 @@ class MessageDialog : public base::MessageLoop::Dispatcher, bool should_close_; bool delete_on_close_; int result_; - string16 title_; + base::string16 title_; views::Widget* widget_; views::MessageBoxView* message_box_view_; scoped_ptr dialog_scope_; diff --git a/atom/browser/ui/win/native_menu_win.cc b/atom/browser/ui/win/native_menu_win.cc index f82a0f04043..0a0a171a199 100644 --- a/atom/browser/ui/win/native_menu_win.cc +++ b/atom/browser/ui/win/native_menu_win.cc @@ -55,7 +55,7 @@ struct NativeMenuWin::ItemData { // The Windows API requires that whoever creates the menus must own the // strings used for labels, and keep them around for the lifetime of the // created menu. So be it. - string16 label; + base::string16 label; // Someone needs to own submenus, it may as well be us. scoped_ptr submenu; @@ -182,7 +182,7 @@ class NativeMenuWin::MenuHostWindow { if (data->submenu.get()) measure_item_struct->itemWidth += kArrowWidth; // If the label contains an accelerator, make room for tab. - if (data->label.find(L'\t') != string16::npos) + if (data->label.find(L'\t') != base::string16::npos) measure_item_struct->itemWidth += font.GetStringWidth(L" "); measure_item_struct->itemHeight = font.GetHeight() + kItemBottomMargin + kItemTopMargin; @@ -238,10 +238,10 @@ class NativeMenuWin::MenuHostWindow { // left and the accelerator on the right. // TODO(jungshik): This will break in RTL UI. Currently, he/ar use the // window system UI font and will not hit here. - string16 label = data->label; - string16 accel; - string16::size_type tab_pos = label.find(L'\t'); - if (tab_pos != string16::npos) { + base::string16 label = data->label; + base::string16 accel; + base::string16::size_type tab_pos = label.find(L'\t'); + if (tab_pos != base::string16::npos) { accel = label.substr(tab_pos); label = label.substr(0, tab_pos); } @@ -635,7 +635,7 @@ void NativeMenuWin::AddMenuItemAt(int menu_index, int model_index) { mii.fType = MFT_OWNERDRAW; ItemData* item_data = new ItemData; - item_data->label = string16(); + item_data->label = base::string16(); ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); if (type == ui::MenuModel::TYPE_SUBMENU) { item_data->submenu.reset(new Menu2(model_->GetSubmenuModelAt(model_index))); @@ -687,7 +687,7 @@ void NativeMenuWin::SetMenuItemState(int menu_index, bool enabled, bool checked, void NativeMenuWin::SetMenuItemLabel(int menu_index, int model_index, - const string16& label) { + const base::string16& label) { if (IsSeparatorItemAt(menu_index)) return; @@ -699,8 +699,8 @@ void NativeMenuWin::SetMenuItemLabel(int menu_index, void NativeMenuWin::UpdateMenuItemInfoForString(MENUITEMINFO* mii, int model_index, - const string16& label) { - string16 formatted = label; + const base::string16& label) { + base::string16 formatted = label; ui::MenuModel::ItemType type = model_->GetTypeAt(model_index); // Strip out any tabs, otherwise they get interpreted as accelerators and can // lead to weird behavior. diff --git a/atom/browser/ui/win/native_menu_win.h b/atom/browser/ui/win/native_menu_win.h index 121cb2ddb2d..821e641eb50 100644 --- a/atom/browser/ui/win/native_menu_win.h +++ b/atom/browser/ui/win/native_menu_win.h @@ -94,7 +94,7 @@ class NativeMenuWin { // Sets the label of the item at the specified index. void SetMenuItemLabel(int menu_index, int model_index, - const string16& label); + const base::string16& label); // Updates the local data structure with the correctly formatted version of // |label| at the specified model_index, and adds string data to |mii| if @@ -102,7 +102,7 @@ class NativeMenuWin { // of the peculiarities of the Windows menu API. void UpdateMenuItemInfoForString(MENUITEMINFO* mii, int model_index, - const string16& label); + const base::string16& label); // Returns the alignment flags to be passed to TrackPopupMenuEx, based on the // supplied alignment and the UI text direction. diff --git a/atom/common/api/atom_api_clipboard.cc b/atom/common/api/atom_api_clipboard.cc index 4275dabf412..64e53a78cd2 100644 --- a/atom/common/api/atom_api_clipboard.cc +++ b/atom/common/api/atom_api_clipboard.cc @@ -8,24 +8,25 @@ #include "atom/common/native_mate_converters/string16_converter.h" #include "native_mate/dictionary.h" #include "ui/base/clipboard/clipboard.h" +#include "ui/base/clipboard/scoped_clipboard_writer.h" #include "atom/common/node_includes.h" namespace mate { template<> -struct Converter { +struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Handle val, - ui::Clipboard::Buffer* out) { + ui::ClipboardType* out) { std::string type; if (!Converter::FromV8(isolate, val, &type)) return false; if (type == "selection") - *out = ui::Clipboard::BUFFER_SELECTION; + *out = ui::CLIPBOARD_TYPE_SELECTION; else - *out = ui::Clipboard::BUFFER_STANDARD; + *out = ui::CLIPBOARD_TYPE_COPY_PASTE; return true; } }; @@ -34,14 +35,14 @@ struct Converter { namespace { -bool Has(const std::string& format_string, ui::Clipboard::Buffer buffer) { +bool Has(const std::string& format_string, ui::ClipboardType type) { ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string)); - return clipboard->IsFormatAvailable(format, buffer); + return clipboard->IsFormatAvailable(format, type); } std::string Read(const std::string& format_string, - ui::Clipboard::Buffer buffer) { + ui::ClipboardType type) { ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); ui::Clipboard::FormatType format(ui::Clipboard::GetFormatType(format_string)); @@ -50,23 +51,20 @@ std::string Read(const std::string& format_string, return data; } -string16 ReadText(ui::Clipboard::Buffer buffer) { - string16 data; - ui::Clipboard::GetForCurrentThread()->ReadText(buffer, &data); +base::string16 ReadText(ui::ClipboardType type) { + base::string16 data; + ui::Clipboard::GetForCurrentThread()->ReadText(type, &data); return data; } -void WriteText(const std::string text, ui::Clipboard::Buffer buffer) { - ui::Clipboard::ObjectMap object_map; - object_map[ui::Clipboard::CBF_TEXT].push_back( - std::vector(text.begin(), text.end())); - +void WriteText(const base::string16& text, ui::ClipboardType type) { ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); - clipboard->WriteObjects(buffer, object_map); + ui::ScopedClipboardWriter writer(clipboard, type); + writer.WriteText(text); } -void Clear(ui::Clipboard::Buffer buffer) { - ui::Clipboard::GetForCurrentThread()->Clear(buffer); +void Clear(ui::ClipboardType type) { + ui::Clipboard::GetForCurrentThread()->Clear(type); } void Initialize(v8::Handle exports) { @@ -80,4 +78,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_common_clipboard, Initialize) +NODE_MODULE_X(atom_common_clipboard, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/common/api/atom_api_crash_reporter.cc b/atom/common/api/atom_api_crash_reporter.cc index ddf869a217d..2bd5ce4342e 100644 --- a/atom/common/api/atom_api_crash_reporter.cc +++ b/atom/common/api/atom_api_crash_reporter.cc @@ -45,4 +45,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_common_crash_reporter, Initialize) +NODE_MODULE_X(atom_common_crash_reporter, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/common/api/atom_api_id_weak_map.cc b/atom/common/api/atom_api_id_weak_map.cc index 8b451ab51e0..3461f0e0b10 100644 --- a/atom/common/api/atom_api_id_weak_map.cc +++ b/atom/common/api/atom_api_id_weak_map.cc @@ -29,14 +29,14 @@ int32_t IDWeakMap::Add(v8::Isolate* isolate, v8::Handle object) { mate::Converter::ToV8(isolate, key)); map_[key] = new mate::RefCountedPersistent(object); - map_[key]->MakeWeak(this, WeakCallback); + map_[key]->SetWeak(this, WeakCallback); return key; } -v8::Handle IDWeakMap::Get(int32_t key) { +v8::Handle IDWeakMap::Get(v8::Isolate* isolate, int32_t key) { if (!Has(key)) { node::ThrowError("Invalid key"); - return v8::Undefined(); + return v8::Undefined(isolate); } return map_[key]->NewHandle(); @@ -77,14 +77,11 @@ void IDWeakMap::BuildPrototype(v8::Isolate* isolate, } // static -void IDWeakMap::WeakCallback(v8::Isolate* isolate, - v8::Persistent* value, - IDWeakMap* self) { - v8::HandleScope handle_scope(isolate); - v8::Local object = v8::Local::New(isolate, *value); - int32_t key = object->GetHiddenValue( - mate::StringToV8(isolate, "IDWeakMapKey"))->Int32Value(); - self->Remove(key); +void IDWeakMap::WeakCallback( + const v8::WeakCallbackData& data) { + int32_t key = data.GetValue()->GetHiddenValue( + mate::StringToV8(data.GetIsolate(), "IDWeakMapKey"))->Int32Value(); + data.GetParameter()->Remove(key); } } // namespace api @@ -107,4 +104,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_common_id_weak_map, Initialize) +NODE_MODULE_X(atom_common_id_weak_map, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/common/api/atom_api_id_weak_map.h b/atom/common/api/atom_api_id_weak_map.h index 092d3f90985..acadebf2e19 100644 --- a/atom/common/api/atom_api_id_weak_map.h +++ b/atom/common/api/atom_api_id_weak_map.h @@ -29,15 +29,14 @@ class IDWeakMap : public mate::Wrappable { virtual ~IDWeakMap(); int32_t Add(v8::Isolate* isolate, v8::Handle object); - v8::Handle Get(int32_t key); + v8::Handle Get(v8::Isolate* isolate, int32_t key); bool Has(int32_t key) const; std::vector Keys() const; void Remove(int32_t key); int GetNextID(); - static void WeakCallback(v8::Isolate* isolate, - v8::Persistent* value, - IDWeakMap* self); + static void WeakCallback( + const v8::WeakCallbackData& data); int32_t next_id_; diff --git a/atom/common/api/atom_api_screen.cc b/atom/common/api/atom_api_screen.cc index 3d71040d9a0..547adc4a284 100644 --- a/atom/common/api/atom_api_screen.cc +++ b/atom/common/api/atom_api_screen.cc @@ -103,4 +103,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_common_screen, Initialize) +NODE_MODULE_X(atom_common_screen, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/common/api/atom_api_shell.cc b/atom/common/api/atom_api_shell.cc index 39ff09a43a7..d88a0e4c8ee 100644 --- a/atom/common/api/atom_api_shell.cc +++ b/atom/common/api/atom_api_shell.cc @@ -24,4 +24,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_common_shell, Initialize) +NODE_MODULE_X(atom_common_shell, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/common/api/atom_api_v8_util.cc b/atom/common/api/atom_api_v8_util.cc index d68e7f8d2fe..f585df720e1 100644 --- a/atom/common/api/atom_api_v8_util.cc +++ b/atom/common/api/atom_api_v8_util.cc @@ -10,8 +10,9 @@ namespace { -v8::Handle CreateObjectWithName(v8::Handle name) { - v8::Local t = v8::FunctionTemplate::New(); +v8::Handle CreateObjectWithName(v8::Isolate* isolate, + v8::Handle name) { + v8::Local t = v8::FunctionTemplate::New(isolate); t->SetClassName(name); return t->GetFunction()->NewInstance(); } @@ -31,14 +32,15 @@ int32_t GetObjectHash(v8::Handle object) { return object->GetIdentityHash(); } -void SetDestructor(v8::Handle object, +void SetDestructor(v8::Isolate* isolate, + v8::Handle object, v8::Handle callback) { - atom::ObjectLifeMonitor::BindTo(object, callback); + atom::ObjectLifeMonitor::BindTo(isolate, object, callback); } -void TakeHeapSnapshot() { - node::node_isolate->GetHeapProfiler()->TakeHeapSnapshot( - v8::String::New("test")); +void TakeHeapSnapshot(v8::Isolate* isolate) { + isolate->GetHeapProfiler()->TakeHeapSnapshot( + mate::StringToV8(isolate, "test")); } void Initialize(v8::Handle exports) { @@ -53,4 +55,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_common_v8_util, Initialize) +NODE_MODULE_X(atom_common_v8_util, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/common/api/atom_bindings.cc b/atom/common/api/atom_bindings.cc index 29ec5eca724..13191b46183 100644 --- a/atom/common/api/atom_bindings.cc +++ b/atom/common/api/atom_bindings.cc @@ -17,9 +17,6 @@ namespace atom { -// Defined in atom_extensions.cc. -node::node_module_struct* GetBuiltinModule(const char *name, bool is_browser); - namespace { // Async handle to wake up uv loop. @@ -35,8 +32,9 @@ base::Closure g_v8_callback; struct DummyClass { bool crash; }; // Async handler to call next process.nextTick callbacks. -void UvCallNextTick(uv_async_t* handle, int status) { - node::Environment* env = node::Environment::GetCurrent(node_isolate); +void UvCallNextTick(uv_async_t* handle) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + node::Environment* env = node::Environment::GetCurrent(isolate); node::Environment::TickInfo* tick_info = env->tick_info(); if (tick_info->in_tick()) @@ -53,7 +51,7 @@ void UvCallNextTick(uv_async_t* handle, int status) { } // Async handler to execute the stored v8 callback. -void UvOnCallback(uv_async_t* handle, int status) { +void UvOnCallback(uv_async_t* handle) { g_v8_callback.Run(); } @@ -72,45 +70,6 @@ v8::Handle DumpStackFrame(v8::Isolate* isolate, return mate::ConvertToV8(isolate, frame_dict);; } -v8::Handle Binding(v8::Handle module) { - v8::String::Utf8Value module_v(module); - node::node_module_struct* modp; - - v8::Local process = v8::Context::GetCurrent()->Global()-> - Get(v8::String::New("process"))->ToObject(); - DCHECK(!process.IsEmpty()); - - // is_browser = process.type == 'browser'. - bool is_browser = std::string("browser") == *v8::String::Utf8Value( - process->Get(v8::String::New("type"))); - - // Cached in process.__atom_binding_cache. - v8::Local binding_cache; - v8::Local bc_name = v8::String::New("__atomBindingCache"); - if (process->Has(bc_name)) { - binding_cache = process->Get(bc_name)->ToObject(); - DCHECK(!binding_cache.IsEmpty()); - } else { - binding_cache = v8::Object::New(); - process->Set(bc_name, binding_cache); - } - - if (binding_cache->Has(module)) - return binding_cache->Get(module)->ToObject(); - - if ((modp = GetBuiltinModule(*module_v, is_browser)) != NULL) { - v8::Local exports = v8::Object::New(); - // Internal bindings don't have a "module" object, - // only exports. - modp->register_func(exports, v8::Undefined()); - binding_cache->Set(module, exports); - return exports; - } - - node::ThrowError("No such module"); - return v8::Undefined(); -} - void Crash() { static_cast(NULL)->crash = true; } @@ -119,17 +78,17 @@ void ActivateUVLoop() { uv_async_send(&g_next_tick_uv_handle); } -void Log(const string16& message) { +void Log(const base::string16& message) { logging::LogMessage("CONSOLE", 0, 0).stream() << message; } v8::Handle GetCurrentStackTrace(v8::Isolate* isolate, int stack_limit) { v8::Local stack_trace = v8::StackTrace::CurrentStackTrace( - stack_limit, v8::StackTrace::kDetailed); + isolate, stack_limit, v8::StackTrace::kDetailed); int frame_count = stack_trace->GetFrameCount(); - v8::Local result = v8::Array::New(frame_count); + v8::Local result = v8::Array::New(isolate, frame_count); for (int i = 0; i < frame_count; ++i) result->Set(i, DumpStackFrame(isolate, stack_trace->GetFrame(i))); @@ -153,10 +112,9 @@ AtomBindings::AtomBindings() { AtomBindings::~AtomBindings() { } -void AtomBindings::BindTo(v8::Handle process) { - v8::Isolate* isolate = v8::Isolate::GetCurrent(); +void AtomBindings::BindTo(v8::Isolate* isolate, + v8::Handle process) { mate::Dictionary dict(isolate, process); - dict.SetMethod("atomBinding", &Binding); dict.SetMethod("crash", &Crash); dict.SetMethod("activateUvLoop", &ActivateUVLoop); dict.SetMethod("log", &Log); diff --git a/atom/common/api/atom_bindings.h b/atom/common/api/atom_bindings.h index 4b5f314b11f..e4f3a418904 100644 --- a/atom/common/api/atom_bindings.h +++ b/atom/common/api/atom_bindings.h @@ -17,9 +17,9 @@ class AtomBindings { AtomBindings(); virtual ~AtomBindings(); - // Add process.atom_binding function, which behaves like process.binding but + // Add process.atom_binding function, which behaves like process.atomBinding but // load native code from atom-shell instead. - virtual void BindTo(v8::Handle process); + virtual void BindTo(v8::Isolate* isolate, v8::Handle process); private: DISALLOW_COPY_AND_ASSIGN(AtomBindings); diff --git a/atom/common/api/atom_extensions.cc b/atom/common/api/atom_extensions.cc deleted file mode 100644 index a9943aea6a1..00000000000 --- a/atom/common/api/atom_extensions.cc +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include -#include - -#include "base/strings/string_util.h" -#include "vendor/node/src/node_version.h" - -#include "atom/common/node_includes.h" - -namespace atom { - -#undef NODE_EXT_LIST_START -#undef NODE_EXT_LIST_ITEM -#undef NODE_EXT_LIST_END - -#define NODE_EXT_LIST_START -#define NODE_EXT_LIST_ITEM NODE_MODULE_DECL -#define NODE_EXT_LIST_END - -#include "atom/common/api/atom_extensions.h" - -#undef NODE_EXT_LIST_START -#undef NODE_EXT_LIST_ITEM -#undef NODE_EXT_LIST_END - -#define NODE_EXT_STRING(x) &x ## _module, -#define NODE_EXT_LIST_START node::node_module_struct *node_module_list[] = { -#define NODE_EXT_LIST_ITEM NODE_EXT_STRING -#define NODE_EXT_LIST_END NULL}; - -#include "atom/common/api/atom_extensions.h" // NOLINT - -node::node_module_struct* GetBuiltinModule(const char *name, bool is_browser) { - char common[128]; - char spec[128]; - node::node_module_struct *cur = NULL; - base::snprintf(common, sizeof(common), "atom_common_%s", name); - base::snprintf(spec, sizeof(spec), - (is_browser ? "atom_browser_%s": "atom_renderer_%s"), - name); - /* TODO: you could look these up in a hash, but there are only - * a few, and once loaded they are cached. */ - for (int i = 0; node_module_list[i] != NULL; i++) { - cur = node_module_list[i]; - if (strcmp(cur->modname, common) == 0 || strcmp(cur->modname, spec) == 0) { - return cur; - } - } - - return NULL; -} - -} // namespace atom diff --git a/atom/common/api/atom_extensions.h b/atom/common/api/atom_extensions.h deleted file mode 100644 index e8fefac7843..00000000000 --- a/atom/common/api/atom_extensions.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2013 GitHub, Inc. All rights reserved. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -// Multiply-included file, no traditional include guard. - -// Used by atom_extensions.cc to declare a list of built-in modules of Atom. - -NODE_EXT_LIST_START - -// Module names start with `atom_browser_` can only be used by browser process. -NODE_EXT_LIST_ITEM(atom_browser_app) -NODE_EXT_LIST_ITEM(atom_browser_auto_updater) -NODE_EXT_LIST_ITEM(atom_browser_dialog) -NODE_EXT_LIST_ITEM(atom_browser_menu) -NODE_EXT_LIST_ITEM(atom_browser_power_monitor) -NODE_EXT_LIST_ITEM(atom_browser_protocol) -NODE_EXT_LIST_ITEM(atom_browser_tray) -NODE_EXT_LIST_ITEM(atom_browser_window) - -// Module names start with `atom_renderer_` can only be used by renderer -// process. -NODE_EXT_LIST_ITEM(atom_renderer_ipc) -NODE_EXT_LIST_ITEM(atom_renderer_web_view) - -// Module names start with `atom_common_` can be used by both browser and -// renderer processes. -NODE_EXT_LIST_ITEM(atom_common_clipboard) -NODE_EXT_LIST_ITEM(atom_common_crash_reporter) -NODE_EXT_LIST_ITEM(atom_common_id_weak_map) -NODE_EXT_LIST_ITEM(atom_common_screen) -NODE_EXT_LIST_ITEM(atom_common_shell) -NODE_EXT_LIST_ITEM(atom_common_v8_util) - -NODE_EXT_LIST_END diff --git a/atom/common/api/object_life_monitor.cc b/atom/common/api/object_life_monitor.cc index f4ca8c49104..8d51e3d4889 100644 --- a/atom/common/api/object_life_monitor.cc +++ b/atom/common/api/object_life_monitor.cc @@ -5,34 +5,32 @@ #include "atom/common/api/object_life_monitor.h" +#include "native_mate/compat.h" + namespace atom { // static -void ObjectLifeMonitor::BindTo(v8::Handle target, +void ObjectLifeMonitor::BindTo(v8::Isolate* isolate, + v8::Handle target, v8::Handle destructor) { - target->SetHiddenValue(v8::String::New("destructor"), destructor); + target->SetHiddenValue(MATE_STRING_NEW(isolate, "destructor"), destructor); ObjectLifeMonitor* olm = new ObjectLifeMonitor(); olm->handle_.reset(target); - olm->handle_.MakeWeak(olm, WeakCallback); + olm->handle_.SetWeak(olm, WeakCallback); } ObjectLifeMonitor::ObjectLifeMonitor() { } // static -void ObjectLifeMonitor::WeakCallback(v8::Isolate* isolate, - v8::Persistent* value, - ObjectLifeMonitor* self) { +void ObjectLifeMonitor::WeakCallback( + const v8::WeakCallbackData& data) { // destructor.call(object, object); - { - v8::HandleScope handle_scope(isolate); - v8::Local obj = self->handle_.NewHandle(); - v8::Local::Cast(obj->GetHiddenValue( - v8::String::New("destructor")))->Call(obj, 0, NULL); - } - - delete self; + v8::Local obj = data.GetValue(); + v8::Local::Cast(obj->GetHiddenValue( + MATE_STRING_NEW(data.GetIsolate(), "destructor")))->Call(obj, 0, NULL); + delete data.GetParameter(); } } // namespace atom diff --git a/atom/common/api/object_life_monitor.h b/atom/common/api/object_life_monitor.h index 46b5b4b7b5b..3caaa91aaa7 100644 --- a/atom/common/api/object_life_monitor.h +++ b/atom/common/api/object_life_monitor.h @@ -12,15 +12,15 @@ namespace atom { class ObjectLifeMonitor { public: - static void BindTo(v8::Handle target, + static void BindTo(v8::Isolate* isolate, + v8::Handle target, v8::Handle destructor); private: ObjectLifeMonitor(); - static void WeakCallback(v8::Isolate* isolate, - v8::Persistent* value, - ObjectLifeMonitor* self); + static void WeakCallback( + const v8::WeakCallbackData& data); mate::ScopedPersistent handle_; diff --git a/atom/common/crash_reporter/crash_reporter_win.cc b/atom/common/crash_reporter/crash_reporter_win.cc index cff97e202ac..6e73249f0ec 100644 --- a/atom/common/crash_reporter/crash_reporter_win.cc +++ b/atom/common/crash_reporter/crash_reporter_win.cc @@ -45,7 +45,7 @@ void CrashReporterWin::InitBreakpad(const std::string& product_name, return; } - string16 pipe_name = ReplaceStringPlaceholders(kPipeNameFormat, + base::string16 pipe_name = ReplaceStringPlaceholders(kPipeNameFormat, UTF8ToUTF16(product_name), NULL); diff --git a/atom/common/crash_reporter/win/crash_service_main.cc b/atom/common/crash_reporter/win/crash_service_main.cc index 85b376ab61b..77b8848a407 100644 --- a/atom/common/crash_reporter/win/crash_service_main.cc +++ b/atom/common/crash_reporter/win/crash_service_main.cc @@ -68,7 +68,7 @@ int Main(const wchar_t* cmd) { VLOG(1) << "Session start. cmdline is [" << cmd << "]"; // Setting the crash reporter. - string16 pipe_name = ReplaceStringPlaceholders(kPipeNameFormat, + base::string16 pipe_name = ReplaceStringPlaceholders(kPipeNameFormat, application_name, NULL); cmd_line.AppendSwitch("no-window"); diff --git a/atom/common/lib/init.coffee b/atom/common/lib/init.coffee index 5e2602ac180..35ad5e512d9 100644 --- a/atom/common/lib/init.coffee +++ b/atom/common/lib/init.coffee @@ -2,6 +2,8 @@ path = require 'path' timers = require 'timers' Module = require 'module' +process.atomBinding = (name) -> process.binding "atom_#{process.type}_#{name}" + # Add common/api/lib to module search paths. globalPaths = Module.globalPaths globalPaths.push path.join(process.resourcesPath, 'atom', 'common', 'api', 'lib') diff --git a/atom/common/native_mate_converters/image_converter.cc b/atom/common/native_mate_converters/image_converter.cc index ca676c8d009..f3292297405 100644 --- a/atom/common/native_mate_converters/image_converter.cc +++ b/atom/common/native_mate_converters/image_converter.cc @@ -12,6 +12,7 @@ #include "ui/gfx/codec/jpeg_codec.h" #include "ui/gfx/codec/png_codec.h" #include "ui/gfx/image/image_skia.h" +#include "ui/base/layout.h" namespace mate { diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index ca0af6f825b..fc128434526 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -36,74 +36,76 @@ void V8ValueConverter::SetStripNullFromObjects(bool val) { strip_null_from_objects_ = val; } -v8::Handle V8ValueConverter::ToV8Value( - const base::Value* value, v8::Handle context) const { +v8::Local V8ValueConverter::ToV8Value( + const base::Value* value, v8::Local context) const { v8::Context::Scope context_scope(context); - v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); - return handle_scope.Close(ToV8ValueImpl(value)); + v8::EscapableHandleScope handle_scope(context->GetIsolate()); + return handle_scope.Escape(ToV8ValueImpl(context->GetIsolate(), value)); } -Value* V8ValueConverter::FromV8Value( - v8::Handle val, - v8::Handle context) const { +base::Value* V8ValueConverter::FromV8Value( + v8::Local val, + v8::Local context) const { v8::Context::Scope context_scope(context); - v8::HandleScope handle_scope(v8::Isolate::GetCurrent()); + v8::HandleScope handle_scope(context->GetIsolate()); HashToHandleMap unique_map; return FromV8ValueImpl(val, &unique_map); } -v8::Handle V8ValueConverter::ToV8ValueImpl( - const base::Value* value) const { +v8::Local V8ValueConverter::ToV8ValueImpl( + v8::Isolate* isolate, const base::Value* value) const { CHECK(value); switch (value->GetType()) { case base::Value::TYPE_NULL: - return v8::Null(); + return v8::Null(isolate); case base::Value::TYPE_BOOLEAN: { bool val = false; CHECK(value->GetAsBoolean(&val)); - return v8::Boolean::New(val); + return v8::Boolean::New(isolate, val); } case base::Value::TYPE_INTEGER: { int val = 0; CHECK(value->GetAsInteger(&val)); - return v8::Integer::New(val); + return v8::Integer::New(isolate, val); } case base::Value::TYPE_DOUBLE: { double val = 0.0; CHECK(value->GetAsDouble(&val)); - return v8::Number::New(val); + return v8::Number::New(isolate, val); } case base::Value::TYPE_STRING: { std::string val; CHECK(value->GetAsString(&val)); - return v8::String::New(val.c_str(), val.length()); + return v8::String::NewFromUtf8( + isolate, val.c_str(), v8::String::kNormalString, val.length()); } case base::Value::TYPE_LIST: - return ToV8Array(static_cast(value)); + return ToV8Array(isolate, static_cast(value)); case base::Value::TYPE_DICTIONARY: - return ToV8Object(static_cast(value)); + return ToV8Object(isolate, + static_cast(value)); default: LOG(ERROR) << "Unexpected value type: " << value->GetType(); - return v8::Null(); + return v8::Null(isolate); } } -v8::Handle V8ValueConverter::ToV8Array( - const base::ListValue* val) const { - v8::Handle result(v8::Array::New(val->GetSize())); +v8::Local V8ValueConverter::ToV8Array( + v8::Isolate* isolate, const base::ListValue* val) const { + v8::Local result(v8::Array::New(isolate, val->GetSize())); for (size_t i = 0; i < val->GetSize(); ++i) { const base::Value* child = NULL; CHECK(val->Get(i, &child)); - v8::Handle child_v8 = ToV8ValueImpl(child); + v8::Local child_v8 = ToV8ValueImpl(isolate, child); CHECK(!child_v8.IsEmpty()); v8::TryCatch try_catch; @@ -115,18 +117,21 @@ v8::Handle V8ValueConverter::ToV8Array( return result; } -v8::Handle V8ValueConverter::ToV8Object( - const base::DictionaryValue* val) const { - v8::Handle result(v8::Object::New()); +v8::Local V8ValueConverter::ToV8Object( + v8::Isolate* isolate, const base::DictionaryValue* val) const { + v8::Local result(v8::Object::New(isolate)); for (base::DictionaryValue::Iterator iter(*val); !iter.IsAtEnd(); iter.Advance()) { const std::string& key = iter.key(); - v8::Handle child_v8 = ToV8ValueImpl(&iter.value()); + v8::Local child_v8 = ToV8ValueImpl(isolate, &iter.value()); CHECK(!child_v8.IsEmpty()); v8::TryCatch try_catch; - result->Set(v8::String::New(key.c_str(), key.length()), child_v8); + result->Set( + v8::String::NewFromUtf8(isolate, key.c_str(), v8::String::kNormalString, + key.length()), + child_v8); if (try_catch.HasCaught()) { LOG(ERROR) << "Setter for property " << key.c_str() << " threw an " << "exception."; @@ -136,7 +141,7 @@ v8::Handle V8ValueConverter::ToV8Object( return result; } -Value* V8ValueConverter::FromV8ValueImpl(v8::Handle val, +base::Value* V8ValueConverter::FromV8ValueImpl(v8::Local val, HashToHandleMap* unique_map) const { CHECK(!val.IsEmpty()); @@ -196,16 +201,17 @@ Value* V8ValueConverter::FromV8ValueImpl(v8::Handle val, return NULL; } -Value* V8ValueConverter::FromV8Array(v8::Handle val, +base::Value* V8ValueConverter::FromV8Array(v8::Local val, HashToHandleMap* unique_map) const { if (!UpdateAndCheckUniqueness(unique_map, val)) return base::Value::CreateNullValue(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); scoped_ptr scope; // If val was created in a different context than our current one, change to // that context, but change back after val is converted. if (!val->CreationContext().IsEmpty() && - val->CreationContext() != v8::Context::GetCurrent()) + val->CreationContext() != isolate->GetCurrentContext()) scope.reset(new v8::Context::Scope(val->CreationContext())); base::ListValue* result = new base::ListValue(); @@ -213,10 +219,10 @@ Value* V8ValueConverter::FromV8Array(v8::Handle val, // Only fields with integer keys are carried over to the ListValue. for (uint32 i = 0; i < val->Length(); ++i) { v8::TryCatch try_catch; - v8::Handle child_v8 = val->Get(i); + v8::Local child_v8 = val->Get(i); if (try_catch.HasCaught()) { LOG(ERROR) << "Getter for index " << i << " threw an exception."; - child_v8 = v8::Null(); + child_v8 = v8::Null(isolate); } if (!val->HasRealIndexedProperty(i)) @@ -233,28 +239,29 @@ Value* V8ValueConverter::FromV8Array(v8::Handle val, return result; } -Value* V8ValueConverter::FromV8Object( - v8::Handle val, +base::Value* V8ValueConverter::FromV8Object( + v8::Local val, HashToHandleMap* unique_map) const { if (!UpdateAndCheckUniqueness(unique_map, val)) return base::Value::CreateNullValue(); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); scoped_ptr scope; // If val was created in a different context than our current one, change to // that context, but change back after val is converted. if (!val->CreationContext().IsEmpty() && - val->CreationContext() != v8::Context::GetCurrent()) + val->CreationContext() != isolate->GetCurrentContext()) scope.reset(new v8::Context::Scope(val->CreationContext())); scoped_ptr result(new base::DictionaryValue()); - v8::Handle property_names(val->GetOwnPropertyNames()); + v8::Local property_names(val->GetOwnPropertyNames()); for (uint32 i = 0; i < property_names->Length(); ++i) { - v8::Handle key(property_names->Get(i)); + v8::Local key(property_names->Get(i)); // Extend this test to cover more types as necessary and if sensible. if (!key->IsString() && !key->IsNumber()) { - NOTREACHED() << "Key \"" << *v8::String::AsciiValue(key) << "\" " + NOTREACHED() << "Key \"" << *v8::String::Utf8Value(key) << "\" " "is neither a string nor a number"; continue; } @@ -266,12 +273,12 @@ Value* V8ValueConverter::FromV8Object( v8::String::Utf8Value name_utf8(key->ToString()); v8::TryCatch try_catch; - v8::Handle child_v8 = val->Get(key); + v8::Local child_v8 = val->Get(key); if (try_catch.HasCaught()) { LOG(ERROR) << "Getter for property " << *name_utf8 << " threw an exception."; - child_v8 = v8::Null(); + child_v8 = v8::Null(isolate); } scoped_ptr child(FromV8ValueImpl(child_v8, unique_map)); @@ -300,7 +307,7 @@ Value* V8ValueConverter::FromV8Object( // there *is* a "windowId" property, but since it should be an int, code // on the browser which doesn't additionally check for null will fail. // We can avoid all bugs related to this by stripping null. - if (strip_null_from_objects_ && child->IsType(Value::TYPE_NULL)) + if (strip_null_from_objects_ && child->IsType(base::Value::TYPE_NULL)) continue; result->SetWithoutPathExpansion(std::string(*name_utf8, name_utf8.length()), @@ -312,7 +319,7 @@ Value* V8ValueConverter::FromV8Object( bool V8ValueConverter::UpdateAndCheckUniqueness( HashToHandleMap* map, - v8::Handle handle) const { + v8::Local handle) const { typedef HashToHandleMap::const_iterator Iterator; int hash = avoid_identity_hash_for_testing_ ? 0 : handle->GetIdentityHash(); @@ -326,7 +333,7 @@ bool V8ValueConverter::UpdateAndCheckUniqueness( return false; } - map->insert(std::pair >(hash, handle)); + map->insert(std::pair >(hash, handle)); return true; } diff --git a/atom/common/native_mate_converters/v8_value_converter.h b/atom/common/native_mate_converters/v8_value_converter.h index 5c7e6182acb..40688978bbd 100644 --- a/atom/common/native_mate_converters/v8_value_converter.h +++ b/atom/common/native_mate_converters/v8_value_converter.h @@ -28,25 +28,28 @@ class V8ValueConverter { void SetRegExpAllowed(bool val); void SetFunctionAllowed(bool val); void SetStripNullFromObjects(bool val); - v8::Handle ToV8Value(const base::Value* value, - v8::Handle context) const; - base::Value* FromV8Value(v8::Handle value, - v8::Handle context) const; + v8::Local ToV8Value(const base::Value* value, + v8::Local context) const; + base::Value* FromV8Value(v8::Local value, + v8::Local context) const; private: - typedef std::multimap > HashToHandleMap; + typedef std::multimap > HashToHandleMap; - v8::Handle ToV8ValueImpl(const base::Value* value) const; - v8::Handle ToV8Array(const base::ListValue* list) const; - v8::Handle ToV8Object( + v8::Local ToV8ValueImpl(v8::Isolate* isolate, + const base::Value* value) const; + v8::Local ToV8Array(v8::Isolate* isolate, + const base::ListValue* list) const; + v8::Local ToV8Object( + v8::Isolate* isolate, const base::DictionaryValue* dictionary) const; - base::Value* FromV8ValueImpl(v8::Handle value, + base::Value* FromV8ValueImpl(v8::Local value, HashToHandleMap* unique_map) const; - base::Value* FromV8Array(v8::Handle array, + base::Value* FromV8Array(v8::Local array, HashToHandleMap* unique_map) const; - base::Value* FromV8Object(v8::Handle object, + base::Value* FromV8Object(v8::Local object, HashToHandleMap* unique_map) const; // If |handle| is not in |map|, then add it to |map| and return true. @@ -55,7 +58,7 @@ class V8ValueConverter { // be unique even if there already is another handle with the same identity // hash (key) in the map, because two objects can have the same hash. bool UpdateAndCheckUniqueness(HashToHandleMap* map, - v8::Handle handle) const; + v8::Local handle) const; // If true, we will convert Date JavaScript objects to doubles. bool date_allowed_; diff --git a/atom/common/native_mate_converters/value_converter.cc b/atom/common/native_mate_converters/value_converter.cc index 79848b28bf4..e56100b1504 100644 --- a/atom/common/native_mate_converters/value_converter.cc +++ b/atom/common/native_mate_converters/value_converter.cc @@ -14,9 +14,9 @@ bool Converter::FromV8(v8::Isolate* isolate, base::DictionaryValue* out) { scoped_ptr converter(new atom::V8ValueConverter); scoped_ptr value(converter->FromV8Value( - val, v8::Context::GetCurrent())); + val, isolate->GetCurrentContext())); if (value && value->IsType(base::Value::TYPE_DICTIONARY)) { - out->Swap(static_cast(value.get())); + out->Swap(static_cast(value.get())); return true; } else { return false; @@ -28,9 +28,9 @@ bool Converter::FromV8(v8::Isolate* isolate, base::ListValue* out) { scoped_ptr converter(new atom::V8ValueConverter); scoped_ptr value(converter->FromV8Value( - val, v8::Context::GetCurrent())); + val, isolate->GetCurrentContext())); if (value->IsType(base::Value::TYPE_LIST)) { - out->Swap(static_cast(value.get())); + out->Swap(static_cast(value.get())); return true; } else { return false; diff --git a/atom/common/node_bindings.cc b/atom/common/node_bindings.cc index 4d78cea6b22..01eaaa305bc 100644 --- a/atom/common/node_bindings.cc +++ b/atom/common/node_bindings.cc @@ -36,7 +36,7 @@ namespace atom { namespace { // Empty callback for async handle. -void UvNoOp(uv_async_t* handle, int status) { +void UvNoOp(uv_async_t* handle) { } // Convert the given vector to an array of C-strings. The strings in the @@ -85,16 +85,9 @@ NodeBindings::~NodeBindings() { // Clear uv. uv_sem_destroy(&embed_sem_); - uv_timer_stop(&idle_timer_); } void NodeBindings::Initialize() { - // Init idle GC for browser. - if (is_browser_) { - uv_timer_init(uv_default_loop(), &idle_timer_); - uv_timer_start(&idle_timer_, IdleCallback, 5000, 5000); - } - // Open node's error reporting system for browser process. node::g_standalone_mode = is_browser_; node::g_upstream_node_mode = false; @@ -162,7 +155,7 @@ node::Environment* NodeBindings::CreateEnvironment( uv_unref(reinterpret_cast(env->idle_prepare_handle())); uv_unref(reinterpret_cast(env->idle_check_handle())); - Local process_template = FunctionTemplate::New(); + Local process_template = FunctionTemplate::New(isolate); process_template->SetClassName(FIXED_ONE_BYTE_STRING(isolate, "process")); Local process_object = process_template->GetFunction()->NewInstance(); @@ -199,15 +192,16 @@ void NodeBindings::RunMessageLoop() { void NodeBindings::UvRunOnce() { DCHECK(!is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI)); - // Use Locker in browser process. - BrowserV8Locker locker(node_isolate); - - v8::HandleScope handle_scope(node_isolate); - - // Enter node context while dealing with uv events, by default the global - // env would be used unless user specified another one (this happens for - // renderer process, which wraps the uv loop with web page context). + // By default the global env would be used unless user specified another one + // (this happens for renderer process, which wraps the uv loop with web page + // context). node::Environment* env = uv_env() ? uv_env() : global_env; + + // Use Locker in browser process. + BrowserV8Locker locker(env->isolate()); + v8::HandleScope handle_scope(env->isolate()); + + // Enter node context while dealing with uv events. v8::Context::Scope context_scope(env->context()); // Deal with uv events. @@ -253,9 +247,4 @@ void NodeBindings::EmbedThreadRunner(void *arg) { } } -// static -void NodeBindings::IdleCallback(uv_timer_t*, int) { - v8::V8::IdleNotification(); -} - } // namespace atom diff --git a/atom/common/node_bindings.h b/atom/common/node_bindings.h index a011a032ae2..6d9c4f75434 100644 --- a/atom/common/node_bindings.h +++ b/atom/common/node_bindings.h @@ -70,18 +70,12 @@ class NodeBindings { // Thread to poll uv events. static void EmbedThreadRunner(void *arg); - // Do idle GC. - static void IdleCallback(uv_timer_t*, int); - // Whether the libuv loop has ended. bool embed_closed_; // Dummy handle to make uv's loop not quit. uv_async_t dummy_uv_handle_; - // Timer to do idle GC. - uv_timer_t idle_timer_; - // Thread for polling events. uv_thread_t embed_thread_; diff --git a/atom/renderer/api/atom_api_renderer_ipc.cc b/atom/renderer/api/atom_api_renderer_ipc.cc index 13c73add873..baf9ec606c3 100644 --- a/atom/renderer/api/atom_api_renderer_ipc.cc +++ b/atom/renderer/api/atom_api_renderer_ipc.cc @@ -13,8 +13,8 @@ #include "atom/common/node_includes.h" using content::RenderView; -using WebKit::WebFrame; -using WebKit::WebView; +using blink::WebFrame; +using blink::WebView; namespace { @@ -30,7 +30,7 @@ RenderView* GetCurrentRenderView() { return RenderView::FromWebView(view); } -void Send(const string16& channel, const base::ListValue& arguments) { +void Send(const base::string16& channel, const base::ListValue& arguments) { RenderView* render_view = GetCurrentRenderView(); if (render_view == NULL) return; @@ -42,8 +42,9 @@ void Send(const string16& channel, const base::ListValue& arguments) { node::ThrowError("Unable to send AtomViewHostMsg_Message"); } -string16 SendSync(const string16& channel, const base::ListValue& arguments) { - string16 json; +base::string16 SendSync(const base::string16& channel, + const base::ListValue& arguments) { + base::string16 json; RenderView* render_view = GetCurrentRenderView(); if (render_view == NULL) @@ -69,4 +70,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_renderer_ipc, Initialize) +NODE_MODULE_X(atom_renderer_ipc, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/renderer/api/atom_api_web_view.cc b/atom/renderer/api/atom_api_web_view.cc index 4cbb2953bca..81ce35521c2 100644 --- a/atom/renderer/api/atom_api_web_view.cc +++ b/atom/renderer/api/atom_api_web_view.cc @@ -17,8 +17,8 @@ namespace api { namespace { -WebKit::WebView* GetCurrentWebView() { - WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext(); +blink::WebView* GetCurrentWebView() { + blink::WebFrame* frame = blink::WebFrame::frameForCurrentContext(); if (!frame) return NULL; return frame->view(); @@ -41,12 +41,12 @@ double WebView::GetZoomLevel() const { } double WebView::SetZoomFactor(double factor) { - return WebKit::WebView::zoomLevelToZoomFactor(SetZoomLevel( - WebKit::WebView::zoomFactorToZoomLevel(factor))); + return blink::WebView::zoomLevelToZoomFactor(SetZoomLevel( + blink::WebView::zoomFactorToZoomLevel(factor))); } double WebView::GetZoomFactor() const { - return WebKit::WebView::zoomLevelToZoomFactor(GetZoomLevel()); + return blink::WebView::zoomLevelToZoomFactor(GetZoomLevel()); } mate::ObjectTemplateBuilder WebView::GetObjectTemplateBuilder( @@ -77,4 +77,4 @@ void Initialize(v8::Handle exports) { } // namespace -NODE_MODULE(atom_renderer_web_view, Initialize) +NODE_MODULE_X(atom_renderer_web_view, Initialize, NULL, NM_F_BUILTIN) diff --git a/atom/renderer/api/atom_api_web_view.h b/atom/renderer/api/atom_api_web_view.h index c8c289b959c..be6012e84dd 100644 --- a/atom/renderer/api/atom_api_web_view.h +++ b/atom/renderer/api/atom_api_web_view.h @@ -8,7 +8,7 @@ #include "native_mate/handle.h" #include "native_mate/wrappable.h" -namespace WebKit { +namespace blink { class WebView; } @@ -33,7 +33,7 @@ class WebView : public mate::Wrappable { virtual mate::ObjectTemplateBuilder GetObjectTemplateBuilder( v8::Isolate* isolate); - WebKit::WebView* web_view_; + blink::WebView* web_view_; DISALLOW_COPY_AND_ASSIGN(WebView); }; diff --git a/atom/renderer/api/atom_renderer_bindings.cc b/atom/renderer/api/atom_renderer_bindings.cc index d21f0a655f2..50acaf1cb19 100644 --- a/atom/renderer/api/atom_renderer_bindings.cc +++ b/atom/renderer/api/atom_renderer_bindings.cc @@ -11,6 +11,7 @@ #include "base/memory/scoped_ptr.h" #include "base/values.h" #include "content/public/renderer/render_view.h" +#include "native_mate/converter.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebView.h" @@ -21,8 +22,8 @@ namespace atom { namespace { v8::Handle GetProcessObject(v8::Handle context) { - v8::Handle process = - context->Global()->Get(v8::String::New("process"))->ToObject(); + v8::Handle process = context->Global()->Get( + mate::StringToV8(context->GetIsolate(), "process"))->ToObject(); DCHECK(!process.IsEmpty()); return process; @@ -36,24 +37,26 @@ AtomRendererBindings::AtomRendererBindings() { AtomRendererBindings::~AtomRendererBindings() { } -void AtomRendererBindings::BindToFrame(WebKit::WebFrame* frame) { - v8::HandleScope handle_scope(node_isolate); +void AtomRendererBindings::BindToFrame(blink::WebFrame* frame) { + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope handle_scope(isolate); v8::Handle context = frame->mainWorldScriptContext(); if (context.IsEmpty()) return; v8::Context::Scope scope(context); - AtomBindings::BindTo(GetProcessObject(context)); + AtomBindings::BindTo(isolate, GetProcessObject(context)); } void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view, - const string16& channel, + const base::string16& channel, const base::ListValue& args) { if (!render_view->GetWebView()) return; - v8::HandleScope handle_scope(node_isolate); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope handle_scope(isolate); v8::Local context = render_view->GetWebView()->mainFrame()->mainWorldScriptContext(); @@ -67,7 +70,7 @@ void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view, std::vector> arguments; arguments.reserve(1 + args.GetSize()); - arguments.push_back(mate::ConvertToV8(node_isolate, channel)); + arguments.push_back(mate::ConvertToV8(isolate, channel)); for (size_t i = 0; i < args.GetSize(); i++) { const base::Value* value; @@ -75,7 +78,7 @@ void AtomRendererBindings::OnBrowserMessage(content::RenderView* render_view, arguments.push_back(converter->ToV8Value(value, context)); } - node::MakeCallback(process, "emit", arguments.size(), &arguments[0]); + node::MakeCallback(isolate, process, "emit", arguments.size(), &arguments[0]); } } // namespace atom diff --git a/atom/renderer/api/atom_renderer_bindings.h b/atom/renderer/api/atom_renderer_bindings.h index 8f5667766a2..1b0c9c2ae97 100644 --- a/atom/renderer/api/atom_renderer_bindings.h +++ b/atom/renderer/api/atom_renderer_bindings.h @@ -17,7 +17,7 @@ namespace content { class RenderView; } -namespace WebKit { +namespace blink { class WebFrame; } @@ -29,11 +29,11 @@ class AtomRendererBindings : public AtomBindings { virtual ~AtomRendererBindings(); // Call BindTo for process object of the frame. - void BindToFrame(WebKit::WebFrame* frame); + void BindToFrame(blink::WebFrame* frame); // Dispatch messages from browser. void OnBrowserMessage(content::RenderView* render_view, - const string16& channel, + const base::string16& channel, const base::ListValue& args); private: diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index e5f9c181a0f..05d17e1d96f 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -22,7 +22,7 @@ #include "atom/common/node_includes.h" -using WebKit::WebFrame; +using blink::WebFrame; namespace atom { @@ -36,7 +36,7 @@ AtomRenderViewObserver::AtomRenderViewObserver( AtomRenderViewObserver::~AtomRenderViewObserver() { } -void AtomRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) { +void AtomRenderViewObserver::DidCreateDocumentElement(blink::WebFrame* frame) { // Read --zoom-factor from command line. std::string zoom_factor_str = CommandLine::ForCurrentProcess()-> GetSwitchValueASCII(switches::kZoomFactor);; @@ -45,12 +45,12 @@ void AtomRenderViewObserver::DidCreateDocumentElement(WebKit::WebFrame* frame) { double zoom_factor; if (!base::StringToDouble(zoom_factor_str, &zoom_factor)) return; - double zoom_level = WebKit::WebView::zoomFactorToZoomLevel(zoom_factor); + double zoom_level = blink::WebView::zoomFactorToZoomLevel(zoom_factor); frame->view()->setZoomLevel(zoom_level); } -void AtomRenderViewObserver::DraggableRegionsChanged(WebKit::WebFrame* frame) { - WebKit::WebVector webregions = +void AtomRenderViewObserver::DraggableRegionsChanged(blink::WebFrame* frame) { + blink::WebVector webregions = frame->document().draggableRegions(); std::vector regions; for (size_t i = 0; i < webregions.size(); ++i) { @@ -72,12 +72,12 @@ bool AtomRenderViewObserver::OnMessageReceived(const IPC::Message& message) { return handled; } -void AtomRenderViewObserver::OnBrowserMessage(const string16& channel, +void AtomRenderViewObserver::OnBrowserMessage(const base::string16& channel, const base::ListValue& args) { if (!render_view()->GetWebView()) return; - WebKit::WebFrame* frame = render_view()->GetWebView()->mainFrame(); + blink::WebFrame* frame = render_view()->GetWebView()->mainFrame(); if (!renderer_client_->IsNodeBindingEnabled(frame)) return; diff --git a/atom/renderer/atom_render_view_observer.h b/atom/renderer/atom_render_view_observer.h index 4de9fd33cfe..8941c04b017 100644 --- a/atom/renderer/atom_render_view_observer.h +++ b/atom/renderer/atom_render_view_observer.h @@ -25,11 +25,11 @@ class AtomRenderViewObserver : public content::RenderViewObserver { private: // content::RenderViewObserver implementation. - virtual void DidCreateDocumentElement(WebKit::WebFrame* frame) OVERRIDE; - virtual void DraggableRegionsChanged(WebKit::WebFrame* frame) OVERRIDE; + virtual void DidCreateDocumentElement(blink::WebFrame* frame) OVERRIDE; + virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - void OnBrowserMessage(const string16& channel, + void OnBrowserMessage(const base::string16& channel, const base::ListValue& args); // Weak reference to renderer client. diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index b9567b1323b..eb7131d9a8e 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -12,6 +12,7 @@ #include "atom/renderer/api/atom_renderer_bindings.h" #include "atom/renderer/atom_render_view_observer.h" #include "base/command_line.h" +#include "native_mate/converter.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebFrame.h" @@ -65,16 +66,21 @@ void AtomRendererClient::RenderThreadStarted() { // Create a default empty environment which would be used when we need to // run V8 code out of a window context (like running a uv callback). - v8::HandleScope handle_scope(node_isolate); - v8::Local context = v8::Context::New(node_isolate); + v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope handle_scope(isolate); + v8::Local context = v8::Context::New(isolate); global_env = node::Environment::New(context); } +void AtomRendererClient::RenderFrameCreated( + content::RenderFrame* render_frame) { +} + void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) { new AtomRenderViewObserver(render_view, this); } -void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame, +void AtomRendererClient::DidCreateScriptContext(blink::WebFrame* frame, v8::Handle context, int extension_group, int world_id) { @@ -88,7 +94,8 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame, v8::Context::Scope scope(context); // Check the existance of process object to prevent duplicate initialization. - if (context->Global()->Has(v8::String::New("process"))) + if (context->Global()->Has( + mate::StringToV8(context->GetIsolate(), "process"))) return; // Give the node loop a run to make sure everything is ready. @@ -109,7 +116,7 @@ void AtomRendererClient::DidCreateScriptContext(WebKit::WebFrame* frame, } void AtomRendererClient::WillReleaseScriptContext( - WebKit::WebFrame* frame, + blink::WebFrame* frame, v8::Handle context, int world_id) { if (!IsNodeBindingEnabled(frame)) @@ -143,7 +150,7 @@ void AtomRendererClient::WillReleaseScriptContext( } } -bool AtomRendererClient::ShouldFork(WebKit::WebFrame* frame, +bool AtomRendererClient::ShouldFork(blink::WebFrame* frame, const GURL& url, const std::string& http_method, bool is_initial_navigation, @@ -156,7 +163,7 @@ bool AtomRendererClient::ShouldFork(WebKit::WebFrame* frame, return http_method == "GET"; } -bool AtomRendererClient::IsNodeBindingEnabled(WebKit::WebFrame* frame) { +bool AtomRendererClient::IsNodeBindingEnabled(blink::WebFrame* frame) { if (node_integration_ == DISABLE) return false; // Node integration is enabled in main frame unless explictly disabled. diff --git a/atom/renderer/atom_renderer_client.h b/atom/renderer/atom_renderer_client.h index 6cf63b798cf..78eab3012ae 100644 --- a/atom/renderer/atom_renderer_client.h +++ b/atom/renderer/atom_renderer_client.h @@ -24,7 +24,7 @@ class AtomRendererClient : public content::ContentRendererClient { AtomRendererClient(); virtual ~AtomRendererClient(); - bool IsNodeBindingEnabled(WebKit::WebFrame* frame = NULL); + bool IsNodeBindingEnabled(blink::WebFrame* frame = NULL); AtomRendererBindings* atom_bindings() const { return atom_bindings_.get(); } @@ -36,16 +36,18 @@ class AtomRendererClient : public content::ContentRendererClient { DISABLE, }; + // content::ContentRendererClient: virtual void RenderThreadStarted() OVERRIDE; + virtual void RenderFrameCreated(content::RenderFrame* render_frame) OVERRIDE; virtual void RenderViewCreated(content::RenderView*) OVERRIDE; - virtual void DidCreateScriptContext(WebKit::WebFrame* frame, + virtual void DidCreateScriptContext(blink::WebFrame* frame, v8::Handle context, int extension_group, int world_id) OVERRIDE; - virtual void WillReleaseScriptContext(WebKit::WebFrame* frame, + virtual void WillReleaseScriptContext(blink::WebFrame* frame, v8::Handle, - int world_id) OVERRIDE; - virtual bool ShouldFork(WebKit::WebFrame* frame, + int world_id); + virtual bool ShouldFork(blink::WebFrame* frame, const GURL& url, const std::string& http_method, bool is_initial_navigation, @@ -61,7 +63,7 @@ class AtomRendererClient : public content::ContentRendererClient { NodeIntegration node_integration_; // The main frame. - WebKit::WebFrame* main_frame_; + blink::WebFrame* main_frame_; DISALLOW_COPY_AND_ASSIGN(AtomRendererClient); }; diff --git a/vendor/native_mate b/vendor/native_mate index 6f574c38020..e6db1875d02 160000 --- a/vendor/native_mate +++ b/vendor/native_mate @@ -1 +1 @@ -Subproject commit 6f574c38020bdf9d6ed9dd079905f4b110fbd10e +Subproject commit e6db1875d0259d7750ad57d58d6fecaeeaea0cf6