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

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: Rebase and address some style nits. 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 "net/base/url_constants.h"
13 #include "url/gurl.h" 14 #include "url/gurl.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 net::kHttpScheme, net::kHttpsScheme,
24 content::kHttpsScheme, 25 content::kFileScheme, content::kFtpScheme,
25 content::kFileScheme, 26 content::kChromeUIScheme, extensions::kExtensionScheme,
26 content::kFtpScheme, 27 content::kFileSystemScheme,
27 content::kChromeUIScheme,
28 extensions::kExtensionScheme,
29 content::kFileSystemScheme,
30 }; 28 };
31 29
32 const int kValidSchemeMasks[] = { 30 const int kValidSchemeMasks[] = {
33 URLPattern::SCHEME_HTTP, 31 URLPattern::SCHEME_HTTP,
34 URLPattern::SCHEME_HTTPS, 32 URLPattern::SCHEME_HTTPS,
35 URLPattern::SCHEME_FILE, 33 URLPattern::SCHEME_FILE,
36 URLPattern::SCHEME_FTP, 34 URLPattern::SCHEME_FTP,
37 URLPattern::SCHEME_CHROMEUI, 35 URLPattern::SCHEME_CHROMEUI,
38 URLPattern::SCHEME_EXTENSION, 36 URLPattern::SCHEME_EXTENSION,
39 URLPattern::SCHEME_FILESYSTEM, 37 URLPattern::SCHEME_FILESYSTEM,
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 356 }
359 357
360 bool URLPattern::MatchesScheme(const std::string& test) const { 358 bool URLPattern::MatchesScheme(const std::string& test) const {
361 if (!IsValidScheme(test)) 359 if (!IsValidScheme(test))
362 return false; 360 return false;
363 361
364 return scheme_ == "*" || test == scheme_; 362 return scheme_ == "*" || test == scheme_;
365 } 363 }
366 364
367 bool URLPattern::MatchesHost(const std::string& host) const { 365 bool URLPattern::MatchesHost(const std::string& host) const {
368 std::string test(content::kHttpScheme); 366 std::string test(net::kHttpScheme);
369 test += content::kStandardSchemeSeparator; 367 test += content::kStandardSchemeSeparator;
370 test += host; 368 test += host;
371 test += "/"; 369 test += "/";
372 return MatchesHost(GURL(test)); 370 return MatchesHost(GURL(test));
373 } 371 }
374 372
375 bool URLPattern::MatchesHost(const GURL& test) const { 373 bool URLPattern::MatchesHost(const GURL& test) const {
376 // If the hosts are exactly equal, we have a match. 374 // If the hosts are exactly equal, we have a match.
377 if (test.host() == host_) 375 if (test.host() == host_)
378 return true; 376 return true;
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 534 }
537 535
538 return result; 536 return result;
539 } 537 }
540 538
541 // static 539 // static
542 const char* URLPattern::GetParseResultString( 540 const char* URLPattern::GetParseResultString(
543 URLPattern::ParseResult parse_result) { 541 URLPattern::ParseResult parse_result) {
544 return kParseResultMessages[parse_result]; 542 return kParseResultMessages[parse_result];
545 } 543 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698