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 22 matching lines...) Expand all Loading... |
33 if (StartsWithASCII(request.relative_url, kServerRedirectUrl, true)) { | 33 if (StartsWithASCII(request.relative_url, kServerRedirectUrl, true)) { |
34 // Extract the target URL and redirect there. | 34 // Extract the target URL and redirect there. |
35 size_t query_string_pos = request.relative_url.find('?'); | 35 size_t query_string_pos = request.relative_url.find('?'); |
36 std::string redirect_target = | 36 std::string redirect_target = |
37 request.relative_url.substr(query_string_pos + 1); | 37 request.relative_url.substr(query_string_pos + 1); |
38 | 38 |
39 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 39 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
40 new net::test_server::BasicHttpResponse); | 40 new net::test_server::BasicHttpResponse); |
41 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); | 41 http_response->set_code(net::HTTP_MOVED_PERMANENTLY); |
42 http_response->AddCustomHeader("Location", redirect_target); | 42 http_response->AddCustomHeader("Location", redirect_target); |
43 return http_response.PassAs<net::test_server::HttpResponse>(); | 43 return http_response.Pass(); |
44 } else { | 44 } else { |
45 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 45 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
46 new net::test_server::BasicHttpResponse); | 46 new net::test_server::BasicHttpResponse); |
47 http_response->set_code(net::HTTP_OK); | 47 http_response->set_code(net::HTTP_OK); |
48 http_response->set_content("Success"); | 48 http_response->set_content("Success"); |
49 return http_response.PassAs<net::test_server::HttpResponse>(); | 49 return http_response.Pass(); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 class TestDispatcherHostDelegate : public ChromeResourceDispatcherHostDelegate { | 53 class TestDispatcherHostDelegate : public ChromeResourceDispatcherHostDelegate { |
54 public: | 54 public: |
55 explicit TestDispatcherHostDelegate( | 55 explicit TestDispatcherHostDelegate( |
56 prerender::PrerenderTracker* prerender_tracker) | 56 prerender::PrerenderTracker* prerender_tracker) |
57 : ChromeResourceDispatcherHostDelegate(prerender_tracker) { | 57 : ChromeResourceDispatcherHostDelegate(prerender_tracker) { |
58 } | 58 } |
59 | 59 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 redirect_url += kServerRedirectUrl; | 175 redirect_url += kServerRedirectUrl; |
176 redirect_url += "?"; | 176 redirect_url += "?"; |
177 redirect_url += dm_url_.spec(); | 177 redirect_url += dm_url_.spec(); |
178 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( | 178 ui_test_utils::NavigateToURL(browser(), embedded_test_server()->GetURL( |
179 redirect_url)); | 179 redirect_url)); |
180 std::string value; | 180 std::string value; |
181 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( | 181 ASSERT_TRUE(dispatcher_host_delegate_->request_headers_.GetHeader( |
182 policy::kChromePolicyHeader, &value)); | 182 policy::kChromePolicyHeader, &value)); |
183 ASSERT_EQ(kTestPolicyHeader, value); | 183 ASSERT_EQ(kTestPolicyHeader, value); |
184 } | 184 } |
OLD | NEW |