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