Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Side by Side Diff: chrome/browser/extensions/extension_webstore_private_api.cc

Issue 8772031: Add a JS API for detecting WebGL availability. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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(
516 webgl_allowed ? "webgl_allowed" : "webgl_blocked"));
517 SendResponse(true);
518
519 Release();
520 }
521
522 bool GetWebGLStatusFunction::RunImpl() {
523 bool finalized = true;
524 #if defined(OS_LINUX)
525 finalized = false;
526 #endif
527
528
529 GpuDataManager* manager = GpuDataManager::GetInstance();
530 if (manager->complete_gpu_info_available())
531 finalized = true;
532
533 bool webgl_allowed = IsWebGLAllowed(manager);
534 if (!webgl_allowed)
535 finalized = true;
536
537 if (finalized) {
538 result_.reset(Value::CreateStringValue(
539 webgl_allowed ? "webgl_allowed" : "webgl_blocked"));
540 SendResponse(true);
541 } else {
542 manager->AddObserver(this);
Ken Russell (switch to Gerrit) 2011/12/03 02:59:42 I don't fully understand the multithreading in thi
Zhenyao Mo 2011/12/03 07:13:27 Ah you are right. I need to think more on this.
543 manager->RequestCompleteGpuInfoIfNeeded();
544
545 AddRef();
546 }
547 return true;
548 }
549
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698