navigator.h revision 116680a4aac90f2aa7413d9095a592090648e557
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. 4 5#ifndef CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_ 6#define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_ 7 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" 12 13class GURL; 14struct FrameHostMsg_DidCommitProvisionalLoad_Params; 15struct FrameHostMsg_DidFailProvisionalLoadWithError_Params; 16 17namespace base { 18class TimeTicks; 19} 20 21namespace content { 22 23class NavigationControllerImpl; 24class NavigationEntryImpl; 25class NavigatorDelegate; 26class RenderFrameHostImpl; 27 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. 35class CONTENT_EXPORT Navigator : public base::RefCounted<Navigator> { 36 public: 37 // Returns the NavigationController associated with this Navigator. 38 virtual NavigationController* GetController(); 39 40 41 // Notifications coming from the RenderFrameHosts ---------------------------- 42 43 // The RenderFrameHostImpl started a provisional load. 44 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host, 45 const GURL& url) {}; 46 47 // The RenderFrameHostImpl has failed a provisional load. 48 virtual void DidFailProvisionalLoadWithError( 49 RenderFrameHostImpl* render_frame_host, 50 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) {}; 51 52 // The RenderFrameHostImpl has failed to load the document. 53 virtual void DidFailLoadWithError( 54 RenderFrameHostImpl* render_frame_host, 55 const GURL& url, 56 int error_code, 57 const base::string16& error_description) {} 58 59 // The RenderFrameHostImpl processed a redirect during a provisional load. 60 // 61 // TODO(creis): Remove this method and have the pre-rendering code listen to 62 // WebContentsObserver::DidGetRedirectForResourceRequest instead. 63 // See http://crbug.com/78512. 64 virtual void DidRedirectProvisionalLoad( 65 RenderFrameHostImpl* render_frame_host, 66 int32 page_id, 67 const GURL& source_url, 68 const GURL& target_url) {} 69 70 // The RenderFrameHostImpl has committed a navigation. 71 virtual void DidNavigate( 72 RenderFrameHostImpl* render_frame_host, 73 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) {} 74 75 // Called by the NavigationController to cause the Navigator to navigate 76 // to the current pending entry. The NavigationController should be called 77 // back with RendererDidNavigate on success or DiscardPendingEntry on failure. 78 // The callbacks can be inside of this function, or at some future time. 79 // 80 // The entry has a PageID of -1 if newly created (corresponding to navigation 81 // to a new URL). 82 // 83 // If this method returns false, then the navigation is discarded (equivalent 84 // to calling DiscardPendingEntry on the NavigationController). 85 // 86 // TODO(nasko): Remove this method from the interface, since Navigator and 87 // NavigationController know about each other. This will be possible once 88 // initialization of Navigator and NavigationController is properly done. 89 virtual bool NavigateToPendingEntry( 90 RenderFrameHostImpl* render_frame_host, 91 NavigationController::ReloadType reload_type); 92 93 94 // Navigation requests ------------------------------------------------------- 95 96 virtual base::TimeTicks GetCurrentLoadStart(); 97 98 // The RenderFrameHostImpl has received a request to open a URL with the 99 // specified |disposition|. 100 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host, 101 const GURL& url, 102 const Referrer& referrer, 103 WindowOpenDisposition disposition, 104 bool should_replace_current_entry, 105 bool user_gesture) {} 106 107 // The RenderFrameHostImpl wants to transfer the request to a new renderer. 108 // |redirect_chain| contains any redirect URLs (excluding |url|) that happened 109 // before the transfer. 110 virtual void RequestTransferURL( 111 RenderFrameHostImpl* render_frame_host, 112 const GURL& url, 113 const std::vector<GURL>& redirect_chain, 114 const Referrer& referrer, 115 PageTransition page_transition, 116 WindowOpenDisposition disposition, 117 const GlobalRequestID& transferred_global_request_id, 118 bool should_replace_current_entry, 119 bool user_gesture) {} 120 121 protected: 122 friend class base::RefCounted<Navigator>; 123 virtual ~Navigator() {} 124}; 125 126} // namespace content 127 128#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_H_ 129