| 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_handle_impl.h" | 9 #include "content/browser/frame_host/navigation_handle_impl.h" |
| 10 #include "content/browser/frame_host/navigation_request.h" | 10 #include "content/browser/frame_host/navigation_request.h" |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 const GURL& url) { | 314 const GURL& url) { |
| 315 SendRendererInitiatedNavigationRequest(url, false); | 315 SendRendererInitiatedNavigationRequest(url, false); |
| 316 // PlzNavigate: If no network request is needed by the navigation, then there | 316 // PlzNavigate: If no network request is needed by the navigation, then there |
| 317 // will be no NavigationRequest, nor is it necessary to simulate the network | 317 // will be no NavigationRequest, nor is it necessary to simulate the network |
| 318 // stack commit. | 318 // stack commit. |
| 319 if (frame_tree_node()->navigation_request()) | 319 if (frame_tree_node()->navigation_request()) |
| 320 PrepareForCommit(); | 320 PrepareForCommit(); |
| 321 bool browser_side_navigation = | 321 bool browser_side_navigation = |
| 322 base::CommandLine::ForCurrentProcess()->HasSwitch( | 322 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 323 switches::kEnableBrowserSideNavigation); | 323 switches::kEnableBrowserSideNavigation); |
| 324 CHECK(!browser_side_navigation || is_loading()); | 324 CHECK_IMPLIES(browser_side_navigation, is_loading()); |
| 325 CHECK(!browser_side_navigation || !frame_tree_node()->navigation_request()); | 325 CHECK_IMPLIES(browser_side_navigation, |
| 326 !frame_tree_node()->navigation_request()); |
| 326 SendNavigate(page_id, 0, did_create_new_entry, url); | 327 SendNavigate(page_id, 0, did_create_new_entry, url); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( | 330 void TestRenderFrameHost::SendRendererInitiatedNavigationRequest( |
| 330 const GURL& url, | 331 const GURL& url, |
| 331 bool has_user_gesture) { | 332 bool has_user_gesture) { |
| 332 // Since this is renderer-initiated navigation, the RenderFrame must be | 333 // Since this is renderer-initiated navigation, the RenderFrame must be |
| 333 // initialized. Do it if it hasn't happened yet. | 334 // initialized. Do it if it hasn't happened yet. |
| 334 InitializeRenderFrameIfNeeded(); | 335 InitializeRenderFrameIfNeeded(); |
| 335 | 336 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 // Simulate the network stack commit. | 390 // Simulate the network stack commit. |
| 390 scoped_refptr<ResourceResponse> response(new ResourceResponse); | 391 scoped_refptr<ResourceResponse> response(new ResourceResponse); |
| 391 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to | 392 // TODO(carlosk): ideally with PlzNavigate it should be possible someday to |
| 392 // fully commit the navigation at this call to CallOnResponseStarted. | 393 // fully commit the navigation at this call to CallOnResponseStarted. |
| 393 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); | 394 url_loader->CallOnResponseStarted(response, MakeEmptyStream()); |
| 394 } | 395 } |
| 395 | 396 |
| 396 int32 TestRenderFrameHost::ComputeNextPageID() { | 397 int32 TestRenderFrameHost::ComputeNextPageID() { |
| 397 const NavigationEntryImpl* entry = static_cast<NavigationEntryImpl*>( | 398 const NavigationEntryImpl* entry = static_cast<NavigationEntryImpl*>( |
| 398 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 399 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
| 399 DCHECK(!(entry && entry->site_instance()) || | 400 DCHECK_IMPLIES(entry && entry->site_instance(), |
| 400 entry->site_instance() == GetSiteInstance()); | 401 entry->site_instance() == GetSiteInstance()); |
| 401 // Entry can be null when committing an error page (the pending entry was | 402 // Entry can be null when committing an error page (the pending entry was |
| 402 // cleared during DidFailProvisionalLoad). | 403 // cleared during DidFailProvisionalLoad). |
| 403 int page_id = entry ? entry->GetPageID() : -1; | 404 int page_id = entry ? entry->GetPageID() : -1; |
| 404 if (page_id == -1) { | 405 if (page_id == -1) { |
| 405 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(delegate()); | 406 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(delegate()); |
| 406 page_id = web_contents->GetMaxPageIDForSiteInstance(GetSiteInstance()) + 1; | 407 page_id = web_contents->GetMaxPageIDForSiteInstance(GetSiteInstance()) + 1; |
| 407 } | 408 } |
| 408 return page_id; | 409 return page_id; |
| 409 } | 410 } |
| 410 | 411 |
| 411 } // namespace content | 412 } // namespace content |
| OLD | NEW |