| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 229 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 230 switches::kEnableBrowserSideNavigation)) { | 230 switches::kEnableBrowserSideNavigation)) { |
| 231 // Non PlzNavigate | 231 // Non PlzNavigate |
| 232 SendBeforeUnloadACK(true); | 232 SendBeforeUnloadACK(true); |
| 233 return; | 233 return; |
| 234 } | 234 } |
| 235 | 235 |
| 236 // PlzNavigate | 236 // PlzNavigate |
| 237 NavigationRequest* request = | 237 NavigationRequest* request = |
| 238 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) | 238 static_cast<NavigatorImpl*>(frame_tree_node_->navigator()) |
| 239 ->GetNavigationRequestForNodeForTesting(frame_tree_node_); | 239 ->GetNavigationRequestForNodeForTesting( |
| 240 frame_tree_node_->frame_tree_node_id()); |
| 240 CHECK(request); | 241 CHECK(request); |
| 241 | 242 |
| 242 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for | 243 // Simulate a beforeUnload ACK from the renderer if the browser is waiting for |
| 243 // it. If it runs it will update the request state. | 244 // it. If it runs it will update the request state. |
| 244 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) | 245 if (request->state() == NavigationRequest::WAITING_FOR_RENDERER_RESPONSE) |
| 245 SendBeforeUnloadACK(true); | 246 SendBeforeUnloadACK(true); |
| 246 | 247 |
| 247 // If a network request is not needed for this URL, just check the request is | 248 // If a network request is not needed for this URL, just check the request is |
| 248 // in the correct state and return. | 249 // in the correct state and return. |
| 249 if (!request->ShouldMakeNetworkRequest(request->common_params().url)) { | 250 if (!request->ShouldMakeNetworkRequest(request->common_params().url)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 262 url_loader->SimulateServerRedirect(redirect_url); | 263 url_loader->SimulateServerRedirect(redirect_url); |
| 263 | 264 |
| 264 // Simulate the network stack commit. | 265 // Simulate the network stack commit. |
| 265 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 266 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 266 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to | 267 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to |
| 267 // fully commit the navigation at this call to CallOnResponseStarted. | 268 // fully commit the navigation at this call to CallOnResponseStarted. |
| 268 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); | 269 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); |
| 269 } | 270 } |
| 270 | 271 |
| 271 } // namespace content | 272 } // namespace content |
| OLD | NEW |