Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / extensions / requirements_checker.h
blobcca3503b41b6d5c2a453fc3dbd36422b63ae63d9
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
6 #define CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_
8 #include <vector>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/extensions/extension_service.h"
15 class GPUFeatureChecker;
17 namespace extensions {
18 class Extension;
20 // Validates the 'requirements' extension manifest field. This is an
21 // asynchronous process that involves several threads, but the public interface
22 // of this class (including constructor and destructor) must only be used on
23 // the UI thread.
24 class RequirementsChecker : public base::SupportsWeakPtr<RequirementsChecker> {
25 public:
26 RequirementsChecker();
27 ~RequirementsChecker();
29 // The vector passed to the callback are any localized errors describing
30 // requirement violations. If this vector is non-empty, requirements checking
31 // failed. This should only be called once. |callback| will always be invoked
32 // asynchronously on the UI thread. |callback| will only be called once, and
33 // will be reset after called.
34 void Check(scoped_refptr<const Extension> extension,
35 base::Callback<void(std::vector<std::string> requirement)> callback);
37 private:
38 // Callbacks for the GPUFeatureChecker.
39 void SetWebGLAvailability(bool available);
40 void SetCSS3DAvailability(bool available);
42 void MaybeRunCallback();
44 std::vector<std::string> errors_;
46 // Every requirement that needs to be resolved asynchronously will add to
47 // this counter. When the counter is depleted, the callback will be run.
48 int pending_requirement_checks_;
50 scoped_refptr<GPUFeatureChecker> webgl_checker_;
51 scoped_refptr<GPUFeatureChecker> css3d_checker_;
53 base::Callback<void(std::vector<std::string> requirement_errorss)> callback_;
56 } // namespace extensions
58 #endif // CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_