blob: e59fa4e6888421e90ae290c4f71784e885b85028 [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
dcheng9bfa5162016-04-09 01:00:578#include <memory>
9
avib7348942015-12-25 20:57:1010#include "base/macros.h"
[email protected]6ea6bdf2013-12-06 13:35:0111#include "base/memory/ref_counted.h"
carloskbb156a042014-09-30 11:55:1012#include "base/time/time.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"
clamy4b0b18202016-02-11 19:56:0616#include "content/common/navigation_params.h"
megjabloncaf312f2017-01-12 18:47:4917#include "content/public/common/previews_state.h"
carloskbb156a042014-09-30 11:55:1018#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0119
clamy9bfeef42014-09-30 20:50:4220class GURL;
[email protected]8a58a8e2014-08-19 15:59:0821
[email protected]6ea6bdf2013-12-06 13:35:0122namespace content {
23
24class NavigationControllerImpl;
25class NavigatorDelegate;
lukaszade802372016-06-16 17:17:2326class ResourceRequestBodyImpl;
[email protected]37567b432014-02-12 01:12:2227struct LoadCommittedDetails;
[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
clamy5a3c3642016-03-24 17:46:5636 static void CheckWebUIRendererDoesNotDisplayNormalURL(
37 RenderFrameHostImpl* render_frame_host,
38 const GURL& url);
39
[email protected]52913802013-12-10 05:52:1840 // Navigator implementation.
fdegansa696e5112015-04-17 01:57:5941 NavigatorDelegate* GetDelegate() override;
dchengc2282aa2014-10-21 12:07:5842 NavigationController* GetController() override;
bmcquadebb887bb2016-12-13 13:01:1743 void DidStartProvisionalLoad(
44 RenderFrameHostImpl* render_frame_host,
45 const GURL& url,
jamb5d1a4a2017-02-07 00:07:4646 const std::vector<GURL>& redirect_chain,
bmcquadebb887bb2016-12-13 13:01:1747 const base::TimeTicks& navigation_start) override;
dchengc2282aa2014-10-21 12:07:5848 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1549 RenderFrameHostImpl* render_frame_host,
50 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2851 override;
dchengc2282aa2014-10-21 12:07:5852 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
53 const GURL& url,
54 int error_code,
gsennton6fbb38692015-06-24 19:23:5555 const base::string16& error_description,
56 bool was_ignored_by_handler) override;
avib81c9222015-08-21 16:28:1757 void DidNavigate(
58 RenderFrameHostImpl* render_frame_host,
clamy3bf35e3c2016-11-10 15:59:4459 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
60 std::unique_ptr<NavigationHandleImpl> navigation_handle) override;
creis4e2ecb72015-06-20 00:46:3061 bool NavigateToPendingEntry(FrameTreeNode* frame_tree_node,
62 const FrameNavigationEntry& frame_entry,
toyoshim0df1d3a2016-09-09 09:52:4863 ReloadType reload_type,
creis4e2ecb72015-06-20 00:46:3064 bool is_same_document_history_load) override;
creise20a1c112016-10-06 02:19:3465 bool NavigateNewChildFrame(RenderFrameHostImpl* render_frame_host,
66 const GURL& default_url) override;
dchengc2282aa2014-10-21 12:07:5867 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
68 const GURL& url,
lukaszabb2101b82016-06-17 16:52:2569 bool uses_post,
70 const scoped_refptr<ResourceRequestBodyImpl>& body,
lukasza4a07d3a2016-10-19 21:03:2271 const std::string& extra_headers,
dchengc2282aa2014-10-21 12:07:5872 const Referrer& referrer,
73 WindowOpenDisposition disposition,
74 bool should_replace_current_entry,
75 bool user_gesture) override;
lukasza4a07d3a2016-10-19 21:03:2276 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
77 const GURL& url,
78 SiteInstance* source_site_instance,
79 const std::vector<GURL>& redirect_chain,
80 const Referrer& referrer,
81 ui::PageTransition page_transition,
82 const GlobalRequestID& transferred_global_request_id,
83 bool should_replace_current_entry,
84 const std::string& method,
85 scoped_refptr<ResourceRequestBodyImpl> post_body,
86 const std::string& extra_headers) override;
clamy0ab288e2015-02-05 17:39:1487 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
dchengc2282aa2014-10-21 12:07:5888 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
clamy0ab288e2015-02-05 17:39:1489 const CommonNavigationParams& common_params,
lukaszad04640f2016-05-25 17:08:4490 const BeginNavigationParams& begin_params) override;
clamya86695b2017-03-23 14:45:4891 void OnAbortNavigation(FrameTreeNode* frame_tree_node) override;
dchengc2282aa2014-10-21 12:07:5892 void LogResourceRequestTime(base::TimeTicks timestamp,
93 const GURL& url) override;
94 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:1895 const base::TimeTicks& renderer_before_unload_start_time,
96 const base::TimeTicks& renderer_before_unload_end_time) override;
clamya86695b2017-03-23 14:45:4897 void CancelNavigation(FrameTreeNode* frame_tree_node,
98 bool inform_renderer) override;
jamde407dc2016-10-03 23:05:3999 void DiscardPendingEntryIfNeeded(NavigationHandleImpl* handle) override;
carloskbb156a042014-09-30 11:55:10100
[email protected]6ea6bdf2013-12-06 13:35:01101 private:
carloska045c8c2014-10-14 10:43:18102 // Holds data used to track browser side navigation metrics.
103 struct NavigationMetricsData;
104
clamy72c72792014-11-18 18:09:46105 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:58106 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01107
creise18ce072015-12-02 02:00:02108 // Navigates to the given entry, which might be the pending entry (if
109 // |is_pending_entry| is true). Private because all callers should use either
110 // NavigateToPendingEntry or NavigateToNewChildFrame.
creis4e2ecb72015-06-20 00:46:30111 bool NavigateToEntry(FrameTreeNode* frame_tree_node,
112 const FrameNavigationEntry& frame_entry,
113 const NavigationEntryImpl& entry,
toyoshim0df1d3a2016-09-09 09:52:48114 ReloadType reload_type,
creise18ce072015-12-02 02:00:02115 bool is_same_document_history_load,
creis881b44282016-07-01 23:50:13116 bool is_history_navigation_in_new_child,
lukasza5aa2c3742016-06-03 19:38:08117 bool is_pending_entry,
lukaszade802372016-06-16 17:17:23118 const scoped_refptr<ResourceRequestBodyImpl>& post_body);
[email protected]0449c3f2014-02-28 20:31:22119
[email protected]37567b432014-02-12 01:12:22120 bool ShouldAssignSiteForURL(const GURL& url);
121
clamy0ab288e2015-02-05 17:39:14122 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
123 // to execute the beforeUnload event. Otherwise, the navigation request will
124 // be started.
125 void RequestNavigation(FrameTreeNode* frame_tree_node,
lfg573e8be62015-07-15 16:00:11126 const GURL& dest_url,
127 const Referrer& dest_referrer,
creis4e2ecb72015-06-20 00:46:30128 const FrameNavigationEntry& frame_entry,
clamy71a42ec2014-10-02 18:43:22129 const NavigationEntryImpl& entry,
toyoshim0df1d3a2016-09-09 09:52:48130 ReloadType reload_type,
megjabloncaf312f2017-01-12 18:47:49131 PreviewsState previews_state,
creis4e2ecb72015-06-20 00:46:30132 bool is_same_document_history_load,
creis881b44282016-07-01 23:50:13133 bool is_history_navigation_in_new_child,
clamy71a42ec2014-10-02 18:43:22134 base::TimeTicks navigation_start);
135
carloska045c8c2014-10-14 10:43:18136 void RecordNavigationMetrics(
137 const LoadCommittedDetails& details,
138 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
139 SiteInstance* site_instance);
140
clamyfa0939fd2015-06-04 08:39:11141 // Called when a navigation has started in a main frame, to update the pending
142 // NavigationEntry if the controller does not currently have a
143 // browser-initiated one.
144 void DidStartMainFrameNavigation(const GURL& url,
creisb4dc9332016-03-14 21:39:19145 SiteInstanceImpl* site_instance,
146 NavigationHandleImpl* navigation_handle);
clamyfa0939fd2015-06-04 08:39:11147
[email protected]52913802013-12-10 05:52:18148 // The NavigationController that will keep track of session history for all
149 // RenderFrameHost objects using this NavigatorImpl.
150 // TODO(nasko): Move ownership of the NavigationController from
151 // WebContentsImpl to this class.
152 NavigationControllerImpl* controller_;
153
154 // Used to notify the object embedding this Navigator about navigation
155 // events. Can be NULL in tests.
156 NavigatorDelegate* delegate_;
157
dcheng9bfa5162016-04-09 01:00:57158 std::unique_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10159
[email protected]6ea6bdf2013-12-06 13:35:01160 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
161};
162
163} // namespace content
164
165#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_