| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 50 |
| 51 // Initializes this object for use, including reading preferences and | 51 // Initializes this object for use, including reading preferences and |
| 52 // validating the stored signature. | 52 // validating the stored signature. |
| 53 void Init(); | 53 void Init(); |
| 54 | 54 |
| 55 // Returns the timestamp of our InstallSignature, if we have one. | 55 // Returns the timestamp of our InstallSignature, if we have one. |
| 56 base::Time SignatureTimestamp(); | 56 base::Time SignatureTimestamp(); |
| 57 | 57 |
| 58 // Returns true if |id| is either verified or our stored signature explicitly | 58 // 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. | 59 // tells us that it was invalid when we asked the server about it. |
| 60 bool IsKnownId(const std::string& id); | 60 bool IsKnownId(const std::string& id) const; |
| 61 |
| 62 // Returns whether the given |id| is included in our verified signature. |
| 63 bool IsVerified(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 |
| 86 // Determines if an extension claims to be from the webstore. |
| 87 static bool FromStore(const Extension& extension); |
| 88 |
| 76 // ManagementPolicy::Provider interface. | 89 // ManagementPolicy::Provider interface. |
| 77 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; | 90 virtual std::string GetDebugPolicyProviderName() const OVERRIDE; |
| 78 virtual bool MustRemainDisabled(const Extension* extension, | 91 virtual bool MustRemainDisabled(const Extension* extension, |
| 79 Extension::DisableReason* reason, | 92 Extension::DisableReason* reason, |
| 80 base::string16* error) const OVERRIDE; | 93 base::string16* error) const OVERRIDE; |
| 81 | 94 |
| 82 private: | 95 private: |
| 83 // We keep a list of operations to the current set of extensions. | 96 // We keep a list of operations to the current set of extensions. |
| 84 enum OperationType { | 97 enum OperationType { |
| 85 ADD_SINGLE, // Adding a single extension to be verified. | 98 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. | 124 // Try adding a new set of |ids| to the list of verified ids. |
| 112 void AddMany(const ExtensionIdSet& ids, OperationType type); | 125 void AddMany(const ExtensionIdSet& ids, OperationType type); |
| 113 | 126 |
| 114 // Record the result of the verification for the histograms, and notify the | 127 // Record the result of the verification for the histograms, and notify the |
| 115 // ExtensionPrefs if we verified all extensions. | 128 // ExtensionPrefs if we verified all extensions. |
| 116 void OnVerificationComplete(bool success, OperationType type); | 129 void OnVerificationComplete(bool success, OperationType type); |
| 117 | 130 |
| 118 // Removes any no-longer-installed ids, requesting a new signature if needed. | 131 // Removes any no-longer-installed ids, requesting a new signature if needed. |
| 119 void GarbageCollect(); | 132 void GarbageCollect(); |
| 120 | 133 |
| 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. | |
| 125 bool IsVerified(const std::string& id) const; | |
| 126 | |
| 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. |
| 134 void BeginFetch(); | 141 void BeginFetch(); |
| 135 | 142 |
| 136 // Saves the current value of |signature_| to the prefs; | 143 // Saves the current value of |signature_| to the prefs; |
| (...skipping 25 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 |