| Index: chrome/browser/extensions/extension_install_checker.h
|
| diff --git a/chrome/browser/extensions/extension_install_checker.h b/chrome/browser/extensions/extension_install_checker.h
|
| index a309f0e2eb40ccb421177fc62f0c288b5beb4232..3f1ed5e4ed8386676dd43d5e47d515f53bbe9a23 100644
|
| --- a/chrome/browser/extensions/extension_install_checker.h
|
| +++ b/chrome/browser/extensions/extension_install_checker.h
|
| @@ -14,6 +14,7 @@
|
| #include "base/memory/weak_ptr.h"
|
| #include "base/strings/string16.h"
|
| #include "extensions/browser/preload_check.h"
|
| +#include "extensions/browser/preload_check_group.h"
|
| #include "extensions/common/extension.h"
|
|
|
| class Profile;
|
| @@ -24,6 +25,9 @@ class RequirementsChecker;
|
|
|
| // Performs common checks for an extension. Extensions that violate these checks
|
| // would be disabled or not even installed.
|
| +// This class is used as an aggregator for classes such as CrxInstaller.
|
| +// TODO(michaelpg): Remove this class and have clients create the relevant
|
| +// PreloadChecks directly.
|
| class ExtensionInstallChecker {
|
| public:
|
| // Called when checks are complete. The returned value is a bitmask of
|
| @@ -49,26 +53,23 @@ class ExtensionInstallChecker {
|
| // If |fail_fast| is true, the callback will be invoked once any check fails.
|
| // Otherwise it will be invoked when all checks have completed. |callback|
|
| // will only be called once.
|
| - // This function must be called on the UI thread. The callback also occurs on
|
| - // the UI thread. Checks may run asynchronously in parallel.
|
| - // If checks are currently running, the caller must wait for the callback to
|
| - // be invoked before starting another set of checks.
|
| - void Start(int enabled_checks, bool fail_fast, const Callback& callback);
|
| + // This function must be called on the UI thread and should be called at most
|
| + // once. The callback also occurs on the UI thread. Checks may run
|
| + // asynchronously in parallel.
|
| + void Start(scoped_refptr<const Extension> extension, int enabled_checks,
|
| + bool fail_fast, const Callback& callback);
|
|
|
| Profile* profile() const { return profile_; }
|
|
|
| const scoped_refptr<const Extension>& extension() { return extension_; }
|
| - void set_extension(const scoped_refptr<const Extension>& extension) {
|
| - extension_ = extension;
|
| - }
|
|
|
| // Returns true if any checks are currently running.
|
| - bool is_running() const { return running_checks_ != 0; }
|
| + bool is_running() const { return is_running_; }
|
|
|
| - // Returns the requirement violations. A non-empty list is considered to be
|
| + // Returns the requirement violations. A non-empty string is considered to be
|
| // a check failure.
|
| - const std::vector<std::string>& requirement_errors() const {
|
| - return requirement_errors_;
|
| + const base::string16& requirement_error_message() const {
|
| + return requirement_error_message_;
|
| }
|
|
|
| // Returns the blacklist error of the extension. A blacklist state of
|
| @@ -76,8 +77,12 @@ class ExtensionInstallChecker {
|
| PreloadCheck::Error blacklist_error() const { return blacklist_error_; }
|
|
|
| // Returns whether management policy permits installation of the extension.
|
| - const std::string& policy_error() const { return policy_error_; }
|
| + const base::string16& policy_error() const { return policy_error_; }
|
|
|
| + void SetRequirementsCheckerForTesting(
|
| + std::unique_ptr<PreloadCheck> requirements_checker) {
|
| + requirements_checker_ = std::move(requirements_checker);
|
| + }
|
| void SetBlacklistCheckForTesting(std::unique_ptr<PreloadCheck> policy_check) {
|
| blacklist_check_ = std::move(policy_check);
|
| }
|
| @@ -85,25 +90,9 @@ class ExtensionInstallChecker {
|
| policy_check_ = std::move(policy_check);
|
| }
|
|
|
| - protected:
|
| - virtual void CheckManagementPolicy();
|
| - void OnManagementPolicyCheckDone(PreloadCheck::Errors errors);
|
| -
|
| - virtual void CheckRequirements();
|
| - void OnRequirementsCheckDone(int sequence_number,
|
| - const std::vector<std::string>& errors);
|
| -
|
| - virtual void CheckBlacklistState();
|
| - void OnBlacklistStateCheckDone(int sequence_number,
|
| - PreloadCheck::Errors errors);
|
| -
|
| - virtual void ResetResults();
|
| - int current_sequence_number() const { return current_sequence_number_; }
|
| -
|
| private:
|
| - void MaybeInvokeCallback();
|
| -
|
| - std::unique_ptr<RequirementsChecker> requirements_checker_;
|
| + void OnInstallChecksComplete(PreloadCheck::Errors errors);
|
| + int ProcessErrors(PreloadCheck::Errors errors);
|
|
|
| // The Profile where the extension is being installed in.
|
| Profile* profile_;
|
| @@ -111,22 +100,20 @@ class ExtensionInstallChecker {
|
| // The extension to run checks for.
|
| scoped_refptr<const Extension> extension_;
|
|
|
| - // Requirement violations.
|
| - std::vector<std::string> requirement_errors_;
|
| + // Checks for requirement violations.
|
| + std::unique_ptr<PreloadCheck> requirements_checker_;
|
| + base::string16 requirement_error_message_;
|
|
|
| - // Checks if the extension in blacklisted.
|
| + // Checks if the extension is blacklisted.
|
| std::unique_ptr<PreloadCheck> blacklist_check_;
|
| PreloadCheck::Error blacklist_error_;
|
|
|
| - // Checks whether management policies allow the extension to be installed.
|
| + // Checks whether management policies prevent installing the extension.
|
| std::unique_ptr<PreloadCheck> policy_check_;
|
| - std::string policy_error_;
|
| -
|
| - // The sequence number of the currently running checks.
|
| - int current_sequence_number_;
|
| + base::string16 policy_error_;
|
|
|
| - // Bitmask of currently running checks.
|
| - int running_checks_;
|
| + // Whether the checks are currently running.
|
| + bool is_running_;
|
|
|
| // If true, the callback is invoked when the first check fails.
|
| bool fail_fast_;
|
| @@ -134,7 +121,13 @@ class ExtensionInstallChecker {
|
| // The callback to invoke when checks are complete.
|
| Callback callback_;
|
|
|
| - base::WeakPtrFactory<ExtensionInstallChecker> weak_ptr_factory_;
|
| + // Installation errors from |preload_check_group_|.
|
| + PreloadCheck::Errors errors_;
|
| +
|
| + // Manages asynchronous extension checks on the UI thread.
|
| + std::unique_ptr<PreloadCheckGroup> preload_check_group_;
|
| +
|
| + //base::WeakPtrFactory<ExtensionInstallChecker> weak_ptr_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ExtensionInstallChecker);
|
| };
|
|
|