Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 1080143003: Move DidStartLoading, DidStopLoading, DidChangeLoadProgress to RFHI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Add delegate accessor from Navigator + Re-add scoped trackers Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 FrameTreeNode'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_->DidStopLoading();
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
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);
1427 is_loading_ = true;
nasko 2015/04/15 19:17:06 Why not set the state before calling the FTN metho
Fabrice (no longer in Chrome) 2015/04/16 13:55:26 In FTN, we're going to check the tree status to se
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();
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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 new NavigationParams(common_params, start_params, request_params)); 1597 new NavigationParams(common_params, start_params, request_params));
1555 } else { 1598 } else {
1556 // Get back to a clean state, in case we start a new navigation without 1599 // Get back to a clean state, in case we start a new navigation without
1557 // completing a RFH swap or unload handler. 1600 // completing a RFH swap or unload handler.
1558 SetState(RenderFrameHostImpl::STATE_DEFAULT); 1601 SetState(RenderFrameHostImpl::STATE_DEFAULT);
1559 1602
1560 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params, 1603 Send(new FrameMsg_Navigate(routing_id_, common_params, start_params,
1561 request_params)); 1604 request_params));
1562 } 1605 }
1563 1606
1564 // Force the throbber to start. We do this because Blink's "started 1607 // Force the throbber to start. This is done because Blink's "started loading"
1565 // loading" message will be received asynchronously from the UI of the 1608 // message will be received asynchronously from the UI of the browser. But the
1566 // browser. But we want to keep the throbber in sync with what's happening 1609 // throbber needs to be kept in sync with what's happening in the UI. For
1567 // in the UI. For example, we want to start throbbing immediately when the 1610 // example, the throbber will start immediately when the user navigates even
1568 // user navigates even if the renderer is delayed. There is also an issue 1611 // if the renderer is delayed. There is also an issue with the throbber
1569 // with the throbber starting because the WebUI (which controls whether the 1612 // starting because the WebUI (which controls whether the favicon is
1570 // favicon is displayed) happens synchronously. If the start loading 1613 // displayed) happens synchronously. If the start loading messages was
1571 // messages was asynchronous, then the default favicon would flash in. 1614 // 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 it is not
1574 // don't want to either. 1617 // done here either.
nasko 2015/04/15 19:17:06 Thanks for improving this comment!
Fabrice (no longer in Chrome) 2015/04/16 13:55:26 Welcome!
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_->DidStartLoading(true);
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698