blob: 7401d576da1c656a1320b11c6492d88cc21c2737 [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"
Arthur Hemery7b67a972017-12-01 15:24:4917#include "content/common/navigation_params.mojom.h"
megjabloncaf312f2017-01-12 18:47:4918#include "content/public/common/previews_state.h"
carloskbb156a042014-09-30 11:55:1019#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0120
clamy9bfeef42014-09-30 20:50:4221class GURL;
[email protected]8a58a8e2014-08-19 15:59:0822
[email protected]6ea6bdf2013-12-06 13:35:0123namespace content {
24
25class NavigationControllerImpl;
26class NavigatorDelegate;
mmenke947258b62017-06-29 22:52:1427class ResourceRequestBody;
[email protected]37567b432014-02-12 01:12:2228struct LoadCommittedDetails;
[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
clamy5a3c3642016-03-24 17:46:5637 static void CheckWebUIRendererDoesNotDisplayNormalURL(
38 RenderFrameHostImpl* render_frame_host,
39 const GURL& url);
40
[email protected]52913802013-12-10 05:52:1841 // Navigator implementation.
fdegansa696e5112015-04-17 01:57:5942 NavigatorDelegate* GetDelegate() override;
dchengc2282aa2014-10-21 12:07:5843 NavigationController* GetController() override;
bmcquadebb887bb2016-12-13 13:01:1744 void DidStartProvisionalLoad(
45 RenderFrameHostImpl* render_frame_host,
46 const GURL& url,
jamb5d1a4a2017-02-07 00:07:4647 const std::vector<GURL>& redirect_chain,
bmcquadebb887bb2016-12-13 13:01:1748 const base::TimeTicks& navigation_start) override;
dchengc2282aa2014-10-21 12:07:5849 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1550 RenderFrameHostImpl* render_frame_host,
51 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2852 override;
dchengc2282aa2014-10-21 12:07:5853 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
54 const GURL& url,
55 int error_code,
Yutaka Hirano16d3c5d2017-07-31 06:17:3056 const base::string16& error_description) 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;
Charles Harrisonbd8675982017-06-20 22:13:4967 void RequestOpenURL(
68 RenderFrameHostImpl* render_frame_host,
69 const GURL& url,
70 bool uses_post,
mmenke947258b62017-06-29 22:52:1471 const scoped_refptr<ResourceRequestBody>& body,
Charles Harrisonbd8675982017-06-20 22:13:4972 const std::string& extra_headers,
73 const Referrer& referrer,
74 WindowOpenDisposition disposition,
Charles Harrisonbd8675982017-06-20 22:13:4975 bool should_replace_current_entry,
76 bool user_gesture,
77 blink::WebTriggeringEventInfo triggering_event_info) override;
lukasza4a07d3a2016-10-19 21:03:2278 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
79 const GURL& url,
80 SiteInstance* source_site_instance,
81 const std::vector<GURL>& redirect_chain,
82 const Referrer& referrer,
83 ui::PageTransition page_transition,
84 const GlobalRequestID& transferred_global_request_id,
85 bool should_replace_current_entry,
86 const std::string& method,
mmenke947258b62017-06-29 22:52:1487 scoped_refptr<ResourceRequestBody> post_body,
lukasza4a07d3a2016-10-19 21:03:2288 const std::string& extra_headers) override;
clamy080e7962017-05-25 00:44:1889 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
90 bool proceed,
91 const base::TimeTicks& proceed_time) override;
dchengc2282aa2014-10-21 12:07:5892 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
clamy0ab288e2015-02-05 17:39:1493 const CommonNavigationParams& common_params,
Arthur Hemery7b67a972017-12-01 15:24:4994 mojom::BeginNavigationParamsPtr begin_params) override;
clamya86695b2017-03-23 14:45:4895 void OnAbortNavigation(FrameTreeNode* frame_tree_node) override;
dchengc2282aa2014-10-21 12:07:5896 void LogResourceRequestTime(base::TimeTicks timestamp,
97 const GURL& url) override;
98 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:1899 const base::TimeTicks& renderer_before_unload_start_time,
100 const base::TimeTicks& renderer_before_unload_end_time) override;
clamya86695b2017-03-23 14:45:48101 void CancelNavigation(FrameTreeNode* frame_tree_node,
102 bool inform_renderer) override;
clamy080e7962017-05-25 00:44:18103 void DiscardPendingEntryIfNeeded(int expected_pending_entry_id) override;
carloskbb156a042014-09-30 11:55:10104
[email protected]6ea6bdf2013-12-06 13:35:01105 private:
carloska045c8c2014-10-14 10:43:18106 // Holds data used to track browser side navigation metrics.
107 struct NavigationMetricsData;
108
clamy72c72792014-11-18 18:09:46109 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:58110 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01111
creise18ce072015-12-02 02:00:02112 // Navigates to the given entry, which might be the pending entry (if
113 // |is_pending_entry| is true). Private because all callers should use either
114 // NavigateToPendingEntry or NavigateToNewChildFrame.
creis4e2ecb72015-06-20 00:46:30115 bool NavigateToEntry(FrameTreeNode* frame_tree_node,
116 const FrameNavigationEntry& frame_entry,
117 const NavigationEntryImpl& entry,
toyoshim0df1d3a2016-09-09 09:52:48118 ReloadType reload_type,
creise18ce072015-12-02 02:00:02119 bool is_same_document_history_load,
creis881b44282016-07-01 23:50:13120 bool is_history_navigation_in_new_child,
lukasza5aa2c3742016-06-03 19:38:08121 bool is_pending_entry,
mmenke947258b62017-06-29 22:52:14122 const scoped_refptr<ResourceRequestBody>& post_body);
[email protected]0449c3f2014-02-28 20:31:22123
clamy0ab288e2015-02-05 17:39:14124 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
125 // to execute the beforeUnload event. Otherwise, the navigation request will
126 // be started.
mmenke947258b62017-06-29 22:52:14127 void RequestNavigation(FrameTreeNode* frame_tree_node,
128 const GURL& dest_url,
129 const Referrer& dest_referrer,
130 const FrameNavigationEntry& frame_entry,
131 const NavigationEntryImpl& entry,
132 ReloadType reload_type,
133 PreviewsState previews_state,
134 bool is_same_document_history_load,
135 bool is_history_navigation_in_new_child,
136 const scoped_refptr<ResourceRequestBody>& post_body,
137 base::TimeTicks navigation_start);
clamy71a42ec2014-10-02 18:43:22138
carloska045c8c2014-10-14 10:43:18139 void RecordNavigationMetrics(
140 const LoadCommittedDetails& details,
141 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
142 SiteInstance* site_instance);
143
clamyfa0939fd2015-06-04 08:39:11144 // Called when a navigation has started in a main frame, to update the pending
145 // NavigationEntry if the controller does not currently have a
146 // browser-initiated one.
147 void DidStartMainFrameNavigation(const GURL& url,
creisb4dc9332016-03-14 21:39:19148 SiteInstanceImpl* site_instance,
149 NavigationHandleImpl* navigation_handle);
clamyfa0939fd2015-06-04 08:39:11150
[email protected]52913802013-12-10 05:52:18151 // The NavigationController that will keep track of session history for all
152 // RenderFrameHost objects using this NavigatorImpl.
153 // TODO(nasko): Move ownership of the NavigationController from
154 // WebContentsImpl to this class.
155 NavigationControllerImpl* controller_;
156
157 // Used to notify the object embedding this Navigator about navigation
158 // events. Can be NULL in tests.
159 NavigatorDelegate* delegate_;
160
dcheng9bfa5162016-04-09 01:00:57161 std::unique_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10162
[email protected]6ea6bdf2013-12-06 13:35:01163 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
164};
165
166} // namespace content
167
168#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_