| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 &explicit_hosts); | 190 &explicit_hosts); |
| 191 | 191 |
| 192 URLPatternSet scriptable_hosts; | 192 URLPatternSet scriptable_hosts; |
| 193 URLPatternSet::CreateUnion(set1_safe->scriptable_hosts(), | 193 URLPatternSet::CreateUnion(set1_safe->scriptable_hosts(), |
| 194 set2_safe->scriptable_hosts(), | 194 set2_safe->scriptable_hosts(), |
| 195 &scriptable_hosts); | 195 &scriptable_hosts); |
| 196 | 196 |
| 197 return new PermissionSet(apis, explicit_hosts, scriptable_hosts); | 197 return new PermissionSet(apis, explicit_hosts, scriptable_hosts); |
| 198 } | 198 } |
| 199 | 199 |
| 200 // static | |
| 201 PermissionSet* PermissionSet::ExcludeNotInManifestPermissions( | |
| 202 const PermissionSet* set) { | |
| 203 if (!set) | |
| 204 return new PermissionSet(); | |
| 205 | |
| 206 APIPermissionSet apis; | |
| 207 for (APIPermissionSet::const_iterator i = set->apis().begin(); | |
| 208 i != set->apis().end(); ++i) { | |
| 209 if (!i->ManifestEntryForbidden()) | |
| 210 apis.insert(i->Clone()); | |
| 211 } | |
| 212 | |
| 213 return new PermissionSet( | |
| 214 apis, set->explicit_hosts(), set->scriptable_hosts()); | |
| 215 } | |
| 216 | |
| 217 bool PermissionSet::operator==( | 200 bool PermissionSet::operator==( |
| 218 const PermissionSet& rhs) const { | 201 const PermissionSet& rhs) const { |
| 219 return apis_ == rhs.apis_ && | 202 return apis_ == rhs.apis_ && |
| 220 scriptable_hosts_ == rhs.scriptable_hosts_ && | 203 scriptable_hosts_ == rhs.scriptable_hosts_ && |
| 221 explicit_hosts_ == rhs.explicit_hosts_; | 204 explicit_hosts_ == rhs.explicit_hosts_; |
| 222 } | 205 } |
| 223 | 206 |
| 224 bool PermissionSet::Contains(const PermissionSet& set) const { | 207 bool PermissionSet::Contains(const PermissionSet& set) const { |
| 225 // Every set includes the empty set. | 208 // Every set includes the empty set. |
| 226 if (set.IsEmpty()) | 209 if (set.IsEmpty()) |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 std::set<std::string> new_hosts_only; | 589 std::set<std::string> new_hosts_only; |
| 607 | 590 |
| 608 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), | 591 std::set_difference(new_hosts_set.begin(), new_hosts_set.end(), |
| 609 old_hosts_set.begin(), old_hosts_set.end(), | 592 old_hosts_set.begin(), old_hosts_set.end(), |
| 610 std::inserter(new_hosts_only, new_hosts_only.begin())); | 593 std::inserter(new_hosts_only, new_hosts_only.begin())); |
| 611 | 594 |
| 612 return !new_hosts_only.empty(); | 595 return !new_hosts_only.empty(); |
| 613 } | 596 } |
| 614 | 597 |
| 615 } // namespace extensions | 598 } // namespace extensions |
| OLD | NEW |