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" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
24 | 24 |
25 using content::ResourceType; | 25 using content::ResourceType; |
26 | 26 |
27 namespace { | 27 namespace { |
28 static const char kTestPolicyHeader[] = "test_header"; | 28 static const char kTestPolicyHeader[] = "test_header"; |
29 static const char kServerRedirectUrl[] = "/server-redirect"; | 29 static const char kServerRedirectUrl[] = "/server-redirect"; |
30 | 30 |
31 scoped_ptr<net::test_server::HttpResponse> HandleTestRequest( | 31 scoped_ptr<net::test_server::HttpResponse> HandleTestRequest( |
32 const net::test_server::HttpRequest& request) { | 32 const net::test_server::HttpRequest& request) { |
33 if (base::StartsWithASCII(request.relative_url, kServerRedirectUrl, true)) { | 33 if (base::StartsWith(request.relative_url, kServerRedirectUrl, |
| 34 base::CompareCase::SENSITIVE)) { |
34 // Extract the target URL and redirect there. | 35 // Extract the target URL and redirect there. |
35 size_t query_string_pos = request.relative_url.find('?'); | 36 size_t query_string_pos = request.relative_url.find('?'); |
36 std::string redirect_target = | 37 std::string redirect_target = |
37 request.relative_url.substr(query_string_pos + 1); | 38 request.relative_url.substr(query_string_pos + 1); |
38 | 39 |
39 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 40 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
40 new net::test_server::BasicHttpResponse); | 41 new net::test_server::BasicHttpResponse); |
41 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 42 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
42 http_response->AddCustomHeader("Location", redirect_target); | 43 http_response->AddCustomHeader("Location", redirect_target); |
43 return http_response.Pass(); | 44 return http_response.Pass(); |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 redirect_url += kServerRedirectUrl; | 170 redirect_url += kServerRedirectUrl; |
170 redirect_url += "?"; | 171 redirect_url += "?"; |
171 redirect_url += dm_url_.spec(); | 172 redirect_url += dm_url_.spec(); |
172 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 173 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
173 redirect_url)); | 174 redirect_url)); |
174 std::string value; | 175 std::string value; |
175 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( | 176 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( |
176 policy::kChromePolicyHeader, &value)); | 177 policy::kChromePolicyHeader, &value)); |
177 ASSERT_EQ(kTestPolicyHeader, value); | 178 ASSERT_EQ(kTestPolicyHeader, value); |
178 } | 179 } |
OLD | NEW |