| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/policy/cloud/policy_header_service_factory.h" | 8 #include "chrome/browser/policy/cloud/policy_header_service_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" | 10 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.
h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
| 14 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 14 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 15 #include "components/policy/core/common/cloud/policy_header_io_helper.h" | 15 #include "components/policy/core/common/cloud/policy_header_io_helper.h" |
| 16 #include "components/policy/core/common/cloud/policy_header_service.h" | 16 #include "components/policy/core/common/cloud/policy_header_service.h" |
| 17 #include "components/policy/core/common/policy_switches.h" | 17 #include "components/policy/core/common/policy_switches.h" |
| 18 #include "content/public/browser/resource_dispatcher_host.h" | 18 #include "content/public/browser/resource_dispatcher_host.h" |
| 19 #include "net/http/http_request_headers.h" | 19 #include "net/http/http_request_headers.h" |
| 20 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "net/test/embedded_test_server/http_request.h" | 21 #include "net/test/embedded_test_server/http_request.h" |
| 22 #include "net/test/embedded_test_server/http_response.h" | 22 #include "net/test/embedded_test_server/http_response.h" |
| 23 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
| 24 | 24 |
| 25 using content::ResourceType; |
| 26 |
| 25 namespace { | 27 namespace { |
| 26 static const char kTestPolicyHeader[] = "test_header"; | 28 static const char kTestPolicyHeader[] = "test_header"; |
| 27 static const char kServerRedirectUrl[] = "/server-redirect"; | 29 static const char kServerRedirectUrl[] = "/server-redirect"; |
| 28 | 30 |
| 29 scoped_ptr<net::test_server::HttpResponse> HandleTestRequest( | 31 scoped_ptr<net::test_server::HttpResponse> HandleTestRequest( |
| 30 const net::test_server::HttpRequest& request) { | 32 const net::test_server::HttpRequest& request) { |
| 31 if (StartsWithASCII(request.relative_url, kServerRedirectUrl, true)) { | 33 if (StartsWithASCII(request.relative_url, kServerRedirectUrl, true)) { |
| 32 // Extract the target URL and redirect there. | 34 // Extract the target URL and redirect there. |
| 33 size_t query_string_pos = request.relative_url.find('?'); | 35 size_t query_string_pos = request.relative_url.find('?'); |
| 34 std::string redirect_target = | 36 std::string redirect_target = |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 redirect_url += kServerRedirectUrl; | 180 redirect_url += kServerRedirectUrl; |
| 179 redirect_url += "?"; | 181 redirect_url += "?"; |
| 180 redirect_url += dm_url_.spec(); | 182 redirect_url += dm_url_.spec(); |
| 181 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 183 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
| 182 redirect_url)); | 184 redirect_url)); |
| 183 std::string value; | 185 std::string value; |
| 184 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( | 186 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( |
| 185 policy::kChromePolicyHeader, &value)); | 187 policy::kChromePolicyHeader, &value)); |
| 186 ASSERT_EQ(kTestPolicyHeader, value); | 188 ASSERT_EQ(kTestPolicyHeader, value); |
| 187 } | 189 } |
| OLD | NEW |