| 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 | 9 |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
| 11 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 12 #include "base/values.h" | 13 #include "base/values.h" |
| 13 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
| 14 #include "extensions/common/url_pattern.h" | 15 #include "extensions/common/url_pattern.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 #include "url/url_constants.h" | 17 #include "url/url_constants.h" |
| 17 | 18 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 93 |
| 93 URLPatternSet& URLPatternSet::operator=(const URLPatternSet& rhs) { | 94 URLPatternSet& URLPatternSet::operator=(const URLPatternSet& rhs) { |
| 94 patterns_ = rhs.patterns_; | 95 patterns_ = rhs.patterns_; |
| 95 return *this; | 96 return *this; |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool URLPatternSet::operator==(const URLPatternSet& other) const { | 99 bool URLPatternSet::operator==(const URLPatternSet& other) const { |
| 99 return patterns_ == other.patterns_; | 100 return patterns_ == other.patterns_; |
| 100 } | 101 } |
| 101 | 102 |
| 103 std::ostream& operator<<(std::ostream& out, |
| 104 const URLPatternSet& url_pattern_set) { |
| 105 out << "{ "; |
| 106 |
| 107 std::set<URLPattern>::const_iterator iter = |
| 108 url_pattern_set.patterns().begin(); |
| 109 if (!url_pattern_set.patterns().empty()) { |
| 110 out << *iter; |
| 111 ++iter; |
| 112 } |
| 113 |
| 114 for (;iter != url_pattern_set.patterns().end(); ++iter) |
| 115 out << ", " << *iter; |
| 116 |
| 117 if (!url_pattern_set.patterns().empty()) |
| 118 out << " "; |
| 119 |
| 120 out << "}"; |
| 121 return out; |
| 122 } |
| 123 |
| 102 bool URLPatternSet::is_empty() const { | 124 bool URLPatternSet::is_empty() const { |
| 103 return patterns_.empty(); | 125 return patterns_.empty(); |
| 104 } | 126 } |
| 105 | 127 |
| 106 size_t URLPatternSet::size() const { | 128 size_t URLPatternSet::size() const { |
| 107 return patterns_.size(); | 129 return patterns_.size(); |
| 108 } | 130 } |
| 109 | 131 |
| 110 bool URLPatternSet::AddPattern(const URLPattern& pattern) { | 132 bool URLPatternSet::AddPattern(const URLPattern& pattern) { |
| 111 return patterns_.insert(pattern).second; | 133 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) { | 237 for (size_t i = 0; i < value.GetSize(); ++i) { |
| 216 std::string item; | 238 std::string item; |
| 217 if (!value.GetString(i, &item)) | 239 if (!value.GetString(i, &item)) |
| 218 return false; | 240 return false; |
| 219 patterns.push_back(item); | 241 patterns.push_back(item); |
| 220 } | 242 } |
| 221 return Populate(patterns, valid_schemes, allow_file_access, error); | 243 return Populate(patterns, valid_schemes, allow_file_access, error); |
| 222 } | 244 } |
| 223 | 245 |
| 224 } // namespace extensions | 246 } // namespace extensions |
| OLD | NEW |