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