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/extensions/chrome_url_request_util.h" | 5 #include "chrome/browser/extensions/chrome_url_request_util.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 80 matching lines...) Loading... |
91 private: | 91 private: |
92 ~URLRequestResourceBundleJob() override {} | 92 ~URLRequestResourceBundleJob() override {} |
93 | 93 |
94 void OnMimeTypeRead(std::string* out_mime_type, | 94 void OnMimeTypeRead(std::string* out_mime_type, |
95 std::string* charset, | 95 std::string* charset, |
96 scoped_refptr<base::RefCountedMemory> data, | 96 scoped_refptr<base::RefCountedMemory> data, |
97 std::string* read_mime_type, | 97 std::string* read_mime_type, |
98 const net::CompletionCallback& callback, | 98 const net::CompletionCallback& callback, |
99 bool read_result) { | 99 bool read_result) { |
100 *out_mime_type = *read_mime_type; | 100 *out_mime_type = *read_mime_type; |
101 if (base::StartsWithASCII(*read_mime_type, "text/", false)) { | 101 if (base::StartsWith(*read_mime_type, "text/", |
| 102 base::CompareCase::INSENSITIVE_ASCII)) { |
102 // All of our HTML files should be UTF-8 and for other resource types | 103 // All of our HTML files should be UTF-8 and for other resource types |
103 // (like images), charset doesn't matter. | 104 // (like images), charset doesn't matter. |
104 DCHECK(base::IsStringUTF8(base::StringPiece( | 105 DCHECK(base::IsStringUTF8(base::StringPiece( |
105 reinterpret_cast<const char*>(data->front()), data->size()))); | 106 reinterpret_cast<const char*>(data->front()), data->size()))); |
106 *charset = "utf-8"; | 107 *charset = "utf-8"; |
107 } | 108 } |
108 int result = read_result ? net::OK : net::ERR_INVALID_URL; | 109 int result = read_result ? net::OK : net::ERR_INVALID_URL; |
109 callback.Run(result); | 110 callback.Run(result); |
110 } | 111 } |
111 | 112 |
(...skipping 66 matching lines...) Loading... |
178 resource_id, | 179 resource_id, |
179 content_security_policy, | 180 content_security_policy, |
180 send_cors_header); | 181 send_cors_header); |
181 } | 182 } |
182 } | 183 } |
183 return NULL; | 184 return NULL; |
184 } | 185 } |
185 | 186 |
186 } // namespace chrome_url_request_util | 187 } // namespace chrome_url_request_util |
187 } // namespace extensions | 188 } // namespace extensions |
OLD | NEW |