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 #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 <set> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
| 12 #include "base/callback.h" |
11 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
12 | 14 |
13 namespace extensions { | 15 namespace extensions { |
14 | 16 |
15 class Extension; | 17 class Extension; |
16 class ExtensionPrefs; | 18 class ExtensionPrefs; |
17 | 19 |
18 // A blacklist of extensions. | 20 // A blacklist of extensions. |
19 class Blacklist { | 21 class Blacklist { |
20 public: | 22 public: |
21 class Observer { | 23 class Observer { |
22 public: | 24 public: |
23 // Observes |blacklist| on construction and unobserves on destruction. | 25 // Observes |blacklist| on construction and unobserves on destruction. |
24 explicit Observer(Blacklist* blacklist); | 26 explicit Observer(Blacklist* blacklist); |
25 | 27 |
26 virtual void OnBlacklistUpdated() = 0; | 28 virtual void OnBlacklistUpdated() = 0; |
27 | 29 |
28 protected: | 30 protected: |
29 virtual ~Observer(); | 31 virtual ~Observer(); |
30 | 32 |
31 private: | 33 private: |
32 Blacklist* blacklist_; | 34 Blacklist* blacklist_; |
33 }; | 35 }; |
34 | 36 |
| 37 typedef base::Callback<void(const std::set<std::string>&)> |
| 38 GetBlacklistedIDsCallback; |
| 39 |
35 // |prefs_| must outlive this. | 40 // |prefs_| must outlive this. |
36 explicit Blacklist(ExtensionPrefs* prefs); | 41 explicit Blacklist(ExtensionPrefs* prefs); |
37 | 42 |
38 ~Blacklist(); | 43 ~Blacklist(); |
39 | 44 |
40 // Gets whether an extension is blacklisted. | 45 // From the set of extension IDs passed in via |ids|, asynchronously checks |
41 // | 46 // which are blacklisted and includes them in the resulting set passed |
42 // Note that this doesn't entirely determine whether an extension is allowed | 47 // via |callback|, which will be sent on the caller's message loop. |
43 // to be loaded; there are other considerations (e.g. admin settings). | 48 void GetBlacklistedIDs(const std::set<std::string>& ids, |
44 // See extensions::ManagementPolicy (in particular UserMayLoad). | 49 const GetBlacklistedIDsCallback& callback); |
45 bool IsBlacklisted(const std::string& extension_id) const; | |
46 bool IsBlacklisted(const Extension* extension) const; | |
47 | 50 |
48 // Sets the blacklist from the updater to contain the extension IDs in |ids| | 51 // Sets the blacklist from the updater to contain the extension IDs in |ids| |
49 void SetFromUpdater(const std::vector<std::string>& ids, | 52 void SetFromUpdater(const std::vector<std::string>& ids, |
50 const std::string& version); | 53 const std::string& version); |
51 | 54 |
52 // Adds/removes an observer to the blacklist. | 55 // Adds/removes an observer to the blacklist. |
53 void AddObserver(Observer* observer); | 56 void AddObserver(Observer* observer); |
54 void RemoveObserver(Observer* observer); | 57 void RemoveObserver(Observer* observer); |
55 | 58 |
56 private: | 59 private: |
57 ObserverList<Observer> observers_; | 60 ObserverList<Observer> observers_; |
58 | 61 |
59 ExtensionPrefs* const prefs_; | 62 ExtensionPrefs* const prefs_; |
60 | 63 |
| 64 std::set<std::string> prefs_blacklist_; |
| 65 |
61 DISALLOW_COPY_AND_ASSIGN(Blacklist); | 66 DISALLOW_COPY_AND_ASSIGN(Blacklist); |
62 }; | 67 }; |
63 | 68 |
64 } // namespace extensions | 69 } // namespace extensions |
65 | 70 |
66 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ | 71 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ |
OLD | NEW |