OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/webui/shared_resources_data_source.h" | 5 #include "content/browser/webui/shared_resources_data_source.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 std::string | 154 std::string |
155 SharedResourcesDataSource::GetAccessControlAllowOriginForOrigin( | 155 SharedResourcesDataSource::GetAccessControlAllowOriginForOrigin( |
156 const std::string& origin) const { | 156 const std::string& origin) const { |
157 // For now we give access only for "chrome://*" origins. | 157 // For now we give access only for "chrome://*" origins. |
158 // According to CORS spec, Access-Control-Allow-Origin header doesn't support | 158 // According to CORS spec, Access-Control-Allow-Origin header doesn't support |
159 // wildcards, so we need to set its value explicitly by passing the |origin| | 159 // wildcards, so we need to set its value explicitly by passing the |origin| |
160 // back. | 160 // back. |
161 std::string allowed_origin_prefix = kChromeUIScheme; | 161 std::string allowed_origin_prefix = kChromeUIScheme; |
162 allowed_origin_prefix += "://"; | 162 allowed_origin_prefix += "://"; |
163 if (!base::StartsWith(origin, allowed_origin_prefix, | 163 if (origin.find(allowed_origin_prefix) != 0) |
164 base::CompareCase::SENSITIVE)) { | |
165 return "null"; | 164 return "null"; |
166 } | |
167 return origin; | 165 return origin; |
168 } | 166 } |
169 | 167 |
170 } // namespace content | 168 } // namespace content |
OLD | NEW |