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 << "{ "; | |
|
Jeffrey Yasskin
2014/05/28 22:32:04
And <ostream>
aboxhall
2014/05/28 22:44:10
Done.
| |
| 105 | |
| 106 using const_iterator = std::set<URLPattern>::const_iterator; | |
|
Jeffrey Yasskin
2014/05/28 22:32:04
This is C++11 so won't work everywhere. Use typede
aboxhall
2014/05/28 22:44:10
Done.
| |
| 107 const_iterator iter = url_pattern_set.patterns().begin(); | |
| 108 if (!url_pattern_set.patterns().empty()) { | |
| 109 out << *iter; | |
| 110 ++iter; | |
| 111 } | |
| 112 | |
| 113 for (;iter != url_pattern_set.patterns().end(); ++iter) | |
| 114 out << ", " << *iter; | |
| 115 | |
| 116 if (!url_pattern_set.patterns().empty()) | |
| 117 out << " "; | |
| 118 | |
| 119 out << "}"; | |
| 120 return out; | |
| 121 } | |
| 122 | |
| 102 bool URLPatternSet::is_empty() const { | 123 bool URLPatternSet::is_empty() const { |
| 103 return patterns_.empty(); | 124 return patterns_.empty(); |
| 104 } | 125 } |
| 105 | 126 |
| 106 size_t URLPatternSet::size() const { | 127 size_t URLPatternSet::size() const { |
| 107 return patterns_.size(); | 128 return patterns_.size(); |
| 108 } | 129 } |
| 109 | 130 |
| 110 bool URLPatternSet::AddPattern(const URLPattern& pattern) { | 131 bool URLPatternSet::AddPattern(const URLPattern& pattern) { |
| 111 return patterns_.insert(pattern).second; | 132 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) { | 236 for (size_t i = 0; i < value.GetSize(); ++i) { |
| 216 std::string item; | 237 std::string item; |
| 217 if (!value.GetString(i, &item)) | 238 if (!value.GetString(i, &item)) |
| 218 return false; | 239 return false; |
| 219 patterns.push_back(item); | 240 patterns.push_back(item); |
| 220 } | 241 } |
| 221 return Populate(patterns, valid_schemes, allow_file_access, error); | 242 return Populate(patterns, valid_schemes, allow_file_access, error); |
| 222 } | 243 } |
| 223 | 244 |
| 224 } // namespace extensions | 245 } // namespace extensions |
| OLD | NEW |