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

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

Issue 10908184: Enforce the 'requirements' field in manifests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « chrome/browser/extensions/extension_system.cc ('k') | chrome/browser/extensions/requirements_checker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/requirements_checker.h
diff --git a/chrome/browser/extensions/requirements_checker.h b/chrome/browser/extensions/requirements_checker.h
new file mode 100644
index 0000000000000000000000000000000000000000..cca3503b41b6d5c2a453fc3dbd36422b63ae63d9
--- /dev/null
+++ b/chrome/browser/extensions/requirements_checker.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
+#define CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/extensions/extension_service.h"
+
+class GPUFeatureChecker;
+
+namespace extensions {
+class Extension;
+
+// Validates the 'requirements' extension manifest field. This is an
+// asynchronous process that involves several threads, but the public interface
+// of this class (including constructor and destructor) must only be used on
+// the UI thread.
+class RequirementsChecker : public base::SupportsWeakPtr<RequirementsChecker> {
+ public:
+ RequirementsChecker();
+ ~RequirementsChecker();
+
+ // The vector passed to the callback are any localized errors describing
+ // requirement violations. If this vector is non-empty, requirements checking
+ // failed. This should only be called once. |callback| will always be invoked
+ // asynchronously on the UI thread. |callback| will only be called once, and
+ // will be reset after called.
+ void Check(scoped_refptr<const Extension> extension,
+ base::Callback<void(std::vector<std::string> requirement)> callback);
+
+ private:
+ // Callbacks for the GPUFeatureChecker.
+ void SetWebGLAvailability(bool available);
+ void SetCSS3DAvailability(bool available);
+
+ void MaybeRunCallback();
+
+ std::vector<std::string> errors_;
+
+ // Every requirement that needs to be resolved asynchronously will add to
+ // this counter. When the counter is depleted, the callback will be run.
+ int pending_requirement_checks_;
+
+ scoped_refptr<GPUFeatureChecker> webgl_checker_;
+ scoped_refptr<GPUFeatureChecker> css3d_checker_;
+
+ base::Callback<void(std::vector<std::string> requirement_errorss)> callback_;
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
« no previous file with comments | « chrome/browser/extensions/extension_system.cc ('k') | chrome/browser/extensions/requirements_checker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698