OLD | NEW |
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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 | 1304 |
1305 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { | 1305 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { |
1306 if (view) { | 1306 if (view) { |
1307 view->Show(); | 1307 view->Show(); |
1308 #if defined(OS_MACOSX) | 1308 #if defined(OS_MACOSX) |
1309 view->SetActive(true); | 1309 view->SetActive(true); |
1310 #endif | 1310 #endif |
1311 } | 1311 } |
1312 } | 1312 } |
1313 | 1313 |
| 1314 SendPageMessage(new PageMsg_WasShown(MSG_ROUTING_NONE)); |
| 1315 |
1314 last_active_time_ = base::TimeTicks::Now(); | 1316 last_active_time_ = base::TimeTicks::Now(); |
1315 | 1317 |
1316 // The resize rect might have changed while this was inactive -- send the new | 1318 // The resize rect might have changed while this was inactive -- send the new |
1317 // one to make sure it's up to date. | 1319 // one to make sure it's up to date. |
1318 RenderViewHostImpl* rvh = GetRenderViewHost(); | 1320 RenderViewHostImpl* rvh = GetRenderViewHost(); |
1319 if (rvh) { | 1321 if (rvh) { |
1320 rvh->GetWidget()->ResizeRectChanged( | 1322 rvh->GetWidget()->ResizeRectChanged( |
1321 GetRootWindowResizerRect(rvh->GetWidget())); | 1323 GetRootWindowResizerRect(rvh->GetWidget())); |
1322 } | 1324 } |
1323 | 1325 |
1324 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); | 1326 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); |
1325 | 1327 |
1326 should_normally_be_visible_ = true; | 1328 should_normally_be_visible_ = true; |
1327 } | 1329 } |
1328 | 1330 |
1329 void WebContentsImpl::WasHidden() { | 1331 void WebContentsImpl::WasHidden() { |
1330 // If there are entities capturing screenshots or video (e.g., mirroring), | 1332 // If there are entities capturing screenshots or video (e.g., mirroring), |
1331 // don't activate the "disable rendering" optimization. | 1333 // don't activate the "disable rendering" optimization. |
1332 if (capturer_count_ == 0) { | 1334 if (capturer_count_ == 0) { |
1333 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 1335 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
1334 // open a tab in the background, then closes the tab before selecting it. | 1336 // open a tab in the background, then closes the tab before selecting it. |
1335 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 1337 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
1336 // removes the |GetRenderViewHost()|; then when we actually destroy the | 1338 // removes the |GetRenderViewHost()|; then when we actually destroy the |
1337 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 1339 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
1338 // calls us). | 1340 // calls us). |
1339 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { | 1341 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { |
1340 if (view) | 1342 if (view) |
1341 view->Hide(); | 1343 view->Hide(); |
1342 } | 1344 } |
| 1345 |
| 1346 SendPageMessage(new PageMsg_WasHidden(MSG_ROUTING_NONE)); |
1343 } | 1347 } |
1344 | 1348 |
1345 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); | 1349 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); |
1346 | 1350 |
1347 should_normally_be_visible_ = false; | 1351 should_normally_be_visible_ = false; |
1348 } | 1352 } |
1349 | 1353 |
1350 void WebContentsImpl::WasOccluded() { | 1354 void WebContentsImpl::WasOccluded() { |
1351 if (capturer_count_ > 0) | 1355 if (capturer_count_ > 0) |
1352 return; | 1356 return; |
(...skipping 3717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5070 for (RenderViewHost* render_view_host : render_view_host_set) | 5074 for (RenderViewHost* render_view_host : render_view_host_set) |
5071 render_view_host->OnWebkitPreferencesChanged(); | 5075 render_view_host->OnWebkitPreferencesChanged(); |
5072 } | 5076 } |
5073 | 5077 |
5074 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 5078 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
5075 JavaScriptDialogManager* dialog_manager) { | 5079 JavaScriptDialogManager* dialog_manager) { |
5076 dialog_manager_ = dialog_manager; | 5080 dialog_manager_ = dialog_manager; |
5077 } | 5081 } |
5078 | 5082 |
5079 } // namespace content | 5083 } // namespace content |
OLD | NEW |