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