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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 // Mark the extension as approved, but save the expected manifest and ID | 147 // Mark the extension as approved, but save the expected manifest and ID |
148 // so we can check that they match the CRX's. | 148 // so we can check that they match the CRX's. |
149 approved_ = true; | 149 approved_ = true; |
150 expected_manifest_check_level_ = approval->manifest_check_level; | 150 expected_manifest_check_level_ = approval->manifest_check_level; |
151 if (expected_manifest_check_level_ != | 151 if (expected_manifest_check_level_ != |
152 WebstoreInstaller::MANIFEST_CHECK_LEVEL_NONE) | 152 WebstoreInstaller::MANIFEST_CHECK_LEVEL_NONE) |
153 expected_manifest_.reset(approval->manifest->DeepCopy()); | 153 expected_manifest_.reset(approval->manifest->DeepCopy()); |
154 expected_id_ = approval->extension_id; | 154 expected_id_ = approval->extension_id; |
155 } | 155 } |
156 if (approval->minimum_version.get()) { | 156 if (approval->minimum_version.get()) { |
157 expected_version_.reset(new base::Version(*approval->minimum_version)); | 157 expected_version_.reset(new Version(*approval->minimum_version)); |
158 expected_version_strict_checking_ = false; | 158 expected_version_strict_checking_ = false; |
159 } | 159 } |
160 | 160 |
161 show_dialog_callback_ = approval->show_dialog_callback; | 161 show_dialog_callback_ = approval->show_dialog_callback; |
162 set_is_ephemeral(approval->is_ephemeral); | 162 set_is_ephemeral(approval->is_ephemeral); |
163 } | 163 } |
164 | 164 |
165 CrxInstaller::~CrxInstaller() { | 165 CrxInstaller::~CrxInstaller() { |
166 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 166 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
167 // Ensure |client_| and |install_checker_| data members are destroyed on the | 167 // Ensure |client_| and |install_checker_| data members are destroyed on the |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 if (!service || service->browser_terminating()) | 476 if (!service || service->browser_terminating()) |
477 return; | 477 return; |
478 | 478 |
479 // TODO(crbug.com/420147): Move this code to a utility class to avoid | 479 // TODO(crbug.com/420147): Move this code to a utility class to avoid |
480 // duplication of SharedModuleService::CheckImports code. | 480 // duplication of SharedModuleService::CheckImports code. |
481 if (SharedModuleInfo::ImportsModules(extension())) { | 481 if (SharedModuleInfo::ImportsModules(extension())) { |
482 const std::vector<SharedModuleInfo::ImportInfo>& imports = | 482 const std::vector<SharedModuleInfo::ImportInfo>& imports = |
483 SharedModuleInfo::GetImports(extension()); | 483 SharedModuleInfo::GetImports(extension()); |
484 std::vector<SharedModuleInfo::ImportInfo>::const_iterator i; | 484 std::vector<SharedModuleInfo::ImportInfo>::const_iterator i; |
485 for (i = imports.begin(); i != imports.end(); ++i) { | 485 for (i = imports.begin(); i != imports.end(); ++i) { |
486 base::Version version_required(i->minimum_version); | 486 Version version_required(i->minimum_version); |
487 const Extension* imported_module = | 487 const Extension* imported_module = |
488 service->GetExtensionById(i->extension_id, true); | 488 service->GetExtensionById(i->extension_id, true); |
489 if (imported_module && | 489 if (imported_module && |
490 !SharedModuleInfo::IsSharedModule(imported_module)) { | 490 !SharedModuleInfo::IsSharedModule(imported_module)) { |
491 ReportFailureFromUIThread(CrxInstallError( | 491 ReportFailureFromUIThread(CrxInstallError( |
492 CrxInstallError::ERROR_DECLINED, | 492 CrxInstallError::ERROR_DECLINED, |
493 l10n_util::GetStringFUTF16( | 493 l10n_util::GetStringFUTF16( |
494 IDS_EXTENSION_INSTALL_DEPENDENCY_NOT_SHARED_MODULE, | 494 IDS_EXTENSION_INSTALL_DEPENDENCY_NOT_SHARED_MODULE, |
495 base::UTF8ToUTF16(imported_module->name())))); | 495 base::UTF8ToUTF16(imported_module->name())))); |
496 return; | 496 return; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 Release(); // balanced in ConfirmInstall() or ConfirmReEnable(). | 677 Release(); // balanced in ConfirmInstall() or ConfirmReEnable(). |
678 | 678 |
679 // We're done. Since we don't post any more tasks to ourself, our ref count | 679 // We're done. Since we don't post any more tasks to ourself, our ref count |
680 // should go to zero and we die. The destructor will clean up the temp dir. | 680 // should go to zero and we die. The destructor will clean up the temp dir. |
681 } | 681 } |
682 | 682 |
683 void CrxInstaller::CompleteInstall() { | 683 void CrxInstaller::CompleteInstall() { |
684 DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); | 684 DCHECK(installer_task_runner_->RunsTasksOnCurrentThread()); |
685 | 685 |
686 if (!current_version_.empty()) { | 686 if (!current_version_.empty()) { |
687 base::Version current_version(current_version_); | 687 Version current_version(current_version_); |
688 if (current_version.CompareTo(*(extension()->version())) > 0) { | 688 if (current_version.CompareTo(*(extension()->version())) > 0) { |
689 ReportFailureFromFileThread(CrxInstallError( | 689 ReportFailureFromFileThread(CrxInstallError( |
690 CrxInstallError::ERROR_DECLINED, | 690 CrxInstallError::ERROR_DECLINED, |
691 l10n_util::GetStringUTF16( | 691 l10n_util::GetStringUTF16( |
692 extension()->is_app() ? IDS_APP_CANT_DOWNGRADE_VERSION | 692 extension()->is_app() ? IDS_APP_CANT_DOWNGRADE_VERSION |
693 : IDS_EXTENSION_CANT_DOWNGRADE_VERSION))); | 693 : IDS_EXTENSION_CANT_DOWNGRADE_VERSION))); |
694 return; | 694 return; |
695 } | 695 } |
696 } | 696 } |
697 | 697 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
907 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 907 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
908 return; | 908 return; |
909 | 909 |
910 if (client_) { | 910 if (client_) { |
911 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 911 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
912 client_->ConfirmReEnable(this, extension()); | 912 client_->ConfirmReEnable(this, extension()); |
913 } | 913 } |
914 } | 914 } |
915 | 915 |
916 } // namespace extensions | 916 } // namespace extensions |
OLD | NEW |