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> |
(...skipping 30 matching lines...) Expand all Loading... | |
41 // This class should be kept notified of runtime changes to the set of | 41 // This class should be kept notified of runtime changes to the set of |
42 // extensions installed from the webstore. | 42 // extensions installed from the webstore. |
43 class InstallVerifier : public ManagementPolicy::Provider { | 43 class InstallVerifier : public ManagementPolicy::Provider { |
44 public: | 44 public: |
45 InstallVerifier(ExtensionPrefs* prefs, content::BrowserContext* context); | 45 InstallVerifier(ExtensionPrefs* prefs, content::BrowserContext* context); |
46 virtual ~InstallVerifier(); | 46 virtual ~InstallVerifier(); |
47 | 47 |
48 // Returns whether |extension| is of a type that needs verification. | 48 // Returns whether |extension| is of a type that needs verification. |
49 static bool NeedsVerification(const Extension& extension); | 49 static bool NeedsVerification(const Extension& extension); |
50 | 50 |
51 // Determines if an extension claims to be from the webstore. | |
52 static bool FromStore(const Extension& extension); | |
Devlin
2014/08/13 19:50:07
nit: Let's actually make this "IsFromStore".
jwd
2014/08/13 20:22:06
Done.
| |
53 | |
51 // Initializes this object for use, including reading preferences and | 54 // Initializes this object for use, including reading preferences and |
52 // validating the stored signature. | 55 // validating the stored signature. |
53 void Init(); | 56 void Init(); |
54 | 57 |
55 // Returns the timestamp of our InstallSignature, if we have one. | 58 // Returns the timestamp of our InstallSignature, if we have one. |
56 base::Time SignatureTimestamp(); | 59 base::Time SignatureTimestamp(); |
57 | 60 |
58 // Returns true if |id| is either verified or our stored signature explicitly | 61 // Returns true if |id| is either verified or our stored signature explicitly |
59 // tells us that it was invalid when we asked the server about it. | 62 // tells us that it was invalid when we asked the server about it. |
60 bool IsKnownId(const std::string& id); | 63 bool IsKnownId(const std::string& id) const; |
64 | |
65 // Returns whether the given |id| is considered invalid by our verified | |
66 // signature. | |
67 bool IsInvalid(const std::string& id) const; | |
61 | 68 |
62 // Attempts to verify a single extension and add it to the verified list. | 69 // Attempts to verify a single extension and add it to the verified list. |
63 void VerifyExtension(const std::string& extension_id); | 70 void VerifyExtension(const std::string& extension_id); |
64 | 71 |
65 // Attempts to verify all extensions. | 72 // Attempts to verify all extensions. |
66 void VerifyAllExtensions(); | 73 void VerifyAllExtensions(); |
67 | 74 |
68 // Call this to add a set of ids that will immediately be considered allowed, | 75 // Call this to add a set of ids that will immediately be considered allowed, |
69 // and kick off an aysnchronous request to Add. | 76 // and kick off an aysnchronous request to Add. |
70 void AddProvisional(const ExtensionIdSet& ids); | 77 void AddProvisional(const ExtensionIdSet& ids); |
71 | 78 |
72 // Removes an id or set of ids from the verified list. | 79 // Removes an id or set of ids from the verified list. |
73 void Remove(const std::string& id); | 80 void Remove(const std::string& id); |
74 void RemoveMany(const ExtensionIdSet& ids); | 81 void RemoveMany(const ExtensionIdSet& ids); |
75 | 82 |
83 // Returns whether an extension id is allowed by policy. | |
84 bool AllowedByEnterprisePolicy(const std::string& id) const; | |
85 | |
76 // ManagementPolicy::Provider interface. | 86 // ManagementPolicy::Provider interface. |
77 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 87 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
78 virtual bool MustRemainDisabled(const Extension* extension, | 88 virtual bool MustRemainDisabled(const Extension* extension, |
79 Extension::DisableReason* reason, | 89 Extension::DisableReason* reason, |
80 base::string16* error) const OVERRIDE; | 90 base::string16* error) const OVERRIDE; |
81 | 91 |
82 private: | 92 private: |
83 // We keep a list of operations to the current set of extensions. | 93 // We keep a list of operations to the current set of extensions. |
84 enum OperationType { | 94 enum OperationType { |
85 ADD_SINGLE, // Adding a single extension to be verified. | 95 ADD_SINGLE, // Adding a single extension to be verified. |
(...skipping 25 matching lines...) Expand all Loading... | |
111 // Try adding a new set of |ids| to the list of verified ids. | 121 // Try adding a new set of |ids| to the list of verified ids. |
112 void AddMany(const ExtensionIdSet& ids, OperationType type); | 122 void AddMany(const ExtensionIdSet& ids, OperationType type); |
113 | 123 |
114 // Record the result of the verification for the histograms, and notify the | 124 // Record the result of the verification for the histograms, and notify the |
115 // ExtensionPrefs if we verified all extensions. | 125 // ExtensionPrefs if we verified all extensions. |
116 void OnVerificationComplete(bool success, OperationType type); | 126 void OnVerificationComplete(bool success, OperationType type); |
117 | 127 |
118 // Removes any no-longer-installed ids, requesting a new signature if needed. | 128 // Removes any no-longer-installed ids, requesting a new signature if needed. |
119 void GarbageCollect(); | 129 void GarbageCollect(); |
120 | 130 |
121 // Returns whether an extension id is allowed by policy. | |
122 bool AllowedByEnterprisePolicy(const std::string& id) const; | |
123 | |
124 // Returns whether the given |id| is included in our verified signature. | 131 // Returns whether the given |id| is included in our verified signature. |
125 bool IsVerified(const std::string& id) const; | 132 bool IsVerified(const std::string& id) const; |
126 | 133 |
127 // Returns true if the extension with |id| was installed later than the | 134 // Returns true if the extension with |id| was installed later than the |
128 // timestamp of our signature. | 135 // timestamp of our signature. |
129 bool WasInstalledAfterSignature(const std::string& id) const; | 136 bool WasInstalledAfterSignature(const std::string& id) const; |
130 | 137 |
131 // Begins the process of fetching a new signature, based on applying the | 138 // Begins the process of fetching a new signature, based on applying the |
132 // operation at the head of the queue to the current set of ids in | 139 // operation at the head of the queue to the current set of ids in |
133 // |signature_| (if any) and then sending a request to sign that. | 140 // |signature_| (if any) and then sending a request to sign that. |
(...skipping 28 matching lines...) Expand all Loading... | |
162 ExtensionIdSet provisional_; | 169 ExtensionIdSet provisional_; |
163 | 170 |
164 base::WeakPtrFactory<InstallVerifier> weak_factory_; | 171 base::WeakPtrFactory<InstallVerifier> weak_factory_; |
165 | 172 |
166 DISALLOW_COPY_AND_ASSIGN(InstallVerifier); | 173 DISALLOW_COPY_AND_ASSIGN(InstallVerifier); |
167 }; | 174 }; |
168 | 175 |
169 } // namespace extensions | 176 } // namespace extensions |
170 | 177 |
171 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ | 178 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_VERIFIER_H_ |
OLD | NEW |