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

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

Issue 181043006: Implement correct logic for URLPatternSet set operators. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 6 years, 9 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 | « no previous file | extensions/common/url_pattern_set.h » ('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.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"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 return true; 454 return true;
455 return (MatchesAnyScheme(other.GetExplicitSchemes()) || 455 return (MatchesAnyScheme(other.GetExplicitSchemes()) ||
456 other.MatchesAnyScheme(GetExplicitSchemes())) 456 other.MatchesAnyScheme(GetExplicitSchemes()))
457 && (MatchesHost(other.host()) || other.MatchesHost(host())) 457 && (MatchesHost(other.host()) || other.MatchesHost(host()))
458 && (MatchesPortPattern(other.port()) || other.MatchesPortPattern(port())) 458 && (MatchesPortPattern(other.port()) || other.MatchesPortPattern(port()))
459 && (MatchesPath(StripTrailingWildcard(other.path())) || 459 && (MatchesPath(StripTrailingWildcard(other.path())) ||
460 other.MatchesPath(StripTrailingWildcard(path()))); 460 other.MatchesPath(StripTrailingWildcard(path())));
461 } 461 }
462 462
463 bool URLPattern::Contains(const URLPattern& other) const { 463 bool URLPattern::Contains(const URLPattern& other) const {
464 if (*this == other)
465 return true;
464 if (match_all_urls()) 466 if (match_all_urls())
465 return true; 467 return true;
466 return MatchesAllSchemes(other.GetExplicitSchemes()) 468 return MatchesAllSchemes(other.GetExplicitSchemes())
467 && MatchesHost(other.host()) 469 && MatchesHost(other.host())
468 && MatchesPortPattern(other.port()) 470 && MatchesPortPattern(other.port())
469 && MatchesPath(StripTrailingWildcard(other.path())); 471 && MatchesPath(StripTrailingWildcard(other.path()));
470 } 472 }
471 473
472 bool URLPattern::MatchesAnyScheme( 474 bool URLPattern::MatchesAnyScheme(
473 const std::vector<std::string>& schemes) const { 475 const std::vector<std::string>& schemes) const {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 538 }
537 539
538 return result; 540 return result;
539 } 541 }
540 542
541 // static 543 // static
542 const char* URLPattern::GetParseResultString( 544 const char* URLPattern::GetParseResultString(
543 URLPattern::ParseResult parse_result) { 545 URLPattern::ParseResult parse_result) {
544 return kParseResultMessages[parse_result]; 546 return kParseResultMessages[parse_result];
545 } 547 }
OLDNEW
« no previous file with comments | « no previous file | extensions/common/url_pattern_set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698