| 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/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 } | 391 } |
| 392 | 392 |
| 393 if (!BrowserThread::PostTask( | 393 if (!BrowserThread::PostTask( |
| 394 BrowserThread::UI, FROM_HERE, | 394 BrowserThread::UI, FROM_HERE, |
| 395 base::Bind(&CrxInstaller::CheckImportsAndRequirements, this))) | 395 base::Bind(&CrxInstaller::CheckImportsAndRequirements, this))) |
| 396 NOTREACHED(); | 396 NOTREACHED(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 void CrxInstaller::CheckImportsAndRequirements() { | 399 void CrxInstaller::CheckImportsAndRequirements() { |
| 400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 400 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 401 ExtensionService* service = service_weak_; | 401 ExtensionService* service = service_weak_.get(); |
| 402 if (!service || service->browser_terminating()) | 402 if (!service || service->browser_terminating()) |
| 403 return; | 403 return; |
| 404 | 404 |
| 405 if (SharedModuleInfo::ImportsModules(extension())) { | 405 if (SharedModuleInfo::ImportsModules(extension())) { |
| 406 const std::vector<SharedModuleInfo::ImportInfo>& imports = | 406 const std::vector<SharedModuleInfo::ImportInfo>& imports = |
| 407 SharedModuleInfo::GetImports(extension()); | 407 SharedModuleInfo::GetImports(extension()); |
| 408 std::vector<SharedModuleInfo::ImportInfo>::const_iterator i; | 408 std::vector<SharedModuleInfo::ImportInfo>::const_iterator i; |
| 409 for (i = imports.begin(); i != imports.end(); ++i) { | 409 for (i = imports.begin(); i != imports.end(); ++i) { |
| 410 Version version_required(i->minimum_version); | 410 Version version_required(i->minimum_version); |
| 411 const Extension* imported_module = | 411 const Extension* imported_module = |
| (...skipping 30 matching lines...) Expand all Loading... |
| 442 UTF8ToUTF16(JoinString(requirement_errors, ' ')))); | 442 UTF8ToUTF16(JoinString(requirement_errors, ' ')))); |
| 443 return; | 443 return; |
| 444 } | 444 } |
| 445 has_requirement_errors_ = true; | 445 has_requirement_errors_ = true; |
| 446 } | 446 } |
| 447 ConfirmInstall(); | 447 ConfirmInstall(); |
| 448 } | 448 } |
| 449 | 449 |
| 450 void CrxInstaller::ConfirmInstall() { | 450 void CrxInstaller::ConfirmInstall() { |
| 451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 451 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 452 ExtensionService* service = service_weak_; | 452 ExtensionService* service = service_weak_.get(); |
| 453 if (!service || service->browser_terminating()) | 453 if (!service || service->browser_terminating()) |
| 454 return; | 454 return; |
| 455 | 455 |
| 456 string16 error = installer_.CheckManagementPolicy(); | 456 string16 error = installer_.CheckManagementPolicy(); |
| 457 if (!error.empty()) { | 457 if (!error.empty()) { |
| 458 ReportFailureFromUIThread(CrxInstallerError(error)); | 458 ReportFailureFromUIThread(CrxInstallerError(error)); |
| 459 return; | 459 return; |
| 460 } | 460 } |
| 461 | 461 |
| 462 // Check whether this install is initiated from the settings page to | 462 // Check whether this install is initiated from the settings page to |
| (...skipping 27 matching lines...) Expand all Loading... |
| 490 FROM_HERE, | 490 FROM_HERE, |
| 491 base::Bind(&CrxInstaller::CompleteInstall, this))) | 491 base::Bind(&CrxInstaller::CompleteInstall, this))) |
| 492 NOTREACHED(); | 492 NOTREACHED(); |
| 493 } | 493 } |
| 494 return; | 494 return; |
| 495 } | 495 } |
| 496 | 496 |
| 497 void CrxInstaller::InstallUIProceed() { | 497 void CrxInstaller::InstallUIProceed() { |
| 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 498 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 499 | 499 |
| 500 ExtensionService* service = service_weak_; | 500 ExtensionService* service = service_weak_.get(); |
| 501 if (!service || service->browser_terminating()) | 501 if (!service || service->browser_terminating()) |
| 502 return; | 502 return; |
| 503 | 503 |
| 504 // If update_from_settings_page_ boolean is true, this functions is | 504 // If update_from_settings_page_ boolean is true, this functions is |
| 505 // getting called in response to ExtensionInstallPrompt::ConfirmReEnable() | 505 // getting called in response to ExtensionInstallPrompt::ConfirmReEnable() |
| 506 // and if it is false, this function is called in response to | 506 // and if it is false, this function is called in response to |
| 507 // ExtensionInstallPrompt::ConfirmInstall(). | 507 // ExtensionInstallPrompt::ConfirmInstall(). |
| 508 if (update_from_settings_page_) { | 508 if (update_from_settings_page_) { |
| 509 service->GrantPermissionsAndEnableExtension(extension()); | 509 service->GrantPermissionsAndEnableExtension(extension()); |
| 510 } else { | 510 } else { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 base::Bind(&CrxInstaller::ReportSuccessFromUIThread, this))) | 651 base::Bind(&CrxInstaller::ReportSuccessFromUIThread, this))) |
| 652 NOTREACHED(); | 652 NOTREACHED(); |
| 653 | 653 |
| 654 // Delete temporary files. | 654 // Delete temporary files. |
| 655 CleanupTempFiles(); | 655 CleanupTempFiles(); |
| 656 } | 656 } |
| 657 | 657 |
| 658 void CrxInstaller::ReportSuccessFromUIThread() { | 658 void CrxInstaller::ReportSuccessFromUIThread() { |
| 659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 659 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 660 | 660 |
| 661 if (!service_weak_ || service_weak_->browser_terminating()) | 661 if (!service_weak_.get() || service_weak_->browser_terminating()) |
| 662 return; | 662 return; |
| 663 | 663 |
| 664 if (!update_from_settings_page_) { | 664 if (!update_from_settings_page_) { |
| 665 // If there is a client, tell the client about installation. | 665 // If there is a client, tell the client about installation. |
| 666 if (client_) | 666 if (client_) |
| 667 client_->OnInstallSuccess(extension(), install_icon_.get()); | 667 client_->OnInstallSuccess(extension(), install_icon_.get()); |
| 668 | 668 |
| 669 // We update the extension's granted permissions if the user already | 669 // We update the extension's granted permissions if the user already |
| 670 // approved the install (client_ is non NULL), or we are allowed to install | 670 // approved the install (client_ is non NULL), or we are allowed to install |
| 671 // this silently. | 671 // this silently. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 | 749 |
| 750 if (delete_source_ && !source_file_.value().empty()) { | 750 if (delete_source_ && !source_file_.value().empty()) { |
| 751 extension_file_util::DeleteFile(source_file_, false); | 751 extension_file_util::DeleteFile(source_file_, false); |
| 752 source_file_ = base::FilePath(); | 752 source_file_ = base::FilePath(); |
| 753 } | 753 } |
| 754 } | 754 } |
| 755 | 755 |
| 756 void CrxInstaller::CheckUpdateFromSettingsPage() { | 756 void CrxInstaller::CheckUpdateFromSettingsPage() { |
| 757 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 757 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 758 | 758 |
| 759 ExtensionService* service = service_weak_; | 759 ExtensionService* service = service_weak_.get(); |
| 760 if (!service || service->browser_terminating()) | 760 if (!service || service->browser_terminating()) |
| 761 return; | 761 return; |
| 762 | 762 |
| 763 if (off_store_install_allow_reason_ != OffStoreInstallAllowedFromSettingsPage) | 763 if (off_store_install_allow_reason_ != OffStoreInstallAllowedFromSettingsPage) |
| 764 return; | 764 return; |
| 765 | 765 |
| 766 const Extension* installed_extension = | 766 const Extension* installed_extension = |
| 767 service->GetInstalledExtension(extension()->id()); | 767 service->GetInstalledExtension(extension()->id()); |
| 768 if (installed_extension) { | 768 if (installed_extension) { |
| 769 // Previous version of the extension exists. | 769 // Previous version of the extension exists. |
| 770 update_from_settings_page_ = true; | 770 update_from_settings_page_ = true; |
| 771 expected_id_ = installed_extension->id(); | 771 expected_id_ = installed_extension->id(); |
| 772 install_source_ = installed_extension->location(); | 772 install_source_ = installed_extension->location(); |
| 773 install_cause_ = extension_misc::INSTALL_CAUSE_UPDATE; | 773 install_cause_ = extension_misc::INSTALL_CAUSE_UPDATE; |
| 774 } | 774 } |
| 775 } | 775 } |
| 776 | 776 |
| 777 void CrxInstaller::ConfirmReEnable() { | 777 void CrxInstaller::ConfirmReEnable() { |
| 778 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 778 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 779 | 779 |
| 780 ExtensionService* service = service_weak_; | 780 ExtensionService* service = service_weak_.get(); |
| 781 if (!service || service->browser_terminating()) | 781 if (!service || service->browser_terminating()) |
| 782 return; | 782 return; |
| 783 | 783 |
| 784 if (!update_from_settings_page_) | 784 if (!update_from_settings_page_) |
| 785 return; | 785 return; |
| 786 | 786 |
| 787 ExtensionPrefs* prefs = service->extension_prefs(); | 787 ExtensionPrefs* prefs = service->extension_prefs(); |
| 788 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 788 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
| 789 return; | 789 return; |
| 790 | 790 |
| 791 if (client_) { | 791 if (client_) { |
| 792 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 792 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
| 793 client_->ConfirmReEnable(this, extension()); | 793 client_->ConfirmReEnable(this, extension()); |
| 794 } | 794 } |
| 795 } | 795 } |
| 796 | 796 |
| 797 } // namespace extensions | 797 } // namespace extensions |
| OLD | NEW |