blob: 7d4622d7875cee828e0b986cc74c402622d6e6cd [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"
[email protected]3691e5cf2014-01-22 10:16:2012#include "content/browser/frame_host/navigation_controller_impl.h"
[email protected]6ea6bdf2013-12-06 13:35:0113#include "content/browser/frame_host/navigator.h"
14#include "content/common/content_export.h"
carloskbb156a042014-09-30 11:55:1015#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0116
clamy9bfeef42014-09-30 20:50:4217class GURL;
[email protected]8a58a8e2014-08-19 15:59:0818struct FrameMsg_Navigate_Params;
19
[email protected]6ea6bdf2013-12-06 13:35:0120namespace content {
21
22class NavigationControllerImpl;
23class NavigatorDelegate;
clamy71a42ec2014-10-02 18:43:2224class NavigatorTest;
[email protected]37567b432014-02-12 01:12:2225struct LoadCommittedDetails;
clamy9bfeef42014-09-30 20:50:4226struct CommitNavigationParams;
27struct CommonNavigationParams;
28struct RequestNavigationParams;
[email protected]6ea6bdf2013-12-06 13:35:0129
30// This class is an implementation of Navigator, responsible for managing
31// navigations in regular browser tabs.
32class CONTENT_EXPORT NavigatorImpl : public Navigator {
33 public:
34 NavigatorImpl(NavigationControllerImpl* navigation_controller,
35 NavigatorDelegate* delegate);
36
[email protected]52913802013-12-10 05:52:1837 // Navigator implementation.
dchengc2282aa2014-10-21 12:07:5838 NavigationController* GetController() override;
39 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
40 const GURL& url,
41 bool is_transition_navigation) override;
42 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1543 RenderFrameHostImpl* render_frame_host,
44 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2845 override;
dchengc2282aa2014-10-21 12:07:5846 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
47 const GURL& url,
48 int error_code,
49 const base::string16& error_description) override;
50 void DidNavigate(RenderFrameHostImpl* render_frame_host,
51 const FrameHostMsg_DidCommitProvisionalLoad_Params&
52 input_params) override;
53 bool NavigateToPendingEntry(
[email protected]3691e5cf2014-01-22 10:16:2054 RenderFrameHostImpl* render_frame_host,
mohan.reddy383f53b32014-10-07 05:56:2855 NavigationController::ReloadType reload_type) override;
dchengc2282aa2014-10-21 12:07:5856 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
57 const GURL& url,
lfg9ef7d2d2014-12-15 22:32:3058 SiteInstance* source_site_instance,
dchengc2282aa2014-10-21 12:07:5859 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,
lfg9ef7d2d2014-12-15 22:32:3065 SiteInstance* source_site_instance,
dchengc2282aa2014-10-21 12:07:5866 const std::vector<GURL>& redirect_chain,
67 const Referrer& referrer,
68 ui::PageTransition page_transition,
69 WindowOpenDisposition disposition,
70 const GlobalRequestID& transferred_global_request_id,
71 bool should_replace_current_entry,
72 bool user_gesture) override;
clamy0ab288e2015-02-05 17:39:1473 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
dchengc2282aa2014-10-21 12:07:5874 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
clamy0ab288e2015-02-05 17:39:1475 const CommonNavigationParams& common_params,
76 const BeginNavigationParams& begin_params,
77 scoped_refptr<ResourceRequestBody> body) override;
dchengc2282aa2014-10-21 12:07:5878 void CommitNavigation(FrameTreeNode* frame_tree_node,
79 ResourceResponse* response,
80 scoped_ptr<StreamHandle> body) override;
81 void LogResourceRequestTime(base::TimeTicks timestamp,
82 const GURL& url) override;
83 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:1884 const base::TimeTicks& renderer_before_unload_start_time,
85 const base::TimeTicks& renderer_before_unload_end_time) override;
dchengc2282aa2014-10-21 12:07:5886 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
clamyafbf7f02015-01-21 20:38:1187 bool IsWaitingForBeforeUnloadACK(FrameTreeNode* frame_tree_node) override;
carloskbb156a042014-09-30 11:55:1088
clamy72c72792014-11-18 18:09:4689 // PlzNavigate
90 // Returns the navigation request for a given node. Used in tests.
91 NavigationRequest* GetNavigationRequestForNodeForTesting(
92 FrameTreeNode* frame_tree_node);
93
[email protected]6ea6bdf2013-12-06 13:35:0194 private:
carloska045c8c2014-10-14 10:43:1895 // Holds data used to track browser side navigation metrics.
96 struct NavigationMetricsData;
97
clamy72c72792014-11-18 18:09:4698 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:5899 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01100
[email protected]0449c3f2014-02-28 20:31:22101 // Navigates to the given entry, which must be the pending entry. Private
102 // because all callers should use NavigateToPendingEntry.
103 bool NavigateToEntry(
104 RenderFrameHostImpl* render_frame_host,
105 const NavigationEntryImpl& entry,
106 NavigationController::ReloadType reload_type);
107
[email protected]37567b432014-02-12 01:12:22108 bool ShouldAssignSiteForURL(const GURL& url);
109
[email protected]8a58a8e2014-08-19 15:59:08110 void CheckWebUIRendererDoesNotDisplayNormalURL(
111 RenderFrameHostImpl* render_frame_host,
112 const GURL& url);
113
clamy0ab288e2015-02-05 17:39:14114 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
115 // to execute the beforeUnload event. Otherwise, the navigation request will
116 // be started.
117 void RequestNavigation(FrameTreeNode* frame_tree_node,
clamy71a42ec2014-10-02 18:43:22118 const NavigationEntryImpl& entry,
119 NavigationController::ReloadType reload_type,
120 base::TimeTicks navigation_start);
121
clamy0ab288e2015-02-05 17:39:14122 // PlzNavigate: sends the NavigationRequest for |frame_tree_node| to the
123 // network stack so that it can start.
124 void BeginNavigation(FrameTreeNode* frame_tree_node);
125
carloska045c8c2014-10-14 10:43:18126 void RecordNavigationMetrics(
127 const LoadCommittedDetails& details,
128 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
129 SiteInstance* site_instance);
130
[email protected]52913802013-12-10 05:52:18131 // The NavigationController that will keep track of session history for all
132 // RenderFrameHost objects using this NavigatorImpl.
133 // TODO(nasko): Move ownership of the NavigationController from
134 // WebContentsImpl to this class.
135 NavigationControllerImpl* controller_;
136
137 // Used to notify the object embedding this Navigator about navigation
138 // events. Can be NULL in tests.
139 NavigatorDelegate* delegate_;
140
carloska045c8c2014-10-14 10:43:18141 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10142
clamy71a42ec2014-10-02 18:43:22143 // PlzNavigate: used to track the various ongoing NavigationRequests in the
144 // different FrameTreeNodes, based on the frame_tree_node_id.
145 typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
146 NavigationRequestMap navigation_request_map_;
147
[email protected]6ea6bdf2013-12-06 13:35:01148 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
149};
150
151} // namespace content
152
153#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_