Pass ResourceResponse and StreamHandle in CommitNavigation.
[chromium-blink-merge.git] / content / browser / frame_host / navigator_impl.h
blobf5c09ba7d2941273e64853384ad0447480833bb2
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_IMPL_H_
6 #define CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_
8 #include "base/containers/scoped_ptr_hash_map.h"
9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/time/time.h"
12 #include "base/tuple.h"
13 #include "content/browser/frame_host/navigation_controller_impl.h"
14 #include "content/browser/frame_host/navigator.h"
15 #include "content/common/content_export.h"
16 #include "url/gurl.h"
18 class GURL;
19 struct FrameMsg_Navigate_Params;
21 namespace content {
23 class NavigationControllerImpl;
24 class NavigatorDelegate;
25 class NavigatorTest;
26 struct LoadCommittedDetails;
27 struct CommitNavigationParams;
28 struct CommonNavigationParams;
29 struct RequestNavigationParams;
31 // This class is an implementation of Navigator, responsible for managing
32 // navigations in regular browser tabs.
33 class CONTENT_EXPORT NavigatorImpl : public Navigator {
34 public:
35 NavigatorImpl(NavigationControllerImpl* navigation_controller,
36 NavigatorDelegate* delegate);
38 // Navigator implementation.
39 virtual NavigationController* GetController() override;
40 virtual void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
41 const GURL& url,
42 bool is_transition_navigation) override;
43 virtual void DidFailProvisionalLoadWithError(
44 RenderFrameHostImpl* render_frame_host,
45 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
46 override;
47 virtual void DidFailLoadWithError(
48 RenderFrameHostImpl* render_frame_host,
49 const GURL& url,
50 int error_code,
51 const base::string16& error_description) override;
52 virtual void DidNavigate(
53 RenderFrameHostImpl* render_frame_host,
54 const FrameHostMsg_DidCommitProvisionalLoad_Params&
55 input_params) override;
56 virtual bool NavigateToPendingEntry(
57 RenderFrameHostImpl* render_frame_host,
58 NavigationController::ReloadType reload_type) override;
59 virtual void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
60 const GURL& url,
61 const Referrer& referrer,
62 WindowOpenDisposition disposition,
63 bool should_replace_current_entry,
64 bool user_gesture) override;
65 virtual void RequestTransferURL(
66 RenderFrameHostImpl* render_frame_host,
67 const GURL& url,
68 const std::vector<GURL>& redirect_chain,
69 const Referrer& referrer,
70 ui::PageTransition page_transition,
71 WindowOpenDisposition disposition,
72 const GlobalRequestID& transferred_global_request_id,
73 bool should_replace_current_entry,
74 bool user_gesture) override;
75 virtual void OnBeginNavigation(
76 FrameTreeNode* frame_tree_node,
77 const FrameHostMsg_BeginNavigation_Params& params,
78 const CommonNavigationParams& common_params) override;
79 virtual void CommitNavigation(FrameTreeNode* frame_tree_node,
80 ResourceResponse* response,
81 scoped_ptr<StreamHandle> body) override;
82 virtual void LogResourceRequestTime(
83 base::TimeTicks timestamp, const GURL& url) override;
84 virtual void CancelNavigation(FrameTreeNode* frame_tree_node) override;
86 private:
87 friend class NavigatorTest;
88 virtual ~NavigatorImpl();
90 // Navigates to the given entry, which must be the pending entry. Private
91 // because all callers should use NavigateToPendingEntry.
92 bool NavigateToEntry(
93 RenderFrameHostImpl* render_frame_host,
94 const NavigationEntryImpl& entry,
95 NavigationController::ReloadType reload_type);
97 bool ShouldAssignSiteForURL(const GURL& url);
99 void CheckWebUIRendererDoesNotDisplayNormalURL(
100 RenderFrameHostImpl* render_frame_host,
101 const GURL& url);
103 // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to
104 // navigate. If no live renderer is present, then the navigation request will
105 // be sent directly to the ResourceDispatcherHost.
106 bool RequestNavigation(FrameTreeNode* frame_tree_node,
107 const NavigationEntryImpl& entry,
108 NavigationController::ReloadType reload_type,
109 base::TimeTicks navigation_start);
111 // The NavigationController that will keep track of session history for all
112 // RenderFrameHost objects using this NavigatorImpl.
113 // TODO(nasko): Move ownership of the NavigationController from
114 // WebContentsImpl to this class.
115 NavigationControllerImpl* controller_;
117 // Used to notify the object embedding this Navigator about navigation
118 // events. Can be NULL in tests.
119 NavigatorDelegate* delegate_;
121 // The start time and URL for latest navigation request, used for feeding a
122 // few histograms under the Navigation group.
123 Tuple2<base::TimeTicks, GURL> navigation_start_time_and_url;
125 // PlzNavigate: used to track the various ongoing NavigationRequests in the
126 // different FrameTreeNodes, based on the frame_tree_node_id.
127 typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
128 NavigationRequestMap navigation_request_map_;
130 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
133 } // namespace content
135 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_