OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 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" |
| 14 |
| 15 class GPUFeatureChecker; |
| 16 |
| 17 namespace extensions { |
| 18 class Extension; |
| 19 |
| 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(); |
| 28 |
| 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); |
| 36 |
| 37 private: |
| 38 // Callbacks for the GPUFeatureChecker. |
| 39 void SetWebGLAvailability(bool available); |
| 40 void SetCSS3DAvailability(bool available); |
| 41 |
| 42 void MaybeRunCallback(); |
| 43 |
| 44 std::vector<std::string> errors_; |
| 45 |
| 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_; |
| 49 |
| 50 scoped_refptr<GPUFeatureChecker> webgl_checker_; |
| 51 scoped_refptr<GPUFeatureChecker> css3d_checker_; |
| 52 |
| 53 base::Callback<void(std::vector<std::string> requirement_errorss)> callback_; |
| 54 }; |
| 55 |
| 56 } // namespace extensions |
| 57 |
| 58 #endif // CHROME_BROWSER_EXTENSIONS_REQUIREMENTS_CHECKER_H_ |
OLD | NEW |