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_CHROME_REQUIREMENTS_CHECKER_H_
6 #define CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "extensions/browser/requirements_checker.h"
15 class GPUFeatureChecker
;
17 namespace extensions
{
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
24 class ChromeRequirementsChecker
: public RequirementsChecker
{
26 ChromeRequirementsChecker();
27 ~ChromeRequirementsChecker() override
;
30 // RequirementsChecker:
31 void Check(const scoped_refptr
<const Extension
>& extension
,
32 const RequirementsCheckedCallback
& callback
) override
;
34 // Callbacks for the GPUFeatureChecker.
35 void SetWebGLAvailability(bool available
);
37 void MaybeRunCallback();
39 std::vector
<std::string
> errors_
;
41 // Every requirement that needs to be resolved asynchronously will add to
42 // this counter. When the counter is depleted, the callback will be run.
43 int pending_requirement_checks_
;
45 scoped_refptr
<GPUFeatureChecker
> webgl_checker_
;
47 RequirementsCheckedCallback callback_
;
49 base::WeakPtrFactory
<ChromeRequirementsChecker
> weak_ptr_factory_
;
51 DISALLOW_COPY_AND_ASSIGN(ChromeRequirementsChecker
);
54 } // namespace extensions
56 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_REQUIREMENTS_CHECKER_H_