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 IsBlacklistedCallback; | |
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 IsBlacklisted(const std::set<std::string>& ids, |
Yoyo Zhou
2012/11/30 23:44:07
This name reads strangely; I expect an Is* functio
not at google - send to devlin
2012/12/01 02:51:30
Done.
| |
44 // See extensions::ManagementPolicy (in particular UserMayLoad). | 49 const IsBlacklistedCallback& callback); |
45 bool IsBlacklisted(const std::string& extension_id) const; | 50 |
46 bool IsBlacklisted(const Extension* extension) const; | 51 // Convenient form of |IsBlacklisted| for a single extension ID. |
52 void IsBlacklisted(const std::string& id, | |
53 const IsBlacklistedCallback& callback); | |
Yoyo Zhou
2012/11/30 23:44:07
The callback parameter doesn't seem that convenien
not at google - send to devlin
2012/12/01 02:51:30
Done.
| |
47 | 54 |
48 // Sets the blacklist from the updater to contain the extension IDs in |ids| | 55 // Sets the blacklist from the updater to contain the extension IDs in |ids| |
49 void SetFromUpdater(const std::vector<std::string>& ids, | 56 void SetFromUpdater(const std::vector<std::string>& ids, |
50 const std::string& version); | 57 const std::string& version); |
51 | 58 |
52 // Adds/removes an observer to the blacklist. | 59 // Adds/removes an observer to the blacklist. |
53 void AddObserver(Observer* observer); | 60 void AddObserver(Observer* observer); |
54 void RemoveObserver(Observer* observer); | 61 void RemoveObserver(Observer* observer); |
55 | 62 |
56 private: | 63 private: |
57 ObserverList<Observer> observers_; | 64 ObserverList<Observer> observers_; |
58 | 65 |
59 ExtensionPrefs* const prefs_; | 66 ExtensionPrefs* const prefs_; |
60 | 67 |
61 DISALLOW_COPY_AND_ASSIGN(Blacklist); | 68 DISALLOW_COPY_AND_ASSIGN(Blacklist); |
62 }; | 69 }; |
63 | 70 |
64 } // namespace extensions | 71 } // namespace extensions |
65 | 72 |
66 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ | 73 #endif // CHROME_BROWSER_EXTENSIONS_BLACKLIST_H_ |
OLD | NEW |