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_DidCommitProvisionalLoad_Params
;
15 struct FrameHostMsg_DidFailProvisionalLoadWithError_Params
;
23 class NavigationControllerImpl
;
24 class NavigationEntryImpl
;
25 class NavigatorDelegate
;
26 class RenderFrameHostImpl
;
28 // Implementations of this interface are responsible for performing navigations
29 // in a node of the FrameTree. Its lifetime is bound to all FrameTreeNode
30 // objects that are using it and will be released once all nodes that use it are
31 // freed. The Navigator is bound to a single frame tree and cannot be used by
32 // multiple instances of FrameTree.
33 // TODO(nasko): Move all navigation methods, such as didStartProvisionalLoad
34 // from WebContentsImpl to this interface.
35 class CONTENT_EXPORT Navigator
: public base::RefCounted
<Navigator
> {
37 // Returns the NavigationController associated with this Navigator.
38 virtual NavigationController
* GetController();
41 // Notifications coming from the RenderFrameHosts ----------------------------
43 // The RenderFrameHostImpl started a provisional load.
44 virtual void DidStartProvisionalLoad(RenderFrameHostImpl
* render_frame_host
,
45 int parent_routing_id
,
48 // The RenderFrameHostImpl has failed a provisional load.
49 virtual void DidFailProvisionalLoadWithError(
50 RenderFrameHostImpl
* render_frame_host
,
51 const FrameHostMsg_DidFailProvisionalLoadWithError_Params
& params
) {};
53 // The RenderFrameHostImpl has failed to load the document.
54 virtual void DidFailLoadWithError(
55 RenderFrameHostImpl
* render_frame_host
,
58 const base::string16
& error_description
) {}
60 // The RenderFrameHostImpl processed a redirect during a provisional load.
62 // TODO(creis): Remove this method and have the pre-rendering code listen to
63 // WebContentsObserver::DidGetRedirectForResourceRequest instead.
64 // See http://crbug.com/78512.
65 virtual void DidRedirectProvisionalLoad(
66 RenderFrameHostImpl
* render_frame_host
,
68 const GURL
& source_url
,
69 const GURL
& target_url
) {}
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
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 RenderFrameHostImpl
* render_frame_host
,
92 NavigationController::ReloadType reload_type
);
95 // Navigation requests -------------------------------------------------------
97 virtual base::TimeTicks
GetCurrentLoadStart();
99 // The RenderFrameHostImpl has received a request to open a URL with the
100 // specified |disposition|.
101 virtual void RequestOpenURL(RenderFrameHostImpl
* render_frame_host
,
103 const Referrer
& referrer
,
104 WindowOpenDisposition disposition
,
105 bool should_replace_current_entry
,
106 bool user_gesture
) {}
108 // The RenderFrameHostImpl wants to transfer the request to a new renderer.
109 // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
110 // before the transfer.
111 virtual void RequestTransferURL(
112 RenderFrameHostImpl
* render_frame_host
,
114 const std::vector
<GURL
>& redirect_chain
,
115 const Referrer
& referrer
,
116 PageTransition page_transition
,
117 WindowOpenDisposition disposition
,
118 const GlobalRequestID
& transferred_global_request_id
,
119 bool should_replace_current_entry
,
120 bool user_gesture
) {}
123 friend class base::RefCounted
<Navigator
>;
124 virtual ~Navigator() {}
127 } // namespace content
129 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_