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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 OnTextSurroundingSelectionResponse) | 378 OnTextSurroundingSelectionResponse) |
379 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) | 379 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents) |
380 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, | 380 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_LocationChanges, |
381 OnAccessibilityLocationChanges) | 381 OnAccessibilityLocationChanges) |
382 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, | 382 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_FindInPageResult, |
383 OnAccessibilityFindInPageResult) | 383 OnAccessibilityFindInPageResult) |
384 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) | 384 IPC_MESSAGE_HANDLER(FrameHostMsg_ToggleFullscreen, OnToggleFullscreen) |
385 // The following message is synthetic and doesn't come from RenderFrame, but | 385 // The following message is synthetic and doesn't come from RenderFrame, but |
386 // from RenderProcessHost. | 386 // from RenderProcessHost. |
387 IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone) | 387 IPC_MESSAGE_HANDLER(FrameHostMsg_RenderProcessGone, OnRenderProcessGone) |
388 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartLoading, OnDidStartLoading) | |
389 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStopLoading, OnDidStopLoading) | |
390 IPC_MESSAGE_HANDLER(FrameHostMsg_DidChangeLoadProgress, | |
391 OnDidChangeLoadProgress) | |
388 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 392 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
389 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) | 393 IPC_MESSAGE_HANDLER(FrameHostMsg_ShowPopup, OnShowPopup) |
390 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) | 394 IPC_MESSAGE_HANDLER(FrameHostMsg_HidePopup, OnHidePopup) |
391 #endif | 395 #endif |
392 IPC_END_MESSAGE_MAP() | 396 IPC_END_MESSAGE_MAP() |
393 | 397 |
394 // No further actions here, since we may have been deleted. | 398 // No further actions here, since we may have been deleted. |
395 return handled; | 399 return handled; |
396 } | 400 } |
397 | 401 |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
835 bad_message::ReceivedBadMessage( | 839 bad_message::ReceivedBadMessage( |
836 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 840 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
837 return; | 841 return; |
838 } | 842 } |
839 | 843 |
840 accessibility_reset_count_ = 0; | 844 accessibility_reset_count_ = 0; |
841 frame_tree_node()->navigator()->DidNavigate(this, validated_params); | 845 frame_tree_node()->navigator()->DidNavigate(this, validated_params); |
842 } | 846 } |
843 | 847 |
844 void RenderFrameHostImpl::OnDidDropNavigation() { | 848 void RenderFrameHostImpl::OnDidDropNavigation() { |
845 // At the end of Navigate(), the delegate's DidStartLoading is called to force | 849 // At the end of Navigate(), the Navigator's DidStartLoading is called to |
846 // the spinner to start, even if the renderer didn't yet begin the load. If it | 850 // force the spinner to start, even if the renderer didn't yet begin the load. |
847 // turns out that the renderer dropped the navigation, we need to turn off the | 851 // If it turns out that the renderer dropped the navigation, the spinner needs |
848 // spinner. | 852 // to be turned off. |
849 delegate_->DidStopLoading(); | 853 frame_tree_node_->navigator()->DidStopLoading(); |
Fabrice (no longer in Chrome)
2015/04/14 16:54:11
We have to go through the navigator here because c
nasko
2015/04/14 19:54:41
I don't quite follow. During Navigate() we simulat
Fabrice (no longer in Chrome)
2015/04/15 15:15:03
I think this is going to break some tests, trying
nasko
2015/04/15 15:39:28
Different CL or a new patchset?
Fabrice (no longer in Chrome)
2015/04/15 17:46:05
New patchset, sorry.
| |
850 } | 854 } |
851 | 855 |
852 RenderWidgetHostImpl* RenderFrameHostImpl::GetRenderWidgetHost() { | 856 RenderWidgetHostImpl* RenderFrameHostImpl::GetRenderWidgetHost() { |
853 if (render_widget_host_) | 857 if (render_widget_host_) |
854 return render_widget_host_.get(); | 858 return render_widget_host_.get(); |
855 | 859 |
856 // TODO(kenrb): When RenderViewHost no longer inherits RenderWidgetHost, | 860 // TODO(kenrb): When RenderViewHost no longer inherits RenderWidgetHost, |
857 // we can remove this fallback. Currently it is only used for the main | 861 // we can remove this fallback. Currently it is only used for the main |
858 // frame. | 862 // frame. |
859 if (!GetParent()) | 863 if (!GetParent()) |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 if (enter_fullscreen) | 1400 if (enter_fullscreen) |
1397 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); | 1401 delegate_->EnterFullscreenMode(GetLastCommittedURL().GetOrigin()); |
1398 else | 1402 else |
1399 delegate_->ExitFullscreenMode(); | 1403 delegate_->ExitFullscreenMode(); |
1400 | 1404 |
1401 // The previous call might change the fullscreen state. We need to make sure | 1405 // The previous call might change the fullscreen state. We need to make sure |
1402 // the renderer is aware of that, which is done via the resize message. | 1406 // the renderer is aware of that, which is done via the resize message. |
1403 render_view_host_->WasResized(); | 1407 render_view_host_->WasResized(); |
1404 } | 1408 } |
1405 | 1409 |
1410 void RenderFrameHostImpl::OnDidStartLoading(bool to_different_document) { | |
1411 // Any main frame load to a new document should reset the load since it will | |
1412 // replace the current page and any frames. | |
1413 if (to_different_document && !GetParent()) | |
1414 is_loading_ = false; | |
1415 | |
1416 // This method should never be called when the frame is loading. | |
1417 // Unfortunately, it can happen if a history navigation happens during a | |
1418 // BeforeUnload or Unload event. | |
1419 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
1420 // refactored in Blink. See crbug.com/466089 | |
1421 if (is_loading_) { | |
1422 LOG(WARNING) << "OnDidStartLoading was called twice."; | |
1423 return; | |
1424 } | |
1425 | |
1426 frame_tree_node_->DidStartLoading(to_different_document); | |
Fabrice (no longer in Chrome)
2015/04/14 16:54:11
Here and below, it is not clear to me that this wi
nasko
2015/04/14 19:54:41
It is the job of the FTN to ensure that it does th
Fabrice (no longer in Chrome)
2015/04/15 15:15:03
The main issue is you now have to consider 4 diffe
| |
1427 is_loading_ = true; | |
1428 } | |
1429 | |
1430 void RenderFrameHostImpl::OnDidStopLoading() { | |
1431 // This method should never be called when the frame is not loading. | |
1432 // Unfortunately, it can happen if a history navigation happens during a | |
1433 // BeforeUnload or Unload event. | |
1434 // TODO(fdegans): Change this to a DCHECK after LoadEventProgress has been | |
1435 // refactored in Blink. See crbug.com/466089 | |
1436 if (!is_loading_) { | |
1437 LOG(WARNING) << "OnDidStopLoading was called twice."; | |
1438 return; | |
1439 } | |
1440 | |
1441 is_loading_ = false; | |
1442 frame_tree_node_->DidStopLoading(); | |
Fabrice (no longer in Chrome)
2015/04/14 16:54:11
Same as above, it is not clear we'll end up in Web
nasko
2015/04/14 19:54:41
Why do we care to know here whether we end up in W
Fabrice (no longer in Chrome)
2015/04/15 15:15:03
Acknowledged.
| |
1443 } | |
1444 | |
1445 void RenderFrameHostImpl::OnDidChangeLoadProgress(double load_progress) { | |
1446 frame_tree_node_->DidChangeLoadProgress(load_progress); | |
1447 } | |
1448 | |
1406 #if defined(OS_MACOSX) || defined(OS_ANDROID) | 1449 #if defined(OS_MACOSX) || defined(OS_ANDROID) |
1407 void RenderFrameHostImpl::OnShowPopup( | 1450 void RenderFrameHostImpl::OnShowPopup( |
1408 const FrameHostMsg_ShowPopup_Params& params) { | 1451 const FrameHostMsg_ShowPopup_Params& params) { |
1409 RenderViewHostDelegateView* view = | 1452 RenderViewHostDelegateView* view = |
1410 render_view_host_->delegate_->GetDelegateView(); | 1453 render_view_host_->delegate_->GetDelegateView(); |
1411 if (view) { | 1454 if (view) { |
1412 view->ShowPopupMenu(this, | 1455 view->ShowPopupMenu(this, |
1413 params.bounds, | 1456 params.bounds, |
1414 params.item_height, | 1457 params.item_height, |
1415 params.item_font_size, | 1458 params.item_font_size, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1566 // browser. But we want to keep the throbber in sync with what's happening | 1609 // browser. But we want to keep the throbber in sync with what's happening |
1567 // in the UI. For example, we want to start throbbing immediately when the | 1610 // in the UI. For example, we want to start throbbing immediately when the |
1568 // user navigates even if the renderer is delayed. There is also an issue | 1611 // user navigates even if the renderer is delayed. There is also an issue |
1569 // with the throbber starting because the WebUI (which controls whether the | 1612 // with the throbber starting because the WebUI (which controls whether the |
1570 // favicon is displayed) happens synchronously. If the start loading | 1613 // favicon is displayed) happens synchronously. If the start loading |
1571 // messages was asynchronous, then the default favicon would flash in. | 1614 // messages was asynchronous, then the default favicon would flash in. |
1572 // | 1615 // |
1573 // Blink doesn't send throb notifications for JavaScript URLs, so we | 1616 // Blink doesn't send throb notifications for JavaScript URLs, so we |
1574 // don't want to either. | 1617 // don't want to either. |
1575 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) | 1618 if (!common_params.url.SchemeIs(url::kJavaScriptScheme)) |
1576 delegate_->DidStartLoading(this, true); | 1619 frame_tree_node_->navigator()->DidStartLoading(frame_tree_node_, true); |
Fabrice (no longer in Chrome)
2015/04/14 16:54:11
Same as above, we need to go through the Navigator
nasko
2015/04/14 19:54:41
I don't think we need to. FTN is the object which
Fabrice (no longer in Chrome)
2015/04/15 15:15:03
Same as above, trying it in the next patch set.
| |
1577 } | 1620 } |
1578 | 1621 |
1579 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { | 1622 void RenderFrameHostImpl::NavigateToURL(const GURL& url) { |
1580 CommonNavigationParams common_params( | 1623 CommonNavigationParams common_params( |
1581 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL, | 1624 url, Referrer(), ui::PAGE_TRANSITION_LINK, FrameMsg_Navigate_Type::NORMAL, |
1582 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, | 1625 true, base::TimeTicks::Now(), FrameMsg_UILoadMetricsReportType::NO_REPORT, |
1583 GURL(), GURL()); | 1626 GURL(), GURL()); |
1584 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 1627 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
1585 } | 1628 } |
1586 | 1629 |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1955 return; | 1998 return; |
1956 | 1999 |
1957 permission_manager->RegisterPermissionUsage( | 2000 permission_manager->RegisterPermissionUsage( |
1958 PermissionType::GEOLOCATION, | 2001 PermissionType::GEOLOCATION, |
1959 GetLastCommittedURL().GetOrigin(), | 2002 GetLastCommittedURL().GetOrigin(), |
1960 frame_tree_node()->frame_tree()->GetMainFrame() | 2003 frame_tree_node()->frame_tree()->GetMainFrame() |
1961 ->GetLastCommittedURL().GetOrigin()); | 2004 ->GetLastCommittedURL().GetOrigin()); |
1962 } | 2005 } |
1963 | 2006 |
1964 } // namespace content | 2007 } // namespace content |
OLD | NEW |