From 1e15ce6ccdd236eb4d7c75fae75b9c8381b3cc1f Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 24 May 2016 12:37:26 -0700 Subject: [PATCH 01/14] Add failing spec for webview visiblity changes --- spec/fixtures/pages/visibilitychange.html | 11 ++++++++++ .../pages/webview-visibilitychange.html | 8 +++++++ spec/webview-spec.js | 21 +++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 spec/fixtures/pages/visibilitychange.html create mode 100644 spec/fixtures/pages/webview-visibilitychange.html diff --git a/spec/fixtures/pages/visibilitychange.html b/spec/fixtures/pages/visibilitychange.html new file mode 100644 index 000000000000..9f49f520de1f --- /dev/null +++ b/spec/fixtures/pages/visibilitychange.html @@ -0,0 +1,11 @@ + + + + + diff --git a/spec/fixtures/pages/webview-visibilitychange.html b/spec/fixtures/pages/webview-visibilitychange.html new file mode 100644 index 000000000000..b0f05056382e --- /dev/null +++ b/spec/fixtures/pages/webview-visibilitychange.html @@ -0,0 +1,8 @@ + + + + + + diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 8a109b6d7bfd..754321c7454b 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -867,4 +867,25 @@ describe(' tag', function () { }) w.loadURL('file://' + fixtures + '/pages/webview-zoom-factor.html') }) + + it('has the initial hidden state and receives visibilitychange events', function (done) { + w = new BrowserWindow({ + show: false + }) + + ipcMain.once('pong', function (event, visibilityState, hidden) { + assert.equal(visibilityState, 'hidden') + assert.equal(hidden, true) + + w.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', 'visible') + + ipcMain.once('pong', function (event, visibilityState, hidden) { + assert.equal(visibilityState, 'visible') + assert.equal(hidden, false) + done() + }) + }) + + w.loadURL('file://' + fixtures + '/pages/webview-visibilitychange.html') + }) }) From 73b07f76a3004ea64ef88f94161ab820d98cbf42 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 24 May 2016 12:44:09 -0700 Subject: [PATCH 02/14] Support document visiblity state and events in webviews --- atom/browser/web_contents_preferences.cc | 9 ++++++++- atom/common/options_switches.cc | 4 ++++ atom/common/options_switches.h | 2 ++ lib/browser/guest-view-manager.js | 3 ++- lib/renderer/web-view/web-view.js | 9 ++++++++- spec/webview-spec.js | 2 +- 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index bfaca8d7ca77..f57274527fc6 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -160,7 +160,14 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( if (window) { bool visible = window->IsVisible() && !window->IsMinimized(); if (!visible) // Default state is visible. - command_line->AppendSwitch("hidden-page"); + command_line->AppendSwitch(switches::kHiddenPage); + } else { + // Inherit initial visibilty state from parent window in webviews + bool hidden_page; + if (web_preferences.GetBoolean(options::kHiddenPage, &hidden_page) && + hidden_page) { + command_line->AppendSwitch(switches::kHiddenPage); + } } } diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index de130eee13eb..05c2284cbbc7 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -103,6 +103,9 @@ const char kExperimentalCanvasFeatures[] = "experimentalCanvasFeatures"; // Opener window's ID. const char kOpenerID[] = "openerId"; +// Page is hidden. +const char kHiddenPage[] = "hiddenPage"; + // Enable the rubber banding effect. const char kScrollBounce[] = "scrollBounce"; @@ -146,6 +149,7 @@ const char kPreloadURL[] = "preload-url"; const char kNodeIntegration[] = "node-integration"; const char kGuestInstanceID[] = "guest-instance-id"; const char kOpenerID[] = "opener-id"; +const char kHiddenPage[] = "hidden-page"; const char kScrollBounce[] = "scroll-bounce"; // Widevine options diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index fadde79f18c8..b54972288eed 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -56,6 +56,7 @@ extern const char kGuestInstanceID[]; extern const char kExperimentalFeatures[]; extern const char kExperimentalCanvasFeatures[]; extern const char kOpenerID[]; +extern const char kHiddenPage[]; extern const char kScrollBounce[]; extern const char kBlinkFeatures[]; @@ -82,6 +83,7 @@ extern const char kPreloadURL[]; extern const char kNodeIntegration[]; extern const char kGuestInstanceID[]; extern const char kOpenerID[]; +extern const char kHiddenPage[]; extern const char kScrollBounce[]; extern const char kWidevineCdmPath[]; diff --git a/lib/browser/guest-view-manager.js b/lib/browser/guest-view-manager.js index 6876a8d22c12..57ed14af5d22 100644 --- a/lib/browser/guest-view-manager.js +++ b/lib/browser/guest-view-manager.js @@ -181,7 +181,8 @@ var attachGuest = function (embedder, elementInstanceId, guestInstanceId, params plugins: params.plugins, zoomFactor: params.zoomFactor, webSecurity: !params.disablewebsecurity, - blinkFeatures: params.blinkfeatures + blinkFeatures: params.blinkfeatures, + hiddenPage: params.hiddenPage } if (params.preload) { diff --git a/lib/renderer/web-view/web-view.js b/lib/renderer/web-view/web-view.js index 1636d560ee53..fd44d925e456 100644 --- a/lib/renderer/web-view/web-view.js +++ b/lib/renderer/web-view/web-view.js @@ -42,6 +42,11 @@ var WebViewImpl = (function () { this.webviewNode.setZoomLevel(zoomLevel) } webFrame.on('zoom-level-changed', this.onZoomLevelChanged) + + this.onVisibilityChanged = (event, visibilityState) => { + this.webviewNode.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', visibilityState) + } + ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged) } WebViewImpl.prototype.createBrowserPluginNode = function () { @@ -56,6 +61,7 @@ var WebViewImpl = (function () { WebViewImpl.prototype.reset = function () { // Unlisten the zoom-level-changed event. webFrame.removeListener('zoom-level-changed', this.onZoomLevelChanged) + ipcRenderer.removeListener('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.onVisibilityChanged) // If guestInstanceId is defined then the has navigated and has // already picked up a partition ID. Thus, we need to reset the initialization @@ -224,7 +230,8 @@ var WebViewImpl = (function () { params = { instanceId: this.viewInstanceId, userAgentOverride: this.userAgentOverride, - zoomFactor: webFrame.getZoomFactor() + zoomFactor: webFrame.getZoomFactor(), + hiddenPage: document.hidden } ref1 = this.attributes for (attributeName in ref1) { diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 754321c7454b..4b1abbfe92a1 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -868,7 +868,7 @@ describe(' tag', function () { w.loadURL('file://' + fixtures + '/pages/webview-zoom-factor.html') }) - it('has the initial hidden state and receives visibilitychange events', function (done) { + it('inherits the parent window hidden state and receives visibilitychange events', function (done) { w = new BrowserWindow({ show: false }) From 4e68a8d16eb53b96a6f3d9b6b0254afffeec559a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 24 May 2016 12:47:12 -0700 Subject: [PATCH 03/14] Remove logging in parent page --- spec/fixtures/pages/webview-visibilitychange.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/fixtures/pages/webview-visibilitychange.html b/spec/fixtures/pages/webview-visibilitychange.html index b0f05056382e..7c8b7cef9df5 100644 --- a/spec/fixtures/pages/webview-visibilitychange.html +++ b/spec/fixtures/pages/webview-visibilitychange.html @@ -1,8 +1,5 @@ - From 69c69880e5f86e75bb659014e7758a2bc0eceef3 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 24 May 2016 12:47:37 -0700 Subject: [PATCH 04/14] Tweak spec description --- spec/webview-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 4b1abbfe92a1..7bdb3a632e0c 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -868,7 +868,7 @@ describe(' tag', function () { w.loadURL('file://' + fixtures + '/pages/webview-zoom-factor.html') }) - it('inherits the parent window hidden state and receives visibilitychange events', function (done) { + it('inherits the parent window visibility state and receives visibilitychange events', function (done) { w = new BrowserWindow({ show: false }) From 583bb49f6cd2241a9ea02fcbc0e056e85e3104d1 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:13:12 -0700 Subject: [PATCH 05/14] Get hidden state by using parent window directly --- atom/browser/api/atom_api_web_view_manager.cc | 14 ++----------- atom/browser/web_contents_preferences.cc | 21 ++++++++++++------- atom/browser/web_view_manager.cc | 20 +++++++++++++++++- atom/browser/web_view_manager.h | 5 +++++ lib/browser/guest-view-manager.js | 3 +-- lib/renderer/web-view/web-view.js | 3 +-- 6 files changed, 41 insertions(+), 25 deletions(-) diff --git a/atom/browser/api/atom_api_web_view_manager.cc b/atom/browser/api/atom_api_web_view_manager.cc index f06c1105526e..1586c3a10dde 100644 --- a/atom/browser/api/atom_api_web_view_manager.cc +++ b/atom/browser/api/atom_api_web_view_manager.cc @@ -14,22 +14,12 @@ using atom::WebContentsPreferences; namespace { -atom::WebViewManager* GetWebViewManager(content::WebContents* web_contents) { - auto context = web_contents->GetBrowserContext(); - if (context) { - auto manager = context->GetGuestManager(); - return static_cast(manager); - } else { - return nullptr; - } -} - void AddGuest(int guest_instance_id, int element_instance_id, content::WebContents* embedder, content::WebContents* guest_web_contents, const base::DictionaryValue& options) { - auto manager = GetWebViewManager(embedder); + auto manager = atom::WebViewManager::GetWebViewManager(embedder); if (manager) manager->AddGuest(guest_instance_id, element_instance_id, embedder, guest_web_contents); @@ -38,7 +28,7 @@ void AddGuest(int guest_instance_id, } void RemoveGuest(content::WebContents* embedder, int guest_instance_id) { - auto manager = GetWebViewManager(embedder); + auto manager = atom::WebViewManager::GetWebViewManager(embedder); if (manager) manager->RemoveGuest(guest_instance_id); } diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index f57274527fc6..5e1971063fac 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -9,6 +9,7 @@ #include #include "atom/browser/native_window.h" +#include "atom/browser/web_view_manager.h" #include "atom/common/native_mate_converters/value_converter.h" #include "atom/common/options_switches.h" #include "base/command_line.h" @@ -155,19 +156,23 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures, blink_features); - // The initial visibility state. NativeWindow* window = NativeWindow::FromWebContents(web_contents); + + // Inherit initial visibilty state from parent window in webviews + if (guest_instance_id && !window) { + auto manager = WebViewManager::GetWebViewManager(web_contents); + if (manager) { + content::WebContents* embedder = manager->GetEmbedder(guest_instance_id); + if (embedder) + window = NativeWindow::FromWebContents(embedder); + } + } + + // The initial visibility state. if (window) { bool visible = window->IsVisible() && !window->IsMinimized(); if (!visible) // Default state is visible. command_line->AppendSwitch(switches::kHiddenPage); - } else { - // Inherit initial visibilty state from parent window in webviews - bool hidden_page; - if (web_preferences.GetBoolean(options::kHiddenPage, &hidden_page) && - hidden_page) { - command_line->AppendSwitch(switches::kHiddenPage); - } } } diff --git a/atom/browser/web_view_manager.cc b/atom/browser/web_view_manager.cc index d404c1a43680..321820bc2f61 100644 --- a/atom/browser/web_view_manager.cc +++ b/atom/browser/web_view_manager.cc @@ -6,7 +6,6 @@ #include "atom/browser/atom_browser_context.h" #include "content/public/browser/render_process_host.h" -#include "content/public/browser/web_contents.h" namespace atom { @@ -42,6 +41,13 @@ void WebViewManager::RemoveGuest(int guest_instance_id) { } } +content::WebContents* WebViewManager::GetEmbedder(int guest_instance_id) { + if (ContainsKey(web_contents_embedder_map_, guest_instance_id)) + return web_contents_embedder_map_[guest_instance_id].embedder; + else + return nullptr; +} + content::WebContents* WebViewManager::GetGuestByInstanceID( int owner_process_id, int element_instance_id) { @@ -65,4 +71,16 @@ bool WebViewManager::ForEachGuest(content::WebContents* embedder_web_contents, return false; } +// static +WebViewManager* WebViewManager::GetWebViewManager(content::WebContents* web_contents) { + auto context = web_contents->GetBrowserContext(); + if (context) { + auto manager = context->GetGuestManager(); + return static_cast(manager); + } else { + return nullptr; + } +} + + } // namespace atom diff --git a/atom/browser/web_view_manager.h b/atom/browser/web_view_manager.h index ff9a8ecba2ab..b956fa76ecff 100644 --- a/atom/browser/web_view_manager.h +++ b/atom/browser/web_view_manager.h @@ -8,6 +8,7 @@ #include #include "content/public/browser/browser_plugin_guest_manager.h" +#include "content/public/browser/web_contents.h" namespace atom { @@ -22,6 +23,10 @@ class WebViewManager : public content::BrowserPluginGuestManager { content::WebContents* web_contents); void RemoveGuest(int guest_instance_id); + content::WebContents* GetEmbedder(int guest_instance_id); + + static WebViewManager* GetWebViewManager(content::WebContents* web_contents); + protected: // content::BrowserPluginGuestManager: content::WebContents* GetGuestByInstanceID(int owner_process_id, diff --git a/lib/browser/guest-view-manager.js b/lib/browser/guest-view-manager.js index 57ed14af5d22..6876a8d22c12 100644 --- a/lib/browser/guest-view-manager.js +++ b/lib/browser/guest-view-manager.js @@ -181,8 +181,7 @@ var attachGuest = function (embedder, elementInstanceId, guestInstanceId, params plugins: params.plugins, zoomFactor: params.zoomFactor, webSecurity: !params.disablewebsecurity, - blinkFeatures: params.blinkfeatures, - hiddenPage: params.hiddenPage + blinkFeatures: params.blinkfeatures } if (params.preload) { diff --git a/lib/renderer/web-view/web-view.js b/lib/renderer/web-view/web-view.js index fd44d925e456..e9d300aabbcb 100644 --- a/lib/renderer/web-view/web-view.js +++ b/lib/renderer/web-view/web-view.js @@ -230,8 +230,7 @@ var WebViewImpl = (function () { params = { instanceId: this.viewInstanceId, userAgentOverride: this.userAgentOverride, - zoomFactor: webFrame.getZoomFactor(), - hiddenPage: document.hidden + zoomFactor: webFrame.getZoomFactor() } ref1 = this.attributes for (attributeName in ref1) { From f58322891b568e2fc32b4eb46703d96183e70897 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:17:35 -0700 Subject: [PATCH 06/14] Remove added switch/option --- atom/browser/web_contents_preferences.cc | 2 +- atom/browser/web_view_manager.cc | 1 - atom/common/options_switches.cc | 4 ---- atom/common/options_switches.h | 2 -- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 5e1971063fac..c7ff0cfcef14 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -172,7 +172,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( if (window) { bool visible = window->IsVisible() && !window->IsMinimized(); if (!visible) // Default state is visible. - command_line->AppendSwitch(switches::kHiddenPage); + command_line->AppendSwitch("hidden-page"); } } diff --git a/atom/browser/web_view_manager.cc b/atom/browser/web_view_manager.cc index 321820bc2f61..d0d35d5f75af 100644 --- a/atom/browser/web_view_manager.cc +++ b/atom/browser/web_view_manager.cc @@ -82,5 +82,4 @@ WebViewManager* WebViewManager::GetWebViewManager(content::WebContents* web_cont } } - } // namespace atom diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 05c2284cbbc7..de130eee13eb 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -103,9 +103,6 @@ const char kExperimentalCanvasFeatures[] = "experimentalCanvasFeatures"; // Opener window's ID. const char kOpenerID[] = "openerId"; -// Page is hidden. -const char kHiddenPage[] = "hiddenPage"; - // Enable the rubber banding effect. const char kScrollBounce[] = "scrollBounce"; @@ -149,7 +146,6 @@ const char kPreloadURL[] = "preload-url"; const char kNodeIntegration[] = "node-integration"; const char kGuestInstanceID[] = "guest-instance-id"; const char kOpenerID[] = "opener-id"; -const char kHiddenPage[] = "hidden-page"; const char kScrollBounce[] = "scroll-bounce"; // Widevine options diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index b54972288eed..fadde79f18c8 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -56,7 +56,6 @@ extern const char kGuestInstanceID[]; extern const char kExperimentalFeatures[]; extern const char kExperimentalCanvasFeatures[]; extern const char kOpenerID[]; -extern const char kHiddenPage[]; extern const char kScrollBounce[]; extern const char kBlinkFeatures[]; @@ -83,7 +82,6 @@ extern const char kPreloadURL[]; extern const char kNodeIntegration[]; extern const char kGuestInstanceID[]; extern const char kOpenerID[]; -extern const char kHiddenPage[]; extern const char kScrollBounce[]; extern const char kWidevineCdmPath[]; From 03c6fbf80f404c2b67905675f69089c896085b1d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:20:00 -0700 Subject: [PATCH 07/14] :art: --- atom/browser/web_view_manager.cc | 3 ++- atom/browser/web_view_manager.h | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/atom/browser/web_view_manager.cc b/atom/browser/web_view_manager.cc index d0d35d5f75af..a1c5d898dbbb 100644 --- a/atom/browser/web_view_manager.cc +++ b/atom/browser/web_view_manager.cc @@ -72,7 +72,8 @@ bool WebViewManager::ForEachGuest(content::WebContents* embedder_web_contents, } // static -WebViewManager* WebViewManager::GetWebViewManager(content::WebContents* web_contents) { +WebViewManager* WebViewManager::GetWebViewManager( + content::WebContents* web_contents) { auto context = web_contents->GetBrowserContext(); if (context) { auto manager = context->GetGuestManager(); diff --git a/atom/browser/web_view_manager.h b/atom/browser/web_view_manager.h index b956fa76ecff..da1e51bccc0b 100644 --- a/atom/browser/web_view_manager.h +++ b/atom/browser/web_view_manager.h @@ -22,7 +22,6 @@ class WebViewManager : public content::BrowserPluginGuestManager { content::WebContents* embedder, content::WebContents* web_contents); void RemoveGuest(int guest_instance_id); - content::WebContents* GetEmbedder(int guest_instance_id); static WebViewManager* GetWebViewManager(content::WebContents* web_contents); From b1ce57faa993b16ee28d2fdc546b673b96ab6c86 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:22:43 -0700 Subject: [PATCH 08/14] Remove redundant atom:: namespace use --- atom/browser/web_view_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_view_manager.cc b/atom/browser/web_view_manager.cc index a1c5d898dbbb..02d40160fa60 100644 --- a/atom/browser/web_view_manager.cc +++ b/atom/browser/web_view_manager.cc @@ -77,7 +77,7 @@ WebViewManager* WebViewManager::GetWebViewManager( auto context = web_contents->GetBrowserContext(); if (context) { auto manager = context->GetGuestManager(); - return static_cast(manager); + return static_cast(manager); } else { return nullptr; } From 89ffa02d7540ef5ecb6412a8c427f11038226354 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:26:05 -0700 Subject: [PATCH 09/14] Tweak comment --- atom/browser/web_contents_preferences.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index c7ff0cfcef14..cdd563316281 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -158,7 +158,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( NativeWindow* window = NativeWindow::FromWebContents(web_contents); - // Inherit initial visibilty state from parent window in webviews + // Use parent window for webviews if (guest_instance_id && !window) { auto manager = WebViewManager::GetWebViewManager(web_contents); if (manager) { From 6632547b178b34fe16687b88e656f1d0c8f70a3d Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:26:20 -0700 Subject: [PATCH 10/14] parent -> embedder --- atom/browser/web_contents_preferences.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index cdd563316281..30635792a1c9 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -158,7 +158,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( NativeWindow* window = NativeWindow::FromWebContents(web_contents); - // Use parent window for webviews + // Use embedder window for webviews if (guest_instance_id && !window) { auto manager = WebViewManager::GetWebViewManager(web_contents); if (manager) { From 814e4377a402aa94f49d45f5ca3a1a29b6cb8e59 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:26:59 -0700 Subject: [PATCH 11/14] Restore original comment position --- atom/browser/web_contents_preferences.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 30635792a1c9..9ad778970cdc 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -156,6 +156,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( command_line->AppendSwitchASCII(::switches::kEnableBlinkFeatures, blink_features); + // The initial visibility state. NativeWindow* window = NativeWindow::FromWebContents(web_contents); // Use embedder window for webviews @@ -168,7 +169,6 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( } } - // The initial visibility state. if (window) { bool visible = window->IsVisible() && !window->IsMinimized(); if (!visible) // Default state is visible. From 88f665bc1bc26343d39d0f7996ef57f19ac67814 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:28:35 -0700 Subject: [PATCH 12/14] Restore original include location --- atom/browser/web_view_manager.cc | 1 + atom/browser/web_view_manager.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_view_manager.cc b/atom/browser/web_view_manager.cc index 02d40160fa60..815e60a166ca 100644 --- a/atom/browser/web_view_manager.cc +++ b/atom/browser/web_view_manager.cc @@ -6,6 +6,7 @@ #include "atom/browser/atom_browser_context.h" #include "content/public/browser/render_process_host.h" +#include "content/public/browser/web_contents.h" namespace atom { diff --git a/atom/browser/web_view_manager.h b/atom/browser/web_view_manager.h index da1e51bccc0b..eb2ba8ad42c8 100644 --- a/atom/browser/web_view_manager.h +++ b/atom/browser/web_view_manager.h @@ -8,7 +8,6 @@ #include #include "content/public/browser/browser_plugin_guest_manager.h" -#include "content/public/browser/web_contents.h" namespace atom { From 75754804affb026400f47110619b79fc54413bd8 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 10:34:33 -0700 Subject: [PATCH 13/14] Use auto for embedder var --- atom/browser/web_contents_preferences.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 9ad778970cdc..82f2023329e6 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -163,7 +163,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( if (guest_instance_id && !window) { auto manager = WebViewManager::GetWebViewManager(web_contents); if (manager) { - content::WebContents* embedder = manager->GetEmbedder(guest_instance_id); + auto embedder = manager->GetEmbedder(guest_instance_id); if (embedder) window = NativeWindow::FromWebContents(embedder); } From 4e44900930b513316a2915f70d21731a02c33d31 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 25 May 2016 18:05:37 -0700 Subject: [PATCH 14/14] Initialize guest_instance_id --- atom/browser/web_contents_preferences.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/web_contents_preferences.cc b/atom/browser/web_contents_preferences.cc index 82f2023329e6..ef9fc4df0b8c 100644 --- a/atom/browser/web_contents_preferences.cc +++ b/atom/browser/web_contents_preferences.cc @@ -131,7 +131,7 @@ void WebContentsPreferences::AppendExtraCommandLineSwitches( base::DoubleToString(zoom_factor)); // --guest-instance-id, which is used to identify guest WebContents. - int guest_instance_id; + int guest_instance_id = 0; if (web_preferences.GetInteger(options::kGuestInstanceID, &guest_instance_id)) command_line->AppendSwitchASCII(switches::kGuestInstanceID, base::IntToString(guest_instance_id));