| 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 3090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3101 base::Bind(&ExtensionService::ManageBlacklist, | 3101 base::Bind(&ExtensionService::ManageBlacklist, |
| 3102 AsWeakPtr(), | 3102 AsWeakPtr(), |
| 3103 blacklisted_extensions_.GetIDs())); | 3103 blacklisted_extensions_.GetIDs())); |
| 3104 } | 3104 } |
| 3105 | 3105 |
| 3106 void ExtensionService::ManageBlacklist( | 3106 void ExtensionService::ManageBlacklist( |
| 3107 const std::set<std::string>& old_blacklisted_ids, | 3107 const std::set<std::string>& old_blacklisted_ids, |
| 3108 const std::set<std::string>& new_blacklisted_ids) { | 3108 const std::set<std::string>& new_blacklisted_ids) { |
| 3109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3109 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3110 | 3110 |
| 3111 std::set<std::string> no_longer_blacklisted; | 3111 std::set<std::string> no_longer_blacklisted = |
| 3112 std::set_difference(old_blacklisted_ids.begin(), old_blacklisted_ids.end(), | 3112 base::STLSetDifference<std::set<std::string> >(old_blacklisted_ids, |
| 3113 new_blacklisted_ids.begin(), new_blacklisted_ids.end(), | 3113 new_blacklisted_ids); |
| 3114 std::inserter(no_longer_blacklisted, | 3114 std::set<std::string> not_yet_blacklisted = |
| 3115 no_longer_blacklisted.begin())); | 3115 base::STLSetDifference<std::set<std::string> >(new_blacklisted_ids, |
| 3116 std::set<std::string> not_yet_blacklisted; | 3116 old_blacklisted_ids); |
| 3117 std::set_difference(new_blacklisted_ids.begin(), new_blacklisted_ids.end(), | |
| 3118 old_blacklisted_ids.begin(), old_blacklisted_ids.end(), | |
| 3119 std::inserter(not_yet_blacklisted, | |
| 3120 not_yet_blacklisted.begin())); | |
| 3121 | 3117 |
| 3122 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin(); | 3118 for (std::set<std::string>::iterator it = no_longer_blacklisted.begin(); |
| 3123 it != no_longer_blacklisted.end(); ++it) { | 3119 it != no_longer_blacklisted.end(); ++it) { |
| 3124 scoped_refptr<const Extension> extension = | 3120 scoped_refptr<const Extension> extension = |
| 3125 blacklisted_extensions_.GetByID(*it); | 3121 blacklisted_extensions_.GetByID(*it); |
| 3126 DCHECK(extension.get()) << "Extension " << *it << " no longer blacklisted, " | 3122 DCHECK(extension.get()) << "Extension " << *it << " no longer blacklisted, " |
| 3127 << "but it was never blacklisted."; | 3123 << "but it was never blacklisted."; |
| 3128 if (!extension.get()) | 3124 if (!extension.get()) |
| 3129 continue; | 3125 continue; |
| 3130 blacklisted_extensions_.Remove(*it); | 3126 blacklisted_extensions_.Remove(*it); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3151 } | 3147 } |
| 3152 | 3148 |
| 3153 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 3149 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
| 3154 update_observers_.AddObserver(observer); | 3150 update_observers_.AddObserver(observer); |
| 3155 } | 3151 } |
| 3156 | 3152 |
| 3157 void ExtensionService::RemoveUpdateObserver( | 3153 void ExtensionService::RemoveUpdateObserver( |
| 3158 extensions::UpdateObserver* observer) { | 3154 extensions::UpdateObserver* observer) { |
| 3159 update_observers_.RemoveObserver(observer); | 3155 update_observers_.RemoveObserver(observer); |
| 3160 } | 3156 } |
| OLD | NEW |