cc: Make picture pile base thread safe.
[chromium-blink-merge.git] / content / browser / frame_host / navigator_impl.h
blobe142b3fd1ffddc0178aec59e92aae5a7f8f3348c
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 NavigationController* GetController() override;
40 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
41 const GURL& url,
42 bool is_transition_navigation) override;
43 void DidFailProvisionalLoadWithError(
44 RenderFrameHostImpl* render_frame_host,
45 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
46 override;
47 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
48 const GURL& url,
49 int error_code,
50 const base::string16& error_description) override;
51 void DidNavigate(RenderFrameHostImpl* render_frame_host,
52 const FrameHostMsg_DidCommitProvisionalLoad_Params&
53 input_params) override;
54 bool NavigateToPendingEntry(
55 RenderFrameHostImpl* render_frame_host,
56 NavigationController::ReloadType reload_type) override;
57 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
58 const GURL& url,
59 const Referrer& referrer,
60 WindowOpenDisposition disposition,
61 bool should_replace_current_entry,
62 bool user_gesture) override;
63 void RequestTransferURL(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 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
73 const FrameHostMsg_BeginNavigation_Params& params,
74 const CommonNavigationParams& common_params) override;
75 void CommitNavigation(FrameTreeNode* frame_tree_node,
76 ResourceResponse* response,
77 scoped_ptr<StreamHandle> body) override;
78 void LogResourceRequestTime(base::TimeTicks timestamp,
79 const GURL& url) override;
80 void LogBeforeUnloadTime(
81 const base::TimeTicks& renderer_before_unload_start_time,
82 const base::TimeTicks& renderer_before_unload_end_time) override;
83 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
85 private:
86 // Holds data used to track browser side navigation metrics.
87 struct NavigationMetricsData;
89 friend class NavigatorTest;
90 ~NavigatorImpl() override;
92 // Navigates to the given entry, which must be the pending entry. Private
93 // because all callers should use NavigateToPendingEntry.
94 bool NavigateToEntry(
95 RenderFrameHostImpl* render_frame_host,
96 const NavigationEntryImpl& entry,
97 NavigationController::ReloadType reload_type);
99 bool ShouldAssignSiteForURL(const GURL& url);
101 void CheckWebUIRendererDoesNotDisplayNormalURL(
102 RenderFrameHostImpl* render_frame_host,
103 const GURL& url);
105 // PlzNavigate: sends a RequestNavigation IPC to the renderer to ask it to
106 // navigate. If no live renderer is present, then the navigation request will
107 // be sent directly to the ResourceDispatcherHost.
108 bool RequestNavigation(FrameTreeNode* frame_tree_node,
109 const NavigationEntryImpl& entry,
110 NavigationController::ReloadType reload_type,
111 base::TimeTicks navigation_start);
113 void RecordNavigationMetrics(
114 const LoadCommittedDetails& details,
115 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
116 SiteInstance* site_instance);
118 // The NavigationController that will keep track of session history for all
119 // RenderFrameHost objects using this NavigatorImpl.
120 // TODO(nasko): Move ownership of the NavigationController from
121 // WebContentsImpl to this class.
122 NavigationControllerImpl* controller_;
124 // Used to notify the object embedding this Navigator about navigation
125 // events. Can be NULL in tests.
126 NavigatorDelegate* delegate_;
128 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
130 // PlzNavigate: used to track the various ongoing NavigationRequests in the
131 // different FrameTreeNodes, based on the frame_tree_node_id.
132 typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
133 NavigationRequestMap navigation_request_map_;
135 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
138 } // namespace content
140 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_