Chromium Code Reviews| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 | 92 |
| 93 URLPatternSet& URLPatternSet::operator=(const URLPatternSet& rhs) { | 93 URLPatternSet& URLPatternSet::operator=(const URLPatternSet& rhs) { |
| 94 patterns_ = rhs.patterns_; | 94 patterns_ = rhs.patterns_; |
| 95 return *this; | 95 return *this; |
| 96 } | 96 } |
| 97 | 97 |
| 98 bool URLPatternSet::operator==(const URLPatternSet& other) const { | 98 bool URLPatternSet::operator==(const URLPatternSet& other) const { |
| 99 return patterns_ == other.patterns_; | 99 return patterns_ == other.patterns_; |
| 100 } | 100 } |
| 101 | 101 |
| 102 std::ostream& operator<<(std::ostream& out, | |
| 103 const URLPatternSet& url_pattern_set) { | |
| 104 out << "{ "; | |
| 105 std::set<URLPattern>::const_iterator end = url_pattern_set.patterns().end(); | |
| 106 if (!url_pattern_set.patterns().empty()) | |
| 107 --end; | |
| 108 | |
| 109 copy(url_pattern_set.patterns().begin(), | |
|
Jeffrey Yasskin
2014/05/28 21:06:08
Heh. Nice use of the STL, but I think it'll wind u
aboxhall
2014/05/28 22:06:44
Done (not much simpler actually!)
| |
| 110 end, | |
| 111 std::ostream_iterator<URLPattern>(out, ", ")); | |
| 112 | |
| 113 if (!url_pattern_set.patterns().empty()) | |
| 114 out << *end << " "; | |
| 115 | |
| 116 out << "}"; | |
| 117 return out; | |
| 118 } | |
| 119 | |
| 102 bool URLPatternSet::is_empty() const { | 120 bool URLPatternSet::is_empty() const { |
| 103 return patterns_.empty(); | 121 return patterns_.empty(); |
| 104 } | 122 } |
| 105 | 123 |
| 106 size_t URLPatternSet::size() const { | 124 size_t URLPatternSet::size() const { |
| 107 return patterns_.size(); | 125 return patterns_.size(); |
| 108 } | 126 } |
| 109 | 127 |
| 110 bool URLPatternSet::AddPattern(const URLPattern& pattern) { | 128 bool URLPatternSet::AddPattern(const URLPattern& pattern) { |
| 111 return patterns_.insert(pattern).second; | 129 return patterns_.insert(pattern).second; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 for (size_t i = 0; i < value.GetSize(); ++i) { | 233 for (size_t i = 0; i < value.GetSize(); ++i) { |
| 216 std::string item; | 234 std::string item; |
| 217 if (!value.GetString(i, &item)) | 235 if (!value.GetString(i, &item)) |
| 218 return false; | 236 return false; |
| 219 patterns.push_back(item); | 237 patterns.push_back(item); |
| 220 } | 238 } |
| 221 return Populate(patterns, valid_schemes, allow_file_access, error); | 239 return Populate(patterns, valid_schemes, allow_file_access, error); |
| 222 } | 240 } |
| 223 | 241 |
| 224 } // namespace extensions | 242 } // namespace extensions |
| OLD | NEW |