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

Unified Diff: chrome/browser/extensions/extension_webstore_private_api.cc

Issue 8772031: Add a JS API for detecting WebGL availability. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_webstore_private_api.cc
===================================================================
--- chrome/browser/extensions/extension_webstore_private_api.cc (revision 112998)
+++ chrome/browser/extensions/extension_webstore_private_api.cc (working copy)
@@ -491,3 +491,66 @@
prefs->SetWebStoreLogin(login);
return true;
}
+
+GetWebGLStatusFunction::GetWebGLStatusFunction() {}
+GetWebGLStatusFunction::~GetWebGLStatusFunction() {}
+
+// static
+bool GetWebGLStatusFunction::IsWebGLAllowed(GpuDataManager* manager) {
+ bool webgl_allowed = true;
+ if (!manager->GpuAccessAllowed()) {
+ webgl_allowed = false;
+ } else {
+ uint32 blacklist_flags = manager->GetGpuFeatureFlags().flags();
+ if (blacklist_flags & GpuFeatureFlags::kGpuFeatureWebgl)
+ webgl_allowed = false;
+ }
+ return webgl_allowed;
+}
+
+void GetWebGLStatusFunction::OnGpuInfoUpdate() {
+ GpuDataManager* manager = GpuDataManager::GetInstance();
+ manager->RemoveObserver(this);
+ bool webgl_allowed = IsWebGLAllowed(manager);
+ CreateResult(webgl_allowed);
+ SendResponse(true);
+
+ // Matches the AddRef in RunImpl().
+ Release();
+}
+
+void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) {
+ result_.reset(Value::CreateStringValue(
+ webgl_allowed ? "webgl_allowed" : "webgl_blocked"));
+}
+
+bool GetWebGLStatusFunction::RunImpl() {
+ bool finalized = true;
+#if defined(OS_LINUX)
+ // On Windows and Mac, so far we can always make the final WebGL blacklisting
+ // decision based on partial GPU info; on Linux, we need to launch the GPU
+ // process to collect full GPU info and make the final decision.
+ finalized = false;
+#endif
+
+ GpuDataManager* manager = GpuDataManager::GetInstance();
+ if (manager->complete_gpu_info_available())
+ finalized = true;
+
+ bool webgl_allowed = IsWebGLAllowed(manager);
+ if (!webgl_allowed)
+ finalized = true;
+
+ if (finalized) {
+ CreateResult(webgl_allowed);
+ SendResponse(true);
+ } else {
+ // Matched with a Release in OnGpuInfoUpdate.
+ AddRef();
+
+ manager->AddObserver(this);
+ manager->RequestCompleteGpuInfoIfNeeded();
+ }
+ return true;
+}
+

Powered by Google App Engine
This is Rietveld 408576698