navigator_impl.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
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 13struct FrameMsg_Navigate_Params; 14 15namespace content { 16 17class NavigationControllerImpl; 18class NavigatorDelegate; 19struct LoadCommittedDetails; 20 21// This class is an implementation of Navigator, responsible for managing 22// navigations in regular browser tabs. 23class 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 DidRedirectProvisionalLoad( 50 RenderFrameHostImpl* render_frame_host, 51 int32 page_id, 52 const GURL& source_url, 53 const GURL& target_url) OVERRIDE; 54 virtual void DidNavigate( 55 RenderFrameHostImpl* render_frame_host, 56 const FrameHostMsg_DidCommitProvisionalLoad_Params& 57 input_params) OVERRIDE; 58 virtual bool NavigateToPendingEntry( 59 RenderFrameHostImpl* render_frame_host, 60 NavigationController::ReloadType reload_type) OVERRIDE; 61 virtual base::TimeTicks GetCurrentLoadStart() OVERRIDE; 62 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host, 63 const GURL& url, 64 const Referrer& referrer, 65 WindowOpenDisposition disposition, 66 bool should_replace_current_entry, 67 bool user_gesture) OVERRIDE; 68 virtual void RequestTransferURL( 69 RenderFrameHostImpl* render_frame_host, 70 const GURL& url, 71 const std::vector<GURL>& redirect_chain, 72 const Referrer& referrer, 73 PageTransition page_transition, 74 WindowOpenDisposition disposition, 75 const GlobalRequestID& transferred_global_request_id, 76 bool should_replace_current_entry, 77 bool user_gesture) OVERRIDE; 78 virtual void CommitNavigation( 79 RenderFrameHostImpl* render_frame_host, 80 const NavigationBeforeCommitInfo& info) OVERRIDE; 81 82 private: 83 virtual ~NavigatorImpl() {} 84 85 // Navigates to the given entry, which must be the pending entry. Private 86 // because all callers should use NavigateToPendingEntry. 87 bool NavigateToEntry( 88 RenderFrameHostImpl* render_frame_host, 89 const NavigationEntryImpl& entry, 90 NavigationController::ReloadType reload_type); 91 92 bool ShouldAssignSiteForURL(const GURL& url); 93 94 void CheckWebUIRendererDoesNotDisplayNormalURL( 95 RenderFrameHostImpl* render_frame_host, 96 const GURL& url); 97 98 // The NavigationController that will keep track of session history for all 99 // RenderFrameHost objects using this NavigatorImpl. 100 // TODO(nasko): Move ownership of the NavigationController from 101 // WebContentsImpl to this class. 102 NavigationControllerImpl* controller_; 103 104 // Used to notify the object embedding this Navigator about navigation 105 // events. Can be NULL in tests. 106 NavigatorDelegate* delegate_; 107 108 // System time at which the current load was started. 109 base::TimeTicks current_load_start_; 110 111 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl); 112}; 113 114} // namespace content 115 116#endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_ 117