blob: c3a53d4848d251a2f934a5569d4e11b2d5089a10 [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"
Miyoung Shinda5da322019-09-02 10:07:3719#include "mojo/public/cpp/bindings/pending_remote.h"
carloskbb156a042014-09-30 11:55:1020#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0121
clamy9bfeef42014-09-30 20:50:4222class GURL;
[email protected]8a58a8e2014-08-19 15:59:0823
[email protected]6ea6bdf2013-12-06 13:35:0124namespace content {
25
26class NavigationControllerImpl;
27class NavigatorDelegate;
[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;
dchengc2282aa2014-10-21 12:07:5844 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1545 RenderFrameHostImpl* render_frame_host,
Lowell Mannersc39e58272019-05-20 15:46:3846 const GURL& url,
47 int error_code,
48 const base::string16& error_description,
49 bool showing_repost_interstitial) override;
dchengc2282aa2014-10-21 12:07:5850 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
51 const GURL& url,
52 int error_code,
Yutaka Hirano16d3c5d2017-07-31 06:17:3053 const base::string16& error_description) override;
Arthur Hemery7b0ae492018-02-05 16:04:4554 void DidNavigate(RenderFrameHostImpl* render_frame_host,
55 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
Camille Lamy10aafcd32018-12-05 15:48:1356 std::unique_ptr<NavigationRequest> navigation_request,
Arthur Hemery7b0ae492018-02-05 16:04:4557 bool was_within_same_document) override;
clamy987a3752018-05-03 17:36:2658 bool StartHistoryNavigationInNewSubframe(
59 RenderFrameHostImpl* render_frame_host,
Julie Jeongeun Kimed2e5ba72019-09-12 10:14:1760 mojo::PendingAssociatedRemote<mojom::NavigationClient>* navigation_client)
61 override;
clamyea99ea12018-05-28 13:54:2362 void Navigate(std::unique_ptr<NavigationRequest> request,
63 ReloadType reload_type,
64 RestoreType restore_type) override;
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0965 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
66 const GURL& url,
Nasko Oskov93e7c55c2018-12-19 01:59:2967 const base::Optional<url::Origin>& initiator_origin,
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0968 bool uses_post,
69 const scoped_refptr<network::ResourceRequestBody>& body,
70 const std::string& extra_headers,
71 const Referrer& referrer,
72 WindowOpenDisposition disposition,
73 bool should_replace_current_entry,
74 bool user_gesture,
Sergio Villar Senind7f2ee7f2019-10-17 09:02:4175 blink::TriggeringEventInfo triggering_event_info,
Anthony Vallee-Dubois93a11672018-11-21 16:44:4276 const std::string& href_translate,
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0977 scoped_refptr<network::SharedURLLoaderFactory>
78 blob_url_loader_factory) override;
clamy987a3752018-05-03 17:36:2679 void NavigateFromFrameProxy(
Jochen Eisinger68fb0642018-01-17 21:56:4580 RenderFrameHostImpl* render_frame_host,
81 const GURL& url,
Nasko Oskov93e7c55c2018-12-19 01:59:2982 const url::Origin& initiator_origin,
Jochen Eisinger68fb0642018-01-17 21:56:4583 SiteInstance* source_site_instance,
Jochen Eisinger68fb0642018-01-17 21:56:4584 const Referrer& referrer,
85 ui::PageTransition page_transition,
Jochen Eisinger68fb0642018-01-17 21:56:4586 bool should_replace_current_entry,
Charlie Harrison8c113a32019-01-07 16:08:2987 NavigationDownloadPolicy download_policy,
Jochen Eisinger68fb0642018-01-17 21:56:4588 const std::string& method,
89 scoped_refptr<network::ResourceRequestBody> post_body,
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0990 const std::string& extra_headers,
Arthur Hemery0eb432db2019-06-12 16:15:1191 scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory,
92 bool has_user_gesture) override;
clamy080e7962017-05-25 00:44:1893 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
94 bool proceed,
95 const base::TimeTicks& proceed_time) override;
Arthur Hemeryd3011f62018-05-30 10:38:4496 void OnBeginNavigation(
97 FrameTreeNode* frame_tree_node,
Lucas Furukawa Gadanief8290a2019-07-29 20:27:5198 mojom::CommonNavigationParamsPtr common_params,
Arthur Hemeryd3011f62018-05-30 10:38:4499 mojom::BeginNavigationParamsPtr begin_params,
100 scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory,
Julie Jeongeun Kimed2e5ba72019-09-12 10:14:17101 mojo::PendingAssociatedRemote<mojom::NavigationClient> navigation_client,
Miyoung Shinda5da322019-09-02 10:07:37102 mojo::PendingRemote<blink::mojom::NavigationInitiator>
103 navigation_initiator,
Tsuyoshi Horod5eb7612019-05-09 08:59:46104 scoped_refptr<PrefetchedSignedExchangeCache>
Tsuyoshi Horo27f99242019-10-01 09:38:57105 prefetched_signed_exchange_cache,
106 std::unique_ptr<BundledExchangesHandleTracker>
107 bundled_exchanges_handle_tracker) override;
clamyaf4bf2d92018-02-06 10:54:36108 void RestartNavigationAsCrossDocument(
109 std::unique_ptr<NavigationRequest> navigation_request) override;
clamya86695b2017-03-23 14:45:48110 void OnAbortNavigation(FrameTreeNode* frame_tree_node) override;
dchengc2282aa2014-10-21 12:07:58111 void LogResourceRequestTime(base::TimeTicks timestamp,
112 const GURL& url) override;
113 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:18114 const base::TimeTicks& renderer_before_unload_start_time,
115 const base::TimeTicks& renderer_before_unload_end_time) override;
clamya86695b2017-03-23 14:45:48116 void CancelNavigation(FrameTreeNode* frame_tree_node,
117 bool inform_renderer) override;
[email protected]6ea6bdf2013-12-06 13:35:01118 private:
carloska045c8c2014-10-14 10:43:18119 // Holds data used to track browser side navigation metrics.
120 struct NavigationMetricsData;
121
clamy72c72792014-11-18 18:09:46122 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:58123 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01124
carloska045c8c2014-10-14 10:43:18125 void RecordNavigationMetrics(
126 const LoadCommittedDetails& details,
127 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
128 SiteInstance* site_instance);
129
arthursonzogni2ef18ffc2019-09-25 09:36:54130 // Called when a renderer initiated navigation has started. Returns the
131 // pending NavigationEntry to be used. Either null or a new one owned
132 // NavigationController.
133 NavigationEntryImpl* GetNavigationEntryForRendererInitiatedNavigation(
Lucas Furukawa Gadanief8290a2019-07-29 20:27:51134 const mojom::CommonNavigationParams& common_params,
arthursonzogni2ef18ffc2019-09-25 09:36:54135 FrameTreeNode* frame_tree_node);
clamyfa0939fd2015-06-04 08:39:11136
[email protected]52913802013-12-10 05:52:18137 // The NavigationController that will keep track of session history for all
138 // RenderFrameHost objects using this NavigatorImpl.
139 // TODO(nasko): Move ownership of the NavigationController from
140 // WebContentsImpl to this class.
141 NavigationControllerImpl* controller_;
142
143 // Used to notify the object embedding this Navigator about navigation
144 // events. Can be NULL in tests.
145 NavigatorDelegate* delegate_;
146
dcheng9bfa5162016-04-09 01:00:57147 std::unique_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10148
[email protected]6ea6bdf2013-12-06 13:35:01149 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
150};
151
152} // namespace content
153
154#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_