rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 1 | // Copyright 2015 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 | |
michaelpg | 0083fc8 | 2017-01-18 22:15:19 | [diff] [blame] | 5 | #ifndef EXTENSIONS_BROWSER_REQUIREMENTS_CHECKER_H_ |
| 6 | #define EXTENSIONS_BROWSER_REQUIREMENTS_CHECKER_H_ |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 7 | |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 8 | #include "base/macros.h" |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 10 | #include "base/memory/weak_ptr.h" |
| 11 | #include "extensions/browser/preload_check.h" |
| 12 | |
| 13 | namespace content { |
| 14 | class GpuFeatureChecker; |
| 15 | } |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 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. |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 24 | class RequirementsChecker : public PreloadCheck { |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 25 | public: |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 26 | explicit RequirementsChecker(scoped_refptr<const Extension> extension); |
| 27 | ~RequirementsChecker() override; |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 28 | |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 29 | // PreloadCheck: |
| 30 | void Start(ResultCallback callback) override; |
| 31 | // Joins multiple errors into a space-separated string. |
| 32 | base::string16 GetErrorMessage() const override; |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 33 | |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 34 | private: |
| 35 | // Callback for the GpuFeatureChecker. |
| 36 | void VerifyWebGLAvailability(bool available); |
| 37 | |
| 38 | // Helper function to post a task on the UI thread to call RunCallback(). |
| 39 | void PostRunCallback(); |
| 40 | |
| 41 | // Helper function to run the callback. |
| 42 | void RunCallback(); |
| 43 | |
| 44 | scoped_refptr<content::GpuFeatureChecker> webgl_checker_; |
| 45 | |
| 46 | ResultCallback callback_; |
| 47 | Errors errors_; |
| 48 | |
Jeremy Roman | 9fc2de6 | 2019-07-12 14:15:03 | [diff] [blame] | 49 | base::WeakPtrFactory<RequirementsChecker> weak_ptr_factory_{this}; |
michaelpg | a8ea037 | 2017-04-06 20:41:35 | [diff] [blame] | 50 | |
| 51 | DISALLOW_COPY_AND_ASSIGN(RequirementsChecker); |
rdevlin.cronin | 69bf7531 | 2015-02-24 20:21:10 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | } // namespace extensions |
| 55 | |
michaelpg | 0083fc8 | 2017-01-18 22:15:19 | [diff] [blame] | 56 | #endif // EXTENSIONS_BROWSER_REQUIREMENTS_CHECKER_H_ |