Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 1991273003: Fire visibilityChange event on out-of-process iframes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressing comments Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <cmath> 9 #include <cmath>
10 #include <utility> 10 #include <utility>
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 1307
1308 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { 1308 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) {
1309 if (view) { 1309 if (view) {
1310 view->Show(); 1310 view->Show();
1311 #if defined(OS_MACOSX) 1311 #if defined(OS_MACOSX)
1312 view->SetActive(true); 1312 view->SetActive(true);
1313 #endif 1313 #endif
1314 } 1314 }
1315 } 1315 }
1316 1316
1317 SendPageMessage(new PageMsg_WasShown(MSG_ROUTING_NONE));
1318
1317 last_active_time_ = base::TimeTicks::Now(); 1319 last_active_time_ = base::TimeTicks::Now();
1318 1320
1319 // The resize rect might have changed while this was inactive -- send the new 1321 // The resize rect might have changed while this was inactive -- send the new
1320 // one to make sure it's up to date. 1322 // one to make sure it's up to date.
1321 RenderViewHostImpl* rvh = GetRenderViewHost(); 1323 RenderViewHostImpl* rvh = GetRenderViewHost();
1322 if (rvh) { 1324 if (rvh) {
1323 rvh->GetWidget()->ResizeRectChanged( 1325 rvh->GetWidget()->ResizeRectChanged(
1324 GetRootWindowResizerRect(rvh->GetWidget())); 1326 GetRootWindowResizerRect(rvh->GetWidget()));
1325 } 1327 }
1326 1328
1327 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); 1329 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown());
1328 1330
1329 should_normally_be_visible_ = true; 1331 should_normally_be_visible_ = true;
1330 } 1332 }
1331 1333
1332 void WebContentsImpl::WasHidden() { 1334 void WebContentsImpl::WasHidden() {
1333 // If there are entities capturing screenshots or video (e.g., mirroring), 1335 // If there are entities capturing screenshots or video (e.g., mirroring),
1334 // don't activate the "disable rendering" optimization. 1336 // don't activate the "disable rendering" optimization.
1335 if (capturer_count_ == 0) { 1337 if (capturer_count_ == 0) {
1336 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to 1338 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to
1337 // open a tab in the background, then closes the tab before selecting it. 1339 // open a tab in the background, then closes the tab before selecting it.
1338 // This is because closing the tab calls WebContentsImpl::Destroy(), which 1340 // This is because closing the tab calls WebContentsImpl::Destroy(), which
1339 // removes the |GetRenderViewHost()|; then when we actually destroy the 1341 // removes the |GetRenderViewHost()|; then when we actually destroy the
1340 // window, OnWindowPosChanged() notices and calls WasHidden() (which 1342 // window, OnWindowPosChanged() notices and calls WasHidden() (which
1341 // calls us). 1343 // calls us).
1342 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { 1344 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) {
1343 if (view) 1345 if (view)
1344 view->Hide(); 1346 view->Hide();
1345 } 1347 }
1348
1349 SendPageMessage(new PageMsg_WasHidden(MSG_ROUTING_NONE));
1346 } 1350 }
1347 1351
1348 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); 1352 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden());
1349 1353
1350 should_normally_be_visible_ = false; 1354 should_normally_be_visible_ = false;
1351 } 1355 }
1352 1356
1353 void WebContentsImpl::WasOccluded() { 1357 void WebContentsImpl::WasOccluded() {
1354 if (capturer_count_ > 0) 1358 if (capturer_count_ > 0)
1355 return; 1359 return;
(...skipping 3749 matching lines...) Expand 10 before | Expand all | Expand 10 after
5105 for (RenderViewHost* render_view_host : render_view_host_set) 5109 for (RenderViewHost* render_view_host : render_view_host_set)
5106 render_view_host->OnWebkitPreferencesChanged(); 5110 render_view_host->OnWebkitPreferencesChanged();
5107 } 5111 }
5108 5112
5109 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( 5113 void WebContentsImpl::SetJavaScriptDialogManagerForTesting(
5110 JavaScriptDialogManager* dialog_manager) { 5114 JavaScriptDialogManager* dialog_manager) {
5111 dialog_manager_ = dialog_manager; 5115 dialog_manager_ = dialog_manager;
5112 } 5116 }
5113 5117
5114 } // namespace content 5118 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698