| 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 18 matching lines...) Expand all Loading... |
| 29 #include "chrome/browser/extensions/extension_install_ui.h" | 29 #include "chrome/browser/extensions/extension_install_ui.h" |
| 30 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
| 31 #include "chrome/browser/extensions/install_tracker.h" | 31 #include "chrome/browser/extensions/install_tracker.h" |
| 32 #include "chrome/browser/extensions/install_tracker_factory.h" | 32 #include "chrome/browser/extensions/install_tracker_factory.h" |
| 33 #include "chrome/browser/extensions/permissions_updater.h" | 33 #include "chrome/browser/extensions/permissions_updater.h" |
| 34 #include "chrome/browser/extensions/webstore_installer.h" | 34 #include "chrome/browser/extensions/webstore_installer.h" |
| 35 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 36 #include "chrome/browser/web_applications/web_app.h" | 36 #include "chrome/browser/web_applications/web_app.h" |
| 37 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/extensions/extension_constants.h" | 38 #include "chrome/common/extensions/extension_constants.h" |
| 39 #include "chrome/common/extensions/extension_file_util.h" | |
| 40 #include "chrome/common/extensions/manifest_url_handler.h" | 39 #include "chrome/common/extensions/manifest_url_handler.h" |
| 41 #include "content/public/browser/browser_thread.h" | 40 #include "content/public/browser/browser_thread.h" |
| 42 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 43 #include "content/public/browser/resource_dispatcher_host.h" | 42 #include "content/public/browser/resource_dispatcher_host.h" |
| 44 #include "content/public/browser/user_metrics.h" | 43 #include "content/public/browser/user_metrics.h" |
| 45 #include "extensions/browser/extension_system.h" | 44 #include "extensions/browser/extension_system.h" |
| 46 #include "extensions/common/extension_icon_set.h" | 45 #include "extensions/common/extension_icon_set.h" |
| 47 #include "extensions/common/feature_switch.h" | 46 #include "extensions/common/feature_switch.h" |
| 47 #include "extensions/common/file_util.h" |
| 48 #include "extensions/common/manifest.h" | 48 #include "extensions/common/manifest.h" |
| 49 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" | 49 #include "extensions/common/manifest_handlers/kiosk_mode_info.h" |
| 50 #include "extensions/common/manifest_handlers/shared_module_info.h" | 50 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 51 #include "extensions/common/permissions/permission_message_provider.h" | 51 #include "extensions/common/permissions/permission_message_provider.h" |
| 52 #include "extensions/common/permissions/permission_set.h" | 52 #include "extensions/common/permissions/permission_set.h" |
| 53 #include "extensions/common/permissions/permissions_data.h" | 53 #include "extensions/common/permissions/permissions_data.h" |
| 54 #include "extensions/common/user_script.h" | 54 #include "extensions/common/user_script.h" |
| 55 #include "grit/chromium_strings.h" | 55 #include "grit/chromium_strings.h" |
| 56 #include "grit/generated_resources.h" | 56 #include "grit/generated_resources.h" |
| 57 #include "grit/theme_resources.h" | 57 #include "grit/theme_resources.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 676 } |
| 677 } | 677 } |
| 678 | 678 |
| 679 // See how long extension install paths are. This is important on | 679 // See how long extension install paths are. This is important on |
| 680 // windows, because file operations may fail if the path to a file | 680 // windows, because file operations may fail if the path to a file |
| 681 // exceeds a small constant. See crbug.com/69693 . | 681 // exceeds a small constant. See crbug.com/69693 . |
| 682 UMA_HISTOGRAM_CUSTOM_COUNTS( | 682 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 683 "Extensions.CrxInstallDirPathLength", | 683 "Extensions.CrxInstallDirPathLength", |
| 684 install_directory_.value().length(), 0, 500, 100); | 684 install_directory_.value().length(), 0, 500, 100); |
| 685 | 685 |
| 686 base::FilePath version_dir = extension_file_util::InstallExtension( | 686 base::FilePath version_dir = |
| 687 unpacked_extension_root_, | 687 file_util::InstallExtension(unpacked_extension_root_, |
| 688 extension()->id(), | 688 extension()->id(), |
| 689 extension()->VersionString(), | 689 extension()->VersionString(), |
| 690 install_directory_); | 690 install_directory_); |
| 691 if (version_dir.empty()) { | 691 if (version_dir.empty()) { |
| 692 ReportFailureFromFileThread( | 692 ReportFailureFromFileThread( |
| 693 CrxInstallerError( | 693 CrxInstallerError( |
| 694 l10n_util::GetStringUTF16( | 694 l10n_util::GetStringUTF16( |
| 695 IDS_EXTENSION_MOVE_DIRECTORY_TO_PROFILE_FAILED))); | 695 IDS_EXTENSION_MOVE_DIRECTORY_TO_PROFILE_FAILED))); |
| 696 return; | 696 return; |
| 697 } | 697 } |
| 698 | 698 |
| 699 // This is lame, but we must reload the extension because absolute paths | 699 // This is lame, but we must reload the extension because absolute paths |
| 700 // inside the content scripts are established inside InitFromValue() and we | 700 // inside the content scripts are established inside InitFromValue() and we |
| 701 // just moved the extension. | 701 // just moved the extension. |
| 702 // TODO(aa): All paths to resources inside extensions should be created | 702 // TODO(aa): All paths to resources inside extensions should be created |
| 703 // lazily and based on the Extension's root path at that moment. | 703 // lazily and based on the Extension's root path at that moment. |
| 704 // TODO(rdevlin.cronin): Continue removing std::string errors and replacing | 704 // TODO(rdevlin.cronin): Continue removing std::string errors and replacing |
| 705 // with base::string16 | 705 // with base::string16 |
| 706 std::string extension_id = extension()->id(); | 706 std::string extension_id = extension()->id(); |
| 707 std::string error; | 707 std::string error; |
| 708 installer_.set_extension(extension_file_util::LoadExtension( | 708 installer_.set_extension( |
| 709 version_dir, | 709 file_util::LoadExtension( |
| 710 install_source_, | 710 version_dir, |
| 711 extension()->creation_flags() | Extension::REQUIRE_KEY, | 711 install_source_, |
| 712 &error).get()); | 712 extension()->creation_flags() | Extension::REQUIRE_KEY, |
| 713 &error).get()); |
| 713 | 714 |
| 714 if (extension()) { | 715 if (extension()) { |
| 715 ReportSuccessFromFileThread(); | 716 ReportSuccessFromFileThread(); |
| 716 } else { | 717 } else { |
| 717 LOG(ERROR) << error << " " << extension_id << " " << download_url_; | 718 LOG(ERROR) << error << " " << extension_id << " " << download_url_; |
| 718 ReportFailureFromFileThread(CrxInstallerError(base::UTF8ToUTF16(error))); | 719 ReportFailureFromFileThread(CrxInstallerError(base::UTF8ToUTF16(error))); |
| 719 } | 720 } |
| 720 | 721 |
| 721 } | 722 } |
| 722 | 723 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 if (!installer_task_runner_->PostTask( | 823 if (!installer_task_runner_->PostTask( |
| 823 FROM_HERE, | 824 FROM_HERE, |
| 824 base::Bind(&CrxInstaller::CleanupTempFiles, this))) { | 825 base::Bind(&CrxInstaller::CleanupTempFiles, this))) { |
| 825 NOTREACHED(); | 826 NOTREACHED(); |
| 826 } | 827 } |
| 827 return; | 828 return; |
| 828 } | 829 } |
| 829 | 830 |
| 830 // Delete the temp directory and crx file as necessary. | 831 // Delete the temp directory and crx file as necessary. |
| 831 if (!temp_dir_.value().empty()) { | 832 if (!temp_dir_.value().empty()) { |
| 832 extension_file_util::DeleteFile(temp_dir_, true); | 833 file_util::DeleteFile(temp_dir_, true); |
| 833 temp_dir_ = base::FilePath(); | 834 temp_dir_ = base::FilePath(); |
| 834 } | 835 } |
| 835 | 836 |
| 836 if (delete_source_ && !source_file_.value().empty()) { | 837 if (delete_source_ && !source_file_.value().empty()) { |
| 837 extension_file_util::DeleteFile(source_file_, false); | 838 file_util::DeleteFile(source_file_, false); |
| 838 source_file_ = base::FilePath(); | 839 source_file_ = base::FilePath(); |
| 839 } | 840 } |
| 840 } | 841 } |
| 841 | 842 |
| 842 void CrxInstaller::CheckUpdateFromSettingsPage() { | 843 void CrxInstaller::CheckUpdateFromSettingsPage() { |
| 843 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 844 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 844 | 845 |
| 845 ExtensionService* service = service_weak_.get(); | 846 ExtensionService* service = service_weak_.get(); |
| 846 if (!service || service->browser_terminating()) | 847 if (!service || service->browser_terminating()) |
| 847 return; | 848 return; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 874 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) | 875 if (!prefs->DidExtensionEscalatePermissions(extension()->id())) |
| 875 return; | 876 return; |
| 876 | 877 |
| 877 if (client_) { | 878 if (client_) { |
| 878 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). | 879 AddRef(); // Balanced in InstallUIProceed() and InstallUIAbort(). |
| 879 client_->ConfirmReEnable(this, extension()); | 880 client_->ConfirmReEnable(this, extension()); |
| 880 } | 881 } |
| 881 } | 882 } |
| 882 | 883 |
| 883 } // namespace extensions | 884 } // namespace extensions |
| OLD | NEW |