| 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 std::unique_ptr<NavigationHandleImpl>()); | 544 std::unique_ptr<NavigationHandleImpl>()); |
| 545 } | 545 } |
| 546 } | 546 } |
| 547 | 547 |
| 548 #if defined(ENABLE_PLUGINS) | 548 #if defined(ENABLE_PLUGINS) |
| 549 // Call this before WebContentsDestroyed() is broadcasted since | 549 // Call this before WebContentsDestroyed() is broadcasted since |
| 550 // AudioFocusManager will be destroyed after that. | 550 // AudioFocusManager will be destroyed after that. |
| 551 pepper_playback_observer_.reset(); | 551 pepper_playback_observer_.reset(); |
| 552 #endif // defined(ENABLED_PLUGINS) | 552 #endif // defined(ENABLED_PLUGINS) |
| 553 | 553 |
| 554 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 554 for (auto& observer : observers_) |
| 555 FrameDeleted(root->current_frame_host())); | 555 observer.FrameDeleted(root->current_frame_host()); |
| 556 | 556 |
| 557 if (root->pending_render_view_host()) { | 557 if (root->pending_render_view_host()) { |
| 558 FOR_EACH_OBSERVER(WebContentsObserver, | 558 for (auto& observer : observers_) |
| 559 observers_, | 559 observer.RenderViewDeleted(root->pending_render_view_host()); |
| 560 RenderViewDeleted(root->pending_render_view_host())); | |
| 561 } | 560 } |
| 562 | 561 |
| 563 FOR_EACH_OBSERVER(WebContentsObserver, | 562 for (auto& observer : observers_) |
| 564 observers_, | 563 observer.RenderViewDeleted(root->current_host()); |
| 565 RenderViewDeleted(root->current_host())); | |
| 566 | 564 |
| 567 FOR_EACH_OBSERVER(WebContentsObserver, | 565 for (auto& observer : observers_) |
| 568 observers_, | 566 observer.WebContentsDestroyed(); |
| 569 WebContentsDestroyed()); | |
| 570 | 567 |
| 571 FOR_EACH_OBSERVER(WebContentsObserver, | 568 for (auto& observer : observers_) |
| 572 observers_, | 569 observer.ResetWebContents(); |
| 573 ResetWebContents()); | |
| 574 | 570 |
| 575 SetDelegate(NULL); | 571 SetDelegate(NULL); |
| 576 } | 572 } |
| 577 | 573 |
| 578 WebContentsImpl* WebContentsImpl::CreateWithOpener( | 574 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
| 579 const WebContents::CreateParams& params, | 575 const WebContents::CreateParams& params, |
| 580 FrameTreeNode* opener) { | 576 FrameTreeNode* opener) { |
| 581 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); | 577 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); |
| 582 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context); | 578 WebContentsImpl* new_contents = new WebContentsImpl(params.browser_context); |
| 583 | 579 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 RenderViewHost* host = GetRenderViewHost(); | 1054 RenderViewHost* host = GetRenderViewHost(); |
| 1059 if (host) | 1055 if (host) |
| 1060 host->SyncRendererPrefs(); | 1056 host->SyncRendererPrefs(); |
| 1061 | 1057 |
| 1062 // Reload the page if a load is currently in progress to avoid having | 1058 // Reload the page if a load is currently in progress to avoid having |
| 1063 // different parts of the page loaded using different user agents. | 1059 // different parts of the page loaded using different user agents. |
| 1064 NavigationEntry* entry = controller_.GetVisibleEntry(); | 1060 NavigationEntry* entry = controller_.GetVisibleEntry(); |
| 1065 if (IsLoading() && entry != NULL && entry->GetIsOverridingUserAgent()) | 1061 if (IsLoading() && entry != NULL && entry->GetIsOverridingUserAgent()) |
| 1066 controller_.ReloadBypassingCache(true); | 1062 controller_.ReloadBypassingCache(true); |
| 1067 | 1063 |
| 1068 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1064 for (auto& observer : observers_) |
| 1069 UserAgentOverrideSet(override)); | 1065 observer.UserAgentOverrideSet(override); |
| 1070 } | 1066 } |
| 1071 | 1067 |
| 1072 const std::string& WebContentsImpl::GetUserAgentOverride() const { | 1068 const std::string& WebContentsImpl::GetUserAgentOverride() const { |
| 1073 return renderer_preferences_.user_agent_override; | 1069 return renderer_preferences_.user_agent_override; |
| 1074 } | 1070 } |
| 1075 | 1071 |
| 1076 void WebContentsImpl::EnableTreeOnlyAccessibilityMode() { | 1072 void WebContentsImpl::EnableTreeOnlyAccessibilityMode() { |
| 1077 if (GetAccessibilityMode() != AccessibilityModeOff) { | 1073 if (GetAccessibilityMode() != AccessibilityModeOff) { |
| 1078 for (RenderFrameHost* rfh : GetAllFrames()) | 1074 for (RenderFrameHost* rfh : GetAllFrames()) |
| 1079 ResetAccessibility(rfh); | 1075 ResetAccessibility(rfh); |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 | 1245 |
| 1250 if (mute) { | 1246 if (mute) { |
| 1251 if (!audio_muter_) | 1247 if (!audio_muter_) |
| 1252 audio_muter_.reset(new WebContentsAudioMuter(this)); | 1248 audio_muter_.reset(new WebContentsAudioMuter(this)); |
| 1253 audio_muter_->StartMuting(); | 1249 audio_muter_->StartMuting(); |
| 1254 } else { | 1250 } else { |
| 1255 DCHECK(audio_muter_); | 1251 DCHECK(audio_muter_); |
| 1256 audio_muter_->StopMuting(); | 1252 audio_muter_->StopMuting(); |
| 1257 } | 1253 } |
| 1258 | 1254 |
| 1259 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1255 for (auto& observer : observers_) |
| 1260 DidUpdateAudioMutingState(mute)); | 1256 observer.DidUpdateAudioMutingState(mute); |
| 1261 | 1257 |
| 1262 // Notification for UI updates in response to the changed muting state. | 1258 // Notification for UI updates in response to the changed muting state. |
| 1263 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); | 1259 NotifyNavigationStateChanged(INVALIDATE_TYPE_TAB); |
| 1264 } | 1260 } |
| 1265 | 1261 |
| 1266 bool WebContentsImpl::IsConnectedToBluetoothDevice() const { | 1262 bool WebContentsImpl::IsConnectedToBluetoothDevice() const { |
| 1267 return bluetooth_connected_device_count_ > 0; | 1263 return bluetooth_connected_device_count_ > 0; |
| 1268 } | 1264 } |
| 1269 | 1265 |
| 1270 bool WebContentsImpl::IsCrashed() const { | 1266 bool WebContentsImpl::IsCrashed() const { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 #if defined(OS_MACOSX) | 1333 #if defined(OS_MACOSX) |
| 1338 view->SetActive(true); | 1334 view->SetActive(true); |
| 1339 #endif | 1335 #endif |
| 1340 } | 1336 } |
| 1341 } | 1337 } |
| 1342 | 1338 |
| 1343 SendPageMessage(new PageMsg_WasShown(MSG_ROUTING_NONE)); | 1339 SendPageMessage(new PageMsg_WasShown(MSG_ROUTING_NONE)); |
| 1344 | 1340 |
| 1345 last_active_time_ = base::TimeTicks::Now(); | 1341 last_active_time_ = base::TimeTicks::Now(); |
| 1346 | 1342 |
| 1347 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasShown()); | 1343 for (auto& observer : observers_) |
| 1344 observer.WasShown(); |
| 1348 | 1345 |
| 1349 should_normally_be_visible_ = true; | 1346 should_normally_be_visible_ = true; |
| 1350 } | 1347 } |
| 1351 | 1348 |
| 1352 void WebContentsImpl::WasHidden() { | 1349 void WebContentsImpl::WasHidden() { |
| 1353 // If there are entities capturing screenshots or video (e.g., mirroring), | 1350 // If there are entities capturing screenshots or video (e.g., mirroring), |
| 1354 // don't activate the "disable rendering" optimization. | 1351 // don't activate the "disable rendering" optimization. |
| 1355 if (capturer_count_ == 0) { | 1352 if (capturer_count_ == 0) { |
| 1356 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to | 1353 // |GetRenderViewHost()| can be NULL if the user middle clicks a link to |
| 1357 // open a tab in the background, then closes the tab before selecting it. | 1354 // open a tab in the background, then closes the tab before selecting it. |
| 1358 // This is because closing the tab calls WebContentsImpl::Destroy(), which | 1355 // This is because closing the tab calls WebContentsImpl::Destroy(), which |
| 1359 // removes the |GetRenderViewHost()|; then when we actually destroy the | 1356 // removes the |GetRenderViewHost()|; then when we actually destroy the |
| 1360 // window, OnWindowPosChanged() notices and calls WasHidden() (which | 1357 // window, OnWindowPosChanged() notices and calls WasHidden() (which |
| 1361 // calls us). | 1358 // calls us). |
| 1362 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { | 1359 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { |
| 1363 if (view) | 1360 if (view) |
| 1364 view->Hide(); | 1361 view->Hide(); |
| 1365 } | 1362 } |
| 1366 | 1363 |
| 1367 SendPageMessage(new PageMsg_WasHidden(MSG_ROUTING_NONE)); | 1364 SendPageMessage(new PageMsg_WasHidden(MSG_ROUTING_NONE)); |
| 1368 } | 1365 } |
| 1369 | 1366 |
| 1370 FOR_EACH_OBSERVER(WebContentsObserver, observers_, WasHidden()); | 1367 for (auto& observer : observers_) |
| 1368 observer.WasHidden(); |
| 1371 | 1369 |
| 1372 should_normally_be_visible_ = false; | 1370 should_normally_be_visible_ = false; |
| 1373 } | 1371 } |
| 1374 | 1372 |
| 1375 void WebContentsImpl::WasOccluded() { | 1373 void WebContentsImpl::WasOccluded() { |
| 1376 if (capturer_count_ > 0) | 1374 if (capturer_count_ > 0) |
| 1377 return; | 1375 return; |
| 1378 | 1376 |
| 1379 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { | 1377 for (RenderWidgetHostView* view : GetRenderWidgetHostViewsInTree()) { |
| 1380 if (view) | 1378 if (view) |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 // TODO(ekaramad): Is it possible to have TextInputState before attaching to | 1443 // TODO(ekaramad): Is it possible to have TextInputState before attaching to |
| 1446 // outer WebContents? In such a case, is this still the right way to hand off | 1444 // outer WebContents? In such a case, is this still the right way to hand off |
| 1447 // state tracking from inner WebContents's TextInputManager to that of the | 1445 // state tracking from inner WebContents's TextInputManager to that of the |
| 1448 // outer WebContent (crbug.com/609846)? | 1446 // outer WebContent (crbug.com/609846)? |
| 1449 text_input_manager_.reset(nullptr); | 1447 text_input_manager_.reset(nullptr); |
| 1450 } | 1448 } |
| 1451 | 1449 |
| 1452 void WebContentsImpl::Stop() { | 1450 void WebContentsImpl::Stop() { |
| 1453 for (FrameTreeNode* node : frame_tree_.Nodes()) | 1451 for (FrameTreeNode* node : frame_tree_.Nodes()) |
| 1454 node->StopLoading(); | 1452 node->StopLoading(); |
| 1455 FOR_EACH_OBSERVER(WebContentsObserver, observers_, NavigationStopped()); | 1453 for (auto& observer : observers_) |
| 1454 observer.NavigationStopped(); |
| 1456 } | 1455 } |
| 1457 | 1456 |
| 1458 WebContents* WebContentsImpl::Clone() { | 1457 WebContents* WebContentsImpl::Clone() { |
| 1459 // We use our current SiteInstance since the cloned entry will use it anyway. | 1458 // We use our current SiteInstance since the cloned entry will use it anyway. |
| 1460 // We pass our own opener so that the cloned page can access it if it was set | 1459 // We pass our own opener so that the cloned page can access it if it was set |
| 1461 // before. | 1460 // before. |
| 1462 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); | 1461 CreateParams create_params(GetBrowserContext(), GetSiteInstance()); |
| 1463 create_params.initial_size = GetContainerBounds().size(); | 1462 create_params.initial_size = GetContainerBounds().size(); |
| 1464 WebContentsImpl* tc = | 1463 WebContentsImpl* tc = |
| 1465 CreateWithOpener(create_params, frame_tree_.root()->opener()); | 1464 CreateWithOpener(create_params, frame_tree_.root()->opener()); |
| 1466 tc->GetController().CopyStateFrom(controller_); | 1465 tc->GetController().CopyStateFrom(controller_); |
| 1467 FOR_EACH_OBSERVER(WebContentsObserver, | 1466 for (auto& observer : observers_) |
| 1468 observers_, | 1467 observer.DidCloneToNewWebContents(this, tc); |
| 1469 DidCloneToNewWebContents(this, tc)); | |
| 1470 return tc; | 1468 return tc; |
| 1471 } | 1469 } |
| 1472 | 1470 |
| 1473 void WebContentsImpl::Observe(int type, | 1471 void WebContentsImpl::Observe(int type, |
| 1474 const NotificationSource& source, | 1472 const NotificationSource& source, |
| 1475 const NotificationDetails& details) { | 1473 const NotificationDetails& details) { |
| 1476 switch (type) { | 1474 switch (type) { |
| 1477 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { | 1475 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: { |
| 1478 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); | 1476 RenderWidgetHost* host = Source<RenderWidgetHost>(source).ptr(); |
| 1479 RenderWidgetHostView* view = host->GetView(); | 1477 RenderWidgetHostView* view = host->GetView(); |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1706 | 1704 |
| 1707 if (is_being_destroyed_) | 1705 if (is_being_destroyed_) |
| 1708 return; | 1706 return; |
| 1709 | 1707 |
| 1710 if (render_widget_host && | 1708 if (render_widget_host && |
| 1711 render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_ && | 1709 render_widget_host->GetRoutingID() == fullscreen_widget_routing_id_ && |
| 1712 render_widget_host->GetProcess()->GetID() == | 1710 render_widget_host->GetProcess()->GetID() == |
| 1713 fullscreen_widget_process_id_) { | 1711 fullscreen_widget_process_id_) { |
| 1714 if (delegate_ && delegate_->EmbedsFullscreenWidget()) | 1712 if (delegate_ && delegate_->EmbedsFullscreenWidget()) |
| 1715 delegate_->ExitFullscreenModeForTab(this); | 1713 delegate_->ExitFullscreenModeForTab(this); |
| 1716 FOR_EACH_OBSERVER(WebContentsObserver, | 1714 for (auto& observer : observers_) |
| 1717 observers_, | 1715 observer.DidDestroyFullscreenWidget(); |
| 1718 DidDestroyFullscreenWidget()); | |
| 1719 fullscreen_widget_process_id_ = ChildProcessHost::kInvalidUniqueID; | 1716 fullscreen_widget_process_id_ = ChildProcessHost::kInvalidUniqueID; |
| 1720 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE; | 1717 fullscreen_widget_routing_id_ = MSG_ROUTING_NONE; |
| 1721 if (fullscreen_widget_had_focus_at_shutdown_) | 1718 if (fullscreen_widget_had_focus_at_shutdown_) |
| 1722 view_->RestoreFocus(); | 1719 view_->RestoreFocus(); |
| 1723 } | 1720 } |
| 1724 | 1721 |
| 1725 CHECK(mouse_lock_widget_ != render_widget_host); | 1722 CHECK(mouse_lock_widget_ != render_widget_host); |
| 1726 } | 1723 } |
| 1727 | 1724 |
| 1728 void WebContentsImpl::RenderWidgetGotFocus( | 1725 void WebContentsImpl::RenderWidgetGotFocus( |
| 1729 RenderWidgetHostImpl* render_widget_host) { | 1726 RenderWidgetHostImpl* render_widget_host) { |
| 1730 // Notify the observers if an embedded fullscreen widget was focused. | 1727 // Notify the observers if an embedded fullscreen widget was focused. |
| 1731 if (delegate_ && render_widget_host && delegate_->EmbedsFullscreenWidget() && | 1728 if (delegate_ && render_widget_host && delegate_->EmbedsFullscreenWidget() && |
| 1732 render_widget_host->GetView() == GetFullscreenRenderWidgetHostView()) { | 1729 render_widget_host->GetView() == GetFullscreenRenderWidgetHostView()) { |
| 1733 NotifyWebContentsFocused(); | 1730 NotifyWebContentsFocused(); |
| 1734 } | 1731 } |
| 1735 } | 1732 } |
| 1736 | 1733 |
| 1737 void WebContentsImpl::RenderWidgetWasResized( | 1734 void WebContentsImpl::RenderWidgetWasResized( |
| 1738 RenderWidgetHostImpl* render_widget_host, | 1735 RenderWidgetHostImpl* render_widget_host, |
| 1739 bool width_changed) { | 1736 bool width_changed) { |
| 1740 RenderFrameHostImpl* rfh = GetMainFrame(); | 1737 RenderFrameHostImpl* rfh = GetMainFrame(); |
| 1741 if (!rfh || render_widget_host != rfh->GetRenderWidgetHost()) | 1738 if (!rfh || render_widget_host != rfh->GetRenderWidgetHost()) |
| 1742 return; | 1739 return; |
| 1743 | 1740 |
| 1744 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1741 for (auto& observer : observers_) |
| 1745 MainFrameWasResized(width_changed)); | 1742 observer.MainFrameWasResized(width_changed); |
| 1746 } | 1743 } |
| 1747 | 1744 |
| 1748 void WebContentsImpl::ScreenInfoChanged() { | 1745 void WebContentsImpl::ScreenInfoChanged() { |
| 1749 if (browser_plugin_embedder_) | 1746 if (browser_plugin_embedder_) |
| 1750 browser_plugin_embedder_->ScreenInfoChanged(); | 1747 browser_plugin_embedder_->ScreenInfoChanged(); |
| 1751 } | 1748 } |
| 1752 | 1749 |
| 1753 bool WebContentsImpl::PreHandleKeyboardEvent( | 1750 bool WebContentsImpl::PreHandleKeyboardEvent( |
| 1754 const NativeWebKeyboardEvent& event, | 1751 const NativeWebKeyboardEvent& event, |
| 1755 bool* is_keyboard_shortcut) { | 1752 bool* is_keyboard_shortcut) { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 // Make sure any existing fullscreen widget is shut down first. | 1843 // Make sure any existing fullscreen widget is shut down first. |
| 1847 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1844 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1848 if (widget_view) { | 1845 if (widget_view) { |
| 1849 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) | 1846 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) |
| 1850 ->ShutdownAndDestroyWidget(true); | 1847 ->ShutdownAndDestroyWidget(true); |
| 1851 } | 1848 } |
| 1852 | 1849 |
| 1853 if (delegate_) | 1850 if (delegate_) |
| 1854 delegate_->EnterFullscreenModeForTab(this, origin); | 1851 delegate_->EnterFullscreenModeForTab(this, origin); |
| 1855 | 1852 |
| 1856 FOR_EACH_OBSERVER( | 1853 for (auto& observer : observers_) |
| 1857 WebContentsObserver, observers_, | 1854 observer.DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), false); |
| 1858 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), false)); | |
| 1859 } | 1855 } |
| 1860 | 1856 |
| 1861 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { | 1857 void WebContentsImpl::ExitFullscreenMode(bool will_cause_resize) { |
| 1862 // This method is being called to leave renderer-initiated fullscreen mode. | 1858 // This method is being called to leave renderer-initiated fullscreen mode. |
| 1863 // Make sure any existing fullscreen widget is shut down first. | 1859 // Make sure any existing fullscreen widget is shut down first. |
| 1864 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); | 1860 RenderWidgetHostView* const widget_view = GetFullscreenRenderWidgetHostView(); |
| 1865 if (widget_view) { | 1861 if (widget_view) { |
| 1866 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) | 1862 RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost()) |
| 1867 ->ShutdownAndDestroyWidget(true); | 1863 ->ShutdownAndDestroyWidget(true); |
| 1868 } | 1864 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1884 // entering "tab fullscreen". Exiting the contents "tab fullscreen" then won't | 1880 // entering "tab fullscreen". Exiting the contents "tab fullscreen" then won't |
| 1885 // have the side effect of the view resizing, hence the explicit call here is | 1881 // have the side effect of the view resizing, hence the explicit call here is |
| 1886 // required. | 1882 // required. |
| 1887 if (!will_cause_resize) { | 1883 if (!will_cause_resize) { |
| 1888 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { | 1884 if (RenderWidgetHostView* rwhv = GetRenderWidgetHostView()) { |
| 1889 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) | 1885 if (RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost()) |
| 1890 render_widget_host->WasResized(); | 1886 render_widget_host->WasResized(); |
| 1891 } | 1887 } |
| 1892 } | 1888 } |
| 1893 | 1889 |
| 1894 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 1890 for (auto& observer : observers_) { |
| 1895 DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), | 1891 observer.DidToggleFullscreenModeForTab(IsFullscreenForCurrentTab(), |
| 1896 will_cause_resize)); | 1892 will_cause_resize); |
| 1893 } |
| 1897 } | 1894 } |
| 1898 | 1895 |
| 1899 bool WebContentsImpl::IsFullscreenForCurrentTab() const { | 1896 bool WebContentsImpl::IsFullscreenForCurrentTab() const { |
| 1900 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; | 1897 return delegate_ ? delegate_->IsFullscreenForTabOrPending(this) : false; |
| 1901 } | 1898 } |
| 1902 | 1899 |
| 1903 blink::WebDisplayMode WebContentsImpl::GetDisplayMode( | 1900 blink::WebDisplayMode WebContentsImpl::GetDisplayMode( |
| 1904 RenderWidgetHostImpl* render_widget_host) const { | 1901 RenderWidgetHostImpl* render_widget_host) const { |
| 1905 if (!RenderViewHostImpl::From(render_widget_host)) | 1902 if (!RenderViewHostImpl::From(render_widget_host)) |
| 1906 return blink::WebDisplayModeBrowser; | 1903 return blink::WebDisplayModeBrowser; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2237 view_->StoreFocus(); | 2234 view_->StoreFocus(); |
| 2238 fullscreen_widget_process_id_ = | 2235 fullscreen_widget_process_id_ = |
| 2239 widget_host_view->GetRenderWidgetHost()->GetProcess()->GetID(); | 2236 widget_host_view->GetRenderWidgetHost()->GetProcess()->GetID(); |
| 2240 fullscreen_widget_routing_id_ = route_id; | 2237 fullscreen_widget_routing_id_ = route_id; |
| 2241 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { | 2238 if (delegate_ && delegate_->EmbedsFullscreenWidget()) { |
| 2242 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); | 2239 widget_host_view->InitAsChild(GetRenderWidgetHostView()->GetNativeView()); |
| 2243 delegate_->EnterFullscreenModeForTab(this, GURL()); | 2240 delegate_->EnterFullscreenModeForTab(this, GURL()); |
| 2244 } else { | 2241 } else { |
| 2245 widget_host_view->InitAsFullscreen(view); | 2242 widget_host_view->InitAsFullscreen(view); |
| 2246 } | 2243 } |
| 2247 FOR_EACH_OBSERVER(WebContentsObserver, | 2244 for (auto& observer : observers_) |
| 2248 observers_, | 2245 observer.DidShowFullscreenWidget(); |
| 2249 DidShowFullscreenWidget()); | |
| 2250 if (!widget_host_view->HasFocus()) | 2246 if (!widget_host_view->HasFocus()) |
| 2251 widget_host_view->Focus(); | 2247 widget_host_view->Focus(); |
| 2252 } else { | 2248 } else { |
| 2253 widget_host_view->InitAsPopup(view, initial_rect); | 2249 widget_host_view->InitAsPopup(view, initial_rect); |
| 2254 } | 2250 } |
| 2255 | 2251 |
| 2256 RenderWidgetHostImpl* render_widget_host_impl = | 2252 RenderWidgetHostImpl* render_widget_host_impl = |
| 2257 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost()); | 2253 RenderWidgetHostImpl::From(widget_host_view->GetRenderWidgetHost()); |
| 2258 render_widget_host_impl->Init(); | 2254 render_widget_host_impl->Init(); |
| 2259 // Only allow privileged mouse lock for fullscreen render widget, which is | 2255 // Only allow privileged mouse lock for fullscreen render widget, which is |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2360 bool WebContentsImpl::IsJavaScriptDialogShowing() const { | 2356 bool WebContentsImpl::IsJavaScriptDialogShowing() const { |
| 2361 return is_showing_javascript_dialog_; | 2357 return is_showing_javascript_dialog_; |
| 2362 } | 2358 } |
| 2363 | 2359 |
| 2364 AccessibilityMode WebContentsImpl::GetAccessibilityMode() const { | 2360 AccessibilityMode WebContentsImpl::GetAccessibilityMode() const { |
| 2365 return accessibility_mode_; | 2361 return accessibility_mode_; |
| 2366 } | 2362 } |
| 2367 | 2363 |
| 2368 void WebContentsImpl::AccessibilityEventReceived( | 2364 void WebContentsImpl::AccessibilityEventReceived( |
| 2369 const std::vector<AXEventNotificationDetails>& details) { | 2365 const std::vector<AXEventNotificationDetails>& details) { |
| 2370 FOR_EACH_OBSERVER( | 2366 for (auto& observer : observers_) |
| 2371 WebContentsObserver, observers_, AccessibilityEventReceived(details)); | 2367 observer.AccessibilityEventReceived(details); |
| 2372 } | 2368 } |
| 2373 | 2369 |
| 2374 void WebContentsImpl::AccessibilityLocationChangesReceived( | 2370 void WebContentsImpl::AccessibilityLocationChangesReceived( |
| 2375 const std::vector<AXLocationChangeNotificationDetails>& details) { | 2371 const std::vector<AXLocationChangeNotificationDetails>& details) { |
| 2376 FOR_EACH_OBSERVER(WebContentsObserver, | 2372 for (auto& observer : observers_) |
| 2377 observers_, | 2373 observer.AccessibilityLocationChangesReceived(details); |
| 2378 AccessibilityLocationChangesReceived(details)); | |
| 2379 } | 2374 } |
| 2380 | 2375 |
| 2381 RenderFrameHost* WebContentsImpl::GetGuestByInstanceID( | 2376 RenderFrameHost* WebContentsImpl::GetGuestByInstanceID( |
| 2382 RenderFrameHost* render_frame_host, | 2377 RenderFrameHost* render_frame_host, |
| 2383 int browser_plugin_instance_id) { | 2378 int browser_plugin_instance_id) { |
| 2384 BrowserPluginGuestManager* guest_manager = | 2379 BrowserPluginGuestManager* guest_manager = |
| 2385 GetBrowserContext()->GetGuestManager(); | 2380 GetBrowserContext()->GetGuestManager(); |
| 2386 if (!guest_manager) | 2381 if (!guest_manager) |
| 2387 return nullptr; | 2382 return nullptr; |
| 2388 | 2383 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2435 SendPageMessage(new PageMsg_UpdateWindowScreenRect( | 2430 SendPageMessage(new PageMsg_UpdateWindowScreenRect( |
| 2436 MSG_ROUTING_NONE, rwhv->GetBoundsInRootWindow())); | 2431 MSG_ROUTING_NONE, rwhv->GetBoundsInRootWindow())); |
| 2437 } | 2432 } |
| 2438 | 2433 |
| 2439 if (browser_plugin_embedder_) | 2434 if (browser_plugin_embedder_) |
| 2440 browser_plugin_embedder_->DidSendScreenRects(); | 2435 browser_plugin_embedder_->DidSendScreenRects(); |
| 2441 } | 2436 } |
| 2442 | 2437 |
| 2443 void WebContentsImpl::OnFirstPaintAfterLoad( | 2438 void WebContentsImpl::OnFirstPaintAfterLoad( |
| 2444 RenderWidgetHostImpl* render_widget_host) { | 2439 RenderWidgetHostImpl* render_widget_host) { |
| 2445 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2440 for (auto& observer : observers_) |
| 2446 DidFirstPaintAfterLoad(render_widget_host)); | 2441 observer.DidFirstPaintAfterLoad(render_widget_host); |
| 2447 } | 2442 } |
| 2448 | 2443 |
| 2449 TextInputManager* WebContentsImpl::GetTextInputManager() { | 2444 TextInputManager* WebContentsImpl::GetTextInputManager() { |
| 2450 if (GetOuterWebContents()) | 2445 if (GetOuterWebContents()) |
| 2451 return GetOuterWebContents()->GetTextInputManager(); | 2446 return GetOuterWebContents()->GetTextInputManager(); |
| 2452 | 2447 |
| 2453 if (!text_input_manager_) | 2448 if (!text_input_manager_) |
| 2454 text_input_manager_.reset(new TextInputManager()); | 2449 text_input_manager_.reset(new TextInputManager()); |
| 2455 | 2450 |
| 2456 return text_input_manager_.get(); | 2451 return text_input_manager_.get(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 if (!GetRenderViewHost()) { | 2520 if (!GetRenderViewHost()) { |
| 2526 delete message; | 2521 delete message; |
| 2527 return false; | 2522 return false; |
| 2528 } | 2523 } |
| 2529 | 2524 |
| 2530 return GetRenderViewHost()->Send(message); | 2525 return GetRenderViewHost()->Send(message); |
| 2531 } | 2526 } |
| 2532 | 2527 |
| 2533 void WebContentsImpl::RenderFrameForInterstitialPageCreated( | 2528 void WebContentsImpl::RenderFrameForInterstitialPageCreated( |
| 2534 RenderFrameHost* render_frame_host) { | 2529 RenderFrameHost* render_frame_host) { |
| 2535 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2530 for (auto& observer : observers_) |
| 2536 RenderFrameForInterstitialPageCreated(render_frame_host)); | 2531 observer.RenderFrameForInterstitialPageCreated(render_frame_host); |
| 2537 } | 2532 } |
| 2538 | 2533 |
| 2539 void WebContentsImpl::AttachInterstitialPage( | 2534 void WebContentsImpl::AttachInterstitialPage( |
| 2540 InterstitialPageImpl* interstitial_page) { | 2535 InterstitialPageImpl* interstitial_page) { |
| 2541 DCHECK(interstitial_page); | 2536 DCHECK(interstitial_page); |
| 2542 GetRenderManager()->set_interstitial_page(interstitial_page); | 2537 GetRenderManager()->set_interstitial_page(interstitial_page); |
| 2543 | 2538 |
| 2544 // Cancel any visible dialogs so that they don't interfere with the | 2539 // Cancel any visible dialogs so that they don't interfere with the |
| 2545 // interstitial. | 2540 // interstitial. |
| 2546 CancelActiveAndPendingDialogs(); | 2541 CancelActiveAndPendingDialogs(); |
| 2547 | 2542 |
| 2548 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2543 for (auto& observer : observers_) |
| 2549 DidAttachInterstitialPage()); | 2544 observer.DidAttachInterstitialPage(); |
| 2550 | 2545 |
| 2551 // Stop the throbber if needed while the interstitial page is shown. | 2546 // Stop the throbber if needed while the interstitial page is shown. |
| 2552 if (frame_tree_.IsLoading()) | 2547 if (frame_tree_.IsLoading()) |
| 2553 LoadingStateChanged(true, true, nullptr); | 2548 LoadingStateChanged(true, true, nullptr); |
| 2554 } | 2549 } |
| 2555 | 2550 |
| 2556 void WebContentsImpl::DidProceedOnInterstitial() { | 2551 void WebContentsImpl::DidProceedOnInterstitial() { |
| 2557 // The interstitial page should no longer be pausing the throbber. | 2552 // The interstitial page should no longer be pausing the throbber. |
| 2558 DCHECK(!(ShowingInterstitialPage() && | 2553 DCHECK(!(ShowingInterstitialPage() && |
| 2559 GetRenderManager()->interstitial_page()->pause_throbber())); | 2554 GetRenderManager()->interstitial_page()->pause_throbber())); |
| 2560 | 2555 |
| 2561 // Restart the throbber now that the interstitial page no longer pauses it. | 2556 // Restart the throbber now that the interstitial page no longer pauses it. |
| 2562 if (ShowingInterstitialPage() && frame_tree_.IsLoading()) | 2557 if (ShowingInterstitialPage() && frame_tree_.IsLoading()) |
| 2563 LoadingStateChanged(true, true, nullptr); | 2558 LoadingStateChanged(true, true, nullptr); |
| 2564 } | 2559 } |
| 2565 | 2560 |
| 2566 void WebContentsImpl::DetachInterstitialPage() { | 2561 void WebContentsImpl::DetachInterstitialPage() { |
| 2567 bool interstitial_pausing_throbber = | 2562 bool interstitial_pausing_throbber = |
| 2568 ShowingInterstitialPage() && | 2563 ShowingInterstitialPage() && |
| 2569 GetRenderManager()->interstitial_page()->pause_throbber(); | 2564 GetRenderManager()->interstitial_page()->pause_throbber(); |
| 2570 if (ShowingInterstitialPage()) | 2565 if (ShowingInterstitialPage()) |
| 2571 GetRenderManager()->remove_interstitial_page(); | 2566 GetRenderManager()->remove_interstitial_page(); |
| 2572 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2567 for (auto& observer : observers_) |
| 2573 DidDetachInterstitialPage()); | 2568 observer.DidDetachInterstitialPage(); |
| 2574 | 2569 |
| 2575 // Restart the throbber if needed now that the interstitial page is going | 2570 // Restart the throbber if needed now that the interstitial page is going |
| 2576 // away. | 2571 // away. |
| 2577 if (interstitial_pausing_throbber && frame_tree_.IsLoading()) | 2572 if (interstitial_pausing_throbber && frame_tree_.IsLoading()) |
| 2578 LoadingStateChanged(true, true, nullptr); | 2573 LoadingStateChanged(true, true, nullptr); |
| 2579 } | 2574 } |
| 2580 | 2575 |
| 2581 void WebContentsImpl::SetHistoryOffsetAndLength(int history_offset, | 2576 void WebContentsImpl::SetHistoryOffsetAndLength(int history_offset, |
| 2582 int history_length) { | 2577 int history_length) { |
| 2583 SendPageMessage(new PageMsg_SetHistoryOffsetAndLength( | 2578 SendPageMessage(new PageMsg_SetHistoryOffsetAndLength( |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2951 NotifyNavigationStateChanged(static_cast<InvalidateTypes>( | 2946 NotifyNavigationStateChanged(static_cast<InvalidateTypes>( |
| 2952 INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB)); | 2947 INVALIDATE_TYPE_LOAD | INVALIDATE_TYPE_TAB)); |
| 2953 } | 2948 } |
| 2954 } | 2949 } |
| 2955 | 2950 |
| 2956 void WebContentsImpl::DidGetResourceResponseStart( | 2951 void WebContentsImpl::DidGetResourceResponseStart( |
| 2957 const ResourceRequestDetails& details) { | 2952 const ResourceRequestDetails& details) { |
| 2958 controller_.ssl_manager()->DidStartResourceResponse( | 2953 controller_.ssl_manager()->DidStartResourceResponse( |
| 2959 details.url, details.has_certificate, details.ssl_cert_status); | 2954 details.url, details.has_certificate, details.ssl_cert_status); |
| 2960 | 2955 |
| 2961 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 2956 for (auto& observer : observers_) |
| 2962 DidGetResourceResponseStart(details)); | 2957 observer.DidGetResourceResponseStart(details); |
| 2963 } | 2958 } |
| 2964 | 2959 |
| 2965 void WebContentsImpl::DidGetRedirectForResourceRequest( | 2960 void WebContentsImpl::DidGetRedirectForResourceRequest( |
| 2966 const ResourceRedirectDetails& details) { | 2961 const ResourceRedirectDetails& details) { |
| 2967 FOR_EACH_OBSERVER( | 2962 for (auto& observer : observers_) |
| 2968 WebContentsObserver, | 2963 observer.DidGetRedirectForResourceRequest(details); |
| 2969 observers_, | |
| 2970 DidGetRedirectForResourceRequest(details)); | |
| 2971 | 2964 |
| 2972 // TODO(avi): Remove. http://crbug.com/170921 | 2965 // TODO(avi): Remove. http://crbug.com/170921 |
| 2973 NotificationService::current()->Notify( | 2966 NotificationService::current()->Notify( |
| 2974 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 2967 NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 2975 Source<WebContents>(this), | 2968 Source<WebContents>(this), |
| 2976 Details<const ResourceRedirectDetails>(&details)); | 2969 Details<const ResourceRedirectDetails>(&details)); |
| 2977 } | 2970 } |
| 2978 | 2971 |
| 2979 void WebContentsImpl::NotifyWebContentsFocused() { | 2972 void WebContentsImpl::NotifyWebContentsFocused() { |
| 2980 FOR_EACH_OBSERVER(WebContentsObserver, observers_, OnWebContentsFocused()); | 2973 for (auto& observer : observers_) |
| 2974 observer.OnWebContentsFocused(); |
| 2981 } | 2975 } |
| 2982 | 2976 |
| 2983 void WebContentsImpl::SystemDragEnded() { | 2977 void WebContentsImpl::SystemDragEnded() { |
| 2984 if (GetRenderViewHost()) | 2978 if (GetRenderViewHost()) |
| 2985 GetRenderViewHost()->DragSourceSystemDragEnded(); | 2979 GetRenderViewHost()->DragSourceSystemDragEnded(); |
| 2986 if (browser_plugin_embedder_.get()) | 2980 if (browser_plugin_embedder_.get()) |
| 2987 browser_plugin_embedder_->SystemDragEnded(); | 2981 browser_plugin_embedder_->SystemDragEnded(); |
| 2988 } | 2982 } |
| 2989 | 2983 |
| 2990 void WebContentsImpl::UserGestureDone() { | 2984 void WebContentsImpl::UserGestureDone() { |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3205 } | 3199 } |
| 3206 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); | 3200 return delegate_ && delegate_->ShouldFocusLocationBarByDefault(this); |
| 3207 } | 3201 } |
| 3208 | 3202 |
| 3209 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { | 3203 void WebContentsImpl::SetFocusToLocationBar(bool select_all) { |
| 3210 if (delegate_) | 3204 if (delegate_) |
| 3211 delegate_->SetFocusToLocationBar(select_all); | 3205 delegate_->SetFocusToLocationBar(select_all); |
| 3212 } | 3206 } |
| 3213 | 3207 |
| 3214 void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) { | 3208 void WebContentsImpl::DidStartNavigation(NavigationHandle* navigation_handle) { |
| 3215 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3209 for (auto& observer : observers_) |
| 3216 DidStartNavigation(navigation_handle)); | 3210 observer.DidStartNavigation(navigation_handle); |
| 3217 } | 3211 } |
| 3218 | 3212 |
| 3219 void WebContentsImpl::DidRedirectNavigation( | 3213 void WebContentsImpl::DidRedirectNavigation( |
| 3220 NavigationHandle* navigation_handle) { | 3214 NavigationHandle* navigation_handle) { |
| 3221 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3215 for (auto& observer : observers_) |
| 3222 DidRedirectNavigation(navigation_handle)); | 3216 observer.DidRedirectNavigation(navigation_handle); |
| 3223 } | 3217 } |
| 3224 | 3218 |
| 3225 void WebContentsImpl::ReadyToCommitNavigation( | 3219 void WebContentsImpl::ReadyToCommitNavigation( |
| 3226 NavigationHandle* navigation_handle) { | 3220 NavigationHandle* navigation_handle) { |
| 3227 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3221 for (auto& observer : observers_) |
| 3228 ReadyToCommitNavigation(navigation_handle)); | 3222 observer.ReadyToCommitNavigation(navigation_handle); |
| 3229 } | 3223 } |
| 3230 | 3224 |
| 3231 void WebContentsImpl::DidFinishNavigation(NavigationHandle* navigation_handle) { | 3225 void WebContentsImpl::DidFinishNavigation(NavigationHandle* navigation_handle) { |
| 3232 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3226 for (auto& observer : observers_) |
| 3233 DidFinishNavigation(navigation_handle)); | 3227 observer.DidFinishNavigation(navigation_handle); |
| 3234 } | 3228 } |
| 3235 | 3229 |
| 3236 void WebContentsImpl::DidStartProvisionalLoad( | 3230 void WebContentsImpl::DidStartProvisionalLoad( |
| 3237 RenderFrameHostImpl* render_frame_host, | 3231 RenderFrameHostImpl* render_frame_host, |
| 3238 const GURL& validated_url, | 3232 const GURL& validated_url, |
| 3239 bool is_error_page, | 3233 bool is_error_page, |
| 3240 bool is_iframe_srcdoc) { | 3234 bool is_iframe_srcdoc) { |
| 3241 // Notify observers about the start of the provisional load. | 3235 // Notify observers about the start of the provisional load. |
| 3242 FOR_EACH_OBSERVER( | 3236 for (auto& observer : observers_) { |
| 3243 WebContentsObserver, | 3237 observer.DidStartProvisionalLoadForFrame(render_frame_host, validated_url, |
| 3244 observers_, | 3238 is_error_page, is_iframe_srcdoc); |
| 3245 DidStartProvisionalLoadForFrame( | 3239 } |
| 3246 render_frame_host, validated_url, is_error_page, is_iframe_srcdoc)); | |
| 3247 | 3240 |
| 3248 // Notify accessibility if this is a reload. | 3241 // Notify accessibility if this is a reload. |
| 3249 NavigationEntry* entry = controller_.GetVisibleEntry(); | 3242 NavigationEntry* entry = controller_.GetVisibleEntry(); |
| 3250 if (entry && ui::PageTransitionCoreTypeIs( | 3243 if (entry && ui::PageTransitionCoreTypeIs( |
| 3251 entry->GetTransitionType(), ui::PAGE_TRANSITION_RELOAD)) { | 3244 entry->GetTransitionType(), ui::PAGE_TRANSITION_RELOAD)) { |
| 3252 FrameTreeNode* ftn = render_frame_host->frame_tree_node(); | 3245 FrameTreeNode* ftn = render_frame_host->frame_tree_node(); |
| 3253 BrowserAccessibilityManager* manager = | 3246 BrowserAccessibilityManager* manager = |
| 3254 ftn->current_frame_host()->browser_accessibility_manager(); | 3247 ftn->current_frame_host()->browser_accessibility_manager(); |
| 3255 if (manager) | 3248 if (manager) |
| 3256 manager->UserIsReloading(); | 3249 manager->UserIsReloading(); |
| 3257 } | 3250 } |
| 3258 } | 3251 } |
| 3259 | 3252 |
| 3260 void WebContentsImpl::DidFailProvisionalLoadWithError( | 3253 void WebContentsImpl::DidFailProvisionalLoadWithError( |
| 3261 RenderFrameHostImpl* render_frame_host, | 3254 RenderFrameHostImpl* render_frame_host, |
| 3262 const GURL& validated_url, | 3255 const GURL& validated_url, |
| 3263 int error_code, | 3256 int error_code, |
| 3264 const base::string16& error_description, | 3257 const base::string16& error_description, |
| 3265 bool was_ignored_by_handler) { | 3258 bool was_ignored_by_handler) { |
| 3266 FOR_EACH_OBSERVER( | 3259 for (auto& observer : observers_) { |
| 3267 WebContentsObserver, observers_, | 3260 observer.DidFailProvisionalLoad(render_frame_host, validated_url, |
| 3268 DidFailProvisionalLoad(render_frame_host, validated_url, error_code, | 3261 error_code, error_description, |
| 3269 error_description, was_ignored_by_handler)); | 3262 was_ignored_by_handler); |
| 3263 } |
| 3270 | 3264 |
| 3271 FrameTreeNode* ftn = render_frame_host->frame_tree_node(); | 3265 FrameTreeNode* ftn = render_frame_host->frame_tree_node(); |
| 3272 BrowserAccessibilityManager* manager = | 3266 BrowserAccessibilityManager* manager = |
| 3273 ftn->current_frame_host()->browser_accessibility_manager(); | 3267 ftn->current_frame_host()->browser_accessibility_manager(); |
| 3274 if (manager) | 3268 if (manager) |
| 3275 manager->NavigationFailed(); | 3269 manager->NavigationFailed(); |
| 3276 } | 3270 } |
| 3277 | 3271 |
| 3278 void WebContentsImpl::DidFailLoadWithError( | 3272 void WebContentsImpl::DidFailLoadWithError( |
| 3279 RenderFrameHostImpl* render_frame_host, | 3273 RenderFrameHostImpl* render_frame_host, |
| 3280 const GURL& url, | 3274 const GURL& url, |
| 3281 int error_code, | 3275 int error_code, |
| 3282 const base::string16& error_description, | 3276 const base::string16& error_description, |
| 3283 bool was_ignored_by_handler) { | 3277 bool was_ignored_by_handler) { |
| 3284 FOR_EACH_OBSERVER( | 3278 for (auto& observer : observers_) { |
| 3285 WebContentsObserver, | 3279 observer.DidFailLoad(render_frame_host, url, error_code, error_description, |
| 3286 observers_, | 3280 was_ignored_by_handler); |
| 3287 DidFailLoad(render_frame_host, url, error_code, error_description, | 3281 } |
| 3288 was_ignored_by_handler)); | |
| 3289 } | 3282 } |
| 3290 | 3283 |
| 3291 void WebContentsImpl::NotifyChangedNavigationState( | 3284 void WebContentsImpl::NotifyChangedNavigationState( |
| 3292 InvalidateTypes changed_flags) { | 3285 InvalidateTypes changed_flags) { |
| 3293 NotifyNavigationStateChanged(changed_flags); | 3286 NotifyNavigationStateChanged(changed_flags); |
| 3294 } | 3287 } |
| 3295 | 3288 |
| 3296 void WebContentsImpl::DidStartNavigationToPendingEntry(const GURL& url, | 3289 void WebContentsImpl::DidStartNavigationToPendingEntry(const GURL& url, |
| 3297 ReloadType reload_type) { | 3290 ReloadType reload_type) { |
| 3298 // Notify observers about navigation. | 3291 // Notify observers about navigation. |
| 3299 FOR_EACH_OBSERVER( | 3292 for (auto& observer : observers_) |
| 3300 WebContentsObserver, | 3293 observer.DidStartNavigationToPendingEntry(url, reload_type); |
| 3301 observers_, | |
| 3302 DidStartNavigationToPendingEntry(url, reload_type)); | |
| 3303 } | 3294 } |
| 3304 | 3295 |
| 3305 void WebContentsImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host, | 3296 void WebContentsImpl::RequestOpenURL(RenderFrameHostImpl* render_frame_host, |
| 3306 const OpenURLParams& params) { | 3297 const OpenURLParams& params) { |
| 3307 // OpenURL can blow away the source RFH. Use the process/frame routing ID as a | 3298 // OpenURL can blow away the source RFH. Use the process/frame routing ID as a |
| 3308 // weak pointer of sorts. | 3299 // weak pointer of sorts. |
| 3309 const int32_t process_id = render_frame_host->GetProcess()->GetID(); | 3300 const int32_t process_id = render_frame_host->GetProcess()->GetID(); |
| 3310 const int32_t frame_id = render_frame_host->GetRoutingID(); | 3301 const int32_t frame_id = render_frame_host->GetRoutingID(); |
| 3311 | 3302 |
| 3312 WebContents* new_contents = OpenURL(params); | 3303 WebContents* new_contents = OpenURL(params); |
| 3313 | 3304 |
| 3314 if (new_contents && RenderFrameHost::FromID(process_id, frame_id)) { | 3305 if (new_contents && RenderFrameHost::FromID(process_id, frame_id)) { |
| 3315 // Notify observers. | 3306 // Notify observers. |
| 3316 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3307 for (auto& observer : observers_) { |
| 3317 DidOpenRequestedURL(new_contents, | 3308 observer.DidOpenRequestedURL(new_contents, render_frame_host, params.url, |
| 3318 render_frame_host, | 3309 params.referrer, params.disposition, |
| 3319 params.url, | 3310 params.transition); |
| 3320 params.referrer, | 3311 } |
| 3321 params.disposition, | |
| 3322 params.transition)); | |
| 3323 } | 3312 } |
| 3324 } | 3313 } |
| 3325 | 3314 |
| 3326 bool WebContentsImpl::ShouldTransferNavigation(bool is_main_frame_navigation) { | 3315 bool WebContentsImpl::ShouldTransferNavigation(bool is_main_frame_navigation) { |
| 3327 if (!delegate_) | 3316 if (!delegate_) |
| 3328 return true; | 3317 return true; |
| 3329 return delegate_->ShouldTransferNavigation(is_main_frame_navigation); | 3318 return delegate_->ShouldTransferNavigation(is_main_frame_navigation); |
| 3330 } | 3319 } |
| 3331 | 3320 |
| 3332 bool WebContentsImpl::ShouldPreserveAbortedURLs() { | 3321 bool WebContentsImpl::ShouldPreserveAbortedURLs() { |
| 3333 if (!delegate_) | 3322 if (!delegate_) |
| 3334 return false; | 3323 return false; |
| 3335 return delegate_->ShouldPreserveAbortedURLs(this); | 3324 return delegate_->ShouldPreserveAbortedURLs(this); |
| 3336 } | 3325 } |
| 3337 | 3326 |
| 3338 void WebContentsImpl::DidCommitProvisionalLoad( | 3327 void WebContentsImpl::DidCommitProvisionalLoad( |
| 3339 RenderFrameHostImpl* render_frame_host, | 3328 RenderFrameHostImpl* render_frame_host, |
| 3340 const GURL& url, | 3329 const GURL& url, |
| 3341 ui::PageTransition transition_type) { | 3330 ui::PageTransition transition_type) { |
| 3342 // Notify observers about the commit of the provisional load. | 3331 // Notify observers about the commit of the provisional load. |
| 3343 FOR_EACH_OBSERVER(WebContentsObserver, | 3332 for (auto& observer : observers_) { |
| 3344 observers_, | 3333 observer.DidCommitProvisionalLoadForFrame(render_frame_host, url, |
| 3345 DidCommitProvisionalLoadForFrame( | 3334 transition_type); |
| 3346 render_frame_host, url, transition_type)); | 3335 } |
| 3347 | 3336 |
| 3348 BrowserAccessibilityManager* manager = | 3337 BrowserAccessibilityManager* manager = |
| 3349 render_frame_host->browser_accessibility_manager(); | 3338 render_frame_host->browser_accessibility_manager(); |
| 3350 if (manager) | 3339 if (manager) |
| 3351 manager->NavigationSucceeded(); | 3340 manager->NavigationSucceeded(); |
| 3352 } | 3341 } |
| 3353 | 3342 |
| 3354 void WebContentsImpl::DidNavigateMainFramePreCommit( | 3343 void WebContentsImpl::DidNavigateMainFramePreCommit( |
| 3355 bool navigation_is_within_page) { | 3344 bool navigation_is_within_page) { |
| 3356 // Ensure fullscreen mode is exited before committing the navigation to a | 3345 // Ensure fullscreen mode is exited before committing the navigation to a |
| (...skipping 26 matching lines...) Expand all Loading... |
| 3383 if (rwhvb) | 3372 if (rwhvb) |
| 3384 rwhvb->OnDidNavigateMainFrameToNewPage(); | 3373 rwhvb->OnDidNavigateMainFrameToNewPage(); |
| 3385 | 3374 |
| 3386 did_first_visually_non_empty_paint_ = false; | 3375 did_first_visually_non_empty_paint_ = false; |
| 3387 | 3376 |
| 3388 // Reset theme color on navigation to new page. | 3377 // Reset theme color on navigation to new page. |
| 3389 theme_color_ = SK_ColorTRANSPARENT; | 3378 theme_color_ = SK_ColorTRANSPARENT; |
| 3390 } | 3379 } |
| 3391 | 3380 |
| 3392 // Notify observers about navigation. | 3381 // Notify observers about navigation. |
| 3393 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3382 for (auto& observer : observers_) |
| 3394 DidNavigateMainFrame(details, params)); | 3383 observer.DidNavigateMainFrame(details, params); |
| 3395 | 3384 |
| 3396 if (delegate_) | 3385 if (delegate_) |
| 3397 delegate_->DidNavigateMainFramePostCommit(this); | 3386 delegate_->DidNavigateMainFramePostCommit(this); |
| 3398 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 3387 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 3399 } | 3388 } |
| 3400 | 3389 |
| 3401 void WebContentsImpl::DidNavigateAnyFramePostCommit( | 3390 void WebContentsImpl::DidNavigateAnyFramePostCommit( |
| 3402 RenderFrameHostImpl* render_frame_host, | 3391 RenderFrameHostImpl* render_frame_host, |
| 3403 const LoadCommittedDetails& details, | 3392 const LoadCommittedDetails& details, |
| 3404 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { | 3393 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) { |
| 3405 // Now that something has committed, we don't need to track whether the | 3394 // Now that something has committed, we don't need to track whether the |
| 3406 // initial page has been accessed. | 3395 // initial page has been accessed. |
| 3407 has_accessed_initial_document_ = false; | 3396 has_accessed_initial_document_ = false; |
| 3408 | 3397 |
| 3409 // If we navigate off the page, close all JavaScript dialogs. | 3398 // If we navigate off the page, close all JavaScript dialogs. |
| 3410 if (!details.is_in_page) | 3399 if (!details.is_in_page) |
| 3411 CancelActiveAndPendingDialogs(); | 3400 CancelActiveAndPendingDialogs(); |
| 3412 | 3401 |
| 3413 // If this is a user-initiated navigation, start allowing JavaScript dialogs | 3402 // If this is a user-initiated navigation, start allowing JavaScript dialogs |
| 3414 // again. | 3403 // again. |
| 3415 if (params.gesture == NavigationGestureUser && dialog_manager_) { | 3404 if (params.gesture == NavigationGestureUser && dialog_manager_) { |
| 3416 dialog_manager_->CancelDialogs(this, | 3405 dialog_manager_->CancelDialogs(this, |
| 3417 false, // suppress_callbacks, | 3406 false, // suppress_callbacks, |
| 3418 true); // reset_state | 3407 true); // reset_state |
| 3419 } | 3408 } |
| 3420 | 3409 |
| 3421 // Notify observers about navigation. | 3410 // Notify observers about navigation. |
| 3422 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3411 for (auto& observer : observers_) |
| 3423 DidNavigateAnyFrame(render_frame_host, details, params)); | 3412 observer.DidNavigateAnyFrame(render_frame_host, details, params); |
| 3424 } | 3413 } |
| 3425 | 3414 |
| 3426 void WebContentsImpl::SetMainFrameMimeType(const std::string& mime_type) { | 3415 void WebContentsImpl::SetMainFrameMimeType(const std::string& mime_type) { |
| 3427 contents_mime_type_ = mime_type; | 3416 contents_mime_type_ = mime_type; |
| 3428 } | 3417 } |
| 3429 | 3418 |
| 3430 bool WebContentsImpl::CanOverscrollContent() const { | 3419 bool WebContentsImpl::CanOverscrollContent() const { |
| 3431 // Disable overscroll when touch emulation is on. See crbug.com/369938. | 3420 // Disable overscroll when touch emulation is on. See crbug.com/369938. |
| 3432 if (force_disable_overscroll_content_) | 3421 if (force_disable_overscroll_content_) |
| 3433 return false; | 3422 return false; |
| 3434 | 3423 |
| 3435 if (delegate_) | 3424 if (delegate_) |
| 3436 return delegate_->CanOverscrollContent(); | 3425 return delegate_->CanOverscrollContent(); |
| 3437 | 3426 |
| 3438 return false; | 3427 return false; |
| 3439 } | 3428 } |
| 3440 | 3429 |
| 3441 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { | 3430 void WebContentsImpl::OnThemeColorChanged(SkColor theme_color) { |
| 3442 // Update the theme color. This is to be published to observers after the | 3431 // Update the theme color. This is to be published to observers after the |
| 3443 // first visually non-empty paint. | 3432 // first visually non-empty paint. |
| 3444 theme_color_ = theme_color; | 3433 theme_color_ = theme_color; |
| 3445 | 3434 |
| 3446 if (did_first_visually_non_empty_paint_ && | 3435 if (did_first_visually_non_empty_paint_ && |
| 3447 last_sent_theme_color_ != theme_color_) { | 3436 last_sent_theme_color_ != theme_color_) { |
| 3448 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3437 for (auto& observer : observers_) |
| 3449 DidChangeThemeColor(theme_color_)); | 3438 observer.DidChangeThemeColor(theme_color_); |
| 3450 last_sent_theme_color_ = theme_color_; | 3439 last_sent_theme_color_ = theme_color_; |
| 3451 } | 3440 } |
| 3452 } | 3441 } |
| 3453 | 3442 |
| 3454 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( | 3443 void WebContentsImpl::OnDidLoadResourceFromMemoryCache( |
| 3455 const GURL& url, | 3444 const GURL& url, |
| 3456 const std::string& http_method, | 3445 const std::string& http_method, |
| 3457 const std::string& mime_type, | 3446 const std::string& mime_type, |
| 3458 ResourceType resource_type) { | 3447 ResourceType resource_type) { |
| 3459 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3448 for (auto& observer : observers_) |
| 3460 DidLoadResourceFromMemoryCache(url, mime_type, | 3449 observer.DidLoadResourceFromMemoryCache(url, mime_type, resource_type); |
| 3461 resource_type)); | |
| 3462 | 3450 |
| 3463 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { | 3451 if (url.is_valid() && url.SchemeIsHTTPOrHTTPS()) { |
| 3464 scoped_refptr<net::URLRequestContextGetter> request_context( | 3452 scoped_refptr<net::URLRequestContextGetter> request_context( |
| 3465 resource_type == RESOURCE_TYPE_MEDIA ? | 3453 resource_type == RESOURCE_TYPE_MEDIA ? |
| 3466 GetRenderProcessHost()->GetStoragePartition()-> | 3454 GetRenderProcessHost()->GetStoragePartition()-> |
| 3467 GetMediaURLRequestContext() : | 3455 GetMediaURLRequestContext() : |
| 3468 GetRenderProcessHost()->GetStoragePartition()-> | 3456 GetRenderProcessHost()->GetStoragePartition()-> |
| 3469 GetURLRequestContext()); | 3457 GetURLRequestContext()); |
| 3470 BrowserThread::PostTask( | 3458 BrowserThread::PostTask( |
| 3471 BrowserThread::IO, | 3459 BrowserThread::IO, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3506 controller_.ssl_manager()->DidRunContentWithCertErrors( | 3494 controller_.ssl_manager()->DidRunContentWithCertErrors( |
| 3507 entry->GetURL().GetOrigin()); | 3495 entry->GetURL().GetOrigin()); |
| 3508 } | 3496 } |
| 3509 | 3497 |
| 3510 void WebContentsImpl::OnDocumentLoadedInFrame() { | 3498 void WebContentsImpl::OnDocumentLoadedInFrame() { |
| 3511 if (!HasValidFrameSource()) | 3499 if (!HasValidFrameSource()) |
| 3512 return; | 3500 return; |
| 3513 | 3501 |
| 3514 RenderFrameHostImpl* rfh = | 3502 RenderFrameHostImpl* rfh = |
| 3515 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 3503 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 3516 FOR_EACH_OBSERVER( | 3504 for (auto& observer : observers_) |
| 3517 WebContentsObserver, observers_, DocumentLoadedInFrame(rfh)); | 3505 observer.DocumentLoadedInFrame(rfh); |
| 3518 } | 3506 } |
| 3519 | 3507 |
| 3520 void WebContentsImpl::OnDidFinishLoad(const GURL& url) { | 3508 void WebContentsImpl::OnDidFinishLoad(const GURL& url) { |
| 3521 if (!HasValidFrameSource()) | 3509 if (!HasValidFrameSource()) |
| 3522 return; | 3510 return; |
| 3523 | 3511 |
| 3524 GURL validated_url(url); | 3512 GURL validated_url(url); |
| 3525 RenderProcessHost* render_process_host = | 3513 RenderProcessHost* render_process_host = |
| 3526 render_frame_message_source_->GetProcess(); | 3514 render_frame_message_source_->GetProcess(); |
| 3527 render_process_host->FilterURL(false, &validated_url); | 3515 render_process_host->FilterURL(false, &validated_url); |
| 3528 | 3516 |
| 3529 RenderFrameHostImpl* rfh = | 3517 RenderFrameHostImpl* rfh = |
| 3530 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); | 3518 static_cast<RenderFrameHostImpl*>(render_frame_message_source_); |
| 3531 FOR_EACH_OBSERVER( | 3519 for (auto& observer : observers_) |
| 3532 WebContentsObserver, observers_, DidFinishLoad(rfh, validated_url)); | 3520 observer.DidFinishLoad(rfh, validated_url); |
| 3533 } | 3521 } |
| 3534 | 3522 |
| 3535 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { | 3523 void WebContentsImpl::OnGoToEntryAtOffset(int offset) { |
| 3536 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) | 3524 if (!delegate_ || delegate_->OnGoToEntryOffset(offset)) |
| 3537 controller_.GoToOffset(offset); | 3525 controller_.GoToOffset(offset); |
| 3538 } | 3526 } |
| 3539 | 3527 |
| 3540 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, | 3528 void WebContentsImpl::OnUpdateZoomLimits(int minimum_percent, |
| 3541 int maximum_percent) { | 3529 int maximum_percent) { |
| 3542 minimum_zoom_percent_ = minimum_percent; | 3530 minimum_zoom_percent_ = minimum_percent; |
| 3543 maximum_zoom_percent_ = maximum_percent; | 3531 maximum_zoom_percent_ = maximum_percent; |
| 3544 } | 3532 } |
| 3545 | 3533 |
| 3546 void WebContentsImpl::OnPageScaleFactorChanged(float page_scale_factor) { | 3534 void WebContentsImpl::OnPageScaleFactorChanged(float page_scale_factor) { |
| 3547 bool is_one = page_scale_factor == 1.f; | 3535 bool is_one = page_scale_factor == 1.f; |
| 3548 if (is_one != page_scale_factor_is_one_) { | 3536 if (is_one != page_scale_factor_is_one_) { |
| 3549 page_scale_factor_is_one_ = is_one; | 3537 page_scale_factor_is_one_ = is_one; |
| 3550 | 3538 |
| 3551 HostZoomMapImpl* host_zoom_map = | 3539 HostZoomMapImpl* host_zoom_map = |
| 3552 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); | 3540 static_cast<HostZoomMapImpl*>(HostZoomMap::GetForWebContents(this)); |
| 3553 | 3541 |
| 3554 if (host_zoom_map && GetRenderProcessHost()) { | 3542 if (host_zoom_map && GetRenderProcessHost()) { |
| 3555 host_zoom_map->SetPageScaleFactorIsOneForView( | 3543 host_zoom_map->SetPageScaleFactorIsOneForView( |
| 3556 GetRenderProcessHost()->GetID(), GetRoutingID(), | 3544 GetRenderProcessHost()->GetID(), GetRoutingID(), |
| 3557 page_scale_factor_is_one_); | 3545 page_scale_factor_is_one_); |
| 3558 } | 3546 } |
| 3559 } | 3547 } |
| 3560 | 3548 |
| 3561 FOR_EACH_OBSERVER(WebContentsObserver, | 3549 for (auto& observer : observers_) |
| 3562 observers_, | 3550 observer.OnPageScaleFactorChanged(page_scale_factor); |
| 3563 OnPageScaleFactorChanged(page_scale_factor)); | |
| 3564 } | 3551 } |
| 3565 | 3552 |
| 3566 void WebContentsImpl::OnEnumerateDirectory(int request_id, | 3553 void WebContentsImpl::OnEnumerateDirectory(int request_id, |
| 3567 const base::FilePath& path) { | 3554 const base::FilePath& path) { |
| 3568 if (!delegate_) | 3555 if (!delegate_) |
| 3569 return; | 3556 return; |
| 3570 | 3557 |
| 3571 ChildProcessSecurityPolicyImpl* policy = | 3558 ChildProcessSecurityPolicyImpl* policy = |
| 3572 ChildProcessSecurityPolicyImpl::GetInstance(); | 3559 ChildProcessSecurityPolicyImpl::GetInstance(); |
| 3573 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) | 3560 if (policy->CanReadFile(GetRenderProcessHost()->GetID(), path)) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string) { | 3641 void WebContentsImpl::OnDomOperationResponse(const std::string& json_string) { |
| 3655 std::string json = json_string; | 3642 std::string json = json_string; |
| 3656 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, | 3643 NotificationService::current()->Notify(NOTIFICATION_DOM_OPERATION_RESPONSE, |
| 3657 Source<WebContents>(this), | 3644 Source<WebContents>(this), |
| 3658 Details<std::string>(&json)); | 3645 Details<std::string>(&json)); |
| 3659 } | 3646 } |
| 3660 | 3647 |
| 3661 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, | 3648 void WebContentsImpl::OnAppCacheAccessed(const GURL& manifest_url, |
| 3662 bool blocked_by_policy) { | 3649 bool blocked_by_policy) { |
| 3663 // Notify observers about navigation. | 3650 // Notify observers about navigation. |
| 3664 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3651 for (auto& observer : observers_) |
| 3665 AppCacheAccessed(manifest_url, blocked_by_policy)); | 3652 observer.AppCacheAccessed(manifest_url, blocked_by_policy); |
| 3666 } | 3653 } |
| 3667 | 3654 |
| 3668 void WebContentsImpl::OnOpenColorChooser( | 3655 void WebContentsImpl::OnOpenColorChooser( |
| 3669 int color_chooser_id, | 3656 int color_chooser_id, |
| 3670 SkColor color, | 3657 SkColor color, |
| 3671 const std::vector<ColorSuggestion>& suggestions) { | 3658 const std::vector<ColorSuggestion>& suggestions) { |
| 3672 if (!HasValidFrameSource()) | 3659 if (!HasValidFrameSource()) |
| 3673 return; | 3660 return; |
| 3674 | 3661 |
| 3675 ColorChooser* new_color_chooser = delegate_ ? | 3662 ColorChooser* new_color_chooser = delegate_ ? |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3704 // bindings enabled. | 3691 // bindings enabled. |
| 3705 void WebContentsImpl::OnWebUISend(const GURL& source_url, | 3692 void WebContentsImpl::OnWebUISend(const GURL& source_url, |
| 3706 const std::string& name, | 3693 const std::string& name, |
| 3707 const base::ListValue& args) { | 3694 const base::ListValue& args) { |
| 3708 if (delegate_) | 3695 if (delegate_) |
| 3709 delegate_->WebUISend(this, source_url, name, args); | 3696 delegate_->WebUISend(this, source_url, name, args); |
| 3710 } | 3697 } |
| 3711 | 3698 |
| 3712 #if defined(ENABLE_PLUGINS) | 3699 #if defined(ENABLE_PLUGINS) |
| 3713 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) { | 3700 void WebContentsImpl::OnPepperInstanceCreated(int32_t pp_instance) { |
| 3714 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3701 for (auto& observer : observers_) |
| 3715 PepperInstanceCreated()); | 3702 observer.PepperInstanceCreated(); |
| 3716 pepper_playback_observer_->PepperInstanceCreated(pp_instance); | 3703 pepper_playback_observer_->PepperInstanceCreated(pp_instance); |
| 3717 } | 3704 } |
| 3718 | 3705 |
| 3719 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) { | 3706 void WebContentsImpl::OnPepperInstanceDeleted(int32_t pp_instance) { |
| 3720 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3707 for (auto& observer : observers_) |
| 3721 PepperInstanceDeleted()); | 3708 observer.PepperInstanceDeleted(); |
| 3722 pepper_playback_observer_->PepperInstanceDeleted(pp_instance); | 3709 pepper_playback_observer_->PepperInstanceDeleted(pp_instance); |
| 3723 } | 3710 } |
| 3724 | 3711 |
| 3725 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, | 3712 void WebContentsImpl::OnPepperPluginHung(int plugin_child_id, |
| 3726 const base::FilePath& path, | 3713 const base::FilePath& path, |
| 3727 bool is_hung) { | 3714 bool is_hung) { |
| 3728 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); | 3715 UMA_HISTOGRAM_COUNTS("Pepper.PluginHung", 1); |
| 3729 | 3716 |
| 3730 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3717 for (auto& observer : observers_) |
| 3731 PluginHungStatusChanged(plugin_child_id, path, is_hung)); | 3718 observer.PluginHungStatusChanged(plugin_child_id, path, is_hung); |
| 3732 } | 3719 } |
| 3733 | 3720 |
| 3734 void WebContentsImpl::OnPepperStartsPlayback(int32_t pp_instance) { | 3721 void WebContentsImpl::OnPepperStartsPlayback(int32_t pp_instance) { |
| 3735 pepper_playback_observer_->PepperStartsPlayback(pp_instance); | 3722 pepper_playback_observer_->PepperStartsPlayback(pp_instance); |
| 3736 } | 3723 } |
| 3737 | 3724 |
| 3738 void WebContentsImpl::OnPepperStopsPlayback(int32_t pp_instance) { | 3725 void WebContentsImpl::OnPepperStopsPlayback(int32_t pp_instance) { |
| 3739 pepper_playback_observer_->PepperStopsPlayback(pp_instance); | 3726 pepper_playback_observer_->PepperStopsPlayback(pp_instance); |
| 3740 } | 3727 } |
| 3741 | 3728 |
| 3742 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, | 3729 void WebContentsImpl::OnPluginCrashed(const base::FilePath& plugin_path, |
| 3743 base::ProcessId plugin_pid) { | 3730 base::ProcessId plugin_pid) { |
| 3744 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3731 for (auto& observer : observers_) |
| 3745 PluginCrashed(plugin_path, plugin_pid)); | 3732 observer.PluginCrashed(plugin_path, plugin_pid); |
| 3746 } | 3733 } |
| 3747 | 3734 |
| 3748 void WebContentsImpl::OnRequestPpapiBrokerPermission( | 3735 void WebContentsImpl::OnRequestPpapiBrokerPermission( |
| 3749 int routing_id, | 3736 int routing_id, |
| 3750 const GURL& url, | 3737 const GURL& url, |
| 3751 const base::FilePath& plugin_path) { | 3738 const base::FilePath& plugin_path) { |
| 3752 if (!delegate_) { | 3739 if (!delegate_) { |
| 3753 OnPpapiBrokerPermissionResult(routing_id, false); | 3740 OnPpapiBrokerPermissionResult(routing_id, false); |
| 3754 return; | 3741 return; |
| 3755 } | 3742 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3780 const std::vector<FaviconURL>& candidates) { | 3767 const std::vector<FaviconURL>& candidates) { |
| 3781 // We get updated favicon URLs after the page stops loading. If a cross-site | 3768 // We get updated favicon URLs after the page stops loading. If a cross-site |
| 3782 // navigation occurs while a page is still loading, the initial page | 3769 // navigation occurs while a page is still loading, the initial page |
| 3783 // may stop loading and send us updated favicon URLs after the navigation | 3770 // may stop loading and send us updated favicon URLs after the navigation |
| 3784 // for the new page has committed. | 3771 // for the new page has committed. |
| 3785 RenderViewHostImpl* rvhi = | 3772 RenderViewHostImpl* rvhi = |
| 3786 static_cast<RenderViewHostImpl*>(render_view_message_source_); | 3773 static_cast<RenderViewHostImpl*>(render_view_message_source_); |
| 3787 if (!rvhi->is_active()) | 3774 if (!rvhi->is_active()) |
| 3788 return; | 3775 return; |
| 3789 | 3776 |
| 3790 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3777 for (auto& observer : observers_) |
| 3791 DidUpdateFaviconURL(candidates)); | 3778 observer.DidUpdateFaviconURL(candidates); |
| 3792 } | 3779 } |
| 3793 | 3780 |
| 3794 void WebContentsImpl::OnMediaSessionStateChanged() { | 3781 void WebContentsImpl::OnMediaSessionStateChanged() { |
| 3795 MediaSession* session = MediaSession::Get(this); | 3782 MediaSession* session = MediaSession::Get(this); |
| 3796 for (auto& observer : observers_) { | 3783 for (auto& observer : observers_) { |
| 3797 observer.MediaSessionStateChanged(session->IsControllable(), | 3784 observer.MediaSessionStateChanged(session->IsControllable(), |
| 3798 session->IsSuspended()); | 3785 session->IsSuspended()); |
| 3799 } | 3786 } |
| 3800 } | 3787 } |
| 3801 | 3788 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3820 | 3807 |
| 3821 void WebContentsImpl::OnPasswordInputShownOnHttp() { | 3808 void WebContentsImpl::OnPasswordInputShownOnHttp() { |
| 3822 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); | 3809 controller_.ssl_manager()->DidShowPasswordInputOnHttp(); |
| 3823 } | 3810 } |
| 3824 | 3811 |
| 3825 void WebContentsImpl::OnCreditCardInputShownOnHttp() { | 3812 void WebContentsImpl::OnCreditCardInputShownOnHttp() { |
| 3826 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); | 3813 controller_.ssl_manager()->DidShowCreditCardInputOnHttp(); |
| 3827 } | 3814 } |
| 3828 | 3815 |
| 3829 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { | 3816 void WebContentsImpl::OnFirstVisuallyNonEmptyPaint() { |
| 3830 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3817 for (auto& observer : observers_) |
| 3831 DidFirstVisuallyNonEmptyPaint()); | 3818 observer.DidFirstVisuallyNonEmptyPaint(); |
| 3832 | 3819 |
| 3833 did_first_visually_non_empty_paint_ = true; | 3820 did_first_visually_non_empty_paint_ = true; |
| 3834 | 3821 |
| 3835 if (theme_color_ != last_sent_theme_color_) { | 3822 if (theme_color_ != last_sent_theme_color_) { |
| 3836 // Theme color should have updated by now if there was one. | 3823 // Theme color should have updated by now if there was one. |
| 3837 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3824 for (auto& observer : observers_) |
| 3838 DidChangeThemeColor(theme_color_)); | 3825 observer.DidChangeThemeColor(theme_color_); |
| 3839 last_sent_theme_color_ = theme_color_; | 3826 last_sent_theme_color_ = theme_color_; |
| 3840 } | 3827 } |
| 3841 } | 3828 } |
| 3842 | 3829 |
| 3843 void WebContentsImpl::DidChangeVisibleSSLState() { | 3830 void WebContentsImpl::DidChangeVisibleSSLState() { |
| 3844 if (delegate_) { | 3831 if (delegate_) { |
| 3845 delegate_->VisibleSSLStateChanged(this); | 3832 delegate_->VisibleSSLStateChanged(this); |
| 3846 | 3833 |
| 3847 SecurityStyleExplanations security_style_explanations; | 3834 SecurityStyleExplanations security_style_explanations; |
| 3848 blink::WebSecurityStyle security_style = | 3835 blink::WebSecurityStyle security_style = |
| 3849 delegate_->GetSecurityStyle(this, &security_style_explanations); | 3836 delegate_->GetSecurityStyle(this, &security_style_explanations); |
| 3850 FOR_EACH_OBSERVER( | 3837 for (auto& observer : observers_) { |
| 3851 WebContentsObserver, observers_, | 3838 observer.SecurityStyleChanged(security_style, |
| 3852 SecurityStyleChanged(security_style, security_style_explanations)); | 3839 security_style_explanations); |
| 3840 } |
| 3853 } | 3841 } |
| 3854 } | 3842 } |
| 3855 | 3843 |
| 3856 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { | 3844 void WebContentsImpl::NotifyBeforeFormRepostWarningShow() { |
| 3857 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3845 for (auto& observer : observers_) |
| 3858 BeforeFormRepostWarningShow()); | 3846 observer.BeforeFormRepostWarningShow(); |
| 3859 } | 3847 } |
| 3860 | 3848 |
| 3861 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { | 3849 void WebContentsImpl::ActivateAndShowRepostFormWarningDialog() { |
| 3862 Activate(); | 3850 Activate(); |
| 3863 if (delegate_) | 3851 if (delegate_) |
| 3864 delegate_->ShowRepostFormWarningDialog(this); | 3852 delegate_->ShowRepostFormWarningDialog(this); |
| 3865 } | 3853 } |
| 3866 | 3854 |
| 3867 bool WebContentsImpl::HasAccessedInitialDocument() { | 3855 bool WebContentsImpl::HasAccessedInitialDocument() { |
| 3868 return has_accessed_initial_document_; | 3856 return has_accessed_initial_document_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 3894 } else { | 3882 } else { |
| 3895 if (page_title_when_no_navigation_entry_ == final_title) | 3883 if (page_title_when_no_navigation_entry_ == final_title) |
| 3896 return; // Nothing changed, don't bother. | 3884 return; // Nothing changed, don't bother. |
| 3897 | 3885 |
| 3898 page_title_when_no_navigation_entry_ = final_title; | 3886 page_title_when_no_navigation_entry_ = final_title; |
| 3899 } | 3887 } |
| 3900 | 3888 |
| 3901 // Lastly, set the title for the view. | 3889 // Lastly, set the title for the view. |
| 3902 view_->SetPageTitle(final_title); | 3890 view_->SetPageTitle(final_title); |
| 3903 | 3891 |
| 3904 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3892 for (auto& observer : observers_) |
| 3905 TitleWasSet(entry, explicit_set)); | 3893 observer.TitleWasSet(entry, explicit_set); |
| 3906 | 3894 |
| 3907 // Broadcast notifications when the UI should be updated. | 3895 // Broadcast notifications when the UI should be updated. |
| 3908 if (entry == controller_.GetEntryAtOffset(0)) | 3896 if (entry == controller_.GetEntryAtOffset(0)) |
| 3909 NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); | 3897 NotifyNavigationStateChanged(INVALIDATE_TYPE_TITLE); |
| 3910 } | 3898 } |
| 3911 | 3899 |
| 3912 void WebContentsImpl::SendChangeLoadProgress() { | 3900 void WebContentsImpl::SendChangeLoadProgress() { |
| 3913 loading_last_progress_update_ = base::TimeTicks::Now(); | 3901 loading_last_progress_update_ = base::TimeTicks::Now(); |
| 3914 if (delegate_) | 3902 if (delegate_) |
| 3915 delegate_->LoadProgressChanged(this, frame_tree_.load_progress()); | 3903 delegate_->LoadProgressChanged(this, frame_tree_.load_progress()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3951 | 3939 |
| 3952 if (delegate_) | 3940 if (delegate_) |
| 3953 delegate_->LoadingStateChanged(this, to_different_document); | 3941 delegate_->LoadingStateChanged(this, to_different_document); |
| 3954 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); | 3942 NotifyNavigationStateChanged(INVALIDATE_TYPE_LOAD); |
| 3955 | 3943 |
| 3956 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); | 3944 std::string url = (details ? details->url.possibly_invalid_spec() : "NULL"); |
| 3957 if (is_loading) { | 3945 if (is_loading) { |
| 3958 TRACE_EVENT_ASYNC_BEGIN2("browser,navigation", "WebContentsImpl Loading", | 3946 TRACE_EVENT_ASYNC_BEGIN2("browser,navigation", "WebContentsImpl Loading", |
| 3959 this, "URL", url, "Main FrameTreeNode id", | 3947 this, "URL", url, "Main FrameTreeNode id", |
| 3960 GetFrameTree()->root()->frame_tree_node_id()); | 3948 GetFrameTree()->root()->frame_tree_node_id()); |
| 3961 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStartLoading()); | 3949 for (auto& observer : observers_) |
| 3950 observer.DidStartLoading(); |
| 3962 } else { | 3951 } else { |
| 3963 TRACE_EVENT_ASYNC_END1("browser,navigation", "WebContentsImpl Loading", | 3952 TRACE_EVENT_ASYNC_END1("browser,navigation", "WebContentsImpl Loading", |
| 3964 this, "URL", url); | 3953 this, "URL", url); |
| 3965 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidStopLoading()); | 3954 for (auto& observer : observers_) |
| 3955 observer.DidStopLoading(); |
| 3966 } | 3956 } |
| 3967 | 3957 |
| 3968 // TODO(avi): Remove. http://crbug.com/170921 | 3958 // TODO(avi): Remove. http://crbug.com/170921 |
| 3969 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP; | 3959 int type = is_loading ? NOTIFICATION_LOAD_START : NOTIFICATION_LOAD_STOP; |
| 3970 NotificationDetails det = NotificationService::NoDetails(); | 3960 NotificationDetails det = NotificationService::NoDetails(); |
| 3971 if (details) | 3961 if (details) |
| 3972 det = Details<LoadNotificationDetails>(details); | 3962 det = Details<LoadNotificationDetails>(details); |
| 3973 NotificationService::current()->Notify( | 3963 NotificationService::current()->Notify( |
| 3974 type, Source<NavigationController>(&controller_), det); | 3964 type, Source<NavigationController>(&controller_), det); |
| 3975 } | 3965 } |
| 3976 | 3966 |
| 3977 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, | 3967 void WebContentsImpl::NotifyViewSwapped(RenderViewHost* old_host, |
| 3978 RenderViewHost* new_host) { | 3968 RenderViewHost* new_host) { |
| 3979 // After sending out a swap notification, we need to send a disconnect | 3969 // After sending out a swap notification, we need to send a disconnect |
| 3980 // notification so that clients that pick up a pointer to |this| can NULL the | 3970 // notification so that clients that pick up a pointer to |this| can NULL the |
| 3981 // pointer. See Bug 1230284. | 3971 // pointer. See Bug 1230284. |
| 3982 notify_disconnection_ = true; | 3972 notify_disconnection_ = true; |
| 3983 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3973 for (auto& observer : observers_) |
| 3984 RenderViewHostChanged(old_host, new_host)); | 3974 observer.RenderViewHostChanged(old_host, new_host); |
| 3985 | 3975 |
| 3986 // Ensure that the associated embedder gets cleared after a RenderViewHost | 3976 // Ensure that the associated embedder gets cleared after a RenderViewHost |
| 3987 // gets swapped, so we don't reuse the same embedder next time a | 3977 // gets swapped, so we don't reuse the same embedder next time a |
| 3988 // RenderViewHost is attached to this WebContents. | 3978 // RenderViewHost is attached to this WebContents. |
| 3989 RemoveBrowserPluginEmbedder(); | 3979 RemoveBrowserPluginEmbedder(); |
| 3990 } | 3980 } |
| 3991 | 3981 |
| 3992 void WebContentsImpl::NotifyFrameSwapped(RenderFrameHost* old_host, | 3982 void WebContentsImpl::NotifyFrameSwapped(RenderFrameHost* old_host, |
| 3993 RenderFrameHost* new_host) { | 3983 RenderFrameHost* new_host) { |
| 3994 FOR_EACH_OBSERVER(WebContentsObserver, | 3984 for (auto& observer : observers_) |
| 3995 observers_, | 3985 observer.RenderFrameHostChanged(old_host, new_host); |
| 3996 RenderFrameHostChanged(old_host, new_host)); | |
| 3997 } | 3986 } |
| 3998 | 3987 |
| 3999 // TODO(avi): Remove this entire function because this notification is already | 3988 // TODO(avi): Remove this entire function because this notification is already |
| 4000 // covered by two observer functions. http://crbug.com/170921 | 3989 // covered by two observer functions. http://crbug.com/170921 |
| 4001 void WebContentsImpl::NotifyDisconnected() { | 3990 void WebContentsImpl::NotifyDisconnected() { |
| 4002 if (!notify_disconnection_) | 3991 if (!notify_disconnection_) |
| 4003 return; | 3992 return; |
| 4004 | 3993 |
| 4005 notify_disconnection_ = false; | 3994 notify_disconnection_ = false; |
| 4006 NotificationService::current()->Notify( | 3995 NotificationService::current()->Notify( |
| 4007 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, | 3996 NOTIFICATION_WEB_CONTENTS_DISCONNECTED, |
| 4008 Source<WebContents>(this), | 3997 Source<WebContents>(this), |
| 4009 NotificationService::NoDetails()); | 3998 NotificationService::NoDetails()); |
| 4010 } | 3999 } |
| 4011 | 4000 |
| 4012 void WebContentsImpl::NotifyNavigationEntryCommitted( | 4001 void WebContentsImpl::NotifyNavigationEntryCommitted( |
| 4013 const LoadCommittedDetails& load_details) { | 4002 const LoadCommittedDetails& load_details) { |
| 4014 FOR_EACH_OBSERVER( | 4003 for (auto& observer : observers_) |
| 4015 WebContentsObserver, observers_, NavigationEntryCommitted(load_details)); | 4004 observer.NavigationEntryCommitted(load_details); |
| 4016 } | 4005 } |
| 4017 | 4006 |
| 4018 bool WebContentsImpl::OnMessageReceived(RenderFrameHost* render_frame_host, | 4007 bool WebContentsImpl::OnMessageReceived(RenderFrameHost* render_frame_host, |
| 4019 const IPC::Message& message) { | 4008 const IPC::Message& message) { |
| 4020 return OnMessageReceived(NULL, render_frame_host, message); | 4009 return OnMessageReceived(NULL, render_frame_host, message); |
| 4021 } | 4010 } |
| 4022 | 4011 |
| 4023 void WebContentsImpl::OnAssociatedInterfaceRequest( | 4012 void WebContentsImpl::OnAssociatedInterfaceRequest( |
| 4024 RenderFrameHost* render_frame_host, | 4013 RenderFrameHost* render_frame_host, |
| 4025 const std::string& interface_name, | 4014 const std::string& interface_name, |
| 4026 mojo::ScopedInterfaceEndpointHandle handle) { | 4015 mojo::ScopedInterfaceEndpointHandle handle) { |
| 4027 auto it = binding_sets_.find(interface_name); | 4016 auto it = binding_sets_.find(interface_name); |
| 4028 if (it != binding_sets_.end()) | 4017 if (it != binding_sets_.end()) |
| 4029 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); | 4018 it->second->OnRequestForFrame(render_frame_host, std::move(handle)); |
| 4030 } | 4019 } |
| 4031 | 4020 |
| 4032 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { | 4021 const GURL& WebContentsImpl::GetMainFrameLastCommittedURL() const { |
| 4033 return GetLastCommittedURL(); | 4022 return GetLastCommittedURL(); |
| 4034 } | 4023 } |
| 4035 | 4024 |
| 4036 void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) { | 4025 void WebContentsImpl::RenderFrameCreated(RenderFrameHost* render_frame_host) { |
| 4037 FOR_EACH_OBSERVER(WebContentsObserver, | 4026 for (auto& observer : observers_) |
| 4038 observers_, | 4027 observer.RenderFrameCreated(render_frame_host); |
| 4039 RenderFrameCreated(render_frame_host)); | |
| 4040 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host); | 4028 SetAccessibilityModeOnFrame(accessibility_mode_, render_frame_host); |
| 4041 | 4029 |
| 4042 if (!render_frame_host->IsRenderFrameLive() || render_frame_host->GetParent()) | 4030 if (!render_frame_host->IsRenderFrameLive() || render_frame_host->GetParent()) |
| 4043 return; | 4031 return; |
| 4044 | 4032 |
| 4045 NavigationEntry* entry = controller_.GetPendingEntry(); | 4033 NavigationEntry* entry = controller_.GetPendingEntry(); |
| 4046 if (entry && entry->IsViewSourceMode()) { | 4034 if (entry && entry->IsViewSourceMode()) { |
| 4047 // Put the renderer in view source mode. | 4035 // Put the renderer in view source mode. |
| 4048 render_frame_host->Send( | 4036 render_frame_host->Send( |
| 4049 new FrameMsg_EnableViewSourceMode(render_frame_host->GetRoutingID())); | 4037 new FrameMsg_EnableViewSourceMode(render_frame_host->GetRoutingID())); |
| 4050 } | 4038 } |
| 4051 #if defined(OS_ANDROID) | 4039 #if defined(OS_ANDROID) |
| 4052 render_frame_host->GetInterfaceRegistry()->AddInterface( | 4040 render_frame_host->GetInterfaceRegistry()->AddInterface( |
| 4053 GetJavaInterfaces()->CreateInterfaceFactory<device::nfc::mojom::NFC>()); | 4041 GetJavaInterfaces()->CreateInterfaceFactory<device::nfc::mojom::NFC>()); |
| 4054 #endif | 4042 #endif |
| 4055 } | 4043 } |
| 4056 | 4044 |
| 4057 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { | 4045 void WebContentsImpl::RenderFrameDeleted(RenderFrameHost* render_frame_host) { |
| 4058 FOR_EACH_OBSERVER(WebContentsObserver, | 4046 for (auto& observer : observers_) |
| 4059 observers_, | 4047 observer.RenderFrameDeleted(render_frame_host); |
| 4060 RenderFrameDeleted(render_frame_host)); | |
| 4061 } | 4048 } |
| 4062 | 4049 |
| 4063 void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host, | 4050 void WebContentsImpl::ShowContextMenu(RenderFrameHost* render_frame_host, |
| 4064 const ContextMenuParams& params) { | 4051 const ContextMenuParams& params) { |
| 4065 ContextMenuParams context_menu_params(params); | 4052 ContextMenuParams context_menu_params(params); |
| 4066 // Allow WebContentsDelegates to handle the context menu operation first. | 4053 // Allow WebContentsDelegates to handle the context menu operation first. |
| 4067 if (delegate_ && delegate_->HandleContextMenu(context_menu_params)) | 4054 if (delegate_ && delegate_->HandleContextMenu(context_menu_params)) |
| 4068 return; | 4055 return; |
| 4069 | 4056 |
| 4070 render_view_host_delegate_view_->ShowContextMenu(render_frame_host, | 4057 render_view_host_delegate_view_->ShowContextMenu(render_frame_host, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4220 if (delegate_) | 4207 if (delegate_) |
| 4221 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4208 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4222 | 4209 |
| 4223 NotificationService::current()->Notify( | 4210 NotificationService::current()->Notify( |
| 4224 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, | 4211 NOTIFICATION_WEB_CONTENTS_RENDER_VIEW_HOST_CREATED, |
| 4225 Source<WebContents>(this), | 4212 Source<WebContents>(this), |
| 4226 Details<RenderViewHost>(render_view_host)); | 4213 Details<RenderViewHost>(render_view_host)); |
| 4227 | 4214 |
| 4228 view_->RenderViewCreated(render_view_host); | 4215 view_->RenderViewCreated(render_view_host); |
| 4229 | 4216 |
| 4230 FOR_EACH_OBSERVER( | 4217 for (auto& observer : observers_) |
| 4231 WebContentsObserver, observers_, RenderViewCreated(render_view_host)); | 4218 observer.RenderViewCreated(render_view_host); |
| 4232 } | 4219 } |
| 4233 | 4220 |
| 4234 void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { | 4221 void WebContentsImpl::RenderViewReady(RenderViewHost* rvh) { |
| 4235 if (rvh != GetRenderViewHost()) { | 4222 if (rvh != GetRenderViewHost()) { |
| 4236 // Don't notify the world, since this came from a renderer in the | 4223 // Don't notify the world, since this came from a renderer in the |
| 4237 // background. | 4224 // background. |
| 4238 return; | 4225 return; |
| 4239 } | 4226 } |
| 4240 | 4227 |
| 4241 notify_disconnection_ = true; | 4228 notify_disconnection_ = true; |
| 4242 // TODO(avi): Remove. http://crbug.com/170921 | 4229 // TODO(avi): Remove. http://crbug.com/170921 |
| 4243 NotificationService::current()->Notify( | 4230 NotificationService::current()->Notify( |
| 4244 NOTIFICATION_WEB_CONTENTS_CONNECTED, | 4231 NOTIFICATION_WEB_CONTENTS_CONNECTED, |
| 4245 Source<WebContents>(this), | 4232 Source<WebContents>(this), |
| 4246 NotificationService::NoDetails()); | 4233 NotificationService::NoDetails()); |
| 4247 | 4234 |
| 4248 bool was_crashed = IsCrashed(); | 4235 bool was_crashed = IsCrashed(); |
| 4249 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); | 4236 SetIsCrashed(base::TERMINATION_STATUS_STILL_RUNNING, 0); |
| 4250 | 4237 |
| 4251 // Restore the focus to the tab (otherwise the focus will be on the top | 4238 // Restore the focus to the tab (otherwise the focus will be on the top |
| 4252 // window). | 4239 // window). |
| 4253 if (was_crashed && !FocusLocationBarByDefault() && | 4240 if (was_crashed && !FocusLocationBarByDefault() && |
| 4254 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { | 4241 (!delegate_ || delegate_->ShouldFocusPageAfterCrash())) { |
| 4255 view_->Focus(); | 4242 view_->Focus(); |
| 4256 } | 4243 } |
| 4257 | 4244 |
| 4258 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewReady()); | 4245 for (auto& observer : observers_) |
| 4246 observer.RenderViewReady(); |
| 4259 } | 4247 } |
| 4260 | 4248 |
| 4261 void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, | 4249 void WebContentsImpl::RenderViewTerminated(RenderViewHost* rvh, |
| 4262 base::TerminationStatus status, | 4250 base::TerminationStatus status, |
| 4263 int error_code) { | 4251 int error_code) { |
| 4264 if (rvh != GetRenderViewHost()) { | 4252 if (rvh != GetRenderViewHost()) { |
| 4265 // The pending page's RenderViewHost is gone. | 4253 // The pending page's RenderViewHost is gone. |
| 4266 return; | 4254 return; |
| 4267 } | 4255 } |
| 4268 | 4256 |
| 4269 // Ensure fullscreen mode is exited in the |delegate_| since a crashed | 4257 // Ensure fullscreen mode is exited in the |delegate_| since a crashed |
| 4270 // renderer may not have made a clean exit. | 4258 // renderer may not have made a clean exit. |
| 4271 if (IsFullscreenForCurrentTab()) | 4259 if (IsFullscreenForCurrentTab()) |
| 4272 ExitFullscreenMode(false); | 4260 ExitFullscreenMode(false); |
| 4273 | 4261 |
| 4274 // Cancel any visible dialogs so they are not left dangling over the sad tab. | 4262 // Cancel any visible dialogs so they are not left dangling over the sad tab. |
| 4275 CancelActiveAndPendingDialogs(); | 4263 CancelActiveAndPendingDialogs(); |
| 4276 | 4264 |
| 4277 if (delegate_) | 4265 if (delegate_) |
| 4278 delegate_->HideValidationMessage(this); | 4266 delegate_->HideValidationMessage(this); |
| 4279 | 4267 |
| 4280 // Reset the loading progress. TODO(avi): What does it mean to have a | 4268 // Reset the loading progress. TODO(avi): What does it mean to have a |
| 4281 // "renderer crash" when there is more than one renderer process serving a | 4269 // "renderer crash" when there is more than one renderer process serving a |
| 4282 // webpage? Once this function is called at a more granular frame level, we | 4270 // webpage? Once this function is called at a more granular frame level, we |
| 4283 // probably will need to more granularly reset the state here. | 4271 // probably will need to more granularly reset the state here. |
| 4284 ResetLoadProgressState(); | 4272 ResetLoadProgressState(); |
| 4285 NotifyDisconnected(); | 4273 NotifyDisconnected(); |
| 4286 SetIsCrashed(status, error_code); | 4274 SetIsCrashed(status, error_code); |
| 4287 | 4275 |
| 4288 FOR_EACH_OBSERVER(WebContentsObserver, | 4276 for (auto& observer : observers_) |
| 4289 observers_, | 4277 observer.RenderProcessGone(GetCrashedStatus()); |
| 4290 RenderProcessGone(GetCrashedStatus())); | |
| 4291 } | 4278 } |
| 4292 | 4279 |
| 4293 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 4280 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| 4294 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); | 4281 for (auto& observer : observers_) |
| 4282 observer.RenderViewDeleted(rvh); |
| 4295 } | 4283 } |
| 4296 | 4284 |
| 4297 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 4285 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
| 4298 const PageState& page_state) { | 4286 const PageState& page_state) { |
| 4299 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); | 4287 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 4300 | 4288 |
| 4301 // Ensure that this state update comes from a RenderViewHost that belongs to | 4289 // Ensure that this state update comes from a RenderViewHost that belongs to |
| 4302 // this WebContents. | 4290 // this WebContents. |
| 4303 // TODO(nasko): This should go through RenderFrameHost. | 4291 // TODO(nasko): This should go through RenderFrameHost. |
| 4304 if (rvh->GetDelegate()->GetAsWebContents() != this) | 4292 if (rvh->GetDelegate()->GetAsWebContents() != this) |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4458 // show up underneath it. | 4446 // show up underneath it. |
| 4459 if (!IsLoading() && controller_.GetPendingEntry()) | 4447 if (!IsLoading() && controller_.GetPendingEntry()) |
| 4460 controller_.DiscardPendingEntry(false); | 4448 controller_.DiscardPendingEntry(false); |
| 4461 | 4449 |
| 4462 // Update the URL display. | 4450 // Update the URL display. |
| 4463 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); | 4451 NotifyNavigationStateChanged(INVALIDATE_TYPE_URL); |
| 4464 } | 4452 } |
| 4465 | 4453 |
| 4466 void WebContentsImpl::DidChangeName(RenderFrameHost* render_frame_host, | 4454 void WebContentsImpl::DidChangeName(RenderFrameHost* render_frame_host, |
| 4467 const std::string& name) { | 4455 const std::string& name) { |
| 4468 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4456 for (auto& observer : observers_) |
| 4469 FrameNameChanged(render_frame_host, name)); | 4457 observer.FrameNameChanged(render_frame_host, name); |
| 4470 } | 4458 } |
| 4471 | 4459 |
| 4472 void WebContentsImpl::DocumentOnLoadCompleted( | 4460 void WebContentsImpl::DocumentOnLoadCompleted( |
| 4473 RenderFrameHost* render_frame_host) { | 4461 RenderFrameHost* render_frame_host) { |
| 4474 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4462 for (auto& observer : observers_) |
| 4475 DocumentOnLoadCompletedInMainFrame()); | 4463 observer.DocumentOnLoadCompletedInMainFrame(); |
| 4476 | 4464 |
| 4477 // TODO(avi): Remove. http://crbug.com/170921 | 4465 // TODO(avi): Remove. http://crbug.com/170921 |
| 4478 NotificationService::current()->Notify( | 4466 NotificationService::current()->Notify( |
| 4479 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 4467 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 4480 Source<WebContents>(this), | 4468 Source<WebContents>(this), |
| 4481 NotificationService::NoDetails()); | 4469 NotificationService::NoDetails()); |
| 4482 } | 4470 } |
| 4483 | 4471 |
| 4484 void WebContentsImpl::UpdateStateForFrame(RenderFrameHost* render_frame_host, | 4472 void WebContentsImpl::UpdateStateForFrame(RenderFrameHost* render_frame_host, |
| 4485 const PageState& page_state) { | 4473 const PageState& page_state) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4559 UpdateTitleForEntry(entry, title); | 4547 UpdateTitleForEntry(entry, title); |
| 4560 } | 4548 } |
| 4561 | 4549 |
| 4562 void WebContentsImpl::UpdateEncoding(RenderFrameHost* render_frame_host, | 4550 void WebContentsImpl::UpdateEncoding(RenderFrameHost* render_frame_host, |
| 4563 const std::string& encoding) { | 4551 const std::string& encoding) { |
| 4564 SetEncoding(encoding); | 4552 SetEncoding(encoding); |
| 4565 } | 4553 } |
| 4566 | 4554 |
| 4567 void WebContentsImpl::DocumentAvailableInMainFrame( | 4555 void WebContentsImpl::DocumentAvailableInMainFrame( |
| 4568 RenderViewHost* render_view_host) { | 4556 RenderViewHost* render_view_host) { |
| 4569 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4557 for (auto& observer : observers_) |
| 4570 DocumentAvailableInMainFrame()); | 4558 observer.DocumentAvailableInMainFrame(); |
| 4571 } | 4559 } |
| 4572 | 4560 |
| 4573 void WebContentsImpl::RouteCloseEvent(RenderViewHost* rvh) { | 4561 void WebContentsImpl::RouteCloseEvent(RenderViewHost* rvh) { |
| 4574 // Tell the active RenderViewHost to run unload handlers and close, as long | 4562 // Tell the active RenderViewHost to run unload handlers and close, as long |
| 4575 // as the request came from a RenderViewHost in the same BrowsingInstance. | 4563 // as the request came from a RenderViewHost in the same BrowsingInstance. |
| 4576 // In most cases, we receive this from a swapped out RenderViewHost. | 4564 // In most cases, we receive this from a swapped out RenderViewHost. |
| 4577 // It is possible to receive it from one that has just been swapped in, | 4565 // It is possible to receive it from one that has just been swapped in, |
| 4578 // in which case we might as well deliver the message anyway. | 4566 // in which case we might as well deliver the message anyway. |
| 4579 if (rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) | 4567 if (rvh->GetSiteInstance()->IsRelatedSiteInstance(GetSiteInstance())) |
| 4580 ClosePage(); | 4568 ClosePage(); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4655 source_id); | 4643 source_id); |
| 4656 } | 4644 } |
| 4657 | 4645 |
| 4658 void WebContentsImpl::OnUserInteraction( | 4646 void WebContentsImpl::OnUserInteraction( |
| 4659 RenderWidgetHostImpl* render_widget_host, | 4647 RenderWidgetHostImpl* render_widget_host, |
| 4660 const blink::WebInputEvent::Type type) { | 4648 const blink::WebInputEvent::Type type) { |
| 4661 // Ignore unless the widget is currently in the frame tree. | 4649 // Ignore unless the widget is currently in the frame tree. |
| 4662 if (!HasMatchingWidgetHost(&frame_tree_, render_widget_host)) | 4650 if (!HasMatchingWidgetHost(&frame_tree_, render_widget_host)) |
| 4663 return; | 4651 return; |
| 4664 | 4652 |
| 4665 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4653 for (auto& observer : observers_) |
| 4666 DidGetUserInteraction(type)); | 4654 observer.DidGetUserInteraction(type); |
| 4667 | 4655 |
| 4668 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 4656 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 4669 // Exclude scroll events as user gestures for resource load dispatches. | 4657 // Exclude scroll events as user gestures for resource load dispatches. |
| 4670 // rdh is NULL in unittests. | 4658 // rdh is NULL in unittests. |
| 4671 if (rdh && type != blink::WebInputEvent::MouseWheel) | 4659 if (rdh && type != blink::WebInputEvent::MouseWheel) |
| 4672 rdh->OnUserGesture(); | 4660 rdh->OnUserGesture(); |
| 4673 } | 4661 } |
| 4674 | 4662 |
| 4675 void WebContentsImpl::OnIgnoredUIEvent() { | 4663 void WebContentsImpl::OnIgnoredUIEvent() { |
| 4676 // Notify observers. | 4664 // Notify observers. |
| 4677 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetIgnoredUIEvent()); | 4665 for (auto& observer : observers_) |
| 4666 observer.DidGetIgnoredUIEvent(); |
| 4678 } | 4667 } |
| 4679 | 4668 |
| 4680 void WebContentsImpl::RendererUnresponsive( | 4669 void WebContentsImpl::RendererUnresponsive( |
| 4681 RenderWidgetHostImpl* render_widget_host, | 4670 RenderWidgetHostImpl* render_widget_host, |
| 4682 RendererUnresponsiveType type) { | 4671 RendererUnresponsiveType type) { |
| 4683 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4672 for (auto& observer : observers_) |
| 4684 OnRendererUnresponsive(render_widget_host)); | 4673 observer.OnRendererUnresponsive(render_widget_host); |
| 4685 | 4674 |
| 4686 // Don't show hung renderer dialog for a swapped out RVH. | 4675 // Don't show hung renderer dialog for a swapped out RVH. |
| 4687 if (render_widget_host != GetRenderViewHost()->GetWidget()) | 4676 if (render_widget_host != GetRenderViewHost()->GetWidget()) |
| 4688 return; | 4677 return; |
| 4689 | 4678 |
| 4690 RenderFrameHostImpl* rfhi = | 4679 RenderFrameHostImpl* rfhi = |
| 4691 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame()); | 4680 static_cast<RenderFrameHostImpl*>(GetRenderViewHost()->GetMainFrame()); |
| 4692 | 4681 |
| 4693 // Ignore renderer unresponsive event if debugger is attached to the tab | 4682 // Ignore renderer unresponsive event if debugger is attached to the tab |
| 4694 // since the event may be a result of the renderer sitting on a breakpoint. | 4683 // since the event may be a result of the renderer sitting on a breakpoint. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4746 if (render_widget_host != GetRenderViewHost()->GetWidget()) | 4735 if (render_widget_host != GetRenderViewHost()->GetWidget()) |
| 4747 return; | 4736 return; |
| 4748 | 4737 |
| 4749 if (delegate_) | 4738 if (delegate_) |
| 4750 delegate_->RendererResponsive(this); | 4739 delegate_->RendererResponsive(this); |
| 4751 } | 4740 } |
| 4752 | 4741 |
| 4753 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( | 4742 void WebContentsImpl::BeforeUnloadFiredFromRenderManager( |
| 4754 bool proceed, const base::TimeTicks& proceed_time, | 4743 bool proceed, const base::TimeTicks& proceed_time, |
| 4755 bool* proceed_to_fire_unload) { | 4744 bool* proceed_to_fire_unload) { |
| 4756 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4745 for (auto& observer : observers_) |
| 4757 BeforeUnloadFired(proceed_time)); | 4746 observer.BeforeUnloadFired(proceed_time); |
| 4758 if (delegate_) | 4747 if (delegate_) |
| 4759 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); | 4748 delegate_->BeforeUnloadFired(this, proceed, proceed_to_fire_unload); |
| 4760 // Note: |this| might be deleted at this point. | 4749 // Note: |this| might be deleted at this point. |
| 4761 } | 4750 } |
| 4762 | 4751 |
| 4763 void WebContentsImpl::RenderProcessGoneFromRenderManager( | 4752 void WebContentsImpl::RenderProcessGoneFromRenderManager( |
| 4764 RenderViewHost* render_view_host) { | 4753 RenderViewHost* render_view_host) { |
| 4765 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); | 4754 DCHECK(crashed_status_ != base::TERMINATION_STATUS_STILL_RUNNING); |
| 4766 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); | 4755 RenderViewTerminated(render_view_host, crashed_status_, crashed_error_code_); |
| 4767 } | 4756 } |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4975 last_dialog_suppressed_ = dialog_was_suppressed; | 4964 last_dialog_suppressed_ = dialog_was_suppressed; |
| 4976 | 4965 |
| 4977 if (is_showing_before_unload_dialog_ && !success) { | 4966 if (is_showing_before_unload_dialog_ && !success) { |
| 4978 // It is possible for the current RenderFrameHost to have changed in the | 4967 // It is possible for the current RenderFrameHost to have changed in the |
| 4979 // meantime. Do not reset the navigation state in that case. | 4968 // meantime. Do not reset the navigation state in that case. |
| 4980 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { | 4969 if (rfh && rfh == rfh->frame_tree_node()->current_frame_host()) { |
| 4981 rfh->frame_tree_node()->BeforeUnloadCanceled(); | 4970 rfh->frame_tree_node()->BeforeUnloadCanceled(); |
| 4982 controller_.DiscardNonCommittedEntries(); | 4971 controller_.DiscardNonCommittedEntries(); |
| 4983 } | 4972 } |
| 4984 | 4973 |
| 4985 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4974 for (auto& observer : observers_) |
| 4986 BeforeUnloadDialogCancelled()); | 4975 observer.BeforeUnloadDialogCancelled(); |
| 4987 } | 4976 } |
| 4988 | 4977 |
| 4989 is_showing_javascript_dialog_ = false; | 4978 is_showing_javascript_dialog_ = false; |
| 4990 is_showing_before_unload_dialog_ = false; | 4979 is_showing_before_unload_dialog_ = false; |
| 4991 if (rfh) { | 4980 if (rfh) { |
| 4992 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, | 4981 rfh->JavaScriptDialogClosed(reply_msg, success, user_input, |
| 4993 dialog_was_suppressed); | 4982 dialog_was_suppressed); |
| 4994 } else { | 4983 } else { |
| 4995 // Don't leak the sync IPC reply if the RFH or process is gone. | 4984 // Don't leak the sync IPC reply if the RFH or process is gone. |
| 4996 delete reply_msg; | 4985 delete reply_msg; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5044 gfx::Size WebContentsImpl::GetSizeForNewRenderView() { | 5033 gfx::Size WebContentsImpl::GetSizeForNewRenderView() { |
| 5045 gfx::Size size; | 5034 gfx::Size size; |
| 5046 if (delegate_) | 5035 if (delegate_) |
| 5047 size = delegate_->GetSizeForNewRenderView(this); | 5036 size = delegate_->GetSizeForNewRenderView(this); |
| 5048 if (size.IsEmpty()) | 5037 if (size.IsEmpty()) |
| 5049 size = GetContainerBounds().size(); | 5038 size = GetContainerBounds().size(); |
| 5050 return size; | 5039 return size; |
| 5051 } | 5040 } |
| 5052 | 5041 |
| 5053 void WebContentsImpl::OnFrameRemoved(RenderFrameHost* render_frame_host) { | 5042 void WebContentsImpl::OnFrameRemoved(RenderFrameHost* render_frame_host) { |
| 5054 FOR_EACH_OBSERVER( | 5043 for (auto& observer : observers_) |
| 5055 WebContentsObserver, observers_, FrameDeleted(render_frame_host)); | 5044 observer.FrameDeleted(render_frame_host); |
| 5056 } | 5045 } |
| 5057 | 5046 |
| 5058 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 5047 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 5059 if (!delegate_) | 5048 if (!delegate_) |
| 5060 return; | 5049 return; |
| 5061 const gfx::Size new_size = GetPreferredSize(); | 5050 const gfx::Size new_size = GetPreferredSize(); |
| 5062 if (new_size != old_size) | 5051 if (new_size != old_size) |
| 5063 delegate_->UpdatePreferredSize(this, new_size); | 5052 delegate_->UpdatePreferredSize(this, new_size); |
| 5064 } | 5053 } |
| 5065 | 5054 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5137 #endif | 5126 #endif |
| 5138 | 5127 |
| 5139 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 5128 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 5140 force_disable_overscroll_content_ = force_disable; | 5129 force_disable_overscroll_content_ = force_disable; |
| 5141 if (view_) | 5130 if (view_) |
| 5142 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 5131 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 5143 } | 5132 } |
| 5144 | 5133 |
| 5145 void WebContentsImpl::MediaStartedPlaying( | 5134 void WebContentsImpl::MediaStartedPlaying( |
| 5146 const WebContentsObserver::MediaPlayerId& id) { | 5135 const WebContentsObserver::MediaPlayerId& id) { |
| 5147 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStartedPlaying(id)); | 5136 for (auto& observer : observers_) |
| 5137 observer.MediaStartedPlaying(id); |
| 5148 } | 5138 } |
| 5149 | 5139 |
| 5150 void WebContentsImpl::MediaStoppedPlaying( | 5140 void WebContentsImpl::MediaStoppedPlaying( |
| 5151 const WebContentsObserver::MediaPlayerId& id) { | 5141 const WebContentsObserver::MediaPlayerId& id) { |
| 5152 FOR_EACH_OBSERVER(WebContentsObserver, observers_, MediaStoppedPlaying(id)); | 5142 for (auto& observer : observers_) |
| 5143 observer.MediaStoppedPlaying(id); |
| 5153 } | 5144 } |
| 5154 | 5145 |
| 5155 void WebContentsImpl::UpdateWebContentsVisibility(bool visible) { | 5146 void WebContentsImpl::UpdateWebContentsVisibility(bool visible) { |
| 5156 if (!did_first_set_visible_) { | 5147 if (!did_first_set_visible_) { |
| 5157 // If this WebContents has not yet been set to be visible for the first | 5148 // If this WebContents has not yet been set to be visible for the first |
| 5158 // time, ignore any requests to make it hidden, since resources would | 5149 // time, ignore any requests to make it hidden, since resources would |
| 5159 // immediately be destroyed and only re-created after content loaded. In | 5150 // immediately be destroyed and only re-created after content loaded. In |
| 5160 // this state the window content is undefined and can show garbage. | 5151 // this state the window content is undefined and can show garbage. |
| 5161 // However, the page load mechanism requires an activation call through a | 5152 // However, the page load mechanism requires an activation call through a |
| 5162 // visibility call to (re)load. | 5153 // visibility call to (re)load. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5196 dialog_manager_ = dialog_manager; | 5187 dialog_manager_ = dialog_manager; |
| 5197 } | 5188 } |
| 5198 | 5189 |
| 5199 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5190 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
| 5200 auto it = binding_sets_.find(interface_name); | 5191 auto it = binding_sets_.find(interface_name); |
| 5201 if (it != binding_sets_.end()) | 5192 if (it != binding_sets_.end()) |
| 5202 binding_sets_.erase(it); | 5193 binding_sets_.erase(it); |
| 5203 } | 5194 } |
| 5204 | 5195 |
| 5205 } // namespace content | 5196 } // namespace content |
| OLD | NEW |