Use multiline attribute to check for IA2_STATE_MULTILINE.
[chromium-blink-merge.git] / content / browser / frame_host / navigator_impl.h
blobdebf309aba67d4d3918bab66bedd250f7993ac0a
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 NavigationController* GetController() override;
38 void DidStartProvisionalLoad(RenderFrameHostImpl* render_frame_host,
39 const GURL& url,
40 bool is_transition_navigation) 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) override;
49 void DidNavigate(RenderFrameHostImpl* render_frame_host,
50 const FrameHostMsg_DidCommitProvisionalLoad_Params&
51 input_params) override;
52 bool NavigateToPendingEntry(
53 FrameTreeNode* frame_tree_node,
54 NavigationController::ReloadType reload_type) override;
55 void RequestOpenURL(RenderFrameHostImpl* render_frame_host,
56 const GURL& url,
57 SiteInstance* source_site_instance,
58 const Referrer& referrer,
59 WindowOpenDisposition disposition,
60 bool should_replace_current_entry,
61 bool user_gesture) override;
62 void RequestTransferURL(RenderFrameHostImpl* render_frame_host,
63 const GURL& url,
64 SiteInstance* source_site_instance,
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 OnBeforeUnloadACK(FrameTreeNode* frame_tree_node, bool proceed) override;
73 void OnBeginNavigation(FrameTreeNode* frame_tree_node,
74 const CommonNavigationParams& common_params,
75 const BeginNavigationParams& begin_params,
76 scoped_refptr<ResourceRequestBody> body) override;
77 void CommitNavigation(FrameTreeNode* frame_tree_node,
78 ResourceResponse* response,
79 scoped_ptr<StreamHandle> body) override;
80 void LogResourceRequestTime(base::TimeTicks timestamp,
81 const GURL& url) override;
82 void LogBeforeUnloadTime(
83 const base::TimeTicks& renderer_before_unload_start_time,
84 const base::TimeTicks& renderer_before_unload_end_time) override;
85 void CancelNavigation(FrameTreeNode* frame_tree_node) override;
86 bool IsWaitingForBeforeUnloadACK(FrameTreeNode* frame_tree_node) override;
88 // PlzNavigate
89 // Returns the navigation request for a given node. Used in tests.
90 NavigationRequest* GetNavigationRequestForNodeForTesting(
91 FrameTreeNode* frame_tree_node);
93 private:
94 // Holds data used to track browser side navigation metrics.
95 struct NavigationMetricsData;
97 friend class NavigatorTestWithBrowserSideNavigation;
98 ~NavigatorImpl() override;
100 // Navigates to the given entry, which must be the pending entry. Private
101 // because all callers should use NavigateToPendingEntry.
102 bool NavigateToEntry(
103 FrameTreeNode* frame_tree_node,
104 const NavigationEntryImpl& entry,
105 NavigationController::ReloadType reload_type);
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 NavigationEntryImpl& entry,
118 NavigationController::ReloadType reload_type,
119 base::TimeTicks navigation_start);
121 // PlzNavigate: sends the NavigationRequest for |frame_tree_node| to the
122 // network stack so that it can start.
123 void BeginNavigation(FrameTreeNode* frame_tree_node);
125 void RecordNavigationMetrics(
126 const LoadCommittedDetails& details,
127 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
128 SiteInstance* site_instance);
130 // The NavigationController that will keep track of session history for all
131 // RenderFrameHost objects using this NavigatorImpl.
132 // TODO(nasko): Move ownership of the NavigationController from
133 // WebContentsImpl to this class.
134 NavigationControllerImpl* controller_;
136 // Used to notify the object embedding this Navigator about navigation
137 // events. Can be NULL in tests.
138 NavigatorDelegate* delegate_;
140 scoped_ptr<NavigatorImpl::NavigationMetricsData> navigation_data_;
142 // PlzNavigate: used to track the various ongoing NavigationRequests in the
143 // different FrameTreeNodes, based on the frame_tree_node_id.
144 typedef base::ScopedPtrHashMap<int64, NavigationRequest> NavigationRequestMap;
145 NavigationRequestMap navigation_request_map_;
147 DISALLOW_COPY_AND_ASSIGN(NavigatorImpl);
150 } // namespace content
152 #endif // CONTENT_BROWSER_FRAME_HOST_NAVIGATOR_IMPL_H_