blob: 3b729d1935891592109eb561b6d707dcbdf2ee9b [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;
dchengc2282aa2014-10-21 12:07:5843 void DidFailProvisionalLoadWithError(
[email protected]3109fbb72014-01-06 23:57:1544 RenderFrameHostImpl* render_frame_host,
45 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2846 override;
dchengc2282aa2014-10-21 12:07:5847 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
48 const GURL& url,
49 int error_code,
Yutaka Hirano16d3c5d2017-07-31 06:17:3050 const base::string16& error_description) override;
Arthur Hemery7b0ae492018-02-05 16:04:4551 void DidNavigate(RenderFrameHostImpl* render_frame_host,
52 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
Camille Lamy10aafcd32018-12-05 15:48:1353 std::unique_ptr<NavigationRequest> navigation_request,
Arthur Hemery7b0ae492018-02-05 16:04:4554 bool was_within_same_document) override;
clamy987a3752018-05-03 17:36:2655 bool StartHistoryNavigationInNewSubframe(
56 RenderFrameHostImpl* render_frame_host,
57 const GURL& default_url) override;
clamyea99ea12018-05-28 13:54:2358 void Navigate(std::unique_ptr<NavigationRequest> request,
59 ReloadType reload_type,
60 RestoreType restore_type) override;
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0961 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
62 const GURL& url,
Nasko Oskov93e7c55c2018-12-19 01:59:2963 const base::Optional<url::Origin>& initiator_origin,
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0964 bool uses_post,
65 const scoped_refptr<network::ResourceRequestBody>& body,
66 const std::string& extra_headers,
67 const Referrer& referrer,
68 WindowOpenDisposition disposition,
69 bool should_replace_current_entry,
70 bool user_gesture,
71 blink::WebTriggeringEventInfo triggering_event_info,
Anthony Vallee-Dubois93a11672018-11-21 16:44:4272 const std::string& href_translate,
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0973 scoped_refptr<network::SharedURLLoaderFactory>
74 blob_url_loader_factory) override;
clamy987a3752018-05-03 17:36:2675 void NavigateFromFrameProxy(
Jochen Eisinger68fb0642018-01-17 21:56:4576 RenderFrameHostImpl* render_frame_host,
77 const GURL& url,
Nasko Oskov93e7c55c2018-12-19 01:59:2978 const url::Origin& initiator_origin,
Jochen Eisinger68fb0642018-01-17 21:56:4579 SiteInstance* source_site_instance,
Jochen Eisinger68fb0642018-01-17 21:56:4580 const Referrer& referrer,
81 ui::PageTransition page_transition,
Jochen Eisinger68fb0642018-01-17 21:56:4582 bool should_replace_current_entry,
83 const std::string& method,
84 scoped_refptr<network::ResourceRequestBody> post_body,
Marijn Kruisselbrink7a0d5e182018-05-24 22:55:0985 const std::string& extra_headers,
86 scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory)
87 override;
clamy080e7962017-05-25 00:44:1888 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
89 bool proceed,
90 const base::TimeTicks& proceed_time) override;
Arthur Hemeryd3011f62018-05-30 10:38:4491 void OnBeginNavigation(
92 FrameTreeNode* frame_tree_node,
93 const CommonNavigationParams& common_params,
94 mojom::BeginNavigationParamsPtr begin_params,
95 scoped_refptr<network::SharedURLLoaderFactory> blob_url_loader_factory,
Andy Paicuc93d30862018-10-10 15:33:4596 mojom::NavigationClientAssociatedPtrInfo navigation_client,
97 blink::mojom::NavigationInitiatorPtr navigation_initiator) override;
clamyaf4bf2d92018-02-06 10:54:3698 void RestartNavigationAsCrossDocument(
99 std::unique_ptr<NavigationRequest> navigation_request) override;
clamya86695b2017-03-23 14:45:48100 void OnAbortNavigation(FrameTreeNode* frame_tree_node) override;
dchengc2282aa2014-10-21 12:07:58101 void LogResourceRequestTime(base::TimeTicks timestamp,
102 const GURL& url) override;
103 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:18104 const base::TimeTicks& renderer_before_unload_start_time,
105 const base::TimeTicks& renderer_before_unload_end_time) override;
clamya86695b2017-03-23 14:45:48106 void CancelNavigation(FrameTreeNode* frame_tree_node,
107 bool inform_renderer) override;
Jochen Eisinger7678c8ac2018-05-07 15:47:34108 void DiscardPendingEntryIfNeeded(int expected_pending_entry_id) override;
carloskbb156a042014-09-30 11:55:10109
[email protected]6ea6bdf2013-12-06 13:35:01110 private:
carloska045c8c2014-10-14 10:43:18111 // Holds data used to track browser side navigation metrics.
112 struct NavigationMetricsData;
113
clamy72c72792014-11-18 18:09:46114 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:58115 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01116
carloska045c8c2014-10-14 10:43:18117 void RecordNavigationMetrics(
118 const LoadCommittedDetails& details,
119 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
120 SiteInstance* site_instance);
121
clamyfa0939fd2015-06-04 08:39:11122 // Called when a navigation has started in a main frame, to update the pending
123 // NavigationEntry if the controller does not currently have a
124 // browser-initiated one.
125 void DidStartMainFrameNavigation(const GURL& url,
creisb4dc9332016-03-14 21:39:19126 SiteInstanceImpl* site_instance,
127 NavigationHandleImpl* navigation_handle);
clamyfa0939fd2015-06-04 08:39:11128
[email protected]52913802013-12-10 05:52:18129 // The NavigationController that will keep track of session history for all
130 // RenderFrameHost objects using this NavigatorImpl.
131 // TODO(nasko): Move ownership of the NavigationController from
132 // WebContentsImpl to this class.
133 NavigationControllerImpl* controller_;
134
135 // Used to notify the object embedding this Navigator about navigation
136 // events. Can be NULL in tests.
137 NavigatorDelegate* delegate_;
138
dcheng9bfa5162016-04-09 01:00:57139 std::unique_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10140
[email protected]6ea6bdf2013-12-06 13:35:01141 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
142};
143
144} // namespace content
145
146#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_