| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 bool URLPatternSet::Contains(const URLPatternSet& other) const { | 132 bool URLPatternSet::Contains(const URLPatternSet& other) const { |
| 133 for (URLPatternSet::const_iterator it = other.begin(); | 133 for (URLPatternSet::const_iterator it = other.begin(); |
| 134 it != other.end(); ++it) { | 134 it != other.end(); ++it) { |
| 135 if (!ContainsPattern(*it)) | 135 if (!ContainsPattern(*it)) |
| 136 return false; | 136 return false; |
| 137 } | 137 } |
| 138 | 138 |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 bool URLPatternSet::ContainsPattern(const URLPattern& pattern) const { |
| 143 for (URLPatternSet::const_iterator it = begin(); |
| 144 it != end(); ++it) { |
| 145 if (it->Contains(pattern)) |
| 146 return true; |
| 147 } |
| 148 return false; |
| 149 } |
| 150 |
| 142 bool URLPatternSet::MatchesURL(const GURL& url) const { | 151 bool URLPatternSet::MatchesURL(const GURL& url) const { |
| 143 for (URLPatternSet::const_iterator pattern = patterns_.begin(); | 152 for (URLPatternSet::const_iterator pattern = patterns_.begin(); |
| 144 pattern != patterns_.end(); ++pattern) { | 153 pattern != patterns_.end(); ++pattern) { |
| 145 if (pattern->MatchesURL(url)) | 154 if (pattern->MatchesURL(url)) |
| 146 return true; | 155 return true; |
| 147 } | 156 } |
| 148 | 157 |
| 149 return false; | 158 return false; |
| 150 } | 159 } |
| 151 | 160 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 std::vector<std::string> patterns; | 223 std::vector<std::string> patterns; |
| 215 for (size_t i = 0; i < value.GetSize(); ++i) { | 224 for (size_t i = 0; i < value.GetSize(); ++i) { |
| 216 std::string item; | 225 std::string item; |
| 217 if (!value.GetString(i, &item)) | 226 if (!value.GetString(i, &item)) |
| 218 return false; | 227 return false; |
| 219 patterns.push_back(item); | 228 patterns.push_back(item); |
| 220 } | 229 } |
| 221 return Populate(patterns, valid_schemes, allow_file_access, error); | 230 return Populate(patterns, valid_schemes, allow_file_access, error); |
| 222 } | 231 } |
| 223 | 232 |
| 224 bool URLPatternSet::ContainsPattern(const URLPattern& pattern) const { | |
| 225 for (URLPatternSet::const_iterator it = begin(); | |
| 226 it != end(); ++it) { | |
| 227 if (it->Contains(pattern)) | |
| 228 return true; | |
| 229 } | |
| 230 return false; | |
| 231 } | |
| 232 | |
| 233 } // namespace extensions | 233 } // namespace extensions |
| OLD | NEW |