Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Side by Side Diff: chrome/browser/extensions/blacklist.cc

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Remove '// namespace safe_browsing' for a small fwd decl block. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
15 #include "base/stl_util.h" 15 #include "base/stl_util.h"
16 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chrome_notification_types.h" 18 #include "chrome/browser/chrome_notification_types.h"
19 #include "chrome/browser/extensions/blacklist_factory.h" 19 #include "chrome/browser/extensions/blacklist_factory.h"
20 #include "chrome/browser/extensions/blacklist_state_fetcher.h" 20 #include "chrome/browser/extensions/blacklist_state_fetcher.h"
21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
22 #include "chrome/browser/safe_browsing/safe_browsing_util.h" 22 #include "chrome/browser/safe_browsing/safe_browsing_util.h"
23 #include "content/public/browser/notification_details.h" 23 #include "content/public/browser/notification_details.h"
24 #include "content/public/browser/notification_source.h" 24 #include "content/public/browser/notification_source.h"
25 #include "extensions/browser/extension_prefs.h" 25 #include "extensions/browser/extension_prefs.h"
26 26
27 using content::BrowserThread; 27 using content::BrowserThread;
28 using safe_browsing::SafeBrowsingDatabaseManager;
28 29
29 namespace extensions { 30 namespace extensions {
30 31
31 namespace { 32 namespace {
32 33
33 // The safe browsing database manager to use. Make this a global/static variable 34 // The safe browsing database manager to use. Make this a global/static variable
34 // rather than a member of Blacklist because Blacklist accesses the real 35 // rather than a member of Blacklist because Blacklist accesses the real
35 // database manager before it has a chance to get a fake one. 36 // database manager before it has a chance to get a fake one.
36 class LazySafeBrowsingDatabaseManager { 37 class LazySafeBrowsingDatabaseManager {
37 public: 38 public:
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 157
157 Blacklist::ScopedDatabaseManagerForTest::~ScopedDatabaseManagerForTest() { 158 Blacklist::ScopedDatabaseManagerForTest::~ScopedDatabaseManagerForTest() {
158 SetDatabaseManager(original_); 159 SetDatabaseManager(original_);
159 } 160 }
160 161
161 Blacklist::Blacklist(ExtensionPrefs* prefs) { 162 Blacklist::Blacklist(ExtensionPrefs* prefs) {
162 scoped_refptr<SafeBrowsingDatabaseManager> database_manager = 163 scoped_refptr<SafeBrowsingDatabaseManager> database_manager =
163 g_database_manager.Get().get(); 164 g_database_manager.Get().get();
164 if (database_manager.get()) { 165 if (database_manager.get()) {
165 registrar_.Add( 166 registrar_.Add(
166 this, 167 this, chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
167 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
168 content::Source<SafeBrowsingDatabaseManager>(database_manager.get())); 168 content::Source<SafeBrowsingDatabaseManager>(database_manager.get()));
169 } 169 }
170 170
171 // Clear out the old prefs-backed blacklist, stored as empty extension entries 171 // Clear out the old prefs-backed blacklist, stored as empty extension entries
172 // with just a "blacklisted" property. 172 // with just a "blacklisted" property.
173 // 173 //
174 // TODO(kalman): Delete this block of code, see http://crbug.com/295882. 174 // TODO(kalman): Delete this block of code, see http://crbug.com/295882.
175 std::set<std::string> blacklisted = prefs->GetBlacklistedExtensions(); 175 std::set<std::string> blacklisted = prefs->GetBlacklistedExtensions();
176 for (std::set<std::string>::iterator it = blacklisted.begin(); 176 for (std::set<std::string>::iterator it = blacklisted.begin();
177 it != blacklisted.end(); ++it) { 177 it != blacklisted.end(); ++it) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 349 }
350 350
351 void Blacklist::Observe(int type, 351 void Blacklist::Observe(int type,
352 const content::NotificationSource& source, 352 const content::NotificationSource& source,
353 const content::NotificationDetails& details) { 353 const content::NotificationDetails& details) {
354 DCHECK_EQ(chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, type); 354 DCHECK_EQ(chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, type);
355 FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated()); 355 FOR_EACH_OBSERVER(Observer, observers_, OnBlacklistUpdated());
356 } 356 }
357 357
358 } // namespace extensions 358 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/blacklist.h ('k') | chrome/browser/extensions/blacklist_state_fetcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698