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