OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/data_reduction_proxy/content/browser/data_reduction_proxy_d
ebug_blocking_page.h" | 5 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_d
ebug_blocking_page.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/message_loop/message_loop_proxy.h" | |
11 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
12 #include "base/single_thread_task_runner.h" | 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/thread_task_runner_handle.h" |
13 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_d
ebug_ui_manager.h" | 13 #include "components/data_reduction_proxy/content/browser/data_reduction_proxy_d
ebug_ui_manager.h" |
14 #include "content/public/browser/interstitial_page.h" | 14 #include "content/public/browser/interstitial_page.h" |
15 #include "content/public/browser/navigation_entry.h" | 15 #include "content/public/browser/navigation_entry.h" |
16 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/test/test_renderer_host.h" | 19 #include "content/public/test/test_renderer_host.h" |
20 #include "content/public/test/web_contents_tester.h" | 20 #include "content/public/test/web_contents_tester.h" |
21 | 21 |
22 static const char* kBypassURL = "http://www.bypass.com/"; | 22 static const char* kBypassURL = "http://www.bypass.com/"; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 CANCEL | 77 CANCEL |
78 }; | 78 }; |
79 | 79 |
80 DataReductionProxyDebugBlockingPageTest() : user_response_(PENDING) { | 80 DataReductionProxyDebugBlockingPageTest() : user_response_(PENDING) { |
81 } | 81 } |
82 | 82 |
83 void SetUp() override { | 83 void SetUp() override { |
84 content::RenderViewHostTestHarness::SetUp(); | 84 content::RenderViewHostTestHarness::SetUp(); |
85 DataReductionProxyDebugBlockingPage::RegisterFactory(&factory_); | 85 DataReductionProxyDebugBlockingPage::RegisterFactory(&factory_); |
86 ui_manager_ = new DataReductionProxyDebugUIManager( | 86 ui_manager_ = new DataReductionProxyDebugUIManager( |
87 base::MessageLoopProxy::current(), | 87 base::ThreadTaskRunnerHandle::Get(), |
88 base::MessageLoopProxy::current(), | 88 base::ThreadTaskRunnerHandle::Get(), "en-US"); |
89 "en-US"); | |
90 ResetUserResponse(); | 89 ResetUserResponse(); |
91 } | 90 } |
92 | 91 |
93 void TearDown() override { | 92 void TearDown() override { |
94 // Release the UI manager before the BrowserThreads are destroyed. | 93 // Release the UI manager before the BrowserThreads are destroyed. |
95 ui_manager_ = NULL; | 94 ui_manager_ = NULL; |
96 DataReductionProxyDebugBlockingPage::RegisterFactory(NULL); | 95 DataReductionProxyDebugBlockingPage::RegisterFactory(NULL); |
97 content::RenderViewHostTestHarness::TearDown(); | 96 content::RenderViewHostTestHarness::TearDown(); |
98 } | 97 } |
99 | 98 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 content::WebContentsTester::For(web_contents()) | 151 content::WebContentsTester::For(web_contents()) |
153 ->TestDidNavigate(render_frame_host, entry->GetPageID(), | 152 ->TestDidNavigate(render_frame_host, entry->GetPageID(), |
154 entry->GetUniqueID(), false, GURL(entry->GetURL()), | 153 entry->GetUniqueID(), false, GURL(entry->GetURL()), |
155 ui::PAGE_TRANSITION_TYPED); | 154 ui::PAGE_TRANSITION_TYPED); |
156 } | 155 } |
157 | 156 |
158 void ShowInterstitial(bool is_subresource, const char* url) { | 157 void ShowInterstitial(bool is_subresource, const char* url) { |
159 DataReductionProxyDebugUIManager::BypassResource resource; | 158 DataReductionProxyDebugUIManager::BypassResource resource; |
160 InitResource(&resource, is_subresource, GURL(url)); | 159 InitResource(&resource, is_subresource, GURL(url)); |
161 DataReductionProxyDebugBlockingPage::ShowBlockingPage( | 160 DataReductionProxyDebugBlockingPage::ShowBlockingPage( |
162 ui_manager_.get(), base::MessageLoopProxy::current(), | 161 ui_manager_.get(), base::ThreadTaskRunnerHandle::Get(), resource, |
163 resource, std::string()); | 162 std::string()); |
164 } | 163 } |
165 | 164 |
166 // Returns the DataReductionProxyDebugBlockingPage currently showing or NULL | 165 // Returns the DataReductionProxyDebugBlockingPage currently showing or NULL |
167 // if none is showing. | 166 // if none is showing. |
168 DataReductionProxyDebugBlockingPage* | 167 DataReductionProxyDebugBlockingPage* |
169 GetDataReductionProxyDebugBlockingPage() { | 168 GetDataReductionProxyDebugBlockingPage() { |
170 content::InterstitialPage* interstitial = | 169 content::InterstitialPage* interstitial = |
171 content::InterstitialPage::GetInterstitialPage(web_contents()); | 170 content::InterstitialPage::GetInterstitialPage(web_contents()); |
172 if (!interstitial) | 171 if (!interstitial) |
173 return NULL; | 172 return NULL; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 interstitial->interstitial_page()->Proceed(); | 456 interstitial->interstitial_page()->Proceed(); |
458 interstitial->interstitial_page()->DontProceed(); | 457 interstitial->interstitial_page()->DontProceed(); |
459 base::RunLoop().RunUntilIdle(); | 458 base::RunLoop().RunUntilIdle(); |
460 | 459 |
461 // The interstitial should be gone. | 460 // The interstitial should be gone. |
462 EXPECT_EQ(OK, user_response()); | 461 EXPECT_EQ(OK, user_response()); |
463 EXPECT_FALSE(GetDataReductionProxyDebugBlockingPage()); | 462 EXPECT_FALSE(GetDataReductionProxyDebugBlockingPage()); |
464 } | 463 } |
465 | 464 |
466 } // namespace data_reduction_proxy | 465 } // namespace data_reduction_proxy |
OLD | NEW |