| 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 "chrome/common/extensions/permissions/permission_set.h" | 5 #include "chrome/common/extensions/permissions/permission_set.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool PermissionSet::operator==( | 220 bool PermissionSet::operator==( |
| 221 const PermissionSet& rhs) const { | 221 const PermissionSet& rhs) const { |
| 222 return apis_ == rhs.apis_ && | 222 return apis_ == rhs.apis_ && |
| 223 scriptable_hosts_ == rhs.scriptable_hosts_ && | 223 scriptable_hosts_ == rhs.scriptable_hosts_ && |
| 224 explicit_hosts_ == rhs.explicit_hosts_; | 224 explicit_hosts_ == rhs.explicit_hosts_; |
| 225 } | 225 } |
| 226 | 226 |
| 227 bool PermissionSet::Contains(const PermissionSet& set) const { | 227 bool PermissionSet::Contains(const PermissionSet& set) const { |
| 228 // Every set includes the empty set. | 228 return apis_.Contains(set.apis()) && |
| 229 if (set.IsEmpty()) | 229 explicit_hosts().Contains(set.explicit_hosts()) && |
| 230 return true; | 230 scriptable_hosts().Contains(set.scriptable_hosts()); |
| 231 | |
| 232 if (!apis_.Contains(set.apis())) | |
| 233 return false; | |
| 234 | |
| 235 if (!explicit_hosts().Contains(set.explicit_hosts())) | |
| 236 return false; | |
| 237 | |
| 238 if (!scriptable_hosts().Contains(set.scriptable_hosts())) | |
| 239 return false; | |
| 240 | |
| 241 return true; | |
| 242 } | 231 } |
| 243 | 232 |
| 244 std::set<std::string> PermissionSet::GetAPIsAsStrings() const { | 233 std::set<std::string> PermissionSet::GetAPIsAsStrings() const { |
| 245 std::set<std::string> apis_str; | 234 std::set<std::string> apis_str; |
| 246 for (APIPermissionSet::const_iterator i = apis_.begin(); | 235 for (APIPermissionSet::const_iterator i = apis_.begin(); |
| 247 i != apis_.end(); ++i) { | 236 i != apis_.end(); ++i) { |
| 248 apis_str.insert(i->name()); | 237 apis_str.insert(i->name()); |
| 249 } | 238 } |
| 250 return apis_str; | 239 return apis_str; |
| 251 } | 240 } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 std::set<std::string> new_hosts_only; | 601 std::set<std::string> new_hosts_only; |
| 613 | 602 |
| 614 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 603 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 615 old_hosts_set.begin(), old_hosts_set.end(), | 604 old_hosts_set.begin(), old_hosts_set.end(), |
| 616 std::inserter(new_hosts_only, new_hosts_only.begin())); | 605 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 617 | 606 |
| 618 return !new_hosts_only.empty(); | 607 return !new_hosts_only.empty(); |
| 619 } | 608 } |
| 620 | 609 |
| 621 } // namespace extensions | 610 } // namespace extensions |
| OLD | NEW |