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_INSTALL_VERIFIER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ |
7 | 7 |
8 #include <queue> | 8 #include <queue> |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.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 "components/keyed_service/core/keyed_service.h" |
17 #include "extensions/browser/management_policy.h" | 18 #include "extensions/browser/management_policy.h" |
18 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class BrowserContext; | 22 class BrowserContext; |
22 } | 23 } |
23 | 24 |
24 namespace net { | 25 namespace net { |
25 class URLRequestContextGetter; | 26 class URLRequestContextGetter; |
26 } | 27 } |
27 | 28 |
28 namespace extensions { | 29 namespace extensions { |
29 | 30 |
30 class ExtensionPrefs; | 31 class ExtensionPrefs; |
31 class InstallSigner; | 32 class InstallSigner; |
32 struct InstallSignature; | 33 struct InstallSignature; |
33 | 34 |
34 // This class implements verification that a set of extensions are either from | 35 // This class implements verification that a set of extensions are either from |
35 // the webstore or are whitelisted by enterprise policy. The webstore | 36 // the webstore or are whitelisted by enterprise policy. The webstore |
36 // verification process works by sending a request to a backend server to get a | 37 // verification process works by sending a request to a backend server to get a |
37 // signature proving that a set of extensions are verified. This signature is | 38 // signature proving that a set of extensions are verified. This signature is |
38 // written into the extension preferences and is checked for validity when | 39 // written into the extension preferences and is checked for validity when |
39 // being read back again. | 40 // being read back again. |
40 // | 41 // |
41 // This class should be kept notified of runtime changes to the set of | 42 // This class should be kept notified of runtime changes to the set of |
42 // extensions installed from the webstore. | 43 // extensions installed from the webstore. |
43 class InstallVerifier : public ManagementPolicy::Provider { | 44 class InstallVerifier : public KeyedService, |
| 45 public ManagementPolicy::Provider { |
44 public: | 46 public: |
45 InstallVerifier(ExtensionPrefs* prefs, content::BrowserContext* context); | 47 InstallVerifier(ExtensionPrefs* prefs, content::BrowserContext* context); |
46 ~InstallVerifier() override; | 48 ~InstallVerifier() override; |
47 | 49 |
| 50 // Convenience method to return the InstallVerifier for a given |context|. |
| 51 static InstallVerifier* Get(content::BrowserContext* context); |
| 52 |
48 // Returns whether install verification should be enforced. | 53 // Returns whether install verification should be enforced. |
49 static bool ShouldEnforce(); | 54 static bool ShouldEnforce(); |
50 | 55 |
51 // Returns whether |extension| is of a type that needs verification. | 56 // Returns whether |extension| is of a type that needs verification. |
52 static bool NeedsVerification(const Extension& extension); | 57 static bool NeedsVerification(const Extension& extension); |
53 | 58 |
54 // Determines if an extension claims to be from the webstore. | 59 // Determines if an extension claims to be from the webstore. |
55 static bool IsFromStore(const Extension& extension); | 60 static bool IsFromStore(const Extension& extension); |
56 | 61 |
57 // Initializes this object for use, including reading preferences and | 62 // Initializes this object for use, including reading preferences and |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 ExtensionIdSet provisional_; | 177 ExtensionIdSet provisional_; |
173 | 178 |
174 base::WeakPtrFactory<InstallVerifier> weak_factory_; | 179 base::WeakPtrFactory<InstallVerifier> weak_factory_; |
175 | 180 |
176 DISALLOW_COPY_AND_ASSIGN(InstallVerifier); | 181 DISALLOW_COPY_AND_ASSIGN(InstallVerifier); |
177 }; | 182 }; |
178 | 183 |
179 } // namespace extensions | 184 } // namespace extensions |
180 | 185 |
181 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ | 186 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ |
OLD | NEW |