blob: 12a528bf5ee39c737f12fcecd0097ace303523e1 [file] [log] [blame]
rdevlin.cronin69bf75312015-02-24 20:21:101// 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
michaelpg0083fc82017-01-18 22:15:195#ifndef EXTENSIONS_BROWSER_REQUIREMENTS_CHECKER_H_
6#define EXTENSIONS_BROWSER_REQUIREMENTS_CHECKER_H_
rdevlin.cronin69bf75312015-02-24 20:21:107
michaelpga8ea0372017-04-06 20:41:358#include "base/macros.h"
rdevlin.cronin69bf75312015-02-24 20:21:109#include "base/memory/ref_counted.h"
michaelpga8ea0372017-04-06 20:41:3510#include "base/memory/weak_ptr.h"
11#include "extensions/browser/preload_check.h"
12
13namespace content {
14class GpuFeatureChecker;
15}
rdevlin.cronin69bf75312015-02-24 20:21:1016
17namespace extensions {
18class 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.
michaelpga8ea0372017-04-06 20:41:3524class RequirementsChecker : public PreloadCheck {
rdevlin.cronin69bf75312015-02-24 20:21:1025 public:
michaelpga8ea0372017-04-06 20:41:3526 explicit RequirementsChecker(scoped_refptr<const Extension> extension);
27 ~RequirementsChecker() override;
rdevlin.cronin69bf75312015-02-24 20:21:1028
michaelpga8ea0372017-04-06 20:41:3529 // PreloadCheck:
30 void Start(ResultCallback callback) override;
31 // Joins multiple errors into a space-separated string.
32 base::string16 GetErrorMessage() const override;
rdevlin.cronin69bf75312015-02-24 20:21:1033
michaelpga8ea0372017-04-06 20:41:3534 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 Roman9fc2de62019-07-12 14:15:0349 base::WeakPtrFactory<RequirementsChecker> weak_ptr_factory_{this};
michaelpga8ea0372017-04-06 20:41:3550
51 DISALLOW_COPY_AND_ASSIGN(RequirementsChecker);
rdevlin.cronin69bf75312015-02-24 20:21:1052};
53
54} // namespace extensions
55
michaelpg0083fc82017-01-18 22:15:1956#endif // EXTENSIONS_BROWSER_REQUIREMENTS_CHECKER_H_