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"
14 struct FrameHostMsg_BeginNavigation_Params
;
15 struct FrameHostMsg_DidCommitProvisionalLoad_Params
;
16 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params
;
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
> {
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
,
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
,
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
,
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
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
,
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
,
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
) {}
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
) {};
130 friend class base::RefCounted
<Navigator
>;
131 virtual ~Navigator() {}
134 } // namespace content
136 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_