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

Side by Side Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 10911158: Pass on download or installation errors from WebstoreInstaller to the CompleteInstall function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and rename error204->empty Created 8 years, 3 months 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) 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/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/scoped_vector.h" 10 #include "base/memory/scoped_vector.h"
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 } 431 }
432 432
433 scoped_ptr<WebstoreInstaller::Approval> approval( 433 scoped_ptr<WebstoreInstaller::Approval> approval(
434 g_pending_approvals.Get().PopApproval(profile(), id)); 434 g_pending_approvals.Get().PopApproval(profile(), id));
435 if (!approval.get()) { 435 if (!approval.get()) {
436 error_ = ExtensionErrorUtils::FormatErrorMessage( 436 error_ = ExtensionErrorUtils::FormatErrorMessage(
437 kNoPreviousBeginInstallWithManifestError, id); 437 kNoPreviousBeginInstallWithManifestError, id);
438 return false; 438 return false;
439 } 439 }
440 440
441 AddRef();
442
441 // The extension will install through the normal extension install flow, but 443 // The extension will install through the normal extension install flow, but
442 // the whitelist entry will bypass the normal permissions install dialog. 444 // the whitelist entry will bypass the normal permissions install dialog.
443 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 445 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
444 profile(), test_webstore_installer_delegate, 446 profile(), this,
445 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()), 447 &(dispatcher()->delegate()->GetAssociatedWebContents()->GetController()),
446 id, approval.Pass(), WebstoreInstaller::FLAG_NONE); 448 id, approval.Pass(), WebstoreInstaller::FLAG_NONE);
447 installer->Start(); 449 installer->Start();
448 450
449 return true; 451 return true;
450 } 452 }
451 453
454 void CompleteInstallFunction::OnExtensionInstallSuccess(
455 const std::string& id) {
456 if (test_webstore_installer_delegate)
457 test_webstore_installer_delegate->OnExtensionInstallSuccess(id);
458
459 SendResponse(true);
460
461 // Matches the AddRef in RunImpl().
462 Release();
463 }
464
465 void CompleteInstallFunction::OnExtensionInstallFailure(
466 const std::string& id, const std::string& error) {
467 if (test_webstore_installer_delegate)
468 test_webstore_installer_delegate->OnExtensionInstallFailure(id, error);
469
470 error_ = error;
471 SendResponse(false);
472
473 // Matches the AddRef in RunImpl().
474 Release();
475 }
476
477
452 bool GetBrowserLoginFunction::RunImpl() { 478 bool GetBrowserLoginFunction::RunImpl() {
453 SetResult(CreateLoginResult(profile_->GetOriginalProfile())); 479 SetResult(CreateLoginResult(profile_->GetOriginalProfile()));
454 return true; 480 return true;
455 } 481 }
456 482
457 bool GetStoreLoginFunction::RunImpl() { 483 bool GetStoreLoginFunction::RunImpl() {
458 ExtensionService* service = profile_->GetExtensionService(); 484 ExtensionService* service = profile_->GetExtensionService();
459 ExtensionPrefs* prefs = service->extension_prefs(); 485 ExtensionPrefs* prefs = service->extension_prefs();
460 std::string login; 486 std::string login;
461 if (prefs->GetWebStoreLogin(&login)) { 487 if (prefs->GetWebStoreLogin(&login)) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 feature_checker_->CheckGPUFeatureAvailability(); 519 feature_checker_->CheckGPUFeatureAvailability();
494 return true; 520 return true;
495 } 521 }
496 522
497 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) { 523 void GetWebGLStatusFunction::OnFeatureCheck(bool feature_allowed) {
498 CreateResult(feature_allowed); 524 CreateResult(feature_allowed);
499 SendResponse(true); 525 SendResponse(true);
500 } 526 }
501 527
502 } // namespace extensions 528 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698