Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(281)

Side by Side Diff: extensions/browser/requirements_checker.cc

Issue 2740853002: Use PreloadCheckGroup in ExtensionInstallChecker. Make RequirementsChecker a PreloadCheck. (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/browser/requirements_checker.h ('k') | extensions/strings/extensions_strings.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 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 #include "extensions/browser/requirements_checker.h"
6
7 // TODO
8 #include "base/bind.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "base/strings/string_util.h"
11 #include "build/build_config.h"
12 #include "content/public/browser/gpu_feature_checker.h"
13 #include "content/public/browser/browser_thread.h"
14 #include "extensions/common/extension.h"
15 #include "extensions/common/manifest.h"
16 #include "extensions/common/manifest_handlers/requirements_info.h"
17 #include "extensions/strings/grit/extensions_strings.h"
18 #include "gpu/config/gpu_feature_type.h"
19 #include "ui/base/l10n/l10n_util.h"
20
21 namespace extensions {
22
23 RequirementsChecker::RequirementsChecker(const Extension* extension)
24 : PreloadCheck(extension), weak_ptr_factory_(this) {}
25
26 RequirementsChecker::~RequirementsChecker() {}
27
28 void RequirementsChecker::Start(ResultCallback callback) {
29 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
30
31 const RequirementsInfo& requirements =
32 RequirementsInfo::GetRequirements(extension());
33
34 #if defined(OS_POSIX) && !defined(OS_MACOSX)
35 if (requirements.npapi)
36 errors_.insert(NPAPI_NOT_SUPPORTED);
37 #endif
38
39 #if !defined(USE_AURA)
40 if (requirements.window_shape)
41 errors_.insert(WINDOW_SHAPE_NOT_SUPPORTED);
42 #endif
43
44 if (requirements.webgl) {
45 webgl_checker_ = content::GpuFeatureChecker::Create(
46 gpu::GPU_FEATURE_TYPE_WEBGL,
47 base::Bind(&RequirementsChecker::OnGetWebGLAvailability,
48 weak_ptr_factory_.GetWeakPtr()));
49 webgl_checker_->CheckGpuFeatureAvailability();
50 callback_ = std::move(callback);
51 } else {
52 std::move(callback).Run(errors_);
53 }
54 }
55
56 base::string16 RequirementsChecker::GetErrorMessage() const {
57 // Join the error messages into one string.
58 std::vector<std::string> messages;
59 #if defined(OS_POSIX) && !defined(OS_MACOSX)
60 if (errors_.count(NPAPI_NOT_SUPPORTED)) {
61 messages.push_back(
62 l10n_util::GetStringUTF8(IDS_EXTENSION_NPAPI_NOT_SUPPORTED));
63 }
64 #endif
65 if (errors_.count(WEBGL_NOT_SUPPORTED)) {
66 messages.push_back(
67 l10n_util::GetStringUTF8(IDS_EXTENSION_WEBGL_NOT_SUPPORTED));
68 }
69 #if !defined(USE_AURA)
70 if (errors_.count(WINDOW_SHAPE_NOT_SUPPORTED)) {
71 messages.push_back(
72 l10n_util::GetStringUTF8(IDS_EXTENSION_WINDOW_SHAPE_NOT_SUPPORTED));
73 }
74 #endif
75
76 return base::UTF8ToUTF16(base::JoinString(messages, " "));
77 }
78
79 void RequirementsChecker::OnGetWebGLAvailability(bool available) {
80 if (!available)
81 errors_.insert(WEBGL_NOT_SUPPORTED);
82 std::move(callback_).Run(errors_);
83 }
84
85 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/requirements_checker.h ('k') | extensions/strings/extensions_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698