| OLD | NEW |
| 1 // Copyright 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 "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" | 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 } // namespace | 204 } // namespace |
| 205 | 205 |
| 206 class ChromeResourceDispatcherHostDelegateBrowserTest : | 206 class ChromeResourceDispatcherHostDelegateBrowserTest : |
| 207 public InProcessBrowserTest { | 207 public InProcessBrowserTest { |
| 208 public: | 208 public: |
| 209 ChromeResourceDispatcherHostDelegateBrowserTest() {} | 209 ChromeResourceDispatcherHostDelegateBrowserTest() {} |
| 210 | 210 |
| 211 void SetUpOnMainThread() override { | 211 void SetUpOnMainThread() override { |
| 212 InProcessBrowserTest::SetUpOnMainThread(); | |
| 213 // Hook navigations with our delegate. | 212 // Hook navigations with our delegate. |
| 214 dispatcher_host_delegate_.reset(new TestDispatcherHostDelegate); | 213 dispatcher_host_delegate_.reset(new TestDispatcherHostDelegate); |
| 215 content::ResourceDispatcherHost::Get()->SetDelegate( | 214 content::ResourceDispatcherHost::Get()->SetDelegate( |
| 216 dispatcher_host_delegate_.get()); | 215 dispatcher_host_delegate_.get()); |
| 217 | 216 |
| 218 embedded_test_server()->RegisterRequestHandler( | 217 embedded_test_server()->RegisterRequestHandler( |
| 219 base::Bind(&HandleTestRequest)); | 218 base::Bind(&HandleTestRequest)); |
| 220 ASSERT_TRUE(embedded_test_server()->Start()); | 219 ASSERT_TRUE(embedded_test_server()->Start()); |
| 221 // Tell chrome that this is our DM server. | 220 // Tell chrome that this is our DM server. |
| 222 dm_url_ = embedded_test_server()->GetURL("/DeviceManagement"); | 221 dm_url_ = embedded_test_server()->GetURL("/DeviceManagement"); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // request. | 293 // request. |
| 295 ui_test_utils::NavigateToURL(browser(), dm_url_); | 294 ui_test_utils::NavigateToURL(browser(), dm_url_); |
| 296 std::string value; | 295 std::string value; |
| 297 ASSERT_TRUE(dispatcher_host_delegate_->request_headers().GetHeader( | 296 ASSERT_TRUE(dispatcher_host_delegate_->request_headers().GetHeader( |
| 298 policy::kChromePolicyHeader, &value)); | 297 policy::kChromePolicyHeader, &value)); |
| 299 ASSERT_EQ(kTestPolicyHeader, value); | 298 ASSERT_EQ(kTestPolicyHeader, value); |
| 300 } | 299 } |
| 301 | 300 |
| 302 IN_PROC_BROWSER_TEST_F(ChromeResourceDispatcherHostDelegateBrowserTest, | 301 IN_PROC_BROWSER_TEST_F(ChromeResourceDispatcherHostDelegateBrowserTest, |
| 303 PolicyHeaderForRedirect) { | 302 PolicyHeaderForRedirect) { |
| 304 | |
| 305 // Build up a URL that results in a redirect to the DMServer URL to make | 303 // Build up a URL that results in a redirect to the DMServer URL to make |
| 306 // sure the policy header is still added. | 304 // sure the policy header is still added. |
| 307 std::string redirect_url; | 305 std::string redirect_url; |
| 308 redirect_url += kServerRedirectUrl; | 306 redirect_url += kServerRedirectUrl; |
| 309 redirect_url += "?"; | 307 redirect_url += "?"; |
| 310 redirect_url += dm_url_.spec(); | 308 redirect_url += dm_url_.spec(); |
| 311 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 309 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
| 312 redirect_url)); | 310 redirect_url)); |
| 313 std::string value; | 311 std::string value; |
| 314 ASSERT_TRUE(dispatcher_host_delegate_->request_headers().GetHeader( | 312 ASSERT_TRUE(dispatcher_host_delegate_->request_headers().GetHeader( |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 DownloadTestObserverNotInProgress download_observer( | 623 DownloadTestObserverNotInProgress download_observer( |
| 626 content::BrowserContext::GetDownloadManager(browser()->profile()), 1); | 624 content::BrowserContext::GetDownloadManager(browser()->profile()), 1); |
| 627 download_observer.StartObserving(); | 625 download_observer.StartObserving(); |
| 628 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 626 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
| 629 "/download-anchor-attrib.html")); | 627 "/download-anchor-attrib.html")); |
| 630 download_observer.WaitForFinished(); | 628 download_observer.WaitForFinished(); |
| 631 EXPECT_EQ(1, | 629 EXPECT_EQ(1, |
| 632 GetTimesStandardThrottlesAddedForURL( | 630 GetTimesStandardThrottlesAddedForURL( |
| 633 embedded_test_server()->GetURL("/anchor_download_test.png"))); | 631 embedded_test_server()->GetURL("/anchor_download_test.png"))); |
| 634 } | 632 } |
| OLD | NEW |