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

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

Issue 8312005: Ignore paths when matching patterns for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix silly typo. Created 9 years, 1 month 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/extensions/url_pattern_set.h" 5 #include "chrome/common/extensions/url_pattern_set.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "chrome/common/extensions/url_pattern.h" 10 #include "chrome/common/extensions/url_pattern.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 bool URLPatternSet::MatchesURL(const GURL& url) const { 83 bool URLPatternSet::MatchesURL(const GURL& url) const {
84 for (URLPatternSet::const_iterator pattern = patterns_.begin(); 84 for (URLPatternSet::const_iterator pattern = patterns_.begin();
85 pattern != patterns_.end(); ++pattern) { 85 pattern != patterns_.end(); ++pattern) {
86 if (pattern->MatchesURL(url)) 86 if (pattern->MatchesURL(url))
87 return true; 87 return true;
88 } 88 }
89 89
90 return false; 90 return false;
91 } 91 }
92 92
93 bool URLPatternSet::MatchesSecurityOrigin(const GURL& origin) const {
94 for (URLPatternSet::const_iterator pattern = patterns_.begin();
95 pattern != patterns_.end(); ++pattern) {
96 if (pattern->MatchesSecurityOrigin(origin))
97 return true;
98 }
99
100 return false;
101 }
102
93 bool URLPatternSet::OverlapsWith(const URLPatternSet& other) const { 103 bool URLPatternSet::OverlapsWith(const URLPatternSet& other) const {
94 // Two extension extents overlap if there is any one URL that would match at 104 // Two extension extents overlap if there is any one URL that would match at
95 // least one pattern in each of the extents. 105 // least one pattern in each of the extents.
96 for (URLPatternSet::const_iterator i = patterns_.begin(); 106 for (URLPatternSet::const_iterator i = patterns_.begin();
97 i != patterns_.end(); ++i) { 107 i != patterns_.end(); ++i) {
98 for (URLPatternSet::const_iterator j = other.patterns().begin(); 108 for (URLPatternSet::const_iterator j = other.patterns().begin();
99 j != other.patterns().end(); ++j) { 109 j != other.patterns().end(); ++j) {
100 if (i->OverlapsWith(*j)) 110 if (i->OverlapsWith(*j))
101 return true; 111 return true;
102 } 112 }
103 } 113 }
104 114
105 return false; 115 return false;
106 } 116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698