OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser_side_navigation_test_utils.h" | 5 #include "content/public/test/browser_side_navigation_test_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/guid.h" | 8 #include "base/guid.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "content/browser/frame_host/frame_tree_node.h" | |
11 #include "content/browser/streams/stream.h" | 12 #include "content/browser/streams/stream.h" |
12 #include "content/browser/streams/stream_registry.h" | 13 #include "content/browser/streams/stream_registry.h" |
14 #include "content/browser/web_contents/web_contents_impl.h" | |
13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/stream_handle.h" | 16 #include "content/public/browser/stream_handle.h" |
17 #include "content/public/common/browser_side_navigation_policy.h" | |
15 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
16 #include "content/test/test_navigation_url_loader_factory.h" | 19 #include "content/test/test_navigation_url_loader_factory.h" |
20 #include "content/test/test_render_frame_host.h" | |
17 | 21 |
18 namespace content { | 22 namespace content { |
19 | 23 |
20 namespace { | 24 namespace { |
21 | 25 |
22 // PlzNavigate | 26 // PlzNavigate |
23 // A UI thread singleton helper class for browser side navigations. When browser | 27 // A UI thread singleton helper class for browser side navigations. When browser |
24 // side navigations are enabled, initialize this class before doing any | 28 // side navigations are enabled, initialize this class before doing any |
25 // operation that may start a navigation request on the UI thread. Use TearDown | 29 // operation that may start a navigation request on the UI thread. Use TearDown |
26 // at the end of the test. | 30 // at the end of the test. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
64 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); | 68 scoped_refptr<Stream> stream(new Stream(stream_registry, NULL, url)); |
65 stream->Finalize(); | 69 stream->Finalize(); |
66 return stream->CreateHandle(); | 70 return stream->CreateHandle(); |
67 } | 71 } |
68 | 72 |
69 void EnableBrowserSideNavigation() { | 73 void EnableBrowserSideNavigation() { |
70 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 74 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
71 switches::kEnableBrowserSideNavigation); | 75 switches::kEnableBrowserSideNavigation); |
72 } | 76 } |
73 | 77 |
78 void SimulateCurrentRenderFrameHostUnloading(RenderFrameHost* rfh) { | |
79 bool browser_side_navigation = IsBrowserSideNavigationEnabled(); | |
80 TestRenderFrameHost* main_frame = static_cast<TestRenderFrameHost*>(rfh); | |
81 if (!browser_side_navigation || | |
82 main_frame->frame_tree_node()->navigation_request()) { | |
83 main_frame->PrepareForCommit(); | |
scottmg
2016/08/30 18:15:31
I had to move this file into content/public/test s
| |
84 } | |
85 } | |
86 | |
74 } // namespace content | 87 } // namespace content |
OLD | NEW |