Chromium Code Reviews| Index: chrome/browser/extensions/blacklist.cc |
| diff --git a/chrome/browser/extensions/blacklist.cc b/chrome/browser/extensions/blacklist.cc |
| index 834d262198118505664203a09d61d53780e5c188..3fa93e6165201f40a7a99b67afbf3c6c33c9e6ed 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,25 @@ Blacklist::Blacklist(ExtensionPrefs* prefs) : prefs_(prefs) { |
| Blacklist::~Blacklist() { |
| } |
| -bool Blacklist::IsBlacklisted(const Extension* extension) const { |
| - return prefs_->IsExtensionBlacklisted(extension->id()); |
| +void Blacklist::IsBlacklisted(const std::set<std::string>& ids, |
| + const IsBlacklistedCallback& 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)); |
| } |
| -bool Blacklist::IsBlacklisted(const std::string& extension_id) const { |
| - return prefs_->IsExtensionBlacklisted(extension_id); |
| +void Blacklist::IsBlacklisted(const std::string& id, |
| + const IsBlacklistedCallback& callback) { |
| + std::set<std::string> id_set; |
| + id_set.insert(id); |
| + IsBlacklisted(id_set, callback); |
| } |
| void Blacklist::SetFromUpdater(const std::vector<std::string>& ids, |
| @@ -43,7 +60,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())); |
|
asargent_no_longer_on_chrome
2012/11/30 21:44:22
It would be sort of cool if we had a SetDifference
not at google - send to devlin
2012/11/30 23:09:54
Sounds good to me.
Here we go: https://codereview
|
| + |
| + 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); |
| + } |
|
not at google - send to devlin
2012/11/30 18:57:20
I'm thinking about moving the prefs modification s
asargent_no_longer_on_chrome
2012/11/30 21:49:59
Sorry, I missed this comment when going through th
not at google - send to devlin
2012/11/30 22:06:39
The nice thing about the safebrowsing databases is
not at google - send to devlin
2012/11/30 23:09:54
As you say, I think this change would make more se
Yoyo Zhou
2012/11/30 23:44:07
Just as a general comment, there should be less st
not at google - send to devlin
2012/12/01 02:51:30
My plan was to have Blacklist be essentially an in
|
| + |
| prefs_->pref_service()->SetString(prefs::kExtensionBlacklistUpdateVersion, |
| version); |