| 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;
|
| +}
|
| +
|
|
|