Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: content/browser/webui/shared_resources_data_source.cc

Issue 2121513002: Replace string::find(prefix) == 0 pattern with base::StartsWith(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix typos Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 (origin.find(allowed_origin_prefix) != 0) 163 if (!base::StartsWith(origin, allowed_origin_prefix,
164 base::CompareCase::SENSITIVE)) {
164 return "null"; 165 return "null";
166 }
165 return origin; 167 return origin;
166 } 168 }
167 169
168 } // namespace content 170 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698