| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3118 base::Bind(&ExtensionService::ManageBlacklist, | 3118 base::Bind(&ExtensionService::ManageBlacklist, |
| 3119 AsWeakPtr(), | 3119 AsWeakPtr(), |
| 3120 blacklisted_extensions_.GetIDs())); | 3120 blacklisted_extensions_.GetIDs())); |
| 3121 } | 3121 } |
| 3122 | 3122 |
| 3123 void ExtensionService::ManageBlacklist( | 3123 void ExtensionService::ManageBlacklist( |
| 3124 const std::set<std::string>& old_blacklisted_ids, | 3124 const std::set<std::string>& old_blacklisted_ids, |
| 3125 const std::set<std::string>& new_blacklisted_ids) { | 3125 const std::set<std::string>& new_blacklisted_ids) { |
| 3126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3127 | 3127 |
| 3128 std::set<std::string> no_longer_blacklisted; | 3128 std::set<std::string> no_longer_blacklisted = |
| 3129 std::set_difference(old_blacklisted_ids.begin(), old_blacklisted_ids.end(), | 3129 base::STLSetDifference<std::set<std::string> >(old_blacklisted_ids, |
| 3130 new_blacklisted_ids.begin(), new_blacklisted_ids.end(), | 3130 new_blacklisted_ids); |
| 3131 std::inserter(no_longer_blacklisted, | 3131 std::set<std::string> not_yet_blacklisted = |
| 3132 no_longer_blacklisted.begin())); | 3132 base::STLSetDifference<std::set<std::string> >(new_blacklisted_ids, |
| 3133 std::set<std::string> not_yet_blacklisted; | 3133 old_blacklisted_ids); |
| 3134 std::set_difference(new_blacklisted_ids.begin(), new_blacklisted_ids.end(), | |
| 3135 old_blacklisted_ids.begin(), old_blacklisted_ids.end(), | |
| 3136 std::inserter(not_yet_blacklisted, | |
| 3137 not_yet_blacklisted.begin())); | |
| 3138 | 3134 |
| 3139 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin(); | 3135 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin(); |
| 3140 it != no_longer_blacklisted.end(); ++it) { | 3136 it != no_longer_blacklisted.end(); ++it) { |
| 3141 scoped_refptr<const Extension> extension = | 3137 scoped_refptr<const Extension> extension = |
| 3142 blacklisted_extensions_.GetByID(*it); | 3138 blacklisted_extensions_.GetByID(*it); |
| 3143 DCHECK(extension.get()) << "Extension " << *it << " no longer blacklisted, " | 3139 DCHECK(extension.get()) << "Extension " << *it << " no longer blacklisted, " |
| 3144 << "but it was never blacklisted."; | 3140 << "but it was never blacklisted."; |
| 3145 if (!extension.get()) | 3141 if (!extension.get()) |
| 3146 continue; | 3142 continue; |
| 3147 blacklisted_extensions_.Remove(*it); | 3143 blacklisted_extensions_.Remove(*it); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3168 } | 3164 } |
| 3169 | 3165 |
| 3170 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3166 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3171 update_observers_.AddObserver(observer); | 3167 update_observers_.AddObserver(observer); |
| 3172 } | 3168 } |
| 3173 | 3169 |
| 3174 void ExtensionService::RemoveUpdateObserver( | 3170 void ExtensionService::RemoveUpdateObserver( |
| 3175 extensions::UpdateObserver* observer) { | 3171 extensions::UpdateObserver* observer) { |
| 3176 update_observers_.RemoveObserver(observer); | 3172 update_observers_.RemoveObserver(observer); |
| 3177 } | 3173 } |
| OLD | NEW |