blob: 8618e0f9232311c6211088242963eae870cd2a1e [file] [log] [blame]
[email protected]6ea6bdf2013-12-06 13:35:011// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_
6#define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_
7
clamy71a42ec2014-10-02 18:43:228#include "base/containers/scoped_ptr_hash_map.h"
[email protected]6ea6bdf2013-12-06 13:35:019#include "base/memory/ref_counted.h"
clamy9bfeef42014-09-30 20:50:4210#include "base/memory/scoped_ptr.h"
carloskbb156a042014-09-30 11:55:1011#include "base/time/time.h"
12#include "base/tuple.h"
[email protected]3691e5cf2014-01-22 10:16:2013#include "content/browser/frame_host/navigation_controller_impl.h"
[email protected]6ea6bdf2013-12-06 13:35:0114#include "content/browser/frame_host/navigator.h"
15#include "content/common/content_export.h"
carloskbb156a042014-09-30 11:55:1016#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0117
clamy9bfeef42014-09-30 20:50:4218class GURL;
[email protected]8a58a8e2014-08-19 15:59:0819struct FrameMsg_Navigate_Params;
20
[email protected]6ea6bdf2013-12-06 13:35:0121namespace content {
22
23class NavigationControllerImpl;
24class NavigatorDelegate;
clamy71a42ec2014-10-02 18:43:2225class NavigatorTest;
[email protected]37567b432014-02-12 01:12:2226struct LoadCommittedDetails;
clamy9bfeef42014-09-30 20:50:4227struct CommitNavigationParams;
28struct CommonNavigationParams;
29struct RequestNavigationParams;
[email protected]6ea6bdf2013-12-06 13:35:0130
31// This class is an implementation of Navigator, responsible for managing
32// navigations in regular browser tabs.
33class CONTENT_EXPORT NavigatorImpl : public Navigator {
34 public:
35 NavigatorImpl(NavigationControllerImpl* navigation_controller,
36 NavigatorDelegate* delegate);
37
[email protected]52913802013-12-10 05:52:1838 // Navigator implementation.
dchengc2282aa2014-10-21 12:07:5839 NavigationController* GetController() override;
40 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
41 const GURL& url,
42 bool is_transition_navigation) override;
43 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1544 RenderFrameHostImpl* render_frame_host,
45 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2846 override;
dchengc2282aa2014-10-21 12:07:5847 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
48 const GURL& url,
49 int error_code,
50 const base::string16& error_description) override;
51 void DidNavigate(RenderFrameHostImpl* render_frame_host,
52 const FrameHostMsg_DidCommitProvisionalLoad_Params&
53 input_params) override;
54 bool NavigateToPendingEntry(
[email protected]3691e5cf2014-01-22 10:16:2055 RenderFrameHostImpl* render_frame_host,
mohan.reddy383f53b32014-10-07 05:56:2856 NavigationController::ReloadType reload_type) override;
dchengc2282aa2014-10-21 12:07:5857 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
58 const GURL& url,
59 const Referrer& referrer,
60 WindowOpenDisposition disposition,
61 bool should_replace_current_entry,
62 bool user_gesture) override;
63 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
64 const GURL& url,
65 const std::vector<GURL>& redirect_chain,
66 const Referrer& referrer,
67 ui::PageTransition page_transition,
68 WindowOpenDisposition disposition,
69 const GlobalRequestID& transferred_global_request_id,
70 bool should_replace_current_entry,
71 bool user_gesture) override;
72 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
73 const FrameHostMsg_BeginNavigation_Params& params,
74 const CommonNavigationParams& common_params) override;
75 void CommitNavigation(FrameTreeNode* frame_tree_node,
76 ResourceResponse* response,
77 scoped_ptr<StreamHandle> body) override;
78 void LogResourceRequestTime(base::TimeTicks timestamp,
79 const GURL& url) override;
80 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:1881 const base::TimeTicks& renderer_before_unload_start_time,
82 const base::TimeTicks& renderer_before_unload_end_time) override;
dchengc2282aa2014-10-21 12:07:5883 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
carloskbb156a042014-09-30 11:55:1084
clamy72c72792014-11-18 18:09:4685 // PlzNavigate
86 // Returns the navigation request for a given node. Used in tests.
87 NavigationRequest* GetNavigationRequestForNodeForTesting(
88 FrameTreeNode* frame_tree_node);
89
[email protected]6ea6bdf2013-12-06 13:35:0190 private:
carloska045c8c2014-10-14 10:43:1891 // Holds data used to track browser side navigation metrics.
92 struct NavigationMetricsData;
93
clamy72c72792014-11-18 18:09:4694 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:5895 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:0196
[email protected]0449c3f2014-02-28 20:31:2297 // Navigates to the given entry, which must be the pending entry. Private
98 // because all callers should use NavigateToPendingEntry.
99 bool NavigateToEntry(
100 RenderFrameHostImpl* render_frame_host,
101 const NavigationEntryImpl& entry,
102 NavigationController::ReloadType reload_type);
103
[email protected]37567b432014-02-12 01:12:22104 bool ShouldAssignSiteForURL(const GURL& url);
105
[email protected]8a58a8e2014-08-19 15:59:08106 void CheckWebUIRendererDoesNotDisplayNormalURL(
107 RenderFrameHostImpl* render_frame_host,
108 const GURL& url);
109
clamy71a42ec2014-10-02 18:43:22110 // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to
111 // navigate. If no live renderer is present, then the navigation request will
112 // be sent directly to the ResourceDispatcherHost.
113 bool RequestNavigation(FrameTreeNode* frame_tree_node,
114 const NavigationEntryImpl& entry,
115 NavigationController::ReloadType reload_type,
116 base::TimeTicks navigation_start);
117
carloska045c8c2014-10-14 10:43:18118 void RecordNavigationMetrics(
119 const LoadCommittedDetails& details,
120 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
121 SiteInstance* site_instance);
122
[email protected]52913802013-12-10 05:52:18123 // The NavigationController that will keep track of session history for all
124 // RenderFrameHost objects using this NavigatorImpl.
125 // TODO(nasko): Move ownership of the NavigationController from
126 // WebContentsImpl to this class.
127 NavigationControllerImpl* controller_;
128
129 // Used to notify the object embedding this Navigator about navigation
130 // events. Can be NULL in tests.
131 NavigatorDelegate* delegate_;
132
carloska045c8c2014-10-14 10:43:18133 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10134
clamy71a42ec2014-10-02 18:43:22135 // PlzNavigate: used to track the various ongoing NavigationRequests in the
136 // different FrameTreeNodes, based on the frame_tree_node_id.
137 typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
138 NavigationRequestMap navigation_request_map_;
139
[email protected]6ea6bdf2013-12-06 13:35:01140 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
141};
142
143} // namespace content
144
145#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_