| Index: chrome/browser/extensions/blacklist.cc
|
| diff --git a/chrome/browser/extensions/blacklist.cc b/chrome/browser/extensions/blacklist.cc
|
| index 905b67a34bf35239033c808e6ccdb507f5d04eeb..d69f1d95e1b68a32a6f921e9af9afcd858106aa7 100644
|
| --- a/chrome/browser/extensions/blacklist.cc
|
| +++ b/chrome/browser/extensions/blacklist.cc
|
| @@ -141,22 +141,26 @@ Blacklist::ScopedDatabaseManagerForTest::~ScopedDatabaseManagerForTest() {
|
| SetDatabaseManager(original_);
|
| }
|
|
|
| -Blacklist::Blacklist(ExtensionPrefs* prefs) : prefs_(prefs) {
|
| +Blacklist::Blacklist(ExtensionPrefs* prefs) {
|
| scoped_refptr<SafeBrowsingDatabaseManager> database_manager =
|
| g_database_manager.Get().get();
|
| - if (database_manager.get()) {
|
| + if (database_manager) {
|
| registrar_.Add(
|
| this,
|
| chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
|
| content::Source<SafeBrowsingDatabaseManager>(database_manager.get()));
|
| }
|
|
|
| - // TODO(kalman): Delete anything from the pref blacklist that is in the
|
| - // safebrowsing blacklist (of course, only entries for which the extension
|
| - // hasn't been installed).
|
| + // Clear out the old prefs-backed blacklist, stored as empty extension entries
|
| + // with just a "blacklisted" property.
|
| //
|
| - // Or maybe just wait until we're able to delete the pref blacklist
|
| - // altogether (when we're sure it's a strict subset of the safebrowsing one).
|
| + // TODO(kalman): Delete this block of code, see http://crbug.com/295882.
|
| + std::set<std::string> blacklisted = prefs->GetBlacklistedExtensions();
|
| + for (std::set<std::string>::iterator it = blacklisted.begin();
|
| + it != blacklisted.end(); ++it) {
|
| + if (!prefs->GetInstalledExtensionInfo(*it))
|
| + prefs->DeleteExtensionPrefs(*it);
|
| + }
|
| }
|
|
|
| Blacklist::~Blacklist() {
|
| @@ -166,35 +170,15 @@ void Blacklist::GetBlacklistedIDs(const std::set<std::string>& ids,
|
| const GetBlacklistedIDsCallback& callback) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
|
|
| - if (ids.empty()) {
|
| + if (ids.empty() || !g_database_manager.Get().get().get()) {
|
| base::MessageLoopProxy::current()->PostTask(
|
| - FROM_HERE,
|
| - base::Bind(callback, std::set<std::string>()));
|
| - return;
|
| - }
|
| -
|
| - // The blacklisted IDs are the union of those blacklisted in prefs and
|
| - // those blacklisted from safe browsing.
|
| - std::set<std::string> pref_blacklisted_ids;
|
| - for (std::set<std::string>::const_iterator it = ids.begin();
|
| - it != ids.end(); ++it) {
|
| - if (prefs_->IsExtensionBlacklisted(*it))
|
| - pref_blacklisted_ids.insert(*it);
|
| - }
|
| -
|
| - if (!g_database_manager.Get().get().get()) {
|
| - base::MessageLoopProxy::current()->PostTask(
|
| - FROM_HERE, base::Bind(callback, pref_blacklisted_ids));
|
| + FROM_HERE, base::Bind(callback, std::set<std::string>()));
|
| return;
|
| }
|
|
|
| // Constructing the SafeBrowsingClientImpl begins the process of asking
|
| // safebrowsing for the blacklisted extensions.
|
| - new SafeBrowsingClientImpl(
|
| - ids,
|
| - base::Bind(&Blacklist::OnSafeBrowsingResponse, AsWeakPtr(),
|
| - pref_blacklisted_ids,
|
| - callback));
|
| + new SafeBrowsingClientImpl(ids, callback);
|
| }
|
|
|
| void Blacklist::IsBlacklisted(const std::string& extension_id,
|
| @@ -204,43 +188,6 @@ void Blacklist::IsBlacklisted(const std::string& extension_id,
|
| GetBlacklistedIDs(check, base::Bind(&IsNotEmpty, callback));
|
| }
|
|
|
| -void Blacklist::SetFromUpdater(const std::vector<std::string>& ids,
|
| - const std::string& version) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - std::set<std::string> ids_as_set;
|
| - for (std::vector<std::string>::const_iterator it = ids.begin();
|
| - it != ids.end(); ++it) {
|
| - if (Extension::IdIsValid(*it))
|
| - ids_as_set.insert(*it);
|
| - else
|
| - LOG(WARNING) << "Got invalid extension ID \"" << *it << "\"";
|
| - }
|
| -
|
| - std::set<std::string> from_prefs = prefs_->GetBlacklistedExtensions();
|
| -
|
| - std::set<std::string> no_longer_blacklisted =
|
| - base::STLSetDifference<std::set<std::string> >(from_prefs,
|
| - ids_as_set);
|
| - std::set<std::string> not_yet_blacklisted =
|
| - base::STLSetDifference<std::set<std::string> >(ids_as_set,
|
| - from_prefs);
|
| -
|
| - 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);
|
| -
|
| - FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated());
|
| -}
|
| -
|
| void Blacklist::AddObserver(Observer* observer) {
|
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| observers_.AddObserver(observer);
|
| @@ -262,19 +209,6 @@ scoped_refptr<SafeBrowsingDatabaseManager> Blacklist::GetDatabaseManager() {
|
| return g_database_manager.Get().get();
|
| }
|
|
|
| -void Blacklist::OnSafeBrowsingResponse(
|
| - const std::set<std::string>& pref_blacklisted_ids,
|
| - const GetBlacklistedIDsCallback& callback,
|
| - const std::set<std::string>& safebrowsing_blacklisted_ids) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| -
|
| - std::set<std::string> blacklist = pref_blacklisted_ids;
|
| - blacklist.insert(safebrowsing_blacklisted_ids.begin(),
|
| - safebrowsing_blacklisted_ids.end());
|
| -
|
| - callback.Run(blacklist);
|
| -}
|
| -
|
| void Blacklist::Observe(int type,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) {
|
|
|