From 5ad203ad997a8447b83b6052ea5c7de027ce660f Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 13:56:35 +0800 Subject: [PATCH 01/10] Upgrade to Chrome 36. --- script/lib/config.py | 2 +- vendor/brightray | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/config.py b/script/lib/config.py index 249478cc0d77..dda01b0bec9a 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -5,7 +5,7 @@ import sys NODE_VERSION = 'v0.11.13' BASE_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/libchromiumcontent' -LIBCHROMIUMCONTENT_COMMIT = '177f00b33d8ba5a6befe646e8d39ce19b6a3c668' +LIBCHROMIUMCONTENT_COMMIT = 'dcd011c56f1e19885bac78ca58a397b0c5c25265' ARCH = { 'cygwin': '32bit', diff --git a/vendor/brightray b/vendor/brightray index 13628c0d7f79..04ecc57b5bb2 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 13628c0d7f799952c2d0067dbacded0bd73d5671 +Subproject commit 04ecc57b5bb2f6d015b673d5b17affdce1039ff1 From 7a89a08534f29b74af78bbf950463d63377fc9fd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 15:29:51 +0800 Subject: [PATCH 02/10] Update to new Chromium APIs. --- atom/browser/api/atom_api_menu_mac.mm | 3 +-- atom/browser/api/atom_api_web_contents.cc | 6 +++--- atom/browser/api/atom_api_web_contents.h | 2 +- atom/browser/api/event.cc | 2 +- atom/browser/api/event.h | 2 +- atom/browser/atom_browser_main_parts.cc | 6 +----- atom/browser/native_window.cc | 5 +---- atom/browser/native_window_mac.mm | 13 ++++++------- atom/browser/native_window_views.cc | 1 - atom/browser/ui/accelerator_util.cc | 2 +- atom/common/chrome_version.h | 2 +- atom/renderer/api/atom_api_renderer_ipc.cc | 6 +++--- atom/renderer/api/atom_api_web_view.cc | 4 ++-- atom/renderer/atom_render_view_observer.cc | 4 +++- atom/renderer/atom_render_view_observer.h | 2 +- docs/api/browser-window.md | 1 - vendor/brightray | 2 +- vendor/node | 2 +- 18 files changed, 28 insertions(+), 37 deletions(-) diff --git a/atom/browser/api/atom_api_menu_mac.mm b/atom/browser/api/atom_api_menu_mac.mm index 4b54a7e2f76e..f5428ec487cb 100644 --- a/atom/browser/api/atom_api_menu_mac.mm +++ b/atom/browser/api/atom_api_menu_mac.mm @@ -8,7 +8,6 @@ #include "base/message_loop/message_loop.h" #include "base/strings/sys_string_conversions.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "atom/common/node_includes.h" @@ -44,7 +43,7 @@ void MenuMac::Popup(Window* window) { // Show the menu. [NSMenu popUpContextMenu:[menu_controller menu] withEvent:clickEvent - forView:web_contents->GetView()->GetContentNativeView()]; + forView:web_contents->GetContentNativeView()]; } // static diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 14fc69c31753..33abbcd75e93 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -9,6 +9,7 @@ #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/value_converter.h" #include "base/strings/utf_string_conversions.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/web_contents.h" @@ -66,7 +67,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) { return handled; } -void WebContents::WebContentsDestroyed(content::WebContents*) { +void WebContents::WebContentsDestroyed() { // The RenderViewDeleted was not called when the WebContents is destroyed. RenderViewDeleted(web_contents_->GetRenderViewHost()); Emit("destroyed"); @@ -155,8 +156,7 @@ bool WebContents::IsCrashed() const { } void WebContents::ExecuteJavaScript(const base::string16& code) { - web_contents()->GetRenderViewHost()->ExecuteJavascriptInWebFrame( - base::string16(), code); + web_contents()->GetMainFrame()->ExecuteJavaScript(code); } bool WebContents::SendIPCMessage(const base::string16& channel, diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 36c91434d5ee..4a83153bca2b 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -62,7 +62,7 @@ class WebContents : public mate::EventEmitter, virtual void DidStopLoading( content::RenderViewHost* render_view_host) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE; + virtual void WebContentsDestroyed() OVERRIDE; private: // Called when received a message from renderer. diff --git a/atom/browser/api/event.cc b/atom/browser/api/event.cc index 579fa3a41dcf..c97e968d1e6e 100644 --- a/atom/browser/api/event.cc +++ b/atom/browser/api/event.cc @@ -36,7 +36,7 @@ void Event::SetSenderAndMessage(content::WebContents* sender, Observe(sender); } -void Event::WebContentsDestroyed(content::WebContents* web_contents) { +void Event::WebContentsDestroyed() { sender_ = NULL; message_ = NULL; } diff --git a/atom/browser/api/event.h b/atom/browser/api/event.h index b1713a4e68c9..c32eb8a36aae 100644 --- a/atom/browser/api/event.h +++ b/atom/browser/api/event.h @@ -40,7 +40,7 @@ class Event : public Wrappable, virtual ObjectTemplateBuilder GetObjectTemplateBuilder(v8::Isolate* isolate); // content::WebContentsObserver implementations: - virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE; + virtual void WebContentsDestroyed() OVERRIDE; private: // Replyer for the synchronous messages. diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index c141b265fd75..86d8d6b1e745 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -54,11 +54,7 @@ brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() { } void AtomBrowserMainParts::InitProxyResolverV8() { - // Since we are integrating node in browser, we can just be sure that an - // V8 instance would be prepared, while the ProxyResolverV8::CreateIsolate() - // would try to create a V8 isolate, which messed everything on Windows, so - // we have to override and call RememberDefaultIsolate on Windows instead. - net::ProxyResolverV8::RememberDefaultIsolate(); + brightray::BrowserMainParts::InitProxyResolverV8(); } void AtomBrowserMainParts::PostEarlyInitialization() { diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index bf055570bdbd..4be4ac694124 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -38,7 +38,6 @@ #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" @@ -305,7 +304,7 @@ void NativeWindow::CloseWebContents() { ScheduleUnresponsiveEvent(5000); if (web_contents->NeedToFireBeforeUnload()) - web_contents->GetMainFrame()->DispatchBeforeUnload(false); + web_contents->DispatchBeforeUnload(false); else web_contents->Close(); } @@ -356,8 +355,6 @@ void NativeWindow::OverrideWebkitPrefs(const GURL& url, WebPreferences* prefs) { prefs->experimental_webgl_enabled = b; if (web_preferences.Get("webaudio", &b)) prefs->webaudio_enabled = b; - if (web_preferences.Get("accelerated-compositing", &b)) - prefs->accelerated_compositing_enabled = b; if (web_preferences.Get("plugins", &b)) prefs->plugins_enabled = b; if (web_preferences.Get("extra-plugin-dirs", &list)) diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 77bea46655bf..e16aabdc93a5 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -13,7 +13,6 @@ #include "base/strings/sys_string_conversions.h" #include "content/public/browser/native_web_keyboard_event.h" #include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_view.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/render_widget_host_view.h" #include "native_mate/dictionary.h" @@ -56,7 +55,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; if (!web_contents) return; - web_contents->GetView()->RestoreFocus(); + web_contents->RestoreFocus(); content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); if (rwhv) @@ -70,7 +69,7 @@ static const CGFloat kAtomWindowCornerRadius = 4.0; if (!web_contents) return; - web_contents->GetView()->StoreFocus(); + web_contents->StoreFocus(); content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); if (rwhv) @@ -492,7 +491,7 @@ gfx::NativeWindow NativeWindowMac::GetNativeWindow() { bool NativeWindowMac::IsWithinDraggableRegion(NSPoint point) const { if (!draggable_region_) return false; - NSView* webView = GetWebContents()->GetView()->GetNativeView(); + NSView* webView = GetWebContents()->GetNativeView(); NSInteger webViewHeight = NSHeight([webView bounds]); // |draggable_region_| is stored in local platform-indepdent coordiate system // while |point| is in local Cocoa coordinate system. Do the conversion @@ -581,7 +580,7 @@ void NativeWindowMac::UninstallView() { } void NativeWindowMac::ClipWebView() { - NSView* view = GetWebContents()->GetView()->GetNativeView(); + NSView* view = GetWebContents()->GetNativeView(); view.wantsLayer = YES; view.layer.masksToBounds = YES; @@ -594,7 +593,7 @@ void NativeWindowMac::InstallDraggableRegionViews() { // All ControlRegionViews should be added as children of the WebContentsView, // because WebContentsView will be removed and re-added when entering and // leaving fullscreen mode. - NSView* webView = GetWebContents()->GetView()->GetNativeView(); + NSView* webView = GetWebContents()->GetNativeView(); NSInteger webViewHeight = NSHeight([webView bounds]); // Remove all ControlRegionViews that are added last time. @@ -626,7 +625,7 @@ void NativeWindowMac::UpdateDraggableRegionsForCustomDrag( const std::vector& regions) { // We still need one ControlRegionView to cover the whole window such that // mouse events could be captured. - NSView* web_view = GetWebContents()->GetView()->GetNativeView(); + NSView* web_view = GetWebContents()->GetNativeView(); gfx::Rect window_bounds( 0, 0, NSWidth([web_view bounds]), NSHeight([web_view bounds])); system_drag_exclude_areas_.clear(); diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index b63b8ae46333..4c99a56389fc 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -24,7 +24,6 @@ #include "base/strings/utf_string_conversions.h" #include "browser/inspectable_web_contents_view.h" #include "content/public/browser/native_web_keyboard_event.h" -#include "content/public/browser/web_contents_view.h" #include "native_mate/dictionary.h" #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" diff --git a/atom/browser/ui/accelerator_util.cc b/atom/browser/ui/accelerator_util.cc index 09e98cf02a85..16251e822c6f 100644 --- a/atom/browser/ui/accelerator_util.cc +++ b/atom/browser/ui/accelerator_util.cc @@ -87,7 +87,7 @@ ui::KeyboardCode KeyboardCodeFromCharCode(char c, bool* shifted) { bool StringToAccelerator(const std::string& description, ui::Accelerator* accelerator) { - if (!IsStringASCII(description)) { + if (!base::IsStringASCII(description)) { LOG(ERROR) << "The accelerator string can only contain ASCII characters"; return false; } diff --git a/atom/common/chrome_version.h b/atom/common/chrome_version.h index f6b1b8febed3..a8f70f3ce009 100644 --- a/atom/common/chrome_version.h +++ b/atom/common/chrome_version.h @@ -8,7 +8,7 @@ #ifndef ATOM_COMMON_CHROME_VERSION_H_ #define ATOM_COMMON_CHROME_VERSION_H_ -#define CHROME_VERSION_STRING "35.0.1916.153" +#define CHROME_VERSION_STRING "36.0.1985.125" #define CHROME_VERSION "v" CHROME_VERSION_STRING #endif // ATOM_COMMON_CHROME_VERSION_H_ diff --git a/atom/renderer/api/atom_api_renderer_ipc.cc b/atom/renderer/api/atom_api_renderer_ipc.cc index 678a0c7e1fc6..a0fd27f4dedf 100644 --- a/atom/renderer/api/atom_api_renderer_ipc.cc +++ b/atom/renderer/api/atom_api_renderer_ipc.cc @@ -7,19 +7,19 @@ #include "atom/common/native_mate_converters/value_converter.h" #include "content/public/renderer/render_view.h" #include "native_mate/dictionary.h" -#include "third_party/WebKit/public/web/WebFrame.h" +#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebView.h" #include "atom/common/node_includes.h" using content::RenderView; -using blink::WebFrame; +using blink::WebLocalFrame; using blink::WebView; namespace { RenderView* GetCurrentRenderView() { - WebFrame* frame = WebFrame::frameForCurrentContext(); + WebLocalFrame* frame = WebLocalFrame::frameForCurrentContext(); if (!frame) return NULL; diff --git a/atom/renderer/api/atom_api_web_view.cc b/atom/renderer/api/atom_api_web_view.cc index 1f983cdf96a8..defa8237ec1f 100644 --- a/atom/renderer/api/atom_api_web_view.cc +++ b/atom/renderer/api/atom_api_web_view.cc @@ -6,7 +6,7 @@ #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" -#include "third_party/WebKit/public/web/WebFrame.h" +#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebView.h" #include "atom/common/node_includes.h" @@ -18,7 +18,7 @@ namespace api { namespace { blink::WebView* GetCurrentWebView() { - blink::WebFrame* frame = blink::WebFrame::frameForCurrentContext(); + blink::WebLocalFrame* frame = blink::WebLocalFrame::frameForCurrentContext(); if (!frame) return NULL; return frame->view(); diff --git a/atom/renderer/atom_render_view_observer.cc b/atom/renderer/atom_render_view_observer.cc index 05d17e1d96fe..1ec21ef1f6a8 100644 --- a/atom/renderer/atom_render_view_observer.cc +++ b/atom/renderer/atom_render_view_observer.cc @@ -18,6 +18,7 @@ #include "third_party/WebKit/public/web/WebDraggableRegion.h" #include "third_party/WebKit/public/web/WebDocument.h" #include "third_party/WebKit/public/web/WebFrame.h" +#include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebView.h" #include "atom/common/node_includes.h" @@ -36,7 +37,8 @@ AtomRenderViewObserver::AtomRenderViewObserver( AtomRenderViewObserver::~AtomRenderViewObserver() { } -void AtomRenderViewObserver::DidCreateDocumentElement(blink::WebFrame* frame) { +void AtomRenderViewObserver::DidCreateDocumentElement( + blink::WebLocalFrame* frame) { // Read --zoom-factor from command line. std::string zoom_factor_str = CommandLine::ForCurrentProcess()-> GetSwitchValueASCII(switches::kZoomFactor);; diff --git a/atom/renderer/atom_render_view_observer.h b/atom/renderer/atom_render_view_observer.h index 8941c04b0172..1e1f356f02f6 100644 --- a/atom/renderer/atom_render_view_observer.h +++ b/atom/renderer/atom_render_view_observer.h @@ -25,7 +25,7 @@ class AtomRenderViewObserver : public content::RenderViewObserver { private: // content::RenderViewObserver implementation. - virtual void DidCreateDocumentElement(blink::WebFrame* frame) OVERRIDE; + virtual void DidCreateDocumentElement(blink::WebLocalFrame* frame) OVERRIDE; virtual void DraggableRegionsChanged(blink::WebFrame* frame) OVERRIDE; virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 8e89e6848150..3a9a2815297a 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -63,7 +63,6 @@ You can also create a window without chrome by using * `text-areas-are-resizable` Boolean * `webgl` Boolean * `webaudio` Boolean - * `accelerated-compositing` Boolean * `plugins` Boolean - Whether plugins should be enabled, currently only `NPAPI` plugins are supported. * `extra-plugin-dirs` Array - Array of paths that would be searched for diff --git a/vendor/brightray b/vendor/brightray index 04ecc57b5bb2..6c2709003cb0 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 04ecc57b5bb2f6d015b673d5b17affdce1039ff1 +Subproject commit 6c2709003cb0d06ca105c5cb86ea9f6d666261c3 diff --git a/vendor/node b/vendor/node index 4d2db275a386..6d772c3cda0b 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 4d2db275a386b68e3c22ce87ca0c19fddae139e8 +Subproject commit 6d772c3cda0bb8270857397e128ea1e36c361125 From a6ede12cd75f039c496cc086ec1e69cfc6b13944 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 16:00:15 +0800 Subject: [PATCH 03/10] Make sure javascript environment is initialized after ProxyResolverV8. --- atom.gyp | 2 ++ atom/browser/atom_browser_main_parts.cc | 24 +++++++---------- atom/browser/atom_browser_main_parts.h | 13 +++------- atom/browser/javascript_environment.cc | 17 +++++++++++++ atom/browser/javascript_environment.h | 34 +++++++++++++++++++++++++ 5 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 atom/browser/javascript_environment.cc create mode 100644 atom/browser/javascript_environment.h diff --git a/atom.gyp b/atom.gyp index 6a79cb8c93a6..6bd28b25d90d 100644 --- a/atom.gyp +++ b/atom.gyp @@ -93,6 +93,8 @@ 'atom/browser/browser_mac.mm', 'atom/browser/browser_win.cc', 'atom/browser/browser_observer.h', + 'atom/browser/javascript_environment.cc', + 'atom/browser/javascript_environment.h', 'atom/browser/mac/atom_application.h', 'atom/browser/mac/atom_application.mm', 'atom/browser/mac/atom_application_delegate.h', diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index 86d8d6b1e745..d883367495bc 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -7,10 +7,10 @@ #include "atom/browser/atom_browser_client.h" #include "atom/browser/atom_browser_context.h" #include "atom/browser/browser.h" +#include "atom/browser/javascript_environment.h" #include "atom/common/api/atom_bindings.h" #include "atom/common/node_bindings.h" #include "base/command_line.h" -#include "net/proxy/proxy_resolver_v8.h" #if defined(OS_WIN) #include "ui/gfx/win/dpi.h" @@ -28,14 +28,9 @@ namespace atom { AtomBrowserMainParts* AtomBrowserMainParts::self_ = NULL; AtomBrowserMainParts::AtomBrowserMainParts() - : atom_bindings_(new AtomBindings), - browser_(new Browser), + : browser_(new Browser), node_bindings_(NodeBindings::Create(true)), - isolate_(v8::Isolate::GetCurrent()), - locker_(isolate_), - handle_scope_(isolate_), - context_(isolate_, v8::Context::New(isolate_)), - context_scope_(v8::Local::New(isolate_, context_)) { + atom_bindings_(new AtomBindings) { DCHECK(!self_) << "Cannot have two AtomBrowserMainParts"; self_ = this; } @@ -53,21 +48,20 @@ brightray::BrowserContext* AtomBrowserMainParts::CreateBrowserContext() { return new AtomBrowserContext(); } -void AtomBrowserMainParts::InitProxyResolverV8() { - brightray::BrowserMainParts::InitProxyResolverV8(); -} - void AtomBrowserMainParts::PostEarlyInitialization() { brightray::BrowserMainParts::PostEarlyInitialization(); + // The ProxyResolverV8 has setup a complete V8 environment, in order to avoid + // conflicts we only initialize our V8 environment after that. + js_env_.reset(new JavascriptEnvironment); + node_bindings_->Initialize(); // Create the global environment. - global_env = node_bindings_->CreateEnvironment( - v8::Local::New(isolate_, context_)); + global_env = node_bindings_->CreateEnvironment(js_env_->context()); // Add atom-shell extended APIs. - atom_bindings_->BindTo(isolate_, global_env->process_object()); + atom_bindings_->BindTo(js_env_->isolate(), global_env->process_object()); } void AtomBrowserMainParts::PreMainMessageLoopRun() { diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index d9b94e8d8310..269e042b3768 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -6,12 +6,12 @@ #define ATOM_BROWSER_ATOM_BROWSER_MAIN_PARTS_H_ #include "brightray/browser/browser_main_parts.h" -#include "v8/include/v8.h" namespace atom { class AtomBindings; class Browser; +class JavascriptEnvironment; class NodeBindings; class AtomBrowserMainParts : public brightray::BrowserMainParts { @@ -26,7 +26,6 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { protected: // Implementations of brightray::BrowserMainParts. virtual brightray::BrowserContext* CreateBrowserContext() OVERRIDE; - virtual void InitProxyResolverV8() OVERRIDE; // Implementations of content::BrowserMainParts. virtual void PostEarlyInitialization() OVERRIDE; @@ -37,16 +36,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { #endif private: - scoped_ptr atom_bindings_; scoped_ptr browser_; + scoped_ptr js_env_; scoped_ptr node_bindings_; - - // The V8 environment of browser process. - v8::Isolate* isolate_; - v8::Locker locker_; - v8::HandleScope handle_scope_; - v8::UniquePersistent context_; - v8::Context::Scope context_scope_; + scoped_ptr atom_bindings_; static AtomBrowserMainParts* self_; diff --git a/atom/browser/javascript_environment.cc b/atom/browser/javascript_environment.cc new file mode 100644 index 000000000000..ddc29afcc453 --- /dev/null +++ b/atom/browser/javascript_environment.cc @@ -0,0 +1,17 @@ +// 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 "atom/browser/javascript_environment.h" + +namespace atom { + +JavascriptEnvironment::JavascriptEnvironment() + : isolate_(v8::Isolate::GetCurrent()), + locker_(isolate_), + handle_scope_(isolate_), + context_(isolate_, v8::Context::New(isolate_)), + context_scope_(v8::Local::New(isolate_, context_)) { +} + +} // namespace atom diff --git a/atom/browser/javascript_environment.h b/atom/browser/javascript_environment.h new file mode 100644 index 000000000000..67cab80598f6 --- /dev/null +++ b/atom/browser/javascript_environment.h @@ -0,0 +1,34 @@ +// 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. + +#ifndef ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ +#define ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ + +#include "base/basictypes.h" +#include "v8/include/v8.h" + +namespace atom { + +class JavascriptEnvironment { + public: + JavascriptEnvironment(); + + v8::Isolate* isolate() const { return isolate_; } + v8::Local context() const { + return v8::Local::New(isolate_, context_); + } + + private: + v8::Isolate* isolate_; + v8::Locker locker_; + v8::HandleScope handle_scope_; + v8::UniquePersistent context_; + v8::Context::Scope context_scope_; + + DISALLOW_COPY_AND_ASSIGN(JavascriptEnvironment); +}; + +} // namespace atom + +#endif // ATOM_BROWSER_JAVASCRIPT_ENVIRONMENT_H_ From 143bde007a6112ae53ace58be99507b43ef4ab9a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 17:06:28 +0800 Subject: [PATCH 04/10] Always enable harmony when node binding is on. If we dont' do this we would have lots of "Extension or internal compilation error." error, seems to be V8's bug. --- atom/renderer/atom_renderer_client.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 8b3aaee517f6..7fbc91826607 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -70,6 +70,10 @@ AtomRendererClient::AtomRendererClient() node_integration_ = ALL; if (IsNodeBindingEnabled()) { + // Always enable harmony when node binding is on. + std::string flags("--harmony"); + v8::V8::SetFlagsFromString(flags.c_str(), static_cast(flags.size())); + node_bindings_.reset(NodeBindings::Create(false)); atom_bindings_.reset(new AtomRendererBindings); } From ec4275ca13db5985ab9344926ce403c6a36ab608 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 17:34:21 +0800 Subject: [PATCH 05/10] Make sure window is closed before WebContents is destroyed. Otherwise we would get "RawChannel fatal error". --- atom/browser/native_window.cc | 7 ------- atom/browser/native_window_mac.mm | 1 + atom/browser/native_window_views.cc | 1 + 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 4be4ac694124..5481bfa1d67c 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -104,10 +104,6 @@ NativeWindow::NativeWindow(content::WebContents* web_contents, } NativeWindow::~NativeWindow() { - // Make sure we have the OnRenderViewDeleted message sent even when the window - // is destroyed directly. - DestroyWebContents(); - // It's possible that the windows gets destroyed before it's closed, in that // case we need to ensure the OnWindowClosed message is still notified. NotifyWindowClosed(); @@ -453,9 +449,6 @@ void NativeWindow::MoveContents(content::WebContents* source, } void NativeWindow::CloseContents(content::WebContents* source) { - // Destroy the WebContents before we close the window. - DestroyWebContents(); - // When the web contents is gone, close the window immediately, but the // memory will not be freed until you call delete. // In this way, it would be safe to manage windows via smart pointers. If you diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index e16aabdc93a5..804595edbcfc 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -241,6 +241,7 @@ void NativeWindowMac::Close() { void NativeWindowMac::CloseImmediately() { [window_ close]; + window_.reset(); } void NativeWindowMac::Move(const gfx::Rect& pos) { diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 4c99a56389fc..89665c68d56a 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -137,6 +137,7 @@ void NativeWindowViews::Close() { void NativeWindowViews::CloseImmediately() { window_->CloseNow(); + window_.reset(); } void NativeWindowViews::Move(const gfx::Rect& bounds) { From c23c667c2d3562b5f60ec43339691e4ef3d7babd Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 17:57:54 +0800 Subject: [PATCH 06/10] Update brightray to fix webrtc warning. --- atom/browser/atom_browser_client.h | 1 + vendor/brightray | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index b4b4a08b55ed..8f74dcfae6df 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -17,6 +17,7 @@ class AtomBrowserClient : public brightray::BrowserClient { virtual ~AtomBrowserClient(); protected: + // content::ContentBrowserClient: net::URLRequestContextGetter* CreateRequestContext( content::BrowserContext* browser_context, content::ProtocolHandlerMap* protocol_handlers, diff --git a/vendor/brightray b/vendor/brightray index 6c2709003cb0..91a5af922314 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit 6c2709003cb0d06ca105c5cb86ea9f6d666261c3 +Subproject commit 91a5af92231458009165a853e279192acdca947c From 10c52bd6a6467dfdb15e22178fae6e37f78e4290 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 10:11:47 +0000 Subject: [PATCH 07/10] Fix building on Linux. --- atom/browser/api/atom_api_menu_views.cc | 2 +- atom/browser/ui/views/menu_delegate.cc | 7 ++++--- atom/browser/ui/views/menu_delegate.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/atom/browser/api/atom_api_menu_views.cc b/atom/browser/api/atom_api_menu_views.cc index a8d50eeaa8f5..ded2f7e82702 100644 --- a/atom/browser/api/atom_api_menu_views.cc +++ b/atom/browser/api/atom_api_menu_views.cc @@ -30,7 +30,7 @@ void MenuViews::Popup(Window* window) { static_cast(window->window())->widget(), NULL, gfx::Rect(cursor, gfx::Size()), - views::MenuItemView::TOPLEFT, + views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE, views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); } diff --git a/atom/browser/ui/views/menu_delegate.cc b/atom/browser/ui/views/menu_delegate.cc index 88bba2808dfc..e01a9d4c5253 100644 --- a/atom/browser/ui/views/menu_delegate.cc +++ b/atom/browser/ui/views/menu_delegate.cc @@ -7,6 +7,7 @@ #include "atom/browser/ui/views/menu_bar.h" #include "base/stl_util.h" #include "ui/views/controls/button/menu_button.h" +#include "ui/views/controls/menu/menu_item_view.h" #include "ui/views/controls/menu/menu_model_adapter.h" #include "ui/views/controls/menu/menu_runner.h" #include "ui/views/widget/widget.h" @@ -39,7 +40,7 @@ void MenuDelegate::RunMenu(ui::MenuModel* model, views::MenuButton* button) { button->GetWidget()->GetTopLevelWidget(), button, bounds, - views::MenuItemView::TOPRIGHT, + views::MENU_ANCHOR_TOPRIGHT, ui::MENU_SOURCE_MOUSE, views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); } @@ -107,14 +108,14 @@ void MenuDelegate::WillHideMenu(views::MenuItemView* menu) { views::MenuItemView* MenuDelegate::GetSiblingMenu( views::MenuItemView* menu, const gfx::Point& screen_point, - views::MenuItemView::AnchorPosition* anchor, + views::MenuAnchorPosition* anchor, bool* has_mnemonics, views::MenuButton** button) { ui::MenuModel* model; if (!menu_bar_->GetMenuButtonFromScreenPoint(screen_point, &model, button)) return NULL; - *anchor = views::MenuItemView::TOPLEFT; + *anchor = views::MENU_ANCHOR_TOPLEFT; *has_mnemonics = true; id_ = (*button)->tag(); diff --git a/atom/browser/ui/views/menu_delegate.h b/atom/browser/ui/views/menu_delegate.h index 1d409e171035..ca6492cbc6cd 100644 --- a/atom/browser/ui/views/menu_delegate.h +++ b/atom/browser/ui/views/menu_delegate.h @@ -46,7 +46,7 @@ class MenuDelegate : public views::MenuDelegate { virtual views::MenuItemView* GetSiblingMenu( views::MenuItemView* menu, const gfx::Point& screen_point, - views::MenuItemView::AnchorPosition* anchor, + views::MenuAnchorPosition* anchor, bool* has_mnemonics, views::MenuButton** button); From 87019a1a70d2f6190027440f66248291fe0aa303 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 10:19:04 +0000 Subject: [PATCH 08/10] views: No need to destroy Widget, CloseNow already closed native window. --- atom/browser/native_window_views.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/atom/browser/native_window_views.cc b/atom/browser/native_window_views.cc index 89665c68d56a..4c99a56389fc 100644 --- a/atom/browser/native_window_views.cc +++ b/atom/browser/native_window_views.cc @@ -137,7 +137,6 @@ void NativeWindowViews::Close() { void NativeWindowViews::CloseImmediately() { window_->CloseNow(); - window_.reset(); } void NativeWindowViews::Move(const gfx::Rect& bounds) { From 8dd7f811754386d5857de9eef91dc87c316fc54a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 20:32:10 +0800 Subject: [PATCH 09/10] Fix building on Windows. --- atom/browser/ui/win/notify_icon.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 348ee9310364..55d8a2a6b573 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -66,7 +66,7 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos, NULL, NULL, gfx::Rect(gfx::win::ScreenToDIPPoint(cursor_pos), gfx::Size()), - views::MenuItemView::TOPLEFT, + views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE, views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU); if (result == views::MenuRunner::MENU_DELETED) From 1c415b0666a1dc095d0e82da8a3f8eacd2900209 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 28 Jul 2014 20:44:11 +0800 Subject: [PATCH 10/10] win: No more need to convert to DIP point for context menu. --- atom/browser/api/atom_api_menu_views.cc | 8 -------- atom/browser/ui/win/notify_icon.cc | 11 ++++------- atom/browser/ui/win/notify_icon.h | 5 ----- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/atom/browser/api/atom_api_menu_views.cc b/atom/browser/api/atom_api_menu_views.cc index ded2f7e82702..2a2b85b57de7 100644 --- a/atom/browser/api/atom_api_menu_views.cc +++ b/atom/browser/api/atom_api_menu_views.cc @@ -8,10 +8,6 @@ #include "ui/gfx/screen.h" #include "ui/views/controls/menu/menu_runner.h" -#if defined(OS_WIN) -#include "ui/gfx/win/dpi.h" -#endif - namespace atom { namespace api { @@ -21,10 +17,6 @@ MenuViews::MenuViews() { void MenuViews::Popup(Window* window) { gfx::Point cursor = gfx::Screen::GetNativeScreen()->GetCursorScreenPoint(); -#if defined(OS_WIN) - cursor = gfx::win::ScreenToDIPPoint(cursor); -#endif - views::MenuRunner menu_runner(model()); ignore_result(menu_runner.RunMenuAt( static_cast(window->window())->widget(), diff --git a/atom/browser/ui/win/notify_icon.cc b/atom/browser/ui/win/notify_icon.cc index 55d8a2a6b573..8a3720098792 100644 --- a/atom/browser/ui/win/notify_icon.cc +++ b/atom/browser/ui/win/notify_icon.cc @@ -12,7 +12,6 @@ #include "ui/gfx/icon_util.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" -#include "ui/gfx/win/dpi.h" #include "ui/views/controls/menu/menu_runner.h" namespace atom { @@ -61,16 +60,14 @@ void NotifyIcon::HandleClickEvent(const gfx::Point& cursor_pos, if (!SetForegroundWindow(window_)) return; - menu_runner_.reset(new views::MenuRunner(menu_model_)); - views::MenuRunner::RunResult result = menu_runner_->RunMenuAt( + views::MenuRunner menu_runner(menu_model_); + ignore_result(menu_runner.RunMenuAt( NULL, NULL, - gfx::Rect(gfx::win::ScreenToDIPPoint(cursor_pos), gfx::Size()), + gfx::Rect(cursor_pos, gfx::Size()), views::MENU_ANCHOR_TOPLEFT, ui::MENU_SOURCE_MOUSE, - views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU); - if (result == views::MenuRunner::MENU_DELETED) - LOG(ERROR) << "Menu deleted when running"; + views::MenuRunner::HAS_MNEMONICS | views::MenuRunner::CONTEXT_MENU)); } void NotifyIcon::ResetIcon() { diff --git a/atom/browser/ui/win/notify_icon.h b/atom/browser/ui/win/notify_icon.h index b7cdbe229e1a..d76960ad4925 100644 --- a/atom/browser/ui/win/notify_icon.h +++ b/atom/browser/ui/win/notify_icon.h @@ -20,10 +20,6 @@ namespace gfx { class Point; } -namespace views { -class MenuRunner; -} - namespace atom { class NotifyIconHost; @@ -72,7 +68,6 @@ class NotifyIcon : public TrayIcon { // The context menu. ui::SimpleMenuModel* menu_model_; - scoped_ptr menu_runner_; DISALLOW_COPY_AND_ASSIGN(NotifyIcon); };