| Index: chrome/browser/extensions/blacklist.cc
|
| diff --git a/chrome/browser/extensions/blacklist.cc b/chrome/browser/extensions/blacklist.cc
|
| index 834d262198118505664203a09d61d53780e5c188..3d745a638559e22bb396c8fbfb1494b02dcdbccc 100644
|
| --- a/chrome/browser/extensions/blacklist.cc
|
| +++ b/chrome/browser/extensions/blacklist.cc
|
| @@ -4,6 +4,10 @@
|
|
|
| #include "chrome/browser/extensions/blacklist.h"
|
|
|
| +#include <algorithm>
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/message_loop.h"
|
| #include "chrome/browser/extensions/extension_prefs.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/common/pref_names.h"
|
| @@ -24,12 +28,18 @@ Blacklist::Blacklist(ExtensionPrefs* prefs) : prefs_(prefs) {
|
| Blacklist::~Blacklist() {
|
| }
|
|
|
| -bool Blacklist::IsBlacklisted(const Extension* extension) const {
|
| - return prefs_->IsExtensionBlacklisted(extension->id());
|
| -}
|
| -
|
| -bool Blacklist::IsBlacklisted(const std::string& extension_id) const {
|
| - return prefs_->IsExtensionBlacklisted(extension_id);
|
| +void Blacklist::GetBlacklistedIDs(const std::set<std::string>& ids,
|
| + const GetBlacklistedIDsCallback& callback) {
|
| + // TODO(kalman): Get the blacklisted IDs from the safebrowsing list.
|
| + // This will require going to the IO thread and back.
|
| + std::set<std::string> blacklisted_ids;
|
| + for (std::set<std::string>::const_iterator it = ids.begin();
|
| + it != ids.end(); ++it) {
|
| + if (prefs_->IsExtensionBlacklisted(*it))
|
| + blacklisted_ids.insert(*it);
|
| + }
|
| + MessageLoop::current()->PostTask(FROM_HERE,
|
| + base::Bind(callback, blacklisted_ids));
|
| }
|
|
|
| void Blacklist::SetFromUpdater(const std::vector<std::string>& ids,
|
| @@ -43,7 +53,28 @@ void Blacklist::SetFromUpdater(const std::vector<std::string>& ids,
|
| LOG(WARNING) << "Got invalid extension ID \"" << *it << "\"";
|
| }
|
|
|
| - prefs_->UpdateBlacklist(ids_as_set);
|
| + std::set<std::string> from_prefs = prefs_->GetBlacklistedExtensions();
|
| +
|
| + std::set<std::string> no_longer_blacklisted;
|
| + std::set_difference(from_prefs.begin(), from_prefs.end(),
|
| + ids_as_set.begin(), ids_as_set.end(),
|
| + std::inserter(no_longer_blacklisted,
|
| + no_longer_blacklisted.begin()));
|
| + std::set<std::string> not_yet_blacklisted;
|
| + std::set_difference(ids_as_set.begin(), ids_as_set.end(),
|
| + from_prefs.begin(), from_prefs.end(),
|
| + std::inserter(not_yet_blacklisted,
|
| + not_yet_blacklisted.begin()));
|
| +
|
| + for (std::set<std::string>::iterator it = no_longer_blacklisted.begin();
|
| + it != no_longer_blacklisted.end(); ++it) {
|
| + prefs_->SetExtensionBlacklisted(*it, false);
|
| + }
|
| + for (std::set<std::string>::iterator it = not_yet_blacklisted.begin();
|
| + it != not_yet_blacklisted.end(); ++it) {
|
| + prefs_->SetExtensionBlacklisted(*it, true);
|
| + }
|
| +
|
| prefs_->pref_service()->SetString(prefs::kExtensionBlacklistUpdateVersion,
|
| version);
|
|
|
|
|