diff --git a/DEPS b/DEPS index c9d62a3978fe..17eb7942fa39 100644 --- a/DEPS +++ b/DEPS @@ -12,7 +12,7 @@ gclient_gn_args = [ vars = { 'chromium_version': - '2102ff0fb03469ca5ff317a168e6ad99ca0f23f1', + 'ddac4c3cc1528254008f9e7a2aea5d4426906bfd', 'node_version': 'v12.14.1', 'nan_version': diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index ae99335ff53f..fa60b2ca5479 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -68,7 +68,6 @@ static_library("chrome") { ] deps = [ "//chrome/browser:resource_prefetch_predictor_proto", - "//chrome/browser/ssl:proto", "//components/feature_engagement:buildflags", ] diff --git a/patches/chromium/command-ismediakey.patch b/patches/chromium/command-ismediakey.patch index 810126db98ed..4bb832941afa 100644 --- a/patches/chromium/command-ismediakey.patch +++ b/patches/chromium/command-ismediakey.patch @@ -52,15 +52,6 @@ index 392cf3d58c64c088596e8d321a2ce37b0ec60b6e..43e30f47240dc10a3a9b950255d4e487 return modifiers; } -@@ -151,6 +152,8 @@ void GlobalShortcutListenerX11::OnXKeyPressEvent(::XEvent* x_event) { - modifiers |= (x_event->xkey.state & ShiftMask) ? ui::EF_SHIFT_DOWN : 0; - modifiers |= (x_event->xkey.state & ControlMask) ? ui::EF_CONTROL_DOWN : 0; - modifiers |= (x_event->xkey.state & Mod1Mask) ? ui::EF_ALT_DOWN : 0; -+ // For Windows key -+ modifiers |= (x_event->xkey.state & Mod4Mask) ? ui::EF_COMMAND_DOWN: 0; - - ui::Accelerator accelerator( - ui::KeyboardCodeFromXKeyEvent(x_event), modifiers); diff --git a/ui/base/accelerators/media_keys_listener.cc b/ui/base/accelerators/media_keys_listener.cc index 1145e1f3d79482b5bb468c3128431ac674310e5f..e9f595045e0c076e0735f27dfc38bfbc7951d372 100644 --- a/ui/base/accelerators/media_keys_listener.cc diff --git a/patches/chromium/revert_remove_contentrendererclient_shouldfork.patch b/patches/chromium/revert_remove_contentrendererclient_shouldfork.patch index a873cf2bca2e..2e86219636b8 100644 --- a/patches/chromium/revert_remove_contentrendererclient_shouldfork.patch +++ b/patches/chromium/revert_remove_contentrendererclient_shouldfork.patch @@ -1,18 +1,26 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: deepak1556 -Date: Wed, 23 Oct 2019 15:30:18 -0700 +From: Shelley Vohr +Date: Tue, 4 Feb 2020 08:59:32 -0700 Subject: Revert "Remove ContentRendererClient::ShouldFork." -This reverts commit 6b068eb8ca4a3c7350bdafa22fc0cf0636ef8b74. +This reverts the CL at https://chromium-review.googlesource.com/c/chromium/src/+/1812128. +We use it to force a new renderer process for navigations, and need to start a new renderer process +for every navigation to keep Node.js working properly. Once Native Modules in the renderer process +are required to be NAPI or context aware (Electron v11), this patch can be removed. diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc -index e03ad3a5a115383143d1324164dfd37f87c6f2f2..1c179e0cca8b0b1fc19971d1c9e93d59af7b9383 100644 +index a9b2e3fa8067e0adc7430c5e566d7734c2f75681..c564b64b72a604ee7beee2e4d617ca7c18a00d6b 100644 --- a/chrome/renderer/chrome_content_renderer_client.cc +++ b/chrome/renderer/chrome_content_renderer_client.cc -@@ -1291,6 +1291,17 @@ bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame, - return true; - #endif // BUILDFLAG(ENABLE_EXTENSIONS) +@@ -1269,6 +1269,25 @@ bool ChromeContentRendererClient::AllowPopup() { + #endif + } ++bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame, ++ const GURL& url, ++ const std::string& http_method, ++ bool is_initial_navigation, ++ bool is_server_redirect) { + DCHECK(!frame->Parent()); + + // If |url| matches one of the prerendered URLs, stop this navigation and try @@ -24,84 +32,90 @@ index e03ad3a5a115383143d1324164dfd37f87c6f2f2..1c179e0cca8b0b1fc19971d1c9e93d59 + return true; + } + - return false; - } - -diff --git a/content/renderer/render_view_browsertest.cc b/content/renderer/render_view_browsertest.cc -index b4895b8770bd58d400cc8ca55c74940b25b3a8d5..3c0d6bc9bb50abc5f02e07c24ed8ae424dcda1a5 100644 ---- a/content/renderer/render_view_browsertest.cc -+++ b/content/renderer/render_view_browsertest.cc -@@ -1004,6 +1004,73 @@ TEST_F(RenderViewImplTest, BeginNavigationForWebUI) { - FrameHostMsg_OpenURL::ID)); - } - -+class AlwaysForkingRenderViewTest : public RenderViewImplTest { -+ public: -+ ContentRendererClient* CreateContentRendererClient() override { -+ return new TestContentRendererClient; -+ } ++ return false; ++} + -+ private: -+ class TestContentRendererClient : public ContentRendererClient { -+ public: -+ bool ShouldFork(blink::WebLocalFrame* frame, -+ const GURL& url, -+ const std::string& http_method, -+ bool is_initial_navigation, -+ bool is_server_redirect) override { -+ return true; + void ChromeContentRendererClient::WillSendRequest( + WebLocalFrame* frame, + ui::PageTransition transition_type, +diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h +index b5d52afedb94475f05318bfc35f7e0b595047ee3..c40a6ec13f3ee366dcf9cc5b6440045c89c310b8 100644 +--- a/chrome/renderer/chrome_content_renderer_client.h ++++ b/chrome/renderer/chrome_content_renderer_client.h +@@ -131,6 +131,11 @@ class ChromeContentRendererClient + base::SingleThreadTaskRunner* compositor_thread_task_runner) override; + bool RunIdleHandlerWhenWidgetsHidden() override; + bool AllowPopup() override; ++ bool ShouldFork(blink::WebLocalFrame* frame, ++ const GURL& url, ++ const std::string& http_method, ++ bool is_initial_navigation, ++ bool is_server_redirect) override; + void WillSendRequest(blink::WebLocalFrame* frame, + ui::PageTransition transition_type, + const blink::WebURL& url, +diff --git a/content/public/renderer/content_renderer_client.cc b/content/public/renderer/content_renderer_client.cc +index c4c0e27127ff2976db4e78cf5a02bd22d1c667d3..a4318511d1081d4f101cb2f18ca5fa200fb9773c 100644 +--- a/content/public/renderer/content_renderer_client.cc ++++ b/content/public/renderer/content_renderer_client.cc +@@ -104,6 +104,14 @@ bool ContentRendererClient::HandleNavigation( + } + #endif + ++bool ContentRendererClient::ShouldFork(blink::WebLocalFrame* frame, ++ const GURL& url, ++ const std::string& http_method, ++ bool is_initial_navigation, ++ bool is_server_redirect) { ++ return false; ++} ++ + void ContentRendererClient::WillSendRequest( + blink::WebLocalFrame* frame, + ui::PageTransition transition_type, +diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h +index 0a4ec619e96a840b4b4d5b51246de6c91e0f94f2..5dabb49f061b4e0643256cbf9162d128c1e0bacf 100644 +--- a/content/public/renderer/content_renderer_client.h ++++ b/content/public/renderer/content_renderer_client.h +@@ -213,6 +213,13 @@ class CONTENT_EXPORT ContentRendererClient { + bool is_redirect); + #endif + ++ // Returns true if we should fork a new process for the given navigation. ++ virtual bool ShouldFork(blink::WebLocalFrame* frame, ++ const GURL& url, ++ const std::string& http_method, ++ bool is_initial_navigation, ++ bool is_server_redirect); ++ + // Notifies the embedder that the given frame is requesting the resource at + // |url|. If the function returns a valid |new_url|, the request must be + // updated to use it. The |attach_same_site_cookies| output parameter +diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc +index 3800b761af945bc1592eda7f054199da03183b05..6cabed55988cdfaab422b36a697fc8b0310870a8 100644 +--- a/content/renderer/render_frame_impl.cc ++++ b/content/renderer/render_frame_impl.cc +@@ -5798,6 +5798,23 @@ void RenderFrameImpl::BeginNavigation( + int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); + bool should_fork = HasWebUIScheme(url) || HasWebUIScheme(old_url) || + (cumulative_bindings & kWebUIBindingsPolicyMask); ++ ++ if (!should_fork && url.SchemeIs(url::kFileScheme)) { ++ // Fork non-file to file opens (see https://crbug.com/1031119). Note that ++ // this may fork unnecessarily if another tab (hosting a file or not) ++ // targeted this one before its initial navigation, but that shouldn't ++ // cause a problem. ++ should_fork = !old_url.SchemeIs(url::kFileScheme); + } -+ }; -+}; + -+TEST_F(AlwaysForkingRenderViewTest, BeginNavigationDoesNotForkEmptyUrl) { -+ GURL example_url("http://example.com"); -+ GURL empty_url(""); ++ if (!should_fork) { ++ // Give the embedder a chance. ++ bool is_initial_navigation = render_view_->history_list_length_ == 0; ++ should_fork = GetContentClient()->renderer()->ShouldFork( ++ frame_, url, info->url_request.HttpMethod().Utf8(), ++ is_initial_navigation, false /* is_redirect */); ++ } + -+ LoadHTMLWithUrlOverride("GetWebFrame()->GetDocumentLoader()->GetUrl())); -+ -+ // Empty url should never fork. -+ blink::WebURLRequest request(empty_url); -+ request.SetMode(network::mojom::RequestMode::kNavigate); -+ request.SetRedirectMode(network::mojom::RedirectMode::kManual); -+ request.SetRequestContext(blink::mojom::RequestContextType::INTERNAL); -+ request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(example_url)); -+ auto navigation_info = std::make_unique(); -+ navigation_info->url_request = request; -+ navigation_info->frame_type = -+ network::mojom::RequestContextFrameType::kTopLevel; -+ navigation_info->navigation_policy = blink::kWebNavigationPolicyCurrentTab; -+ frame()->BeginNavigation(std::move(navigation_info)); -+ EXPECT_FALSE(render_thread_->sink().GetUniqueMessageMatching( -+ FrameHostMsg_OpenURL::ID)); -+} -+ -+TEST_F(AlwaysForkingRenderViewTest, BeginNavigationDoesNotForkAboutBlank) { -+ GURL example_url("http://example.com"); -+ GURL blank_url(url::kAboutBlankURL); -+ -+ LoadHTMLWithUrlOverride("GetWebFrame()->GetDocumentLoader()->GetUrl())); -+ -+ // about:blank should never fork. -+ blink::WebURLRequest request(blank_url); -+ request.SetMode(network::mojom::RequestMode::kNavigate); -+ request.SetRedirectMode(network::mojom::RedirectMode::kManual); -+ request.SetRequestContext(blink::mojom::RequestContextType::INTERNAL); -+ request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(example_url)); -+ auto navigation_info = std::make_unique(); -+ navigation_info->url_request = request; -+ navigation_info->frame_type = -+ network::mojom::RequestContextFrameType::kTopLevel; -+ navigation_info->navigation_policy = blink::kWebNavigationPolicyCurrentTab; -+ frame()->BeginNavigation(std::move(navigation_info)); -+ EXPECT_FALSE(render_thread_->sink().GetUniqueMessageMatching( -+ FrameHostMsg_OpenURL::ID)); -+} -+ - // This test verifies that when device emulation is enabled, RenderFrameProxy - // continues to receive the original ScreenInfo and not the emualted - // ScreenInfo. + if (should_fork) { + OpenURL(std::move(info)); + return; // Suppress the load here. diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index 4ef1a141c6f8..39a9f65c1212 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -767,17 +767,18 @@ void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower, } bool Session::AddWordToSpellCheckerDictionary(const std::string& word) { -#if BUILDFLAG(USE_BROWSER_SPELLCHECKER) - if (spellcheck::UseBrowserSpellChecker()) { - spellcheck_platform::AddWord(base::UTF8ToUTF16(word)); - } -#endif - SpellcheckService* spellcheck = + SpellcheckService* service = SpellcheckServiceFactory::GetForContext(browser_context_.get()); - if (!spellcheck) + if (!service) return false; - return spellcheck->GetCustomDictionary()->AddWord(word); +#if BUILDFLAG(USE_BROWSER_SPELLCHECKER) + if (spellcheck::UseBrowserSpellChecker()) { + spellcheck_platform::AddWord(service->platform_spell_checker(), + base::UTF8ToUTF16(word)); + } +#endif + return service->GetCustomDictionary()->AddWord(word); } #endif diff --git a/shell/browser/api/electron_api_web_request.cc b/shell/browser/api/electron_api_web_request.cc index 71b5a031bde7..9b564be52590 100644 --- a/shell/browser/api/electron_api_web_request.cc +++ b/shell/browser/api/electron_api_web_request.cc @@ -38,30 +38,30 @@ struct Converter { }; template <> -struct Converter { +struct Converter { static v8::Local ToV8(v8::Isolate* isolate, - content::ResourceType type) { + blink::mojom::ResourceType type) { const char* result; switch (type) { - case content::ResourceType::kMainFrame: + case blink::mojom::ResourceType::kMainFrame: result = "mainFrame"; break; - case content::ResourceType::kSubFrame: + case blink::mojom::ResourceType::kSubFrame: result = "subFrame"; break; - case content::ResourceType::kStylesheet: + case blink::mojom::ResourceType::kStylesheet: result = "stylesheet"; break; - case content::ResourceType::kScript: + case blink::mojom::ResourceType::kScript: result = "script"; break; - case content::ResourceType::kImage: + case blink::mojom::ResourceType::kImage: result = "image"; break; - case content::ResourceType::kObject: + case blink::mojom::ResourceType::kObject: result = "object"; break; - case content::ResourceType::kXhr: + case blink::mojom::ResourceType::kXhr: result = "xhr"; break; default: diff --git a/shell/browser/browser_process_impl.cc b/shell/browser/browser_process_impl.cc index 3f89f7b20fc2..99853a910dc8 100644 --- a/shell/browser/browser_process_impl.cc +++ b/shell/browser/browser_process_impl.cc @@ -77,6 +77,11 @@ void BrowserProcessImpl::ApplyProxyModeFromCommandLine( } } +BuildState* BrowserProcessImpl::GetBuildState() { + NOTIMPLEMENTED(); + return nullptr; +} + void BrowserProcessImpl::PostEarlyInitialization() { // Mock user prefs, as we only need to track changes for a // in memory pref store. There are no persistent preferences diff --git a/shell/browser/browser_process_impl.h b/shell/browser/browser_process_impl.h index b01d732e3a7d..0833acc5747e 100644 --- a/shell/browser/browser_process_impl.h +++ b/shell/browser/browser_process_impl.h @@ -38,6 +38,7 @@ class BrowserProcessImpl : public BrowserProcess { static void ApplyProxyModeFromCommandLine(ValueMapPrefStore* pref_store); + BuildState* GetBuildState() override; void PostEarlyInitialization(); void PreCreateThreads(); void PostDestroyThreads() {} diff --git a/shell/browser/extensions/electron_extensions_browser_client.cc b/shell/browser/extensions/electron_extensions_browser_client.cc index 6fb991cd5adb..af97bcabeb7e 100644 --- a/shell/browser/extensions/electron_extensions_browser_client.cc +++ b/shell/browser/extensions/electron_extensions_browser_client.cc @@ -143,7 +143,7 @@ void ElectronExtensionsBrowserClient::LoadResourceFromResourceBundle( namespace { bool AllowCrossRendererResourceLoad(const GURL& url, - content::ResourceType resource_type, + blink::mojom::ResourceType resource_type, ui::PageTransition page_transition, int child_id, bool is_incognito, @@ -174,7 +174,7 @@ bool AllowCrossRendererResourceLoad(const GURL& url, bool ElectronExtensionsBrowserClient::AllowCrossRendererResourceLoad( const GURL& url, - content::ResourceType resource_type, + blink::mojom::ResourceType resource_type, ui::PageTransition page_transition, int child_id, bool is_incognito, diff --git a/shell/browser/extensions/electron_extensions_browser_client.h b/shell/browser/extensions/electron_extensions_browser_client.h index 9cab4ffe33ea..796f7570a00b 100644 --- a/shell/browser/extensions/electron_extensions_browser_client.h +++ b/shell/browser/extensions/electron_extensions_browser_client.h @@ -14,6 +14,7 @@ #include "build/build_config.h" #include "extensions/browser/extensions_browser_client.h" #include "mojo/public/cpp/bindings/pending_remote.h" +#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h" class PrefService; @@ -70,7 +71,7 @@ class ElectronExtensionsBrowserClient bool send_cors_header) override; bool AllowCrossRendererResourceLoad( const GURL& url, - content::ResourceType resource_type, + blink::mojom::ResourceType resource_type, ui::PageTransition page_transition, int child_id, bool is_incognito, diff --git a/shell/browser/ui/x/window_state_watcher.cc b/shell/browser/ui/x/window_state_watcher.cc index 9199483a6175..6d4ca95dc720 100644 --- a/shell/browser/ui/x/window_state_watcher.cc +++ b/shell/browser/ui/x/window_state_watcher.cc @@ -3,8 +3,6 @@ // found in the LICENSE file. #include "shell/browser/ui/x/window_state_watcher.h" - -#include "ui/events/platform/platform_event_source.h" #include "ui/gfx/x/x11.h" #include "ui/gfx/x/x11_atom_cache.h" @@ -12,22 +10,22 @@ namespace electron { WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window) : window_(window), widget_(window->GetAcceleratedWidget()) { - ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this); + ui::X11EventSource::GetInstance()->AddXEventObserver(this); } WindowStateWatcher::~WindowStateWatcher() { - ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this); + ui::X11EventSource::GetInstance()->RemoveXEventObserver(this); } -void WindowStateWatcher::WillProcessEvent(const ui::PlatformEvent& event) { - if (IsWindowStateEvent(event)) { +void WindowStateWatcher::WillProcessXEvent(XEvent* xev) { + if (IsWindowStateEvent(xev)) { was_minimized_ = window_->IsMinimized(); was_maximized_ = window_->IsMaximized(); } } -void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) { - if (IsWindowStateEvent(event)) { +void WindowStateWatcher::DidProcessXEvent(XEvent* xev) { + if (IsWindowStateEvent(xev)) { bool is_minimized = window_->IsMinimized(); bool is_maximized = window_->IsMaximized(); bool is_fullscreen = window_->IsFullscreen(); @@ -55,10 +53,10 @@ void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) { } } -bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) { - ::Atom changed_atom = event->xproperty.atom; +bool WindowStateWatcher::IsWindowStateEvent(XEvent* xev) { + ::Atom changed_atom = xev->xproperty.atom; return (changed_atom == gfx::GetAtom("_NET_WM_STATE") && - event->type == PropertyNotify && event->xproperty.window == widget_); + xev->type == PropertyNotify && xev->xproperty.window == widget_); } } // namespace electron diff --git a/shell/browser/ui/x/window_state_watcher.h b/shell/browser/ui/x/window_state_watcher.h index 6018e4ffa098..420e5c1ca197 100644 --- a/shell/browser/ui/x/window_state_watcher.h +++ b/shell/browser/ui/x/window_state_watcher.h @@ -5,24 +5,24 @@ #ifndef SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_ #define SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_ -#include "ui/events/platform/platform_event_observer.h" +#include "ui/events/platform/x11/x11_event_source.h" #include "shell/browser/native_window_views.h" namespace electron { -class WindowStateWatcher : public ui::PlatformEventObserver { +class WindowStateWatcher : public ui::XEventObserver { public: explicit WindowStateWatcher(NativeWindowViews* window); ~WindowStateWatcher() override; protected: - // ui::PlatformEventObserver: - void WillProcessEvent(const ui::PlatformEvent& event) override; - void DidProcessEvent(const ui::PlatformEvent& event) override; + // ui::XEventObserver: + void WillProcessXEvent(XEvent* xev) override; + void DidProcessXEvent(XEvent* xev) override; private: - bool IsWindowStateEvent(const ui::PlatformEvent& event); + bool IsWindowStateEvent(XEvent* xev); NativeWindowViews* window_; gfx::AcceleratedWidget widget_;