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 result_.reset(Value::CreateStringValue( | |
|
Mihai Parparita -not on Chrome
2011/12/06 02:58:11
Rather than repeating the result creation code twi
Zhenyao Mo
2011/12/06 20:00:15
Done.
| |
| 516 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | |
| 517 SendResponse(true); | |
| 518 | |
| 519 Release(); | |
|
Mihai Parparita -not on Chrome
2011/12/06 02:58:11
The convention in extensions code is to add commen
Zhenyao Mo
2011/12/06 20:00:15
Done.
| |
| 520 } | |
| 521 | |
| 522 bool GetWebGLStatusFunction::RunImpl() { | |
| 523 bool finalized = true; | |
| 524 #if defined(OS_LINUX) | |
| 525 finalized = false; | |
| 526 #endif | |
| 527 | |
| 528 GpuDataManager* manager = GpuDataManager::GetInstance(); | |
| 529 if (manager->complete_gpu_info_available()) | |
| 530 finalized = true; | |
| 531 | |
| 532 bool webgl_allowed = IsWebGLAllowed(manager); | |
| 533 if (!webgl_allowed) | |
| 534 finalized = true; | |
|
Mihai Parparita -not on Chrome
2011/12/06 02:58:11
This confused me initially, perhaps add comments t
Zhenyao Mo
2011/12/06 20:00:15
Done. Added comment in .h file
| |
| 535 | |
| 536 if (finalized) { | |
| 537 result_.reset(Value::CreateStringValue( | |
| 538 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | |
| 539 SendResponse(true); | |
| 540 } else { | |
| 541 AddRef(); | |
| 542 | |
| 543 manager->AddObserver(this); | |
| 544 manager->RequestCompleteGpuInfoIfNeeded(); | |
| 545 } | |
| 546 return true; | |
| 547 } | |
| 548 | |
| OLD | NEW |