Chromium Code Reviews| 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,63 @@ |
| 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) |
|
Mihai Parparita -not on Chrome
2011/12/07 00:01:38
Can you comment why Linux gets this special treatm
Zhenyao Mo
2011/12/07 17:26:51
On Mac/Windows, gpu info is also incomplete withou
|
| + 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; |
| +} |
| + |