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 has committed a navigation.
62 virtual void DidNavigate(
63 RenderFrameHostImpl* render_frame_host,
64 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {}
66 // Called by the NavigationController to cause the Navigator to navigate
67 // to the current pending entry. The NavigationController should be called
68 // back with RendererDidNavigate on success or DiscardPendingEntry on failure.
69 // The callbacks can be inside of this function, or at some future time.
71 // The entry has a PageID of -1 if newly created (corresponding to navigation
74 // If this method returns false, then the navigation is discarded (equivalent
75 // to calling DiscardPendingEntry on the NavigationController).
77 // TODO(nasko): Remove this method from the interface, since Navigator and
78 // NavigationController know about each other. This will be possible once
79 // initialization of Navigator and NavigationController is properly done.
80 virtual bool NavigateToPendingEntry(
81 RenderFrameHostImpl* render_frame_host,
82 NavigationController::ReloadType reload_type);
85 // Navigation requests -------------------------------------------------------
87 virtual base::TimeTicks GetCurrentLoadStart();
89 // The RenderFrameHostImpl has received a request to open a URL with the
90 // specified |disposition|.
91 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
93 const Referrer& referrer,
94 WindowOpenDisposition disposition,
95 bool should_replace_current_entry,
98 // The RenderFrameHostImpl wants to transfer the request to a new renderer.
99 // |redirect_chain| contains any redirect URLs (excluding |url|) that happened
100 // before the transfer.
101 virtual void RequestTransferURL(
102 RenderFrameHostImpl* render_frame_host,
104 const std::vector<GURL>& redirect_chain,
105 const Referrer& referrer,
106 ui::PageTransition page_transition,
107 WindowOpenDisposition disposition,
108 const GlobalRequestID& transferred_global_request_id,
109 bool should_replace_current_entry,
110 bool user_gesture) {}
113 // Signal |render_frame_host| that a navigation is ready to commit (the
114 // response to the navigation request has been received).
115 virtual void CommitNavigation(RenderFrameHostImpl* render_frame_host,
116 const NavigationBeforeCommitInfo& info) {};
119 friend class base::RefCounted<Navigator>;
120 virtual ~Navigator() {}
123 } // namespace content
125 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_