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_IMPL_H_ 6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_ 7 8 #include "base/memory/ref_counted.h" 9 #include "content/browser/frame_host/navigation_controller_impl.h" 10 #include "content/browser/frame_host/navigator.h" 11 #include "content/common/content_export.h" 12 13 struct FrameMsg_Navigate_Params; 14 15 namespace content { 16 17 class NavigationControllerImpl; 18 class NavigatorDelegate; 19 struct LoadCommittedDetails; 20 21 // This class is an implementation of Navigator, responsible for managing 22 // navigations in regular browser tabs. 23 class CONTENT_EXPORT NavigatorImpl : public Navigator { 24 public: 25 NavigatorImpl(NavigationControllerImpl* navigation_controller, 26 NavigatorDelegate* delegate); 27 28 // Fills in |params| based on the content of |entry|. 29 static void MakeNavigateParams(const NavigationEntryImpl& entry, 30 const NavigationControllerImpl& controller, 31 NavigationController::ReloadType reload_type, 32 base::TimeTicks navigation_start, 33 FrameMsg_Navigate_Params* params); 34 35 // Navigator implementation. 36 virtual NavigationController* GetController() OVERRIDE; 37 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host, 38 const GURL& url, 39 bool is_transition_navigation) OVERRIDE; 40 virtual void DidFailProvisionalLoadWithError( 41 RenderFrameHostImpl* render_frame_host, 42 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params) 43 OVERRIDE; 44 virtual void DidFailLoadWithError( 45 RenderFrameHostImpl* render_frame_host, 46 const GURL& url, 47 int error_code, 48 const base::string16& error_description) OVERRIDE; 49 virtual void DidNavigate( 50 RenderFrameHostImpl* render_frame_host, 51 const FrameHostMsg_DidCommitProvisionalLoad_Params& 52 input_params) OVERRIDE; 53 virtual bool NavigateToPendingEntry( 54 RenderFrameHostImpl* render_frame_host, 55 NavigationController::ReloadType reload_type) OVERRIDE; 56 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host, 57 const GURL& url, 58 const Referrer& referrer, 59 WindowOpenDisposition disposition, 60 bool should_replace_current_entry, 61 bool user_gesture) OVERRIDE; 62 virtual void RequestTransferURL( 63 RenderFrameHostImpl* render_frame_host, 64 const GURL& url, 65 const std::vector<GURL>& redirect_chain, 66 const Referrer& referrer, 67 ui::PageTransition page_transition, 68 WindowOpenDisposition disposition, 69 const GlobalRequestID& transferred_global_request_id, 70 bool should_replace_current_entry, 71 bool user_gesture) OVERRIDE; 72 virtual void CommitNavigation( 73 RenderFrameHostImpl* render_frame_host, 74 const NavigationBeforeCommitInfo& info) OVERRIDE; 75 76 private: ~NavigatorImpl()77 virtual ~NavigatorImpl() {} 78 79 // Navigates to the given entry, which must be the pending entry. Private 80 // because all callers should use NavigateToPendingEntry. 81 bool NavigateToEntry( 82 RenderFrameHostImpl* render_frame_host, 83 const NavigationEntryImpl& entry, 84 NavigationController::ReloadType reload_type); 85 86 bool ShouldAssignSiteForURL(const GURL& url); 87 88 void CheckWebUIRendererDoesNotDisplayNormalURL( 89 RenderFrameHostImpl* render_frame_host, 90 const GURL& url); 91 92 // The NavigationController that will keep track of session history for all 93 // RenderFrameHost objects using this NavigatorImpl. 94 // TODO(nasko): Move ownership of the NavigationController from 95 // WebContentsImpl to this class. 96 NavigationControllerImpl* controller_; 97 98 // Used to notify the object embedding this Navigator about navigation 99 // events. Can be NULL in tests. 100 NavigatorDelegate* delegate_; 101 102 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); 103 }; 104 105 } // namespace content 106 107 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_ 108