blob: e0cac3ecc64178b127cc746fcbd6821d7bc60c85 [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"
12#include "base/tuple.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"
carloskbb156a042014-09-30 11:55:1016#include "url/gurl.h"
[email protected]6ea6bdf2013-12-06 13:35:0117
clamy9bfeef42014-09-30 20:50:4218class GURL;
[email protected]8a58a8e2014-08-19 15:59:0819struct FrameMsg_Navigate_Params;
20
[email protected]6ea6bdf2013-12-06 13:35:0121namespace content {
22
23class NavigationControllerImpl;
24class NavigatorDelegate;
clamy71a42ec2014-10-02 18:43:2225class NavigatorTest;
[email protected]37567b432014-02-12 01:12:2226struct LoadCommittedDetails;
clamy9bfeef42014-09-30 20:50:4227struct CommitNavigationParams;
28struct CommonNavigationParams;
29struct RequestNavigationParams;
[email protected]6ea6bdf2013-12-06 13:35:0130
31// This class is an implementation of Navigator, responsible for managing
32// navigations in regular browser tabs.
33class CONTENT_EXPORT NavigatorImpl : public Navigator {
34 public:
35 NavigatorImpl(NavigationControllerImpl* navigation_controller,
36 NavigatorDelegate* delegate);
37
[email protected]52913802013-12-10 05:52:1838 // Navigator implementation.
mohan.reddy383f53b32014-10-07 05:56:2839 virtual NavigationController* GetController() override;
[email protected]52913802013-12-10 05:52:1840 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
[email protected]0c3c54f2014-07-31 01:29:0041 const GURL& url,
mohan.reddy383f53b32014-10-07 05:56:2842 bool is_transition_navigation) override;
[email protected]3109fbb72014-01-06 23:57:1543 virtual void DidFailProvisionalLoadWithError(
44 RenderFrameHostImpl* render_frame_host,
45 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
mohan.reddy383f53b32014-10-07 05:56:2846 override;
[email protected]b80624c2014-02-09 02:46:5547 virtual void DidFailLoadWithError(
48 RenderFrameHostImpl* render_frame_host,
[email protected]b80624c2014-02-09 02:46:5549 const GURL& url,
[email protected]b80624c2014-02-09 02:46:5550 int error_code,
mohan.reddy383f53b32014-10-07 05:56:2851 const base::string16& error_description) override;
[email protected]37567b432014-02-12 01:12:2252 virtual void DidNavigate(
53 RenderFrameHostImpl* render_frame_host,
54 const FrameHostMsg_DidCommitProvisionalLoad_Params&
mohan.reddy383f53b32014-10-07 05:56:2855 input_params) override;
[email protected]3691e5cf2014-01-22 10:16:2056 virtual bool NavigateToPendingEntry(
57 RenderFrameHostImpl* render_frame_host,
mohan.reddy383f53b32014-10-07 05:56:2858 NavigationController::ReloadType reload_type) override;
[email protected]65920f332014-03-04 21:14:1859 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
60 const GURL& url,
61 const Referrer& referrer,
62 WindowOpenDisposition disposition,
[email protected]65920f332014-03-04 21:14:1863 bool should_replace_current_entry,
mohan.reddy383f53b32014-10-07 05:56:2864 bool user_gesture) override;
[email protected]65920f332014-03-04 21:14:1865 virtual void RequestTransferURL(
66 RenderFrameHostImpl* render_frame_host,
67 const GURL& url,
68 const std::vector<GURL>& redirect_chain,
69 const Referrer& referrer,
Sylvain Defresnec6ccc77d2014-09-19 10:19:3570 ui::PageTransition page_transition,
[email protected]65920f332014-03-04 21:14:1871 WindowOpenDisposition disposition,
[email protected]65920f332014-03-04 21:14:1872 const GlobalRequestID& transferred_global_request_id,
73 bool should_replace_current_entry,
mohan.reddy383f53b32014-10-07 05:56:2874 bool user_gesture) override;
clamy71a42ec2014-10-02 18:43:2275 virtual void OnBeginNavigation(
76 FrameTreeNode* frame_tree_node,
77 const FrameHostMsg_BeginNavigation_Params& params,
mohan.reddy383f53b32014-10-07 05:56:2878 const CommonNavigationParams& common_params) override;
davidbena5496d62014-10-07 18:52:0479 virtual void CommitNavigation(FrameTreeNode* frame_tree_node,
80 ResourceResponse* response,
81 scoped_ptr<StreamHandle> body) override;
carloskbb156a042014-09-30 11:55:1082 virtual void LogResourceRequestTime(
mohan.reddy383f53b32014-10-07 05:56:2883 base::TimeTicks timestamp, const GURL& url) override;
carloska045c8c2014-10-14 10:43:1884 virtual void LogBeforeUnloadTime(
85 const base::TimeTicks& renderer_before_unload_start_time,
86 const base::TimeTicks& renderer_before_unload_end_time) override;
mohan.reddy383f53b32014-10-07 05:56:2887 virtual void CancelNavigation(FrameTreeNode* frame_tree_node) override;
carloskbb156a042014-09-30 11:55:1088
[email protected]6ea6bdf2013-12-06 13:35:0189 private:
carloska045c8c2014-10-14 10:43:1890 // Holds data used to track browser side navigation metrics.
91 struct NavigationMetricsData;
92
clamy71a42ec2014-10-02 18:43:2293 friend class NavigatorTest;
carloskbb156a042014-09-30 11:55:1094 virtual ~NavigatorImpl();
[email protected]6ea6bdf2013-12-06 13:35:0195
[email protected]0449c3f2014-02-28 20:31:2296 // Navigates to the given entry, which must be the pending entry. Private
97 // because all callers should use NavigateToPendingEntry.
98 bool NavigateToEntry(
99 RenderFrameHostImpl* render_frame_host,
100 const NavigationEntryImpl& entry,
101 NavigationController::ReloadType reload_type);
102
[email protected]37567b432014-02-12 01:12:22103 bool ShouldAssignSiteForURL(const GURL& url);
104
[email protected]8a58a8e2014-08-19 15:59:08105 void CheckWebUIRendererDoesNotDisplayNormalURL(
106 RenderFrameHostImpl* render_frame_host,
107 const GURL& url);
108
clamy71a42ec2014-10-02 18:43:22109 // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to
110 // navigate. If no live renderer is present, then the navigation request will
111 // be sent directly to the ResourceDispatcherHost.
112 bool RequestNavigation(FrameTreeNode* frame_tree_node,
113 const NavigationEntryImpl& entry,
114 NavigationController::ReloadType reload_type,
115 base::TimeTicks navigation_start);
116
carloska045c8c2014-10-14 10:43:18117 void RecordNavigationMetrics(
118 const LoadCommittedDetails& details,
119 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
120 SiteInstance* site_instance);
121
[email protected]52913802013-12-10 05:52:18122 // The NavigationController that will keep track of session history for all
123 // RenderFrameHost objects using this NavigatorImpl.
124 // TODO(nasko): Move ownership of the NavigationController from
125 // WebContentsImpl to this class.
126 NavigationControllerImpl* controller_;
127
128 // Used to notify the object embedding this Navigator about navigation
129 // events. Can be NULL in tests.
130 NavigatorDelegate* delegate_;
131
carloska045c8c2014-10-14 10:43:18132 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
carloskbb156a042014-09-30 11:55:10133
clamy71a42ec2014-10-02 18:43:22134 // PlzNavigate: used to track the various ongoing NavigationRequests in the
135 // different FrameTreeNodes, based on the frame_tree_node_id.
136 typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
137 NavigationRequestMap navigation_request_map_;
138
[email protected]6ea6bdf2013-12-06 13:35:01139 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
140};
141
142} // namespace content
143
144#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_