cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / browser / frame_host / navigator.h
blob5063faf20e525e5bd01b3ea71cf92b5dca876cfd
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/common/content_export.h"
11 #include "content/public/browser/navigation_controller.h"
12 #include "ui/base/window_open_disposition.h"
14 class GURL;
15 struct FrameHostMsg_BeginNavigation_Params;
16 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
17 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
19 namespace base {
20 class TimeTicks;
23 namespace content {
25 class FrameTreeNode;
26 class NavigationControllerImpl;
27 class NavigationEntryImpl;
28 class NavigationRequest;
29 class NavigatorDelegate;
30 class RenderFrameHostImpl;
31 class StreamHandle;
32 struct CommonNavigationParams;
33 struct ResourceResponse;
35 // Implementations of this interface are responsible for performing navigations
36 // in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode
37 // objects that are using it and will be released once all nodes that use it are
38 // freed. The Navigator is bound to a single frame tree and cannot be used by
39 // multiple instances of FrameTree.
40 // TODO(nasko): Move all navigation methods, such as didStartProvisionalLoad
41 // from WebContentsImpl to this interface.
42 class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
43 public:
44 // Returns the NavigationController associated with this Navigator.
45 virtual NavigationController* GetController();
47 // Notifications coming from the RenderFrameHosts ----------------------------
49 // The RenderFrameHostImpl started a provisional load.
50 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
51 const GURL& url,
52 bool is_transition_navigation) {};
54 // The RenderFrameHostImpl has failed a provisional load.
55 virtual void DidFailProvisionalLoadWithError(
56 RenderFrameHostImpl* render_frame_host,
57 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {};
59 // The RenderFrameHostImpl has failed to load the document.
60 virtual void DidFailLoadWithError(
61 RenderFrameHostImpl* render_frame_host,
62 const GURL& url,
63 int error_code,
64 const base::string16& error_description) {}
66 // The RenderFrameHostImpl has committed a navigation.
67 virtual void DidNavigate(
68 RenderFrameHostImpl* render_frame_host,
69 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
71 // Called by the NavigationController to cause the Navigator to navigate
72 // to the current pending entry. The NavigationController should be called
73 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
74 // The callbacks can be inside of this function, or at some future time.
76 // The entry has a PageID of -1 if newly created (corresponding to navigation
77 // to a new URL).
79 // If this method returns false, then the navigation is discarded (equivalent
80 // to calling DiscardPendingEntry on the NavigationController).
82 // TODO(nasko): Remove this method from the interface, since Navigator and
83 // NavigationController know about each other. This will be possible once
84 // initialization of Navigator and NavigationController is properly done.
85 virtual bool NavigateToPendingEntry(
86 RenderFrameHostImpl* render_frame_host,
87 NavigationController::ReloadType reload_type);
90 // Navigation requests -------------------------------------------------------
92 virtual base::TimeTicks GetCurrentLoadStart();
94 // The RenderFrameHostImpl has received a request to open a URL with the
95 // specified |disposition|.
96 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
97 const GURL& url,
98 const Referrer& referrer,
99 WindowOpenDisposition disposition,
100 bool should_replace_current_entry,
101 bool user_gesture) {}
103 // The RenderFrameHostImpl wants to transfer the request to a new renderer.
104 // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
105 // before the transfer.
106 virtual void RequestTransferURL(
107 RenderFrameHostImpl* render_frame_host,
108 const GURL& url,
109 const std::vector<GURL>& redirect_chain,
110 const Referrer& referrer,
111 ui::PageTransition page_transition,
112 WindowOpenDisposition disposition,
113 const GlobalRequestID& transferred_global_request_id,
114 bool should_replace_current_entry,
115 bool user_gesture) {}
117 // PlzNavigate: Used to start a navigation. OnBeginNavigation is called
118 // directly by RequestNavigation when there is no live renderer. Otherwise, it
119 // is called following a BeginNavigation IPC from the renderer (which in
120 // browser-initiated navigation also happens after RequestNavigation has been
121 // called).
122 virtual void OnBeginNavigation(
123 FrameTreeNode* frame_tree_node,
124 const FrameHostMsg_BeginNavigation_Params& params,
125 const CommonNavigationParams& common_params) {}
127 // PlzNavigate
128 // Signal |render_frame_host| that a navigation is ready to commit (the
129 // response to the navigation request has been received).
130 virtual void CommitNavigation(FrameTreeNode* frame_tree_node,
131 ResourceResponse* response,
132 scoped_ptr<StreamHandle> body);
134 // PlzNavigate
135 // Cancel a NavigationRequest for |frame_tree_node|. Called when
136 // |frame_tree_node| is destroyed.
137 virtual void CancelNavigation(FrameTreeNode* frame_tree_node) {}
139 // Called when the first resource request for a given navigation is executed
140 // so that it can be tracked into an histogram.
141 virtual void LogResourceRequestTime(
142 base::TimeTicks timestamp, const GURL& url) {};
144 // Called to record the time it took to execute the before unload hook for the
145 // current navigation.
146 virtual void LogBeforeUnloadTime(
147 const base::TimeTicks& renderer_before_unload_start_time,
148 const base::TimeTicks& renderer_before_unload_end_time) {}
150 protected:
151 friend class base::RefCounted<Navigator>;
152 virtual ~Navigator() {}
155 } // namespace content
157 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_