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) |
| 530 // On Windows and Mac, so far we can always make the final WebGL blacklisting |
| 531 // decision based on partial GPU info; on Linux, we need to launch the GPU |
| 532 // process to collect full GPU info and make the final decision. |
| 533 finalized = false; |
| 534 #endif |
| 535 |
| 536 GpuDataManager* manager = GpuDataManager::GetInstance(); |
| 537 if (manager->complete_gpu_info_available()) |
| 538 finalized = true; |
| 539 |
| 540 bool webgl_allowed = IsWebGLAllowed(manager); |
| 541 if (!webgl_allowed) |
| 542 finalized = true; |
| 543 |
| 544 if (finalized) { |
| 545 CreateResult(webgl_allowed); |
| 546 SendResponse(true); |
| 547 } else { |
| 548 // Matched with a Release in OnGpuInfoUpdate. |
| 549 AddRef(); |
| 550 |
| 551 manager->AddObserver(this); |
| 552 manager->RequestCompleteGpuInfoIfNeeded(); |
| 553 } |
| 554 return true; |
| 555 } |
| 556 |
OLD | NEW |