OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/test_render_frame_host.h" | 5 #include "content/test/test_render_frame_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "content/browser/frame_host/frame_tree.h" | 8 #include "content/browser/frame_host/frame_tree.h" |
9 #include "content/browser/frame_host/navigation_request.h" | 9 #include "content/browser/frame_host/navigation_request.h" |
10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 params.page_state = PageState::CreateForTesting( | 180 params.page_state = PageState::CreateForTesting( |
181 url, | 181 url, |
182 false, | 182 false, |
183 file_path_for_history_item ? "data" : NULL, | 183 file_path_for_history_item ? "data" : NULL, |
184 file_path_for_history_item); | 184 file_path_for_history_item); |
185 | 185 |
186 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params); | 186 FrameHostMsg_DidCommitProvisionalLoad msg(GetRoutingID(), params); |
187 OnDidCommitProvisionalLoad(msg); | 187 OnDidCommitProvisionalLoad(msg); |
188 } | 188 } |
189 | 189 |
190 void TestRenderFrameHost::SendBeginNavigationWithURL(const GURL& url) { | 190 void TestRenderFrameHost::SendBeginNavigationWithURL(const GURL& url, |
191 BeginNavigationParams begin_params( | 191 bool has_user_gesture) { |
192 "GET", std::string(), net::LOAD_NORMAL, false); | 192 BeginNavigationParams begin_params("GET", std::string(), net::LOAD_NORMAL, |
| 193 has_user_gesture); |
193 CommonNavigationParams common_params; | 194 CommonNavigationParams common_params; |
194 common_params.url = url; | 195 common_params.url = url; |
195 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); | 196 common_params.referrer = Referrer(GURL(), blink::WebReferrerPolicyDefault); |
196 common_params.transition = ui::PAGE_TRANSITION_LINK; | 197 common_params.transition = ui::PAGE_TRANSITION_LINK; |
197 OnBeginNavigation(common_params, begin_params, | 198 OnBeginNavigation(common_params, begin_params, |
198 scoped_refptr<ResourceRequestBody>()); | 199 scoped_refptr<ResourceRequestBody>()); |
199 } | 200 } |
200 | 201 |
201 void TestRenderFrameHost::DidDisownOpener() { | 202 void TestRenderFrameHost::DidDisownOpener() { |
202 OnDidDisownOpener(); | 203 OnDidDisownOpener(); |
203 } | 204 } |
204 | 205 |
205 void TestRenderFrameHost::PrepareForCommit(const GURL& url) { | 206 void TestRenderFrameHost::PrepareForCommit(const GURL& url) { |
206 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 207 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
207 switches::kEnableBrowserSideNavigation)) { | 208 switches::kEnableBrowserSideNavigation)) { |
208 SendBeforeUnloadACK(true); | 209 SendBeforeUnloadACK(true); |
209 return; | 210 return; |
210 } | 211 } |
211 | 212 |
212 // PlzNavigate | 213 // PlzNavigate |
213 // Simulate the network stack commit without any redirects. | 214 // Simulate the network stack commit without any redirects. |
214 NavigationRequest* request = | 215 NavigationRequest* request = |
215 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) | 216 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) |
216 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); | 217 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); |
217 | 218 |
218 // We are simulating a renderer-initiated navigation. | 219 // We are simulating a renderer-initiated user-initiated navigation. |
219 if (!request) { | 220 if (!request) { |
220 SendBeginNavigationWithURL(url); | 221 SendBeginNavigationWithURL(url, true); |
221 request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) | 222 request = static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) |
222 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); | 223 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); |
223 } | 224 } |
224 ASSERT_TRUE(request); | 225 ASSERT_TRUE(request); |
225 | 226 |
226 // We may not have simulated the renderer response to the navigation request. | 227 // We may not have simulated the renderer response to the navigation request. |
227 // Do that now. | 228 // Do that now. |
228 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) | 229 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) |
229 SendBeforeUnloadACK(true); | 230 SendBeforeUnloadACK(true); |
230 | 231 |
(...skipping 12 matching lines...) Expand all Loading... |
243 | 244 |
244 void TestRenderFrameHost::SendBeforeUnloadHandlersPresent(bool present) { | 245 void TestRenderFrameHost::SendBeforeUnloadHandlersPresent(bool present) { |
245 OnBeforeUnloadHandlersPresent(present); | 246 OnBeforeUnloadHandlersPresent(present); |
246 } | 247 } |
247 | 248 |
248 void TestRenderFrameHost::SendUnloadHandlersPresent(bool present) { | 249 void TestRenderFrameHost::SendUnloadHandlersPresent(bool present) { |
249 OnUnloadHandlersPresent(present); | 250 OnUnloadHandlersPresent(present); |
250 } | 251 } |
251 | 252 |
252 } // namespace content | 253 } // namespace content |
OLD | NEW |