[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / browser / frame_host / navigator_impl.h
blob8b52dfb5adc08c64fb66bb532d7cd85cb7d4b153
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 "content/browser/frame_host/navigation_controller_impl.h"
13 #include "content/browser/frame_host/navigator.h"
14 #include "content/common/content_export.h"
15 #include "url/gurl.h"
17 class GURL;
19 namespace content {
21 class NavigationControllerImpl;
22 class NavigatorDelegate;
23 class NavigatorTest;
24 struct LoadCommittedDetails;
25 struct CommitNavigationParams;
26 struct CommonNavigationParams;
27 struct RequestNavigationParams;
29 // This class is an implementation of Navigator, responsible for managing
30 // navigations in regular browser tabs.
31 class CONTENT_EXPORT NavigatorImpl : public Navigator {
32 public:
33 NavigatorImpl(NavigationControllerImpl* navigation_controller,
34 NavigatorDelegate* delegate);
36 // Navigator implementation.
37 NavigatorDelegate* GetDelegate() override;
38 NavigationController* GetController() override;
39 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
40 const GURL& url) override;
41 void DidFailProvisionalLoadWithError(
42 RenderFrameHostImpl* render_frame_host,
43 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
44 override;
45 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
46 const GURL& url,
47 int error_code,
48 const base::string16& error_description,
49 bool was_ignored_by_handler) override;
50 void DidNavigate(
51 RenderFrameHostImpl* render_frame_host,
52 const FrameHostMsg_DidCommitProvisionalLoad_Params& params) override;
53 bool NavigateToPendingEntry(FrameTreeNode* frame_tree_node,
54 const FrameNavigationEntry& frame_entry,
55 NavigationController::ReloadType reload_type,
56 bool is_same_document_history_load) override;
57 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
58 const GURL& url,
59 SiteInstance* source_site_instance,
60 const Referrer& referrer,
61 WindowOpenDisposition disposition,
62 bool should_replace_current_entry,
63 bool user_gesture) override;
64 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
65 const GURL& url,
66 SiteInstance* source_site_instance,
67 const std::vector<GURL>& redirect_chain,
68 const Referrer& referrer,
69 ui::PageTransition page_transition,
70 WindowOpenDisposition disposition,
71 const GlobalRequestID& transferred_global_request_id,
72 bool should_replace_current_entry,
73 bool user_gesture) override;
74 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
75 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
76 const CommonNavigationParams& common_params,
77 const BeginNavigationParams& begin_params,
78 scoped_refptr<ResourceRequestBody> body) override;
79 void CommitNavigation(FrameTreeNode* frame_tree_node,
80 ResourceResponse* response,
81 scoped_ptr<StreamHandle> body) override;
82 void FailedNavigation(FrameTreeNode* frame_tree_node,
83 bool has_stale_copy_in_cache,
84 int error_code) override;
85 void LogResourceRequestTime(base::TimeTicks timestamp,
86 const GURL& url) override;
87 void LogBeforeUnloadTime(
88 const base::TimeTicks& renderer_before_unload_start_time,
89 const base::TimeTicks& renderer_before_unload_end_time) override;
90 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
92 private:
93 // Holds data used to track browser side navigation metrics.
94 struct NavigationMetricsData;
96 friend class NavigatorTestWithBrowserSideNavigation;
97 ~NavigatorImpl() override;
99 // Navigates to the given entry, which must be the pending entry. Private
100 // because all callers should use NavigateToPendingEntry.
101 bool NavigateToEntry(FrameTreeNode* frame_tree_node,
102 const FrameNavigationEntry& frame_entry,
103 const NavigationEntryImpl& entry,
104 NavigationController::ReloadType reload_type,
105 bool is_same_document_history_load);
107 bool ShouldAssignSiteForURL(const GURL& url);
109 void CheckWebUIRendererDoesNotDisplayNormalURL(
110 RenderFrameHostImpl* render_frame_host,
111 const GURL& url);
113 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
114 // to execute the beforeUnload event. Otherwise, the navigation request will
115 // be started.
116 void RequestNavigation(FrameTreeNode* frame_tree_node,
117 const GURL& dest_url,
118 const Referrer& dest_referrer,
119 const FrameNavigationEntry& frame_entry,
120 const NavigationEntryImpl& entry,
121 NavigationController::ReloadType reload_type,
122 bool is_same_document_history_load,
123 base::TimeTicks navigation_start);
125 void RecordNavigationMetrics(
126 const LoadCommittedDetails& details,
127 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
128 SiteInstance* site_instance);
130 // Called when a navigation has started in a main frame, to update the pending
131 // NavigationEntry if the controller does not currently have a
132 // browser-initiated one.
133 void DidStartMainFrameNavigation(const GURL& url,
134 SiteInstanceImpl* site_instance);
136 // The NavigationController that will keep track of session history for all
137 // RenderFrameHost objects using this NavigatorImpl.
138 // TODO(nasko): Move ownership of the NavigationController from
139 // WebContentsImpl to this class.
140 NavigationControllerImpl* controller_;
142 // Used to notify the object embedding this Navigator about navigation
143 // events. Can be NULL in tests.
144 NavigatorDelegate* delegate_;
146 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
148 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
151 } // namespace content
153 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_