| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "extensions/browser/requirements_checker.h" | 14 #include "extensions/browser/requirements_checker.h" |
| 15 | 15 |
| 16 class GPUFeatureChecker; | 16 namespace content { |
| 17 class GpuFeatureChecker; |
| 18 } |
| 17 | 19 |
| 18 namespace extensions { | 20 namespace extensions { |
| 19 class Extension; | 21 class Extension; |
| 20 | 22 |
| 21 // Validates the 'requirements' extension manifest field. This is an | 23 // Validates the 'requirements' extension manifest field. This is an |
| 22 // asynchronous process that involves several threads, but the public interface | 24 // asynchronous process that involves several threads, but the public interface |
| 23 // of this class (including constructor and destructor) must only be used on | 25 // of this class (including constructor and destructor) must only be used on |
| 24 // the UI thread. | 26 // the UI thread. |
| 25 class ChromeRequirementsChecker : public RequirementsChecker { | 27 class ChromeRequirementsChecker : public RequirementsChecker { |
| 26 public: | 28 public: |
| 27 ChromeRequirementsChecker(); | 29 ChromeRequirementsChecker(); |
| 28 ~ChromeRequirementsChecker() override; | 30 ~ChromeRequirementsChecker() override; |
| 29 | 31 |
| 30 private: | 32 private: |
| 31 // RequirementsChecker: | 33 // RequirementsChecker: |
| 32 void Check(const scoped_refptr<const Extension>& extension, | 34 void Check(const scoped_refptr<const Extension>& extension, |
| 33 const RequirementsCheckedCallback& callback) override; | 35 const RequirementsCheckedCallback& callback) override; |
| 34 | 36 |
| 35 // Callbacks for the GPUFeatureChecker. | 37 // Callbacks for the GpuFeatureChecker. |
| 36 void SetWebGLAvailability(bool available); | 38 void SetWebGLAvailability(bool available); |
| 37 | 39 |
| 38 void MaybeRunCallback(); | 40 void MaybeRunCallback(); |
| 39 | 41 |
| 40 std::vector<std::string> errors_; | 42 std::vector<std::string> errors_; |
| 41 | 43 |
| 42 // Every requirement that needs to be resolved asynchronously will add to | 44 // Every requirement that needs to be resolved asynchronously will add to |
| 43 // this counter. When the counter is depleted, the callback will be run. | 45 // this counter. When the counter is depleted, the callback will be run. |
| 44 int pending_requirement_checks_; | 46 int pending_requirement_checks_; |
| 45 | 47 |
| 46 scoped_refptr<GPUFeatureChecker> webgl_checker_; | 48 scoped_refptr<content::GpuFeatureChecker> webgl_checker_; |
| 47 | 49 |
| 48 RequirementsCheckedCallback callback_; | 50 RequirementsCheckedCallback callback_; |
| 49 | 51 |
| 50 base::WeakPtrFactory<ChromeRequirementsChecker> weak_ptr_factory_; | 52 base::WeakPtrFactory<ChromeRequirementsChecker> weak_ptr_factory_; |
| 51 | 53 |
| 52 DISALLOW_COPY_AND_ASSIGN(ChromeRequirementsChecker); | 54 DISALLOW_COPY_AND_ASSIGN(ChromeRequirementsChecker); |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 } // namespace extensions | 57 } // namespace extensions |
| 56 | 58 |
| 57 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_ | 59 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_ |
| OLD | NEW |