Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / browser / frame_host / navigator.h
blobb47654839f0f9d70b0729f2c6284d931e1a4ed7b
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 "content/common/content_export.h"
10 #include "content/public/browser/navigation_controller.h"
11 #include "ui/base/window_open_disposition.h"
13 class GURL;
14 struct FrameHostMsg_BeginNavigation_Params;
15 struct FrameHostMsg_DidCommitProvisionalLoad_Params;
16 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params;
18 namespace base {
19 class TimeTicks;
22 namespace content {
24 class NavigationControllerImpl;
25 class NavigationEntryImpl;
26 class NavigatorDelegate;
27 class RenderFrameHostImpl;
28 struct NavigationBeforeCommitInfo;
30 // Implementations of this interface are responsible for performing navigations
31 // in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode
32 // objects that are using it and will be released once all nodes that use it are
33 // freed. The Navigator is bound to a single frame tree and cannot be used by
34 // multiple instances of FrameTree.
35 // TODO(nasko): Move all navigation methods, such as didStartProvisionalLoad
36 // from WebContentsImpl to this interface.
37 class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> {
38 public:
39 // Returns the NavigationController associated with this Navigator.
40 virtual NavigationController* GetController();
42 // Notifications coming from the RenderFrameHosts ----------------------------
44 // The RenderFrameHostImpl started a provisional load.
45 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
46 const GURL& url,
47 bool is_transition_navigation) {};
49 // The RenderFrameHostImpl has failed a provisional load.
50 virtual void DidFailProvisionalLoadWithError(
51 RenderFrameHostImpl* render_frame_host,
52 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {};
54 // The RenderFrameHostImpl has failed to load the document.
55 virtual void DidFailLoadWithError(
56 RenderFrameHostImpl* render_frame_host,
57 const GURL& url,
58 int error_code,
59 const base::string16& error_description) {}
61 // The RenderFrameHostImpl processed a redirect during a provisional load.
63 // TODO(creis): Remove this method and have the pre-rendering code listen to
64 // WebContentsObserver::DidGetRedirectForResourceRequest instead.
65 // See http://crbug.com/78512.
66 virtual void DidRedirectProvisionalLoad(
67 RenderFrameHostImpl* render_frame_host,
68 int32 page_id,
69 const GURL& source_url,
70 const GURL& target_url) {}
72 // The RenderFrameHostImpl has committed a navigation.
73 virtual void DidNavigate(
74 RenderFrameHostImpl* render_frame_host,
75 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
77 // Called by the NavigationController to cause the Navigator to navigate
78 // to the current pending entry. The NavigationController should be called
79 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
80 // The callbacks can be inside of this function, or at some future time.
82 // The entry has a PageID of -1 if newly created (corresponding to navigation
83 // to a new URL).
85 // If this method returns false, then the navigation is discarded (equivalent
86 // to calling DiscardPendingEntry on the NavigationController).
88 // TODO(nasko): Remove this method from the interface, since Navigator and
89 // NavigationController know about each other. This will be possible once
90 // initialization of Navigator and NavigationController is properly done.
91 virtual bool NavigateToPendingEntry(
92 RenderFrameHostImpl* render_frame_host,
93 NavigationController::ReloadType reload_type);
96 // Navigation requests -------------------------------------------------------
98 virtual base::TimeTicks GetCurrentLoadStart();
100 // The RenderFrameHostImpl has received a request to open a URL with the
101 // specified |disposition|.
102 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
103 const GURL& url,
104 const Referrer& referrer,
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 const std::vector<GURL>& redirect_chain,
116 const Referrer& referrer,
117 PageTransition page_transition,
118 WindowOpenDisposition disposition,
119 const GlobalRequestID& transferred_global_request_id,
120 bool should_replace_current_entry,
121 bool user_gesture) {}
123 // PlzNavigate
124 // Signal |render_frame_host| that a navigation is ready to commit (the
125 // response to the navigation request has been received).
126 virtual void CommitNavigation(RenderFrameHostImpl* render_frame_host,
127 const NavigationBeforeCommitInfo& info) {};
129 protected:
130 friend class base::RefCounted<Navigator>;
131 virtual ~Navigator() {}
134 } // namespace content
136 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_