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

Side by Side Diff: extensions/common/url_pattern_set.cc

Issue 120593003: Move kFileScheme constant into content namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "extensions/common/url_pattern_set.h" 5 #include "extensions/common/url_pattern_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 URLPattern pattern(valid_schemes); 199 URLPattern pattern(valid_schemes);
200 if (pattern.Parse(patterns[i]) != URLPattern::PARSE_SUCCESS) { 200 if (pattern.Parse(patterns[i]) != URLPattern::PARSE_SUCCESS) {
201 if (error) { 201 if (error) {
202 *error = ErrorUtils::FormatErrorMessage(kInvalidURLPatternError, 202 *error = ErrorUtils::FormatErrorMessage(kInvalidURLPatternError,
203 patterns[i]); 203 patterns[i]);
204 } else { 204 } else {
205 LOG(ERROR) << "Invalid url pattern: " << patterns[i]; 205 LOG(ERROR) << "Invalid url pattern: " << patterns[i];
206 } 206 }
207 return false; 207 return false;
208 } 208 }
209 if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { 209 if (!allow_file_access && pattern.MatchesScheme(content::kFileScheme)) {
210 pattern.SetValidSchemes( 210 pattern.SetValidSchemes(
211 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); 211 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE);
212 } 212 }
213 AddPattern(pattern); 213 AddPattern(pattern);
214 } 214 }
215 return true; 215 return true;
216 } 216 }
217 217
218 bool URLPatternSet::Populate(const base::ListValue& value, 218 bool URLPatternSet::Populate(const base::ListValue& value,
219 int valid_schemes, 219 int valid_schemes,
220 bool allow_file_access, 220 bool allow_file_access,
221 std::string* error) { 221 std::string* error) {
222 std::vector<std::string> patterns; 222 std::vector<std::string> patterns;
223 for (size_t i = 0; i < value.GetSize(); ++i) { 223 for (size_t i = 0; i < value.GetSize(); ++i) {
224 std::string item; 224 std::string item;
225 if (!value.GetString(i, &item)) 225 if (!value.GetString(i, &item))
226 return false; 226 return false;
227 patterns.push_back(item); 227 patterns.push_back(item);
228 } 228 }
229 return Populate(patterns, valid_schemes, allow_file_access, error); 229 return Populate(patterns, valid_schemes, allow_file_access, error);
230 } 230 }
231 231
232 } // namespace extensions 232 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698