Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 5 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 484 bool SetStoreLoginFunction::RunImpl() { | 484 bool SetStoreLoginFunction::RunImpl() { |
| 485 if (!IsWebStoreURL(profile_, source_url())) | 485 if (!IsWebStoreURL(profile_, source_url())) |
| 486 return false; | 486 return false; |
| 487 std::string login; | 487 std::string login; |
| 488 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); | 488 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); |
| 489 ExtensionService* service = profile_->GetExtensionService(); | 489 ExtensionService* service = profile_->GetExtensionService(); |
| 490 ExtensionPrefs* prefs = service->extension_prefs(); | 490 ExtensionPrefs* prefs = service->extension_prefs(); |
| 491 prefs->SetWebStoreLogin(login); | 491 prefs->SetWebStoreLogin(login); |
| 492 return true; | 492 return true; |
| 493 } | 493 } |
| 494 | |
| 495 GetWebGLStatusFunction::GetWebGLStatusFunction() {} | |
| 496 GetWebGLStatusFunction::~GetWebGLStatusFunction() {} | |
| 497 | |
| 498 // static | |
| 499 bool GetWebGLStatusFunction::IsWebGLAllowed(GpuDataManager* manager) { | |
| 500 bool webgl_allowed = true; | |
| 501 if (!manager->GpuAccessAllowed()) { | |
| 502 webgl_allowed = false; | |
| 503 } else { | |
| 504 uint32 blacklist_flags = manager->GetGpuFeatureFlags().flags(); | |
| 505 if (blacklist_flags & GpuFeatureFlags::kGpuFeatureWebgl) | |
| 506 webgl_allowed = false; | |
| 507 } | |
| 508 return webgl_allowed; | |
| 509 } | |
| 510 | |
| 511 void GetWebGLStatusFunction::OnGpuInfoUpdate() { | |
| 512 GpuDataManager* manager = GpuDataManager::GetInstance(); | |
| 513 manager->RemoveObserver(this); | |
| 514 bool webgl_allowed = IsWebGLAllowed(manager); | |
| 515 CreateResult(webgl_allowed); | |
| 516 SendResponse(true); | |
| 517 | |
| 518 // Matches the AddRef in RunImpl(). | |
| 519 Release(); | |
| 520 } | |
| 521 | |
| 522 void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) { | |
| 523 result_.reset(Value::CreateStringValue( | |
| 524 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | |
| 525 } | |
| 526 | |
| 527 bool GetWebGLStatusFunction::RunImpl() { | |
| 528 bool finalized = true; | |
| 529 #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
| |
| 530 finalized = false; | |
| 531 #endif | |
| 532 | |
| 533 GpuDataManager* manager = GpuDataManager::GetInstance(); | |
| 534 if (manager->complete_gpu_info_available()) | |
| 535 finalized = true; | |
| 536 | |
| 537 bool webgl_allowed = IsWebGLAllowed(manager); | |
| 538 if (!webgl_allowed) | |
| 539 finalized = true; | |
| 540 | |
| 541 if (finalized) { | |
| 542 CreateResult(webgl_allowed); | |
| 543 SendResponse(true); | |
| 544 } else { | |
| 545 // Matched with a Release in OnGpuInfoUpdate. | |
| 546 AddRef(); | |
| 547 | |
| 548 manager->AddObserver(this); | |
| 549 manager->RequestCompleteGpuInfoIfNeeded(); | |
| 550 } | |
| 551 return true; | |
| 552 } | |
| 553 | |
| OLD | NEW |