blob: 775b16f57737744100246f9ffde4630fda4f9a75 [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
clamy71a42ec2014-10-02 18:43:228#include "base/containers/scoped_ptr_hash_map.h"
[email protected]6ea6bdf2013-12-06 13:35:019#include "base/memory/ref_counted.h"
clamy9bfeef42014-09-30 20:50:4210#include "base/memory/scoped_ptr.h"
carloskbb156a042014-09-30 11:55:1011#include "base/time/time.h"
[email protected]3691e5cf2014-01-22 10:16:2012#include "content/browser/frame_host/navigation_controller_impl.h"
[email protected]6ea6bdf2013-12-06 13:35:0113#include "content/browser/frame_host/navigator.h"
14#include "content/common/content_export.h"
carloskbb156a042014-09-30 11:55:1015#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0116
clamy9bfeef42014-09-30 20:50:4217class GURL;
[email protected]8a58a8e2014-08-19 15:59:0818
[email protected]6ea6bdf2013-12-06 13:35:0119namespace content {
20
21class NavigationControllerImpl;
22class NavigatorDelegate;
clamy71a42ec2014-10-02 18:43:2223class NavigatorTest;
[email protected]37567b432014-02-12 01:12:2224struct LoadCommittedDetails;
clamy9bfeef42014-09-30 20:50:4225struct CommitNavigationParams;
26struct CommonNavigationParams;
27struct RequestNavigationParams;
[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
[email protected]52913802013-12-10 05:52:1836 // Navigator implementation.
fdegansa696e5112015-04-17 01:57:5937 NavigatorDelegate* GetDelegate() override;
dchengc2282aa2014-10-21 12:07:5838 NavigationController* GetController() override;
csharrisone77e5ce2015-11-15 02:31:1939 void DidStartProvisionalLoad(
40 RenderFrameHostImpl* render_frame_host,
41 const GURL& url,
42 const base::TimeTicks& navigation_start) 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,
gsennton6fbb38692015-06-24 19:23:5550 const base::string16& error_description,
51 bool was_ignored_by_handler) override;
avib81c9222015-08-21 16:28:1752 void DidNavigate(
53 RenderFrameHostImpl* render_frame_host,
54 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) override;
creis4e2ecb72015-06-20 00:46:3055 bool NavigateToPendingEntry(FrameTreeNode* frame_tree_node,
56 const FrameNavigationEntry& frame_entry,
57 NavigationController::ReloadType reload_type,
58 bool is_same_document_history_load) override;
dchengc2282aa2014-10-21 12:07:5859 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
60 const GURL& url,
lfg9ef7d2d2014-12-15 22:32:3061 SiteInstance* source_site_instance,
dchengc2282aa2014-10-21 12:07:5862 const Referrer& referrer,
63 WindowOpenDisposition disposition,
64 bool should_replace_current_entry,
65 bool user_gesture) override;
66 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
67 const GURL& url,
lfg9ef7d2d2014-12-15 22:32:3068 SiteInstance* source_site_instance,
dchengc2282aa2014-10-21 12:07:5869 const std::vector<GURL>& redirect_chain,
70 const Referrer& referrer,
71 ui::PageTransition page_transition,
72 WindowOpenDisposition disposition,
73 const GlobalRequestID& transferred_global_request_id,
74 bool should_replace_current_entry,
75 bool user_gesture) override;
clamy0ab288e2015-02-05 17:39:1476 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
dchengc2282aa2014-10-21 12:07:5877 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
clamy0ab288e2015-02-05 17:39:1478 const CommonNavigationParams& common_params,
79 const BeginNavigationParams& begin_params,
80 scoped_refptr<ResourceRequestBody> body) override;
dchengc2282aa2014-10-21 12:07:5881 void CommitNavigation(FrameTreeNode* frame_tree_node,
82 ResourceResponse* response,
83 scoped_ptr<StreamHandle> body) override;
clamy62b271d2015-04-16 11:54:5784 void FailedNavigation(FrameTreeNode* frame_tree_node,
85 bool has_stale_copy_in_cache,
86 int error_code) override;
dchengc2282aa2014-10-21 12:07:5887 void LogResourceRequestTime(base::TimeTicks timestamp,
88 const GURL& url) override;
89 void LogBeforeUnloadTime(
carloska045c8c2014-10-14 10:43:1890 const base::TimeTicks& renderer_before_unload_start_time,
91 const base::TimeTicks& renderer_before_unload_end_time) override;
dchengc2282aa2014-10-21 12:07:5892 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
carloskbb156a042014-09-30 11:55:1093
[email protected]6ea6bdf2013-12-06 13:35:0194 private:
carloska045c8c2014-10-14 10:43:1895 // Holds data used to track browser side navigation metrics.
96 struct NavigationMetricsData;
97
clamy72c72792014-11-18 18:09:4698 friend class NavigatorTestWithBrowserSideNavigation;
dchengc2282aa2014-10-21 12:07:5899 ~NavigatorImpl() override;
[email protected]6ea6bdf2013-12-06 13:35:01100
[email protected]0449c3f2014-02-28 20:31:22101 // Navigates to the given entry, which must be the pending entry. Private
102 // because all callers should use NavigateToPendingEntry.
creis4e2ecb72015-06-20 00:46:30103 bool NavigateToEntry(FrameTreeNode* frame_tree_node,
104 const FrameNavigationEntry& frame_entry,
105 const NavigationEntryImpl& entry,
106 NavigationController::ReloadType reload_type,
107 bool is_same_document_history_load);
[email protected]0449c3f2014-02-28 20:31:22108
[email protected]37567b432014-02-12 01:12:22109 bool ShouldAssignSiteForURL(const GURL& url);
110
[email protected]8a58a8e2014-08-19 15:59:08111 void CheckWebUIRendererDoesNotDisplayNormalURL(
112 RenderFrameHostImpl* render_frame_host,
113 const GURL& url);
114
clamy0ab288e2015-02-05 17:39:14115 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
116 // to execute the beforeUnload event. Otherwise, the navigation request will
117 // be started.
118 void RequestNavigation(FrameTreeNode* frame_tree_node,
lfg573e8be62015-07-15 16:00:11119 const GURL& dest_url,
120 const Referrer& dest_referrer,
creis4e2ecb72015-06-20 00:46:30121 const FrameNavigationEntry& frame_entry,
clamy71a42ec2014-10-02 18:43:22122 const NavigationEntryImpl& entry,
123 NavigationController::ReloadType reload_type,
creis4e2ecb72015-06-20 00:46:30124 bool is_same_document_history_load,
clamy71a42ec2014-10-02 18:43:22125 base::TimeTicks navigation_start);
126
carloska045c8c2014-10-14 10:43:18127 void RecordNavigationMetrics(
128 const LoadCommittedDetails& details,
129 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
130 SiteInstance* site_instance);
131
clamyfa0939fd2015-06-04 08:39:11132 // Called when a navigation has started in a main frame, to update the pending
133 // NavigationEntry if the controller does not currently have a
134 // browser-initiated one.
135 void DidStartMainFrameNavigation(const GURL& url,
136 SiteInstanceImpl* site_instance);
137
[email protected]52913802013-12-10 05:52:18138 // The NavigationController that will keep track of session history for all
139 // RenderFrameHost objects using this NavigatorImpl.
140 // TODO(nasko): Move ownership of the NavigationController from
141 // WebContentsImpl to this class.
142 NavigationControllerImpl* controller_;
143
144 // Used to notify the object embedding this Navigator about navigation
145 // events. Can be NULL in tests.
146 NavigatorDelegate* delegate_;
147
carloska045c8c2014-10-14 10:43:18148 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10149
[email protected]6ea6bdf2013-12-06 13:35:01150 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
151};
152
153} // namespace content
154
155#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_