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/chromeos/app_mode/fake_cws.h" | 5 #include "chrome/browser/chromeos/app_mode/fake_cws.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const std::string& crx_fp, | 134 const std::string& crx_fp, |
135 const std::string& crx_size, | 135 const std::string& crx_size, |
136 const std::string& version, | 136 const std::string& version, |
137 std::string* update_check_content) { | 137 std::string* update_check_content) { |
138 base::FilePath test_data_dir; | 138 base::FilePath test_data_dir; |
139 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 139 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
140 base::FilePath update_file = | 140 base::FilePath update_file = |
141 test_data_dir.AppendASCII(update_check_file.c_str()); | 141 test_data_dir.AppendASCII(update_check_file.c_str()); |
142 ASSERT_TRUE(base::ReadFileToString(update_file, update_check_content)); | 142 ASSERT_TRUE(base::ReadFileToString(update_file, update_check_content)); |
143 | 143 |
144 ReplaceSubstringsAfterOffset(update_check_content, 0, "$AppId", app_id); | 144 base::ReplaceSubstringsAfterOffset(update_check_content, 0, "$AppId", app_id); |
145 ReplaceSubstringsAfterOffset( | 145 base::ReplaceSubstringsAfterOffset( |
146 update_check_content, 0, "$CrxDownloadUrl", crx_download_url.spec()); | 146 update_check_content, 0, "$CrxDownloadUrl", crx_download_url.spec()); |
147 ReplaceSubstringsAfterOffset(update_check_content, 0, "$FP", crx_fp); | 147 base::ReplaceSubstringsAfterOffset(update_check_content, 0, "$FP", crx_fp); |
148 ReplaceSubstringsAfterOffset(update_check_content, 0, "$Size", crx_size); | 148 base::ReplaceSubstringsAfterOffset(update_check_content, 0, |
149 ReplaceSubstringsAfterOffset(update_check_content, 0, "$Version", version); | 149 "$Size", crx_size); |
| 150 base::ReplaceSubstringsAfterOffset(update_check_content, 0, |
| 151 "$Version", version); |
150 } | 152 } |
151 | 153 |
152 scoped_ptr<HttpResponse> FakeCWS::HandleRequest(const HttpRequest& request) { | 154 scoped_ptr<HttpResponse> FakeCWS::HandleRequest(const HttpRequest& request) { |
153 GURL request_url = GURL("http://localhost").Resolve(request.relative_url); | 155 GURL request_url = GURL("http://localhost").Resolve(request.relative_url); |
154 std::string request_path = request_url.path(); | 156 std::string request_path = request_url.path(); |
155 if (!update_check_content_.empty() && | 157 if (!update_check_content_.empty() && |
156 request_path.find(update_check_end_point_) != std::string::npos) { | 158 request_path.find(update_check_end_point_) != std::string::npos) { |
157 ++update_check_count_; | 159 ++update_check_count_; |
158 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); | 160 scoped_ptr<BasicHttpResponse> http_response(new BasicHttpResponse()); |
159 http_response->set_code(net::HTTP_OK); | 161 http_response->set_code(net::HTTP_OK); |
160 http_response->set_content_type("text/xml"); | 162 http_response->set_content_type("text/xml"); |
161 http_response->set_content(update_check_content_); | 163 http_response->set_content(update_check_content_); |
162 return http_response.Pass(); | 164 return http_response.Pass(); |
163 } | 165 } |
164 | 166 |
165 return scoped_ptr<HttpResponse>(); | 167 return scoped_ptr<HttpResponse>(); |
166 } | 168 } |
167 | 169 |
168 } // namespace chromeos | 170 } // namespace chromeos |
OLD | NEW |