OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/blacklist.h" | 5 #include "chrome/browser/extensions/blacklist.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/lazy_instance.h" | 11 #include "base/lazy_instance.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/extensions/blacklist_factory.h" |
17 #include "chrome/browser/extensions/blacklist_state_fetcher.h" | 18 #include "chrome/browser/extensions/blacklist_state_fetcher.h" |
18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
19 #include "chrome/browser/safe_browsing/safe_browsing_util.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_util.h" |
20 #include "content/public/browser/notification_details.h" | 21 #include "content/public/browser/notification_details.h" |
21 #include "content/public/browser/notification_source.h" | 22 #include "content/public/browser/notification_source.h" |
22 #include "extensions/browser/extension_prefs.h" | 23 #include "extensions/browser/extension_prefs.h" |
23 | 24 |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 | 26 |
26 namespace extensions { | 27 namespace extensions { |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 for (std::set<std::string>::iterator it = blacklisted.begin(); | 174 for (std::set<std::string>::iterator it = blacklisted.begin(); |
174 it != blacklisted.end(); ++it) { | 175 it != blacklisted.end(); ++it) { |
175 if (!prefs->GetInstalledExtensionInfo(*it)) | 176 if (!prefs->GetInstalledExtensionInfo(*it)) |
176 prefs->DeleteExtensionPrefs(*it); | 177 prefs->DeleteExtensionPrefs(*it); |
177 } | 178 } |
178 } | 179 } |
179 | 180 |
180 Blacklist::~Blacklist() { | 181 Blacklist::~Blacklist() { |
181 } | 182 } |
182 | 183 |
| 184 // static |
| 185 Blacklist* Blacklist::Get(content::BrowserContext* context) { |
| 186 return BlacklistFactory::GetForBrowserContext(context); |
| 187 } |
| 188 |
183 void Blacklist::GetBlacklistedIDs(const std::set<std::string>& ids, | 189 void Blacklist::GetBlacklistedIDs(const std::set<std::string>& ids, |
184 const GetBlacklistedIDsCallback& callback) { | 190 const GetBlacklistedIDsCallback& callback) { |
185 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 191 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
186 | 192 |
187 if (ids.empty() || !g_database_manager.Get().get().get()) { | 193 if (ids.empty() || !g_database_manager.Get().get().get()) { |
188 base::MessageLoopProxy::current()->PostTask( | 194 base::MessageLoopProxy::current()->PostTask( |
189 FROM_HERE, base::Bind(callback, BlacklistStateMap())); | 195 FROM_HERE, base::Bind(callback, BlacklistStateMap())); |
190 return; | 196 return; |
191 } | 197 } |
192 | 198 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 } | 347 } |
342 | 348 |
343 void Blacklist::Observe(int type, | 349 void Blacklist::Observe(int type, |
344 const content::NotificationSource& source, | 350 const content::NotificationSource& source, |
345 const content::NotificationDetails& details) { | 351 const content::NotificationDetails& details) { |
346 DCHECK_EQ(chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, type); | 352 DCHECK_EQ(chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, type); |
347 FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated()); | 353 FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated()); |
348 } | 354 } |
349 | 355 |
350 } // namespace extensions | 356 } // namespace extensions |
OLD | NEW |