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

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

Issue 273193004: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing files. Created 6 years, 6 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
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | 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 <iterator> 7 #include <iterator>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/linked_ptr.h" 10 #include "base/memory/linked_ptr.h"
11 #include "base/stl_util.h" 11 #include "base/stl_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "content/public/common/url_constants.h"
14 #include "extensions/common/error_utils.h" 13 #include "extensions/common/error_utils.h"
15 #include "extensions/common/url_pattern.h" 14 #include "extensions/common/url_pattern.h"
16 #include "url/gurl.h" 15 #include "url/gurl.h"
16 #include "url/url_constants.h"
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 namespace { 20 namespace {
21 21
22 const char kInvalidURLPatternError[] = "Invalid url pattern '*'"; 22 const char kInvalidURLPatternError[] = "Invalid url pattern '*'";
23 23
24 } // namespace 24 } // namespace
25 25
26 // static 26 // static
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 URLPattern pattern(valid_schemes); 191 URLPattern pattern(valid_schemes);
192 if (pattern.Parse(patterns[i]) != URLPattern::PARSE_SUCCESS) { 192 if (pattern.Parse(patterns[i]) != URLPattern::PARSE_SUCCESS) {
193 if (error) { 193 if (error) {
194 *error = ErrorUtils::FormatErrorMessage(kInvalidURLPatternError, 194 *error = ErrorUtils::FormatErrorMessage(kInvalidURLPatternError,
195 patterns[i]); 195 patterns[i]);
196 } else { 196 } else {
197 LOG(ERROR) << "Invalid url pattern: " << patterns[i]; 197 LOG(ERROR) << "Invalid url pattern: " << patterns[i];
198 } 198 }
199 return false; 199 return false;
200 } 200 }
201 if (!allow_file_access && pattern.MatchesScheme(content::kFileScheme)) { 201 if (!allow_file_access && pattern.MatchesScheme(url::kFileScheme)) {
202 pattern.SetValidSchemes( 202 pattern.SetValidSchemes(
203 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); 203 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE);
204 } 204 }
205 AddPattern(pattern); 205 AddPattern(pattern);
206 } 206 }
207 return true; 207 return true;
208 } 208 }
209 209
210 bool URLPatternSet::Populate(const base::ListValue& value, 210 bool URLPatternSet::Populate(const base::ListValue& value,
211 int valid_schemes, 211 int valid_schemes,
212 bool allow_file_access, 212 bool allow_file_access,
213 std::string* error) { 213 std::string* error) {
214 std::vector<std::string> patterns; 214 std::vector<std::string> patterns;
215 for (size_t i = 0; i < value.GetSize(); ++i) { 215 for (size_t i = 0; i < value.GetSize(); ++i) {
216 std::string item; 216 std::string item;
217 if (!value.GetString(i, &item)) 217 if (!value.GetString(i, &item))
218 return false; 218 return false;
219 patterns.push_back(item); 219 patterns.push_back(item);
220 } 220 }
221 return Populate(patterns, valid_schemes, allow_file_access, error); 221 return Populate(patterns, valid_schemes, allow_file_access, error);
222 } 222 }
223 223
224 } // namespace extensions 224 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/url_pattern.cc ('k') | extensions/renderer/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698