Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / content / browser / frame_host / navigator.h
blob3a27601ea624946d0f90099500475876f0a64fa5
1 // 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.
5 #ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/time/time.h"
10 #include "content/browser/frame_host/navigator_delegate.h"
11 #include "content/common/content_export.h"
12 #include "content/public/browser/navigation_controller.h"
13 #include "ui/base/window_open_disposition.h"
15 class GURL;
16 struct FrameHostMsg_BeginNavigation_Params;
17 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
18 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
20 namespace base {
21 class TimeTicks;
24 namespace content {
26 class FrameTreeNode;
27 class NavigationControllerImpl;
28 class NavigationEntryImpl;
29 class NavigationRequest;
30 class RenderFrameHostImpl;
31 class ResourceRequestBody;
32 class StreamHandle;
33 struct BeginNavigationParams;
34 struct CommonNavigationParams;
35 struct ResourceResponse;
37 // Implementations of this interface are responsible for performing navigations
38 // in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode
39 // objects that are using it and will be released once all nodes that use it are
40 // freed. The Navigator is bound to a single frame tree and cannot be used by
41 // multiple instances of FrameTree.
42 // TODO(nasko): Move all navigation methods, such as didStartProvisionalLoad
43 // from WebContentsImpl to this interface.
44 class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
45 public:
46 // Returns the delegate of this Navigator.
47 virtual NavigatorDelegate* GetDelegate();
49 // Returns the NavigationController associated with this Navigator.
50 virtual NavigationController* GetController();
52 // Notifications coming from the RenderFrameHosts ----------------------------
54 // The RenderFrameHostImpl started a provisional load.
55 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
56 const GURL& url,
57 bool is_transition_navigation) {};
59 // The RenderFrameHostImpl has failed a provisional load.
60 virtual void DidFailProvisionalLoadWithError(
61 RenderFrameHostImpl* render_frame_host,
62 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {};
64 // The RenderFrameHostImpl has failed to load the document.
65 virtual void DidFailLoadWithError(
66 RenderFrameHostImpl* render_frame_host,
67 const GURL& url,
68 int error_code,
69 const base::string16& error_description) {}
71 // The RenderFrameHostImpl has committed a navigation.
72 virtual void DidNavigate(
73 RenderFrameHostImpl* render_frame_host,
74 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
76 // Called by the NavigationController to cause the Navigator to navigate
77 // to the current pending entry. The NavigationController should be called
78 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
79 // The callbacks can be inside of this function, or at some future time.
81 // The entry has a PageID of -1 if newly created (corresponding to navigation
82 // to a new URL).
84 // If this method returns false, then the navigation is discarded (equivalent
85 // to calling DiscardPendingEntry on the NavigationController).
87 // TODO(nasko): Remove this method from the interface, since Navigator and
88 // NavigationController know about each other. This will be possible once
89 // initialization of Navigator and NavigationController is properly done.
90 virtual bool NavigateToPendingEntry(
91 FrameTreeNode* frame_tree_node,
92 NavigationController::ReloadType reload_type);
94 // Navigation requests -------------------------------------------------------
96 virtual base::TimeTicks GetCurrentLoadStart();
98 // The RenderFrameHostImpl has received a request to open a URL with the
99 // specified |disposition|.
100 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
101 const GURL& url,
102 SiteInstance* source_site_instance,
103 const Referrer& referrer,
104 ui::PageTransition page_transition,
105 WindowOpenDisposition disposition,
106 bool should_replace_current_entry,
107 bool user_gesture) {}
109 // The RenderFrameHostImpl wants to transfer the request to a new renderer.
110 // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
111 // before the transfer.
112 virtual void RequestTransferURL(
113 RenderFrameHostImpl* render_frame_host,
114 const GURL& url,
115 SiteInstance* source_site_instance,
116 const std::vector<GURL>& redirect_chain,
117 const Referrer& referrer,
118 ui::PageTransition page_transition,
119 WindowOpenDisposition disposition,
120 const GlobalRequestID& transferred_global_request_id,
121 bool should_replace_current_entry,
122 bool user_gesture) {}
124 // PlzNavigate
125 // Called after receiving a BeforeUnloadACK IPC from the renderer. If
126 // |frame_tree_node| has a NavigationRequest waiting for the renderer
127 // response, then the request is either started or canceled, depending on the
128 // value of |proceed|.
129 virtual void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node,
130 bool proceed) {}
132 // PlzNavigate
133 // Used to start a new renderer-initiated navigation, following a
134 // BeginNavigation IPC from the renderer.
135 virtual void OnBeginNavigation(
136 FrameTreeNode* frame_tree_node,
137 const CommonNavigationParams& common_params,
138 const BeginNavigationParams& begin_params,
139 scoped_refptr<ResourceRequestBody> body);
141 // PlzNavigate
142 // Signal |render_frame_host| that a navigation is ready to commit (the
143 // response to the navigation request has been received).
144 virtual void CommitNavigation(FrameTreeNode* frame_tree_node,
145 ResourceResponse* response,
146 scoped_ptr<StreamHandle> body);
148 // PlzNavigate
149 // Called when a NavigationRequest for |frame_tree_node| failed. An
150 // appropriate RenderFrameHost should be selected and asked to show an error
151 // page. |has_stale_copy_in_cache| is true if there is a stale copy of the
152 // unreachable page in cache.
153 virtual void FailedNavigation(FrameTreeNode* frame_tree_node,
154 bool has_stale_copy_in_cache,
155 int error_code) {}
157 // PlzNavigate
158 // Cancel a NavigationRequest for |frame_tree_node|. Called when
159 // |frame_tree_node| is destroyed.
160 virtual void CancelNavigation(FrameTreeNode* frame_tree_node) {}
162 // Called when the network stack started handling the navigation request
163 // so that the |timestamp| when it happened can be recorded into an histogram.
164 // The |url| is used to verify we're tracking the correct navigation.
165 // TODO(carlosk): once PlzNavigate is the only navigation implementation
166 // remove the URL parameter and rename this method to better suit its naming
167 // conventions.
168 virtual void LogResourceRequestTime(
169 base::TimeTicks timestamp, const GURL& url) {};
171 // Called to record the time it took to execute the before unload hook for the
172 // current navigation.
173 virtual void LogBeforeUnloadTime(
174 const base::TimeTicks& renderer_before_unload_start_time,
175 const base::TimeTicks& renderer_before_unload_end_time) {}
177 // PlzNavigate
178 // Returns whether there is an ongoing navigation waiting for the BeforeUnload
179 // event to execute in the renderer process.
180 virtual bool IsWaitingForBeforeUnloadACK(FrameTreeNode* frame_tree_node);
182 protected:
183 friend class base::RefCounted<Navigator>;
184 virtual ~Navigator() {}
187 } // namespace content
189 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_