| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 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 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 312 |
| 313 // The response is sent asynchronously in OnWebstoreParseSuccess/ | 313 // The response is sent asynchronously in OnWebstoreParseSuccess/ |
| 314 // OnWebstoreParseFailure. | 314 // OnWebstoreParseFailure. |
| 315 return true; | 315 return true; |
| 316 } | 316 } |
| 317 | 317 |
| 318 | 318 |
| 319 void BeginInstallWithManifestFunction::SetResult(ResultCode code) { | 319 void BeginInstallWithManifestFunction::SetResult(ResultCode code) { |
| 320 switch (code) { | 320 switch (code) { |
| 321 case ERROR_NONE: | 321 case ERROR_NONE: |
| 322 result_.reset(Value::CreateStringValue("")); | 322 SetSingleResult(Value::CreateStringValue("")); |
| 323 break; | 323 break; |
| 324 case UNKNOWN_ERROR: | 324 case UNKNOWN_ERROR: |
| 325 result_.reset(Value::CreateStringValue("unknown_error")); | 325 SetSingleResult(Value::CreateStringValue("unknown_error")); |
| 326 break; | 326 break; |
| 327 case USER_CANCELLED: | 327 case USER_CANCELLED: |
| 328 result_.reset(Value::CreateStringValue("user_cancelled")); | 328 SetSingleResult(Value::CreateStringValue("user_cancelled")); |
| 329 break; | 329 break; |
| 330 case MANIFEST_ERROR: | 330 case MANIFEST_ERROR: |
| 331 result_.reset(Value::CreateStringValue("manifest_error")); | 331 SetSingleResult(Value::CreateStringValue("manifest_error")); |
| 332 break; | 332 break; |
| 333 case ICON_ERROR: | 333 case ICON_ERROR: |
| 334 result_.reset(Value::CreateStringValue("icon_error")); | 334 SetSingleResult(Value::CreateStringValue("icon_error")); |
| 335 break; | 335 break; |
| 336 case INVALID_ID: | 336 case INVALID_ID: |
| 337 result_.reset(Value::CreateStringValue("invalid_id")); | 337 SetSingleResult(Value::CreateStringValue("invalid_id")); |
| 338 break; | 338 break; |
| 339 case PERMISSION_DENIED: | 339 case PERMISSION_DENIED: |
| 340 result_.reset(Value::CreateStringValue("permission_denied")); | 340 SetSingleResult(Value::CreateStringValue("permission_denied")); |
| 341 break; | 341 break; |
| 342 case INVALID_ICON_URL: | 342 case INVALID_ICON_URL: |
| 343 result_.reset(Value::CreateStringValue("invalid_icon_url")); | 343 SetSingleResult(Value::CreateStringValue("invalid_icon_url")); |
| 344 break; | 344 break; |
| 345 default: | 345 default: |
| 346 CHECK(false); | 346 CHECK(false); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( | 350 void BeginInstallWithManifestFunction::OnWebstoreParseSuccess( |
| 351 const std::string& id, | 351 const std::string& id, |
| 352 const SkBitmap& icon, | 352 const SkBitmap& icon, |
| 353 DictionaryValue* parsed_manifest) { | 353 DictionaryValue* parsed_manifest) { |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 const std::string& id, const std::string& error) { | 545 const std::string& id, const std::string& error) { |
| 546 CHECK_EQ(id_, id); | 546 CHECK_EQ(id_, id); |
| 547 | 547 |
| 548 error_ = error; | 548 error_ = error; |
| 549 SendResponse(false); | 549 SendResponse(false); |
| 550 | 550 |
| 551 Release(); // Matches the AddRef() in RunImpl(). | 551 Release(); // Matches the AddRef() in RunImpl(). |
| 552 } | 552 } |
| 553 | 553 |
| 554 bool GetBrowserLoginFunction::RunImpl() { | 554 bool GetBrowserLoginFunction::RunImpl() { |
| 555 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); | 555 SetSingleResult(CreateLoginResult(profile_->GetOriginalProfile())); |
| 556 return true; | 556 return true; |
| 557 } | 557 } |
| 558 | 558 |
| 559 bool GetStoreLoginFunction::RunImpl() { | 559 bool GetStoreLoginFunction::RunImpl() { |
| 560 ExtensionService* service = profile_->GetExtensionService(); | 560 ExtensionService* service = profile_->GetExtensionService(); |
| 561 ExtensionPrefs* prefs = service->extension_prefs(); | 561 ExtensionPrefs* prefs = service->extension_prefs(); |
| 562 std::string login; | 562 std::string login; |
| 563 if (prefs->GetWebStoreLogin(&login)) { | 563 if (prefs->GetWebStoreLogin(&login)) { |
| 564 result_.reset(Value::CreateStringValue(login)); | 564 SetSingleResult(Value::CreateStringValue(login)); |
| 565 } else { | 565 } else { |
| 566 result_.reset(Value::CreateStringValue(std::string())); | 566 SetSingleResult(Value::CreateStringValue(std::string())); |
| 567 } | 567 } |
| 568 return true; | 568 return true; |
| 569 } | 569 } |
| 570 | 570 |
| 571 bool SetStoreLoginFunction::RunImpl() { | 571 bool SetStoreLoginFunction::RunImpl() { |
| 572 std::string login; | 572 std::string login; |
| 573 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); | 573 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &login)); |
| 574 ExtensionService* service = profile_->GetExtensionService(); | 574 ExtensionService* service = profile_->GetExtensionService(); |
| 575 ExtensionPrefs* prefs = service->extension_prefs(); | 575 ExtensionPrefs* prefs = service->extension_prefs(); |
| 576 prefs->SetWebStoreLogin(login); | 576 prefs->SetWebStoreLogin(login); |
| 577 return true; | 577 return true; |
| 578 } | 578 } |
| 579 | 579 |
| 580 GetWebGLStatusFunction::GetWebGLStatusFunction() { | 580 GetWebGLStatusFunction::GetWebGLStatusFunction() { |
| 581 feature_checker_ = new GPUFeatureChecker( | 581 feature_checker_ = new GPUFeatureChecker( |
| 582 content::GPU_FEATURE_TYPE_WEBGL, | 582 content::GPU_FEATURE_TYPE_WEBGL, |
| 583 base::Bind(&GetWebGLStatusFunction::OnFeatureCheck, this)); | 583 base::Bind(&GetWebGLStatusFunction::OnFeatureCheck, this)); |
| 584 } | 584 } |
| 585 | 585 |
| 586 GetWebGLStatusFunction::~GetWebGLStatusFunction() {} | 586 GetWebGLStatusFunction::~GetWebGLStatusFunction() {} |
| 587 | 587 |
| 588 void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) { | 588 void GetWebGLStatusFunction::CreateResult(bool webgl_allowed) { |
| 589 result_.reset(Value::CreateStringValue( | 589 SetSingleResult(Value::CreateStringValue( |
| 590 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); | 590 webgl_allowed ? "webgl_allowed" : "webgl_blocked")); |
| 591 } | 591 } |
| 592 | 592 |
| 593 bool GetWebGLStatusFunction::RunImpl() { | 593 bool GetWebGLStatusFunction::RunImpl() { |
| 594 feature_checker_->CheckGPUFeatureAvailability(); | 594 feature_checker_->CheckGPUFeatureAvailability(); |
| 595 return true; | 595 return true; |
| 596 } | 596 } |
| 597 | 597 |
| 598 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { | 598 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { |
| 599 CreateResult(feature_allowed); | 599 CreateResult(feature_allowed); |
| 600 SendResponse(true); | 600 SendResponse(true); |
| 601 } | 601 } |
| 602 | 602 |
| 603 } // namespace extensions | 603 } // namespace extensions |
| OLD | NEW |