Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2559)

Unified Diff: chrome/browser/extensions/extension_install_checker.h

Issue 2751013002: Simplify ExtensionInstallChecker into a single-use class (Closed)
Patch Set: todo Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 b73255bdd4f1360c0239f6ec2f97fe434aa4756a..9bafea5185872c39702c66aea20b40c754be5a8d 100644
--- a/chrome/browser/extensions/extension_install_checker.h
+++ b/chrome/browser/extensions/extension_install_checker.h
@@ -22,8 +22,8 @@ namespace extensions {
class RequirementsChecker;
-// Performs common checks for an extension. Extensions that violate these checks
-// would be disabled or not even installed.
+// Performs common checks for validating whether an extension may be installed.
+// This class should be Start()-ed at most once.
class ExtensionInstallChecker {
public:
// Called when checks are complete. The returned value is a bitmask of
@@ -42,25 +42,20 @@ class ExtensionInstallChecker {
CHECK_ALL = (1 << 3) - 1
};
- explicit ExtensionInstallChecker(Profile* profile);
+ // |enabled_checks| is a bitmask of CheckTypes to run.
+ // If |fail_fast| is true, the callback to Start() will be invoked once any
+ // check fails. Otherwise it will be invoked when all checks have completed.
+ ExtensionInstallChecker(Profile* profile,
+ scoped_refptr<const Extension> extension,
+ int enabled_checks,
+ bool fail_fast);
virtual ~ExtensionInstallChecker();
- // Start a set of checks. |enabled_checks| is a bitmask of CheckTypes to run.
- // 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.
+ // Starts the set of checks. |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);
-
- Profile* profile() const { return profile_; }
-
- const scoped_refptr<const Extension>& extension() { return extension_; }
- void set_extension(const scoped_refptr<const Extension>& extension) {
- extension_ = extension;
- }
+ // This function should be invoked at most once.
+ void Start(const Callback& callback);
// Returns true if any checks are currently running.
bool is_running() const { return running_checks_ != 0; }
@@ -84,14 +79,10 @@ class ExtensionInstallChecker {
void OnManagementPolicyCheckDone(bool allows_load, const std::string& error);
virtual void CheckRequirements();
- void OnRequirementsCheckDone(int sequence_number,
- const std::vector<std::string>& errors);
+ void OnRequirementsCheckDone(const std::vector<std::string>& errors);
virtual void CheckBlacklistState();
- void OnBlacklistStateCheckDone(int sequence_number, BlacklistState state);
-
- virtual void ResetResults();
- int current_sequence_number() const { return current_sequence_number_; }
+ void OnBlacklistStateCheckDone(BlacklistState state);
private:
void MaybeInvokeCallback();
@@ -114,10 +105,11 @@ class ExtensionInstallChecker {
bool policy_allows_load_;
std::string policy_error_;
- // The sequence number of the currently running checks.
- int current_sequence_number_;
+ // Bitmask of enabled checks.
+ int enabled_checks_;
// Bitmask of currently running checks.
+ // TODO(michaelpg): Consolidate this with enabled_checks_.
int running_checks_;
// If true, the callback is invoked when the first check fails.
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.h ('k') | chrome/browser/extensions/extension_install_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698