OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 381 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
382 OnAccessibilityLocationChanges) | 382 OnAccessibilityLocationChanges) |
383 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, | 383 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, |
384 OnAccessibilityFindInPageResult) | 384 OnAccessibilityFindInPageResult) |
385 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, | 385 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_SnapshotResponse, |
386 OnAccessibilitySnapshotResponse) | 386 OnAccessibilitySnapshotResponse) |
387 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) | 387 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
388 // The following message is synthetic and doesn't come from RenderFrame, but | 388 // The following message is synthetic and doesn't come from RenderFrame, but |
389 // from RenderProcessHost. | 389 // from RenderProcessHost. |
390 IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone) | 390 IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone) |
| 391 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) |
| 392 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) |
| 393 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, |
| 394 OnDidChangeLoadProgress) |
391 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 395 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
392 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) | 396 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
393 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) | 397 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) |
394 #endif | 398 #endif |
395 IPC_END_MESSAGE_MAP() | 399 IPC_END_MESSAGE_MAP() |
396 | 400 |
397 // No further actions here, since we may have been deleted. | 401 // No further actions here, since we may have been deleted. |
398 return handled; | 402 return handled; |
399 } | 403 } |
400 | 404 |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 bad_message::ReceivedBadMessage( | 844 bad_message::ReceivedBadMessage( |
841 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 845 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
842 return; | 846 return; |
843 } | 847 } |
844 | 848 |
845 accessibility_reset_count_ = 0; | 849 accessibility_reset_count_ = 0; |
846 frame_tree_node()->navigator()->DidNavigate(this, validated_params); | 850 frame_tree_node()->navigator()->DidNavigate(this, validated_params); |
847 } | 851 } |
848 | 852 |
849 void RenderFrameHostImpl::OnDidDropNavigation() { | 853 void RenderFrameHostImpl::OnDidDropNavigation() { |
850 // At the end of Navigate(), the delegate's DidStartLoading is called to force | 854 // At the end of Navigate(), the FrameTreeNode's DidStartLoading is called to |
851 // the spinner to start, even if the renderer didn't yet begin the load. If it | 855 // force the spinner to start, even if the renderer didn't yet begin the load. |
852 // turns out that the renderer dropped the navigation, we need to turn off the | 856 // If it turns out that the renderer dropped the navigation, the spinner needs |
853 // spinner. | 857 // to be turned off. |
854 delegate_->DidStopLoading(); | 858 frame_tree_node_->DidStopLoading(); |
855 } | 859 } |
856 | 860 |
857 RenderWidgetHostImpl* RenderFrameHostImpl::GetRenderWidgetHost() { | 861 RenderWidgetHostImpl* RenderFrameHostImpl::GetRenderWidgetHost() { |
858 if (render_widget_host_) | 862 if (render_widget_host_) |
859 return render_widget_host_.get(); | 863 return render_widget_host_.get(); |
860 | 864 |
861 // TODO(kenrb): When RenderViewHost no longer inherits RenderWidgetHost, | 865 // TODO(kenrb): When RenderViewHost no longer inherits RenderWidgetHost, |
862 // we can remove this fallback. Currently it is only used for the main | 866 // we can remove this fallback. Currently it is only used for the main |
863 // frame. | 867 // frame. |
864 if (!GetParent()) | 868 if (!GetParent()) |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1423 if (enter_fullscreen) | 1427 if (enter_fullscreen) |
1424 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1428 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
1425 else | 1429 else |
1426 delegate_->ExitFullscreenMode(); | 1430 delegate_->ExitFullscreenMode(); |
1427 | 1431 |
1428 // The previous call might change the fullscreen state. We need to make sure | 1432 // The previous call might change the fullscreen state. We need to make sure |
1429 // the renderer is aware of that, which is done via the resize message. | 1433 // the renderer is aware of that, which is done via the resize message. |
1430 render_view_host_->WasResized(); | 1434 render_view_host_->WasResized(); |
1431 } | 1435 } |
1432 | 1436 |
| 1437 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { |
| 1438 // Any main frame load to a new document should reset the load since it will |
| 1439 // replace the current page and any frames. |
| 1440 if (to_different_document && !GetParent()) |
| 1441 is_loading_ = false; |
| 1442 |
| 1443 // This method should never be called when the frame is loading. |
| 1444 // Unfortunately, it can happen if a history navigation happens during a |
| 1445 // BeforeUnload or Unload event. |
| 1446 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
| 1447 // refactored in Blink. See crbug.com/466089 |
| 1448 if (is_loading_) { |
| 1449 LOG(WARNING) << "OnDidStartLoading was called twice."; |
| 1450 return; |
| 1451 } |
| 1452 |
| 1453 frame_tree_node_->DidStartLoading(to_different_document); |
| 1454 is_loading_ = true; |
| 1455 } |
| 1456 |
| 1457 void RenderFrameHostImpl::OnDidStopLoading() { |
| 1458 // This method should never be called when the frame is not loading. |
| 1459 // Unfortunately, it can happen if a history navigation happens during a |
| 1460 // BeforeUnload or Unload event. |
| 1461 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been |
| 1462 // refactored in Blink. See crbug.com/466089 |
| 1463 if (!is_loading_) { |
| 1464 LOG(WARNING) << "OnDidStopLoading was called twice."; |
| 1465 return; |
| 1466 } |
| 1467 |
| 1468 is_loading_ = false; |
| 1469 frame_tree_node_->DidStopLoading(); |
| 1470 } |
| 1471 |
| 1472 void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) { |
| 1473 frame_tree_node_->DidChangeLoadProgress(load_progress); |
| 1474 } |
| 1475 |
1433 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 1476 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
1434 void RenderFrameHostImpl::OnShowPopup( | 1477 void RenderFrameHostImpl::OnShowPopup( |
1435 const FrameHostMsg_ShowPopup_Params& params) { | 1478 const FrameHostMsg_ShowPopup_Params& params) { |
1436 RenderViewHostDelegateView* view = | 1479 RenderViewHostDelegateView* view = |
1437 render_view_host_->delegate_->GetDelegateView(); | 1480 render_view_host_->delegate_->GetDelegateView(); |
1438 if (view) { | 1481 if (view) { |
1439 view->ShowPopupMenu(this, | 1482 view->ShowPopupMenu(this, |
1440 params.bounds, | 1483 params.bounds, |
1441 params.item_height, | 1484 params.item_height, |
1442 params.item_font_size, | 1485 params.item_font_size, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 new NavigationParams(common_params, start_params, request_params)); | 1624 new NavigationParams(common_params, start_params, request_params)); |
1582 } else { | 1625 } else { |
1583 // Get back to a clean state, in case we start a new navigation without | 1626 // Get back to a clean state, in case we start a new navigation without |
1584 // completing a RFH swap or unload handler. | 1627 // completing a RFH swap or unload handler. |
1585 SetState(RenderFrameHostImpl::STATE_DEFAULT); | 1628 SetState(RenderFrameHostImpl::STATE_DEFAULT); |
1586 | 1629 |
1587 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params, | 1630 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params, |
1588 request_params)); | 1631 request_params)); |
1589 } | 1632 } |
1590 | 1633 |
1591 // Force the throbber to start. We do this because Blink's "started | 1634 // Force the throbber to start. This is done because Blink's "started loading" |
1592 // loading" message will be received asynchronously from the UI of the | 1635 // message will be received asynchronously from the UI of the browser. But the |
1593 // browser. But we want to keep the throbber in sync with what's happening | 1636 // throbber needs to be kept in sync with what's happening in the UI. For |
1594 // in the UI. For example, we want to start throbbing immediately when the | 1637 // example, the throbber will start immediately when the user navigates even |
1595 // user navigates even if the renderer is delayed. There is also an issue | 1638 // if the renderer is delayed. There is also an issue with the throbber |
1596 // with the throbber starting because the WebUI (which controls whether the | 1639 // starting because the WebUI (which controls whether the favicon is |
1597 // favicon is displayed) happens synchronously. If the start loading | 1640 // displayed) happens synchronously. If the start loading messages was |
1598 // messages was asynchronous, then the default favicon would flash in. | 1641 // asynchronous, then the default favicon would flash in. |
1599 // | 1642 // |
1600 // Blink doesn't send throb notifications for JavaScript URLs, so we | 1643 // Blink doesn't send throb notifications for JavaScript URLs, so it is not |
1601 // don't want to either. | 1644 // done here either. |
1602 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 1645 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) |
1603 delegate_->DidStartLoading(this, true); | 1646 frame_tree_node_->DidStartLoading(true); |
1604 } | 1647 } |
1605 | 1648 |
1606 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { | 1649 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { |
1607 CommonNavigationParams common_params( | 1650 CommonNavigationParams common_params( |
1608 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL, | 1651 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL, |
1609 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, | 1652 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
1610 GURL(), GURL()); | 1653 GURL(), GURL()); |
1611 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 1654 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
1612 } | 1655 } |
1613 | 1656 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2003 return; | 2046 return; |
2004 | 2047 |
2005 permission_manager->RegisterPermissionUsage( | 2048 permission_manager->RegisterPermissionUsage( |
2006 PermissionType::GEOLOCATION, | 2049 PermissionType::GEOLOCATION, |
2007 GetLastCommittedURL().GetOrigin(), | 2050 GetLastCommittedURL().GetOrigin(), |
2008 frame_tree_node()->frame_tree()->GetMainFrame() | 2051 frame_tree_node()->frame_tree()->GetMainFrame() |
2009 ->GetLastCommittedURL().GetOrigin()); | 2052 ->GetLastCommittedURL().GetOrigin()); |
2010 } | 2053 } |
2011 | 2054 |
2012 } // namespace content | 2055 } // namespace content |
OLD | NEW |