blob: 99aeea9e31da142757a75530c352bff32d446ee7 [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;
[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,
Yutaka Hirano16d3c5d2017-07-31 06:17:3055 const base::string16& error_description) override;
Arthur Hemery7b0ae492018-02-05 16:04:4556 void DidNavigate(RenderFrameHostImpl* render_frame_host,
57 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
58 std::unique_ptr<NavigationHandleImpl> navigation_handle,
59 bool was_within_same_document) override;
Giovanni Ortuño Urquidi640873402018-02-08 23:01:4460 bool NavigateToPendingEntry(
61 FrameTreeNode* frame_tree_node,
62 const FrameNavigationEntry& frame_entry,
63 ReloadType reload_type,
64 bool is_same_document_history_load,
65 std::unique_ptr<NavigationUIData> navigation_ui_data) override;
clamy987a3752018-05-03 17:36:2666 bool NavigateToEntry(
67 FrameTreeNode* frame_tree_node,
68 const FrameNavigationEntry& frame_entry,
69 const NavigationEntryImpl& entry,
70 ReloadType reload_type,
71 bool is_same_document_history_load,
72 bool is_history_navigation_in_new_child,
73 bool is_pending_entry,
74 const scoped_refptr<network::ResourceRequestBody>& post_body,
75 std::unique_ptr<NavigationUIData> navigation_ui_data) override;
76 bool StartHistoryNavigationInNewSubframe(
77 RenderFrameHostImpl* render_frame_host,
78 const GURL& default_url) override;
Charles Harrisonbd8675982017-06-20 22:13:4979 void RequestOpenURL(
80 RenderFrameHostImpl* render_frame_host,
81 const GURL& url,
82 bool uses_post,
John Abd-El-Malekb49606cf2018-01-12 17:23:3483 const scoped_refptr<network::ResourceRequestBody>& body,
Charles Harrisonbd8675982017-06-20 22:13:4984 const std::string& extra_headers,
85 const Referrer& referrer,
86 WindowOpenDisposition disposition,
Charles Harrisonbd8675982017-06-20 22:13:4987 bool should_replace_current_entry,
88 bool user_gesture,
Jochen Eisingere64bca2c2018-01-12 09:17:0389 blink::WebTriggeringEventInfo triggering_event_info,
90 const base::Optional<std::string>& suggested_filename) override;
clamy987a3752018-05-03 17:36:2691 void NavigateFromFrameProxy(
Jochen Eisinger68fb0642018-01-17 21:56:4592 RenderFrameHostImpl* render_frame_host,
93 const GURL& url,
94 SiteInstance* source_site_instance,
Jochen Eisinger68fb0642018-01-17 21:56:4595 const Referrer& referrer,
96 ui::PageTransition page_transition,
Jochen Eisinger68fb0642018-01-17 21:56:4597 bool should_replace_current_entry,
98 const std::string& method,
99 scoped_refptr<network::ResourceRequestBody> post_body,
100 const std::string& extra_headers,
101 const base::Optional<std::string>& suggested_filename) override;
clamy080e7962017-05-25 00:44:18102 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
103 bool proceed,
104 const base::TimeTicks& proceed_time) override;
dchengc2282aa2014-10-21 12:07:58105 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
clamy0ab288e2015-02-05 17:39:14106 const CommonNavigationParams& common_params,
Marijn Kruisselbrink07bf59d52018-04-03 21:50:25107 mojom::BeginNavigationParamsPtr begin_params,
108 scoped_refptr<network::SharedURLLoaderFactory>
109 blob_url_loader_factory) override;
clamyaf4bf2d92018-02-06 10:54:36110 void RestartNavigationAsCrossDocument(
111 std::unique_ptr<NavigationRequest> navigation_request) override;
clamya86695b2017-03-23 14:45:48112 void OnAbortNavigation(FrameTreeNode* frame_tree_node) override;
dchengc2282aa2014-10-21 12:07:58113 void LogResourceRequestTime(base::TimeTicks timestamp,
114 const GURL& url) override;
115 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:18116 const base::TimeTicks& renderer_before_unload_start_time,
117 const base::TimeTicks& renderer_before_unload_end_time) override;
clamya86695b2017-03-23 14:45:48118 void CancelNavigation(FrameTreeNode* frame_tree_node,
119 bool inform_renderer) override;
Jochen Eisinger9f9789e92018-03-07 16:44:01120 void DiscardPendingEntryIfNeeded(int expected_pending_entry_id,
121 bool is_download) override;
carloskbb156a042014-09-30 11:55:10122
[email protected]6ea6bdf2013-12-06 13:35:01123 private:
carloska045c8c2014-10-14 10:43:18124 // Holds data used to track browser side navigation metrics.
125 struct NavigationMetricsData;
126
clamy72c72792014-11-18 18:09:46127 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:58128 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01129
clamy533b5792017-12-21 17:31:17130 // If needed, sends a BeforeUnload IPC to the renderer to ask it to execute
131 // the beforeUnload event. Otherwise, the navigation request will be started.
John Abd-El-Malekb49606cf2018-01-12 17:23:34132 void RequestNavigation(
133 FrameTreeNode* frame_tree_node,
134 const GURL& dest_url,
135 const Referrer& dest_referrer,
136 const FrameNavigationEntry& frame_entry,
137 const NavigationEntryImpl& entry,
138 ReloadType reload_type,
139 PreviewsState previews_state,
140 bool is_same_document_history_load,
141 bool is_history_navigation_in_new_child,
142 const scoped_refptr<network::ResourceRequestBody>& post_body,
Giovanni Ortuño Urquidi640873402018-02-08 23:01:44143 base::TimeTicks navigation_start,
144 std::unique_ptr<NavigationUIData> navigation_ui_data);
clamy71a42ec2014-10-02 18:43:22145
carloska045c8c2014-10-14 10:43:18146 void RecordNavigationMetrics(
147 const LoadCommittedDetails& details,
148 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
149 SiteInstance* site_instance);
150
clamyfa0939fd2015-06-04 08:39:11151 // Called when a navigation has started in a main frame, to update the pending
152 // NavigationEntry if the controller does not currently have a
153 // browser-initiated one.
154 void DidStartMainFrameNavigation(const GURL& url,
creisb4dc9332016-03-14 21:39:19155 SiteInstanceImpl* site_instance,
156 NavigationHandleImpl* navigation_handle);
clamyfa0939fd2015-06-04 08:39:11157
[email protected]52913802013-12-10 05:52:18158 // The NavigationController that will keep track of session history for all
159 // RenderFrameHost objects using this NavigatorImpl.
160 // TODO(nasko): Move ownership of the NavigationController from
161 // WebContentsImpl to this class.
162 NavigationControllerImpl* controller_;
163
164 // Used to notify the object embedding this Navigator about navigation
165 // events. Can be NULL in tests.
166 NavigatorDelegate* delegate_;
167
dcheng9bfa5162016-04-09 01:00:57168 std::unique_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10169
[email protected]6ea6bdf2013-12-06 13:35:01170 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
171};
172
173} // namespace content
174
175#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_