Chromium Code Reviews| 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/guid.h" | 7 #include "base/guid.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" |
| 11 #include "content/browser/frame_host/navigator.h" | 11 #include "content/browser/frame_host/navigator.h" |
| 12 #include "content/browser/frame_host/navigator_impl.h" | 12 #include "content/browser/frame_host/navigator_impl.h" |
| 13 #include "content/browser/frame_host/render_frame_host_delegate.h" | 13 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 14 #include "content/browser/web_contents/web_contents_impl.h" | 14 #include "content/browser/web_contents/web_contents_impl.h" |
| 15 #include "content/common/frame_messages.h" | 15 #include "content/common/frame_messages.h" |
| 16 #include "content/public/browser/navigation_throttle.h" | |
| 16 #include "content/public/browser/stream_handle.h" | 17 #include "content/public/browser/stream_handle.h" |
| 17 #include "content/public/common/browser_side_navigation_policy.h" | 18 #include "content/public/common/browser_side_navigation_policy.h" |
| 18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 19 #include "content/test/browser_side_navigation_test_utils.h" | 20 #include "content/test/browser_side_navigation_test_utils.h" |
| 20 #include "content/test/test_navigation_url_loader.h" | 21 #include "content/test/test_navigation_url_loader.h" |
| 21 #include "content/test/test_render_view_host.h" | 22 #include "content/test/test_render_view_host.h" |
| 22 #include "net/base/load_flags.h" | 23 #include "net/base/load_flags.h" |
| 23 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" | 24 #include "third_party/WebKit/public/platform/WebPageVisibilityState.h" |
| 24 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 25 #include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| 25 #include "third_party/WebKit/public/web/WebTreeScopeType.h" | 26 #include "third_party/WebKit/public/web/WebTreeScopeType.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 } | 99 } |
| 99 | 100 |
| 100 void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) { | 101 void TestRenderFrameHost::SimulateNavigationStart(const GURL& url) { |
| 101 if (IsBrowserSideNavigationEnabled()) { | 102 if (IsBrowserSideNavigationEnabled()) { |
| 102 SendRendererInitiatedNavigationRequest(url, false); | 103 SendRendererInitiatedNavigationRequest(url, false); |
| 103 return; | 104 return; |
| 104 } | 105 } |
| 105 | 106 |
| 106 OnDidStartLoading(true); | 107 OnDidStartLoading(true); |
| 107 OnDidStartProvisionalLoad(url, base::TimeTicks::Now()); | 108 OnDidStartProvisionalLoad(url, base::TimeTicks::Now()); |
| 109 SimulateWillStartRequest(); | |
| 108 } | 110 } |
| 109 | 111 |
| 110 void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) { | 112 void TestRenderFrameHost::SimulateRedirect(const GURL& new_url) { |
| 111 if (IsBrowserSideNavigationEnabled()) { | 113 if (IsBrowserSideNavigationEnabled()) { |
| 112 NavigationRequest* request = frame_tree_node_->navigation_request(); | 114 NavigationRequest* request = frame_tree_node_->navigation_request(); |
| 113 TestNavigationURLLoader* url_loader = | 115 TestNavigationURLLoader* url_loader = |
| 114 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); | 116 static_cast<TestNavigationURLLoader*>(request->loader_for_testing()); |
| 115 CHECK(url_loader); | 117 CHECK(url_loader); |
| 116 url_loader->SimulateServerRedirect(new_url); | 118 url_loader->SimulateServerRedirect(new_url); |
| 117 return; | 119 return; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 ui::PageTransition transition, | 284 ui::PageTransition transition, |
| 283 int response_code, | 285 int response_code, |
| 284 const ModificationCallback& callback) { | 286 const ModificationCallback& callback) { |
| 285 if (!IsBrowserSideNavigationEnabled()) | 287 if (!IsBrowserSideNavigationEnabled()) |
| 286 OnDidStartLoading(true); | 288 OnDidStartLoading(true); |
| 287 | 289 |
| 288 // DidStartProvisionalLoad may delete the pending entry that holds |url|, | 290 // DidStartProvisionalLoad may delete the pending entry that holds |url|, |
| 289 // so we keep a copy of it to use below. | 291 // so we keep a copy of it to use below. |
| 290 GURL url_copy(url); | 292 GURL url_copy(url); |
| 291 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now()); | 293 OnDidStartProvisionalLoad(url_copy, base::TimeTicks::Now()); |
| 294 SimulateWillStartRequest(); | |
| 292 | 295 |
| 293 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 296 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 294 params.page_id = page_id; | 297 params.page_id = page_id; |
| 295 params.nav_entry_id = nav_entry_id; | 298 params.nav_entry_id = nav_entry_id; |
| 296 params.url = url_copy; | 299 params.url = url_copy; |
| 297 params.transition = transition; | 300 params.transition = transition; |
| 298 params.should_update_history = true; | 301 params.should_update_history = true; |
| 299 params.did_create_new_entry = did_create_new_entry; | 302 params.did_create_new_entry = did_create_new_entry; |
| 300 params.should_replace_current_entry = should_replace_entry; | 303 params.should_replace_current_entry = should_replace_entry; |
| 301 params.gesture = NavigationGestureUser; | 304 params.gesture = NavigationGestureUser; |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 432 // Entry can be null when committing an error page (the pending entry was | 435 // Entry can be null when committing an error page (the pending entry was |
| 433 // cleared during DidFailProvisionalLoad). | 436 // cleared during DidFailProvisionalLoad). |
| 434 int page_id = entry ? entry->GetPageID() : -1; | 437 int page_id = entry ? entry->GetPageID() : -1; |
| 435 if (page_id == -1) { | 438 if (page_id == -1) { |
| 436 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(delegate()); | 439 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(delegate()); |
| 437 page_id = web_contents->GetMaxPageIDForSiteInstance(GetSiteInstance()) + 1; | 440 page_id = web_contents->GetMaxPageIDForSiteInstance(GetSiteInstance()) + 1; |
| 438 } | 441 } |
| 439 return page_id; | 442 return page_id; |
| 440 } | 443 } |
| 441 | 444 |
| 445 void TestRenderFrameHost::SimulateWillStartRequest() { | |
| 446 DCHECK(navigation_handle()); | |
| 447 NavigationThrottle::ThrottleCheckResult result = | |
| 448 navigation_handle()->CallWillStartRequestForTesting( | |
| 449 false /* is_post */, | |
| 450 Referrer(GURL(), blink::WebReferrerPolicyDefault), | |
| 451 true /* user_gesture */, ui::PAGE_TRANSITION_LINK, | |
| 452 false /* is_external_protocol */); | |
| 453 DCHECK_EQ(NavigationThrottle::PROCEED, result); | |
|
clamy
2016/07/19 14:10:54
On Android the result won't be proceed because the
| |
| 454 } | |
| 455 | |
| 442 } // namespace content | 456 } // namespace content |
| OLD | NEW |