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 <iterator> | 7 #include <iterator> |
8 #include <ostream> | 8 #include <ostream> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
135 | 135 |
136 void URLPatternSet::AddPatterns(const URLPatternSet& set) { | 136 void URLPatternSet::AddPatterns(const URLPatternSet& set) { |
137 patterns_.insert(set.patterns().begin(), | 137 patterns_.insert(set.patterns().begin(), |
138 set.patterns().end()); | 138 set.patterns().end()); |
139 } | 139 } |
140 | 140 |
141 void URLPatternSet::ClearPatterns() { | 141 void URLPatternSet::ClearPatterns() { |
142 patterns_.clear(); | 142 patterns_.clear(); |
143 } | 143 } |
144 | 144 |
145 bool URLPatternSet::AddOrigin(int valid_schemes, const GURL& origin) { | |
146 DCHECK_EQ(origin.GetOrigin(), origin); | |
147 URLPattern origin_pattern(valid_schemes); | |
not at google - send to devlin
2014/08/12 19:49:27
add that comment about URL parsing potentially fai
gpdavis
2014/08/12 21:19:55
Done.
| |
148 return (origin_pattern.Parse(origin.GetOrigin().spec()) == | |
149 URLPattern::PARSE_SUCCESS) && | |
150 AddPattern(origin_pattern); | |
151 } | |
152 | |
145 bool URLPatternSet::Contains(const URLPatternSet& other) const { | 153 bool URLPatternSet::Contains(const URLPatternSet& other) const { |
146 for (URLPatternSet::const_iterator it = other.begin(); | 154 for (URLPatternSet::const_iterator it = other.begin(); |
147 it != other.end(); ++it) { | 155 it != other.end(); ++it) { |
148 if (!ContainsPattern(*it)) | 156 if (!ContainsPattern(*it)) |
149 return false; | 157 return false; |
150 } | 158 } |
151 | 159 |
152 return true; | 160 return true; |
153 } | 161 } |
154 | 162 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 for (size_t i = 0; i < value.GetSize(); ++i) { | 265 for (size_t i = 0; i < value.GetSize(); ++i) { |
258 std::string item; | 266 std::string item; |
259 if (!value.GetString(i, &item)) | 267 if (!value.GetString(i, &item)) |
260 return false; | 268 return false; |
261 patterns.push_back(item); | 269 patterns.push_back(item); |
262 } | 270 } |
263 return Populate(patterns, valid_schemes, allow_file_access, error); | 271 return Populate(patterns, valid_schemes, allow_file_access, error); |
264 } | 272 } |
265 | 273 |
266 } // namespace extensions | 274 } // namespace extensions |
OLD | NEW |