Fix broken path in extensions/common/PRESUBMIT.py
[chromium-blink-merge.git] / content / browser / frame_host / navigator_impl.h
blob7dd2a0284fb6891592d8ac39da2c98e01694a34c
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,
41 bool is_transition_navigation) override;
42 void DidFailProvisionalLoadWithError(
43 RenderFrameHostImpl* render_frame_host,
44 const FrameHostMsg_DidFailProvisionalLoadWithError_Params& params)
45 override;
46 void DidFailLoadWithError(RenderFrameHostImpl* render_frame_host,
47 const GURL& url,
48 int error_code,
49 const base::string16& error_description) override;
50 void DidNavigate(RenderFrameHostImpl* render_frame_host,
51 const FrameHostMsg_DidCommitProvisionalLoad_Params&
52 input_params) override;
53 bool NavigateToPendingEntry(
54 FrameTreeNode* frame_tree_node,
55 NavigationController::ReloadType reload_type) override;
56 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
57 const GURL& url,
58 SiteInstance* source_site_instance,
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 SiteInstance* source_site_instance,
66 const std::vector<GURL>& redirect_chain,
67 const Referrer& referrer,
68 ui::PageTransition page_transition,
69 WindowOpenDisposition disposition,
70 const GlobalRequestID& transferred_global_request_id,
71 bool should_replace_current_entry,
72 bool user_gesture) override;
73 void OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
74 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
75 const CommonNavigationParams& common_params,
76 const BeginNavigationParams& begin_params,
77 scoped_refptr<ResourceRequestBody> body) override;
78 void CommitNavigation(FrameTreeNode* frame_tree_node,
79 ResourceResponse* response,
80 scoped_ptr<StreamHandle> body) override;
81 void FailedNavigation(FrameTreeNode* frame_tree_node,
82 bool has_stale_copy_in_cache,
83 int error_code) override;
84 void LogResourceRequestTime(base::TimeTicks timestamp,
85 const GURL& url) override;
86 void LogBeforeUnloadTime(
87 const base::TimeTicks& renderer_before_unload_start_time,
88 const base::TimeTicks& renderer_before_unload_end_time) override;
89 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
90 bool IsWaitingForBeforeUnloadACK(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(
102 FrameTreeNode* frame_tree_node,
103 const NavigationEntryImpl& entry,
104 NavigationController::ReloadType reload_type);
106 bool ShouldAssignSiteForURL(const GURL& url);
108 void CheckWebUIRendererDoesNotDisplayNormalURL(
109 RenderFrameHostImpl* render_frame_host,
110 const GURL& url);
112 // PlzNavigate: if needed, sends a BeforeUnload IPC to the renderer to ask it
113 // to execute the beforeUnload event. Otherwise, the navigation request will
114 // be started.
115 void RequestNavigation(FrameTreeNode* frame_tree_node,
116 const NavigationEntryImpl& entry,
117 NavigationController::ReloadType reload_type,
118 base::TimeTicks navigation_start);
120 // PlzNavigate: sends the NavigationRequest for |frame_tree_node| to the
121 // network stack so that it can start.
122 void BeginNavigation(FrameTreeNode* frame_tree_node);
124 void RecordNavigationMetrics(
125 const LoadCommittedDetails& details,
126 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
127 SiteInstance* site_instance);
129 // The NavigationController that will keep track of session history for all
130 // RenderFrameHost objects using this NavigatorImpl.
131 // TODO(nasko): Move ownership of the NavigationController from
132 // WebContentsImpl to this class.
133 NavigationControllerImpl* controller_;
135 // Used to notify the object embedding this Navigator about navigation
136 // events. Can be NULL in tests.
137 NavigatorDelegate* delegate_;
139 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
141 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
144 } // namespace content
146 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_