chore: bump chromium to 28254008f9e7a2aea5d4426906bfd (master) (#22025)
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
parent
c8fe25e109
commit
42a9d72ce1
12 changed files with 142 additions and 132 deletions
2
DEPS
2
DEPS
|
@ -12,7 +12,7 @@ gclient_gn_args = [
|
||||||
|
|
||||||
vars = {
|
vars = {
|
||||||
'chromium_version':
|
'chromium_version':
|
||||||
'2102ff0fb03469ca5ff317a168e6ad99ca0f23f1',
|
'ddac4c3cc1528254008f9e7a2aea5d4426906bfd',
|
||||||
'node_version':
|
'node_version':
|
||||||
'v12.14.1',
|
'v12.14.1',
|
||||||
'nan_version':
|
'nan_version':
|
||||||
|
|
|
@ -68,7 +68,6 @@ static_library("chrome") {
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
"//chrome/browser:resource_prefetch_predictor_proto",
|
"//chrome/browser:resource_prefetch_predictor_proto",
|
||||||
"//chrome/browser/ssl:proto",
|
|
||||||
"//components/feature_engagement:buildflags",
|
"//components/feature_engagement:buildflags",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -52,15 +52,6 @@ index 392cf3d58c64c088596e8d321a2ce37b0ec60b6e..43e30f47240dc10a3a9b950255d4e487
|
||||||
|
|
||||||
return modifiers;
|
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
|
diff --git a/ui/base/accelerators/media_keys_listener.cc b/ui/base/accelerators/media_keys_listener.cc
|
||||||
index 1145e1f3d79482b5bb468c3128431ac674310e5f..e9f595045e0c076e0735f27dfc38bfbc7951d372 100644
|
index 1145e1f3d79482b5bb468c3128431ac674310e5f..e9f595045e0c076e0735f27dfc38bfbc7951d372 100644
|
||||||
--- a/ui/base/accelerators/media_keys_listener.cc
|
--- a/ui/base/accelerators/media_keys_listener.cc
|
||||||
|
|
|
@ -1,18 +1,26 @@
|
||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
From: deepak1556 <hop2deep@gmail.com>
|
From: Shelley Vohr <shelley.vohr@gmail.com>
|
||||||
Date: Wed, 23 Oct 2019 15:30:18 -0700
|
Date: Tue, 4 Feb 2020 08:59:32 -0700
|
||||||
Subject: Revert "Remove ContentRendererClient::ShouldFork."
|
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
|
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
|
--- a/chrome/renderer/chrome_content_renderer_client.cc
|
||||||
+++ b/chrome/renderer/chrome_content_renderer_client.cc
|
+++ b/chrome/renderer/chrome_content_renderer_client.cc
|
||||||
@@ -1291,6 +1291,17 @@ bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
|
@@ -1269,6 +1269,25 @@ bool ChromeContentRendererClient::AllowPopup() {
|
||||||
return true;
|
#endif
|
||||||
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
|
}
|
||||||
|
|
||||||
|
+bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame,
|
||||||
|
+ const GURL& url,
|
||||||
|
+ const std::string& http_method,
|
||||||
|
+ bool is_initial_navigation,
|
||||||
|
+ bool is_server_redirect) {
|
||||||
+ DCHECK(!frame->Parent());
|
+ DCHECK(!frame->Parent());
|
||||||
+
|
+
|
||||||
+ // If |url| matches one of the prerendered URLs, stop this navigation and try
|
+ // If |url| matches one of the prerendered URLs, stop this navigation and try
|
||||||
|
@ -24,84 +32,90 @@ index e03ad3a5a115383143d1324164dfd37f87c6f2f2..1c179e0cca8b0b1fc19971d1c9e93d59
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
return false;
|
+ 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;
|
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
+ private:
|
void ChromeContentRendererClient::WillSendRequest(
|
||||||
+ class TestContentRendererClient : public ContentRendererClient {
|
WebLocalFrame* frame,
|
||||||
+ public:
|
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,
|
+ bool ShouldFork(blink::WebLocalFrame* frame,
|
||||||
+ const GURL& url,
|
+ const GURL& url,
|
||||||
+ const std::string& http_method,
|
+ const std::string& http_method,
|
||||||
+ bool is_initial_navigation,
|
+ bool is_initial_navigation,
|
||||||
+ bool is_server_redirect) override {
|
+ bool is_server_redirect) override;
|
||||||
+ return true;
|
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
|
||||||
+TEST_F(AlwaysForkingRenderViewTest, BeginNavigationDoesNotForkEmptyUrl) {
|
--- a/content/public/renderer/content_renderer_client.cc
|
||||||
+ GURL example_url("http://example.com");
|
+++ b/content/public/renderer/content_renderer_client.cc
|
||||||
+ GURL empty_url("");
|
@@ -104,6 +104,14 @@ bool ContentRendererClient::HandleNavigation(
|
||||||
+
|
}
|
||||||
+ LoadHTMLWithUrlOverride("<body></body", example_url.spec().c_str());
|
#endif
|
||||||
+ EXPECT_EQ(example_url,
|
|
||||||
+ GURL(frame()->GetWebFrame()->GetDocumentLoader()->GetUrl()));
|
+bool ContentRendererClient::ShouldFork(blink::WebLocalFrame* frame,
|
||||||
+
|
+ const GURL& url,
|
||||||
+ // Empty url should never fork.
|
+ const std::string& http_method,
|
||||||
+ blink::WebURLRequest request(empty_url);
|
+ bool is_initial_navigation,
|
||||||
+ request.SetMode(network::mojom::RequestMode::kNavigate);
|
+ bool is_server_redirect) {
|
||||||
+ request.SetRedirectMode(network::mojom::RedirectMode::kManual);
|
+ return false;
|
||||||
+ request.SetRequestContext(blink::mojom::RequestContextType::INTERNAL);
|
|
||||||
+ request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(example_url));
|
|
||||||
+ auto navigation_info = std::make_unique<blink::WebNavigationInfo>();
|
|
||||||
+ 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) {
|
void ContentRendererClient::WillSendRequest(
|
||||||
+ GURL example_url("http://example.com");
|
blink::WebLocalFrame* frame,
|
||||||
+ GURL blank_url(url::kAboutBlankURL);
|
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);
|
||||||
+
|
+
|
||||||
+ LoadHTMLWithUrlOverride("<body></body", example_url.spec().c_str());
|
// Notifies the embedder that the given frame is requesting the resource at
|
||||||
+ EXPECT_EQ(example_url,
|
// |url|. If the function returns a valid |new_url|, the request must be
|
||||||
+ GURL(frame()->GetWebFrame()->GetDocumentLoader()->GetUrl()));
|
// 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);
|
||||||
+
|
+
|
||||||
+ // about:blank should never fork.
|
+ if (!should_fork && url.SchemeIs(url::kFileScheme)) {
|
||||||
+ blink::WebURLRequest request(blank_url);
|
+ // Fork non-file to file opens (see https://crbug.com/1031119). Note that
|
||||||
+ request.SetMode(network::mojom::RequestMode::kNavigate);
|
+ // this may fork unnecessarily if another tab (hosting a file or not)
|
||||||
+ request.SetRedirectMode(network::mojom::RedirectMode::kManual);
|
+ // targeted this one before its initial navigation, but that shouldn't
|
||||||
+ request.SetRequestContext(blink::mojom::RequestContextType::INTERNAL);
|
+ // cause a problem.
|
||||||
+ request.SetRequestorOrigin(blink::WebSecurityOrigin::Create(example_url));
|
+ should_fork = !old_url.SchemeIs(url::kFileScheme);
|
||||||
+ auto navigation_info = std::make_unique<blink::WebNavigationInfo>();
|
|
||||||
+ 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
|
+ if (!should_fork) {
|
||||||
// continues to receive the original ScreenInfo and not the emualted
|
+ // Give the embedder a chance.
|
||||||
// ScreenInfo.
|
+ 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 */);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (should_fork) {
|
||||||
|
OpenURL(std::move(info));
|
||||||
|
return; // Suppress the load here.
|
||||||
|
|
|
@ -767,17 +767,18 @@ void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
|
bool Session::AddWordToSpellCheckerDictionary(const std::string& word) {
|
||||||
#if BUILDFLAG(USE_BROWSER_SPELLCHECKER)
|
SpellcheckService* service =
|
||||||
if (spellcheck::UseBrowserSpellChecker()) {
|
|
||||||
spellcheck_platform::AddWord(base::UTF8ToUTF16(word));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
SpellcheckService* spellcheck =
|
|
||||||
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
SpellcheckServiceFactory::GetForContext(browser_context_.get());
|
||||||
if (!spellcheck)
|
if (!service)
|
||||||
return false;
|
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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -38,30 +38,30 @@ struct Converter<URLPattern> {
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct Converter<content::ResourceType> {
|
struct Converter<blink::mojom::ResourceType> {
|
||||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
content::ResourceType type) {
|
blink::mojom::ResourceType type) {
|
||||||
const char* result;
|
const char* result;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case content::ResourceType::kMainFrame:
|
case blink::mojom::ResourceType::kMainFrame:
|
||||||
result = "mainFrame";
|
result = "mainFrame";
|
||||||
break;
|
break;
|
||||||
case content::ResourceType::kSubFrame:
|
case blink::mojom::ResourceType::kSubFrame:
|
||||||
result = "subFrame";
|
result = "subFrame";
|
||||||
break;
|
break;
|
||||||
case content::ResourceType::kStylesheet:
|
case blink::mojom::ResourceType::kStylesheet:
|
||||||
result = "stylesheet";
|
result = "stylesheet";
|
||||||
break;
|
break;
|
||||||
case content::ResourceType::kScript:
|
case blink::mojom::ResourceType::kScript:
|
||||||
result = "script";
|
result = "script";
|
||||||
break;
|
break;
|
||||||
case content::ResourceType::kImage:
|
case blink::mojom::ResourceType::kImage:
|
||||||
result = "image";
|
result = "image";
|
||||||
break;
|
break;
|
||||||
case content::ResourceType::kObject:
|
case blink::mojom::ResourceType::kObject:
|
||||||
result = "object";
|
result = "object";
|
||||||
break;
|
break;
|
||||||
case content::ResourceType::kXhr:
|
case blink::mojom::ResourceType::kXhr:
|
||||||
result = "xhr";
|
result = "xhr";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -77,6 +77,11 @@ void BrowserProcessImpl::ApplyProxyModeFromCommandLine(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BuildState* BrowserProcessImpl::GetBuildState() {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void BrowserProcessImpl::PostEarlyInitialization() {
|
void BrowserProcessImpl::PostEarlyInitialization() {
|
||||||
// Mock user prefs, as we only need to track changes for a
|
// Mock user prefs, as we only need to track changes for a
|
||||||
// in memory pref store. There are no persistent preferences
|
// in memory pref store. There are no persistent preferences
|
||||||
|
|
|
@ -38,6 +38,7 @@ class BrowserProcessImpl : public BrowserProcess {
|
||||||
|
|
||||||
static void ApplyProxyModeFromCommandLine(ValueMapPrefStore* pref_store);
|
static void ApplyProxyModeFromCommandLine(ValueMapPrefStore* pref_store);
|
||||||
|
|
||||||
|
BuildState* GetBuildState() override;
|
||||||
void PostEarlyInitialization();
|
void PostEarlyInitialization();
|
||||||
void PreCreateThreads();
|
void PreCreateThreads();
|
||||||
void PostDestroyThreads() {}
|
void PostDestroyThreads() {}
|
||||||
|
|
|
@ -143,7 +143,7 @@ void ElectronExtensionsBrowserClient::LoadResourceFromResourceBundle(
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
bool AllowCrossRendererResourceLoad(const GURL& url,
|
bool AllowCrossRendererResourceLoad(const GURL& url,
|
||||||
content::ResourceType resource_type,
|
blink::mojom::ResourceType resource_type,
|
||||||
ui::PageTransition page_transition,
|
ui::PageTransition page_transition,
|
||||||
int child_id,
|
int child_id,
|
||||||
bool is_incognito,
|
bool is_incognito,
|
||||||
|
@ -174,7 +174,7 @@ bool AllowCrossRendererResourceLoad(const GURL& url,
|
||||||
|
|
||||||
bool ElectronExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
bool ElectronExtensionsBrowserClient::AllowCrossRendererResourceLoad(
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
content::ResourceType resource_type,
|
blink::mojom::ResourceType resource_type,
|
||||||
ui::PageTransition page_transition,
|
ui::PageTransition page_transition,
|
||||||
int child_id,
|
int child_id,
|
||||||
bool is_incognito,
|
bool is_incognito,
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "extensions/browser/extensions_browser_client.h"
|
#include "extensions/browser/extensions_browser_client.h"
|
||||||
#include "mojo/public/cpp/bindings/pending_remote.h"
|
#include "mojo/public/cpp/bindings/pending_remote.h"
|
||||||
|
#include "third_party/blink/public/mojom/loader/resource_load_info.mojom-shared.h"
|
||||||
|
|
||||||
class PrefService;
|
class PrefService;
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ class ElectronExtensionsBrowserClient
|
||||||
bool send_cors_header) override;
|
bool send_cors_header) override;
|
||||||
bool AllowCrossRendererResourceLoad(
|
bool AllowCrossRendererResourceLoad(
|
||||||
const GURL& url,
|
const GURL& url,
|
||||||
content::ResourceType resource_type,
|
blink::mojom::ResourceType resource_type,
|
||||||
ui::PageTransition page_transition,
|
ui::PageTransition page_transition,
|
||||||
int child_id,
|
int child_id,
|
||||||
bool is_incognito,
|
bool is_incognito,
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "shell/browser/ui/x/window_state_watcher.h"
|
#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.h"
|
||||||
#include "ui/gfx/x/x11_atom_cache.h"
|
#include "ui/gfx/x/x11_atom_cache.h"
|
||||||
|
|
||||||
|
@ -12,22 +10,22 @@ namespace electron {
|
||||||
|
|
||||||
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
|
WindowStateWatcher::WindowStateWatcher(NativeWindowViews* window)
|
||||||
: window_(window), widget_(window->GetAcceleratedWidget()) {
|
: window_(window), widget_(window->GetAcceleratedWidget()) {
|
||||||
ui::PlatformEventSource::GetInstance()->AddPlatformEventObserver(this);
|
ui::X11EventSource::GetInstance()->AddXEventObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowStateWatcher::~WindowStateWatcher() {
|
WindowStateWatcher::~WindowStateWatcher() {
|
||||||
ui::PlatformEventSource::GetInstance()->RemovePlatformEventObserver(this);
|
ui::X11EventSource::GetInstance()->RemoveXEventObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowStateWatcher::WillProcessEvent(const ui::PlatformEvent& event) {
|
void WindowStateWatcher::WillProcessXEvent(XEvent* xev) {
|
||||||
if (IsWindowStateEvent(event)) {
|
if (IsWindowStateEvent(xev)) {
|
||||||
was_minimized_ = window_->IsMinimized();
|
was_minimized_ = window_->IsMinimized();
|
||||||
was_maximized_ = window_->IsMaximized();
|
was_maximized_ = window_->IsMaximized();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) {
|
void WindowStateWatcher::DidProcessXEvent(XEvent* xev) {
|
||||||
if (IsWindowStateEvent(event)) {
|
if (IsWindowStateEvent(xev)) {
|
||||||
bool is_minimized = window_->IsMinimized();
|
bool is_minimized = window_->IsMinimized();
|
||||||
bool is_maximized = window_->IsMaximized();
|
bool is_maximized = window_->IsMaximized();
|
||||||
bool is_fullscreen = window_->IsFullscreen();
|
bool is_fullscreen = window_->IsFullscreen();
|
||||||
|
@ -55,10 +53,10 @@ void WindowStateWatcher::DidProcessEvent(const ui::PlatformEvent& event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WindowStateWatcher::IsWindowStateEvent(const ui::PlatformEvent& event) {
|
bool WindowStateWatcher::IsWindowStateEvent(XEvent* xev) {
|
||||||
::Atom changed_atom = event->xproperty.atom;
|
::Atom changed_atom = xev->xproperty.atom;
|
||||||
return (changed_atom == gfx::GetAtom("_NET_WM_STATE") &&
|
return (changed_atom == gfx::GetAtom("_NET_WM_STATE") &&
|
||||||
event->type == PropertyNotify && event->xproperty.window == widget_);
|
xev->type == PropertyNotify && xev->xproperty.window == widget_);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace electron
|
} // namespace electron
|
||||||
|
|
|
@ -5,24 +5,24 @@
|
||||||
#ifndef SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
|
#ifndef SHELL_BROWSER_UI_X_WINDOW_STATE_WATCHER_H_
|
||||||
#define 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"
|
#include "shell/browser/native_window_views.h"
|
||||||
|
|
||||||
namespace electron {
|
namespace electron {
|
||||||
|
|
||||||
class WindowStateWatcher : public ui::PlatformEventObserver {
|
class WindowStateWatcher : public ui::XEventObserver {
|
||||||
public:
|
public:
|
||||||
explicit WindowStateWatcher(NativeWindowViews* window);
|
explicit WindowStateWatcher(NativeWindowViews* window);
|
||||||
~WindowStateWatcher() override;
|
~WindowStateWatcher() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ui::PlatformEventObserver:
|
// ui::XEventObserver:
|
||||||
void WillProcessEvent(const ui::PlatformEvent& event) override;
|
void WillProcessXEvent(XEvent* xev) override;
|
||||||
void DidProcessEvent(const ui::PlatformEvent& event) override;
|
void DidProcessXEvent(XEvent* xev) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool IsWindowStateEvent(const ui::PlatformEvent& event);
|
bool IsWindowStateEvent(XEvent* xev);
|
||||||
|
|
||||||
NativeWindowViews* window_;
|
NativeWindowViews* window_;
|
||||||
gfx::AcceleratedWidget widget_;
|
gfx::AcceleratedWidget widget_;
|
||||||
|
|
Loading…
Reference in a new issue