OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/observer_list.h" | 17 #include "base/observer_list.h" |
18 #include "chrome/browser/safe_browsing/database_manager.h" | 18 #include "chrome/browser/safe_browsing/database_manager.h" |
| 19 #include "components/keyed_service/core/keyed_service.h" |
19 #include "content/public/browser/notification_observer.h" | 20 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 21 #include "content/public/browser/notification_registrar.h" |
21 #include "extensions/browser/blacklist_state.h" | 22 #include "extensions/browser/blacklist_state.h" |
22 | 23 |
| 24 namespace content { |
| 25 class BrowserContext; |
| 26 } |
| 27 |
23 namespace extensions { | 28 namespace extensions { |
24 | 29 |
25 class BlacklistStateFetcher; | 30 class BlacklistStateFetcher; |
26 class Extension; | 31 class Extension; |
27 class ExtensionPrefs; | 32 class ExtensionPrefs; |
28 | 33 |
29 // The blacklist of extensions backed by safe browsing. | 34 // The blacklist of extensions backed by safe browsing. |
30 class Blacklist : public content::NotificationObserver, | 35 class Blacklist : public KeyedService, |
| 36 public content::NotificationObserver, |
31 public base::SupportsWeakPtr<Blacklist> { | 37 public base::SupportsWeakPtr<Blacklist> { |
32 public: | 38 public: |
33 class Observer { | 39 class Observer { |
34 public: | 40 public: |
35 // Observes |blacklist| on construction and unobserves on destruction. | 41 // Observes |blacklist| on construction and unobserves on destruction. |
36 explicit Observer(Blacklist* blacklist); | 42 explicit Observer(Blacklist* blacklist); |
37 | 43 |
38 virtual void OnBlacklistUpdated() = 0; | 44 virtual void OnBlacklistUpdated() = 0; |
39 | 45 |
40 protected: | 46 protected: |
(...skipping 23 matching lines...) Expand all Loading... |
64 | 70 |
65 typedef base::Callback<void(const std::set<std::string>&)> | 71 typedef base::Callback<void(const std::set<std::string>&)> |
66 GetMalwareIDsCallback; | 72 GetMalwareIDsCallback; |
67 | 73 |
68 typedef base::Callback<void(BlacklistState)> IsBlacklistedCallback; | 74 typedef base::Callback<void(BlacklistState)> IsBlacklistedCallback; |
69 | 75 |
70 explicit Blacklist(ExtensionPrefs* prefs); | 76 explicit Blacklist(ExtensionPrefs* prefs); |
71 | 77 |
72 ~Blacklist() override; | 78 ~Blacklist() override; |
73 | 79 |
| 80 static Blacklist* Get(content::BrowserContext* context); |
| 81 |
74 // From the set of extension IDs passed in via |ids|, asynchronously checks | 82 // From the set of extension IDs passed in via |ids|, asynchronously checks |
75 // which are blacklisted and includes them in the resulting map passed | 83 // which are blacklisted and includes them in the resulting map passed |
76 // via |callback|, which will be sent on the caller's message loop. The values | 84 // via |callback|, which will be sent on the caller's message loop. The values |
77 // of the map are the blacklist state for each extension. Extensions with | 85 // of the map are the blacklist state for each extension. Extensions with |
78 // a BlacklistState of NOT_BLACKLISTED are not included in the result. | 86 // a BlacklistState of NOT_BLACKLISTED are not included in the result. |
79 // | 87 // |
80 // For a synchronous version which ONLY CHECKS CURRENTLY INSTALLED EXTENSIONS | 88 // For a synchronous version which ONLY CHECKS CURRENTLY INSTALLED EXTENSIONS |
81 // see ExtensionPrefs::IsExtensionBlacklisted. | 89 // see ExtensionPrefs::IsExtensionBlacklisted. |
82 void GetBlacklistedIDs(const std::set<std::string>& ids, | 90 void GetBlacklistedIDs(const std::set<std::string>& ids, |
83 const GetBlacklistedIDsCallback& callback); | 91 const GetBlacklistedIDsCallback& callback); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // GetBlacklistedIDs and deleted when the callback is called from | 153 // GetBlacklistedIDs and deleted when the callback is called from |
146 // OnBlacklistStateReceived. | 154 // OnBlacklistStateReceived. |
147 StateRequestsList state_requests_; | 155 StateRequestsList state_requests_; |
148 | 156 |
149 DISALLOW_COPY_AND_ASSIGN(Blacklist); | 157 DISALLOW_COPY_AND_ASSIGN(Blacklist); |
150 }; | 158 }; |
151 | 159 |
152 } // namespace extensions | 160 } // namespace extensions |
153 | 161 |
154 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ | 162 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ |
OLD | NEW |