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

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

Issue 254763005: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add some missing files. Created 6 years, 7 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 "extensions/common/url_pattern.h" 5 #include "extensions/common/url_pattern.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "content/public/common/url_constants.h" 11 #include "content/public/common/url_constants.h"
12 #include "extensions/common/constants.h" 12 #include "extensions/common/constants.h"
13 #include "url/gurl.h" 13 #include "url/gurl.h"
14 #include "url/url_constants.h"
14 #include "url/url_util.h" 15 #include "url/url_util.h"
15 16
16 const char URLPattern::kAllUrlsPattern[] = "<all_urls>"; 17 const char URLPattern::kAllUrlsPattern[] = "<all_urls>";
17 18
18 namespace { 19 namespace {
19 20
20 // TODO(aa): What about more obscure schemes like data: and javascript: ? 21 // TODO(aa): What about more obscure schemes like data: and javascript: ?
21 // Note: keep this array in sync with kValidSchemeMasks. 22 // Note: keep this array in sync with kValidSchemeMasks.
22 const char* kValidSchemes[] = { 23 const char* kValidSchemes[] = {
23 content::kHttpScheme, 24 url::kHttpScheme,
24 content::kHttpsScheme, 25 url::kHttpsScheme,
25 content::kFileScheme, 26 content::kFileScheme,
26 content::kFtpScheme, 27 content::kFtpScheme,
27 content::kChromeUIScheme, 28 content::kChromeUIScheme,
28 extensions::kExtensionScheme, 29 extensions::kExtensionScheme,
29 content::kFileSystemScheme, 30 content::kFileSystemScheme,
30 }; 31 };
31 32
32 const int kValidSchemeMasks[] = { 33 const int kValidSchemeMasks[] = {
33 URLPattern::SCHEME_HTTP, 34 URLPattern::SCHEME_HTTP,
34 URLPattern::SCHEME_HTTPS, 35 URLPattern::SCHEME_HTTPS,
35 URLPattern::SCHEME_FILE, 36 URLPattern::SCHEME_FILE,
36 URLPattern::SCHEME_FTP, 37 URLPattern::SCHEME_FTP,
37 URLPattern::SCHEME_CHROMEUI, 38 URLPattern::SCHEME_CHROMEUI,
38 URLPattern::SCHEME_EXTENSION, 39 URLPattern::SCHEME_EXTENSION,
39 URLPattern::SCHEME_FILESYSTEM, 40 URLPattern::SCHEME_FILESYSTEM,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 359 }
359 360
360 bool URLPattern::MatchesScheme(const std::string& test) const { 361 bool URLPattern::MatchesScheme(const std::string& test) const {
361 if (!IsValidScheme(test)) 362 if (!IsValidScheme(test))
362 return false; 363 return false;
363 364
364 return scheme_ == "*" || test == scheme_; 365 return scheme_ == "*" || test == scheme_;
365 } 366 }
366 367
367 bool URLPattern::MatchesHost(const std::string& host) const { 368 bool URLPattern::MatchesHost(const std::string& host) const {
368 std::string test(content::kHttpScheme); 369 std::string test(url::kHttpScheme);
369 test += content::kStandardSchemeSeparator; 370 test += content::kStandardSchemeSeparator;
370 test += host; 371 test += host;
371 test += "/"; 372 test += "/";
372 return MatchesHost(GURL(test)); 373 return MatchesHost(GURL(test));
373 } 374 }
374 375
375 bool URLPattern::MatchesHost(const GURL& test) const { 376 bool URLPattern::MatchesHost(const GURL& test) const {
376 // If the hosts are exactly equal, we have a match. 377 // If the hosts are exactly equal, we have a match.
377 if (test.host() == host_) 378 if (test.host() == host_)
378 return true; 379 return true;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 537 }
537 538
538 return result; 539 return result;
539 } 540 }
540 541
541 // static 542 // static
542 const char* URLPattern::GetParseResultString( 543 const char* URLPattern::GetParseResultString(
543 URLPattern::ParseResult parse_result) { 544 URLPattern::ParseResult parse_result) {
544 return kParseResultMessages[parse_result]; 545 return kParseResultMessages[parse_result];
545 } 546 }
OLDNEW
« no previous file with comments | « content/renderer/render_frame_impl.cc ('k') | url/url_constants.h » ('j') | url/url_srcs.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698