blob: 2d2e163ae8cf2ac53196ebd669a4f94bda6c7a86 [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:0818
[email protected]6ea6bdf2013-12-06 13:35:0119namespace content {
20
21class NavigationControllerImpl;
22class NavigatorDelegate;
clamy71a42ec2014-10-02 18:43:2223class NavigatorTest;
[email protected]37567b432014-02-12 01:12:2224struct LoadCommittedDetails;
clamy9bfeef42014-09-30 20:50:4225struct CommitNavigationParams;
26struct CommonNavigationParams;
27struct RequestNavigationParams;
[email protected]6ea6bdf2013-12-06 13:35:0128
29// This class is an implementation of Navigator, responsible for managing
30// navigations in regular browser tabs.
31class CONTENT_EXPORT NavigatorImpl : public Navigator {
32 public:
33 NavigatorImpl(NavigationControllerImpl* navigation_controller,
34 NavigatorDelegate* delegate);
35
[email protected]52913802013-12-10 05:52:1836 // Navigator implementation.
fdegansa696e5112015-04-17 01:57:5937 NavigatorDelegate* GetDelegate() override;
dchengc2282aa2014-10-21 12:07:5838 NavigationController* GetController() override;
39 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
dglazkovcd24f7e2015-05-18 20:00:0040 const GURL& url) override;
dchengc2282aa2014-10-21 12:07:5841 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1542 RenderFrameHostImpl* render_frame_host,
43 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2844 override;
dchengc2282aa2014-10-21 12:07:5845 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
46 const GURL& url,
47 int error_code,
gsennton6fbb38692015-06-24 19:23:5548 const base::string16& error_description,
49 bool was_ignored_by_handler) override;
dchengc2282aa2014-10-21 12:07:5850 void DidNavigate(RenderFrameHostImpl* render_frame_host,
51 const FrameHostMsg_DidCommitProvisionalLoad_Params&
52 input_params) override;
creis4e2ecb72015-06-20 00:46:3053 bool NavigateToPendingEntry(FrameTreeNode* frame_tree_node,
54 const FrameNavigationEntry& frame_entry,
55 NavigationController::ReloadType reload_type,
56 bool is_same_document_history_load) override;
dchengc2282aa2014-10-21 12:07:5857 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
58 const GURL& url,
lfg9ef7d2d2014-12-15 22:32:3059 SiteInstance* source_site_instance,
dchengc2282aa2014-10-21 12:07:5860 const Referrer& referrer,
61 WindowOpenDisposition disposition,
62 bool should_replace_current_entry,
63 bool user_gesture) override;
64 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
65 const GURL& url,
lfg9ef7d2d2014-12-15 22:32:3066 SiteInstance* source_site_instance,
dchengc2282aa2014-10-21 12:07:5867 const std::vector<GURL>& redirect_chain,
68 const Referrer& referrer,
69 ui::PageTransition page_transition,
70 WindowOpenDisposition disposition,
71 const GlobalRequestID& transferred_global_request_id,
72 bool should_replace_current_entry,
73 bool user_gesture) override;
clamy0ab288e2015-02-05 17:39:1474 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
dchengc2282aa2014-10-21 12:07:5875 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
clamy0ab288e2015-02-05 17:39:1476 const CommonNavigationParams& common_params,
77 const BeginNavigationParams& begin_params,
78 scoped_refptr<ResourceRequestBody> body) override;
dchengc2282aa2014-10-21 12:07:5879 void CommitNavigation(FrameTreeNode* frame_tree_node,
80 ResourceResponse* response,
81 scoped_ptr<StreamHandle> body) override;
clamy62b271d2015-04-16 11:54:5782 void FailedNavigation(FrameTreeNode* frame_tree_node,
83 bool has_stale_copy_in_cache,
84 int error_code) override;
dchengc2282aa2014-10-21 12:07:5885 void LogResourceRequestTime(base::TimeTicks timestamp,
86 const GURL& url) override;
87 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:1888 const base::TimeTicks& renderer_before_unload_start_time,
89 const base::TimeTicks& renderer_before_unload_end_time) override;
dchengc2282aa2014-10-21 12:07:5890 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
carloskbb156a042014-09-30 11:55:1091
[email protected]6ea6bdf2013-12-06 13:35:0192 private:
carloska045c8c2014-10-14 10:43:1893 // Holds data used to track browser side navigation metrics.
94 struct NavigationMetricsData;
95
clamy72c72792014-11-18 18:09:4696 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:5897 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:0198
[email protected]0449c3f2014-02-28 20:31:2299 // Navigates to the given entry, which must be the pending entry. Private
100 // because all callers should use NavigateToPendingEntry.
creis4e2ecb72015-06-20 00:46:30101 bool NavigateToEntry(FrameTreeNode* frame_tree_node,
102 const FrameNavigationEntry& frame_entry,
103 const NavigationEntryImpl& entry,
104 NavigationController::ReloadType reload_type,
105 bool is_same_document_history_load);
[email protected]0449c3f2014-02-28 20:31:22106
[email protected]37567b432014-02-12 01:12:22107 bool ShouldAssignSiteForURL(const GURL& url);
108
[email protected]8a58a8e2014-08-19 15:59:08109 void CheckWebUIRendererDoesNotDisplayNormalURL(
110 RenderFrameHostImpl* render_frame_host,
111 const GURL& url);
112
clamy0ab288e2015-02-05 17:39:14113 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
114 // to execute the beforeUnload event. Otherwise, the navigation request will
115 // be started.
116 void RequestNavigation(FrameTreeNode* frame_tree_node,
lfg573e8be62015-07-15 16:00:11117 const GURL& dest_url,
118 const Referrer& dest_referrer,
creis4e2ecb72015-06-20 00:46:30119 const FrameNavigationEntry& frame_entry,
clamy71a42ec2014-10-02 18:43:22120 const NavigationEntryImpl& entry,
121 NavigationController::ReloadType reload_type,
creis4e2ecb72015-06-20 00:46:30122 bool is_same_document_history_load,
clamy71a42ec2014-10-02 18:43:22123 base::TimeTicks navigation_start);
124
carloska045c8c2014-10-14 10:43:18125 void RecordNavigationMetrics(
126 const LoadCommittedDetails& details,
127 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
128 SiteInstance* site_instance);
129
clamyfa0939fd2015-06-04 08:39:11130 // Called when a navigation has started in a main frame, to update the pending
131 // NavigationEntry if the controller does not currently have a
132 // browser-initiated one.
133 void DidStartMainFrameNavigation(const GURL& url,
134 SiteInstanceImpl* site_instance);
135
[email protected]52913802013-12-10 05:52:18136 // The NavigationController that will keep track of session history for all
137 // RenderFrameHost objects using this NavigatorImpl.
138 // TODO(nasko): Move ownership of the NavigationController from
139 // WebContentsImpl to this class.
140 NavigationControllerImpl* controller_;
141
142 // Used to notify the object embedding this Navigator about navigation
143 // events. Can be NULL in tests.
144 NavigatorDelegate* delegate_;
145
carloska045c8c2014-10-14 10:43:18146 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10147
[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_