| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" | 21 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 22 #include "chrome/browser/extensions/component_loader.h" | 22 #include "chrome/browser/extensions/component_loader.h" |
| 23 #include "chrome/browser/extensions/crx_installer.h" | 23 #include "chrome/browser/extensions/crx_installer.h" |
| 24 #include "chrome/browser/extensions/data_deleter.h" | 24 #include "chrome/browser/extensions/data_deleter.h" |
| 25 #include "chrome/browser/extensions/extension_assets_manager.h" |
| 25 #include "chrome/browser/extensions/extension_disabled_ui.h" | 26 #include "chrome/browser/extensions/extension_disabled_ui.h" |
| 26 #include "chrome/browser/extensions/extension_error_controller.h" | 27 #include "chrome/browser/extensions/extension_error_controller.h" |
| 27 #include "chrome/browser/extensions/extension_install_ui.h" | 28 #include "chrome/browser/extensions/extension_install_ui.h" |
| 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 29 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 29 #include "chrome/browser/extensions/extension_sync_service.h" | 30 #include "chrome/browser/extensions/extension_sync_service.h" |
| 30 #include "chrome/browser/extensions/extension_util.h" | 31 #include "chrome/browser/extensions/extension_util.h" |
| 31 #include "chrome/browser/extensions/external_install_ui.h" | 32 #include "chrome/browser/extensions/external_install_ui.h" |
| 32 #include "chrome/browser/extensions/external_provider_impl.h" | 33 #include "chrome/browser/extensions/external_provider_impl.h" |
| 33 #include "chrome/browser/extensions/install_verifier.h" | 34 #include "chrome/browser/extensions/install_verifier.h" |
| 34 #include "chrome/browser/extensions/installed_loader.h" | 35 #include "chrome/browser/extensions/installed_loader.h" |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 "Extensions.Permissions_Uninstall"); | 719 "Extensions.Permissions_Uninstall"); |
| 719 | 720 |
| 720 // Unload before doing more cleanup to ensure that nothing is hanging on to | 721 // Unload before doing more cleanup to ensure that nothing is hanging on to |
| 721 // any of these resources. | 722 // any of these resources. |
| 722 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL); | 723 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL); |
| 723 | 724 |
| 724 // Tell the backend to start deleting installed extensions on the file thread. | 725 // Tell the backend to start deleting installed extensions on the file thread. |
| 725 if (!Manifest::IsUnpackedLocation(extension->location())) { | 726 if (!Manifest::IsUnpackedLocation(extension->location())) { |
| 726 if (!GetFileTaskRunner()->PostTask( | 727 if (!GetFileTaskRunner()->PostTask( |
| 727 FROM_HERE, | 728 FROM_HERE, |
| 728 base::Bind(&extensions::file_util::UninstallExtension, | 729 base::Bind(&ExtensionService::UninstallExtensionOnFileThread, |
| 730 extension_id, |
| 731 profile_, |
| 729 install_directory_, | 732 install_directory_, |
| 730 extension_id))) | 733 extension->path()))) |
| 731 NOTREACHED(); | 734 NOTREACHED(); |
| 732 } | 735 } |
| 733 | 736 |
| 734 // Do not remove the data of ephemeral apps. They will be garbage collected by | 737 // Do not remove the data of ephemeral apps. They will be garbage collected by |
| 735 // EphemeralAppService. | 738 // EphemeralAppService. |
| 736 if (!extension->is_ephemeral()) | 739 if (!extension->is_ephemeral()) |
| 737 extensions::DataDeleter::StartDeleting(profile_, extension.get()); | 740 extensions::DataDeleter::StartDeleting(profile_, extension.get()); |
| 738 | 741 |
| 739 UntrackTerminatedExtension(extension_id); | 742 UntrackTerminatedExtension(extension_id); |
| 740 | 743 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 753 | 756 |
| 754 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), | 757 extension_prefs_->OnExtensionUninstalled(extension_id, extension->location(), |
| 755 external_uninstall); | 758 external_uninstall); |
| 756 | 759 |
| 757 // Track the uninstallation. | 760 // Track the uninstallation. |
| 758 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); | 761 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); |
| 759 | 762 |
| 760 return true; | 763 return true; |
| 761 } | 764 } |
| 762 | 765 |
| 766 // static |
| 767 void ExtensionService::UninstallExtensionOnFileThread( |
| 768 const std::string& id, |
| 769 Profile* profile, |
| 770 const base::FilePath& install_dir, |
| 771 const base::FilePath& extension_path) { |
| 772 extensions::ExtensionAssetsManager* assets_manager = |
| 773 extensions::ExtensionAssetsManager::GetInstance(); |
| 774 assets_manager->UninstallExtension(id, profile, install_dir, extension_path); |
| 775 } |
| 776 |
| 763 bool ExtensionService::IsExtensionEnabled( | 777 bool ExtensionService::IsExtensionEnabled( |
| 764 const std::string& extension_id) const { | 778 const std::string& extension_id) const { |
| 765 if (registry_->enabled_extensions().Contains(extension_id) || | 779 if (registry_->enabled_extensions().Contains(extension_id) || |
| 766 registry_->terminated_extensions().Contains(extension_id)) { | 780 registry_->terminated_extensions().Contains(extension_id)) { |
| 767 return true; | 781 return true; |
| 768 } | 782 } |
| 769 | 783 |
| 770 if (registry_->disabled_extensions().Contains(extension_id) || | 784 if (registry_->disabled_extensions().Contains(extension_id) || |
| 771 registry_->blacklisted_extensions().Contains(extension_id)) { | 785 registry_->blacklisted_extensions().Contains(extension_id)) { |
| 772 return false; | 786 return false; |
| (...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 void ExtensionService::UnloadAllExtensionsInternal() { | 2422 void ExtensionService::UnloadAllExtensionsInternal() { |
| 2409 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); | 2423 profile_->GetExtensionSpecialStoragePolicy()->RevokeRightsForAllExtensions(); |
| 2410 | 2424 |
| 2411 registry_->ClearAll(); | 2425 registry_->ClearAll(); |
| 2412 system_->runtime_data()->ClearAll(); | 2426 system_->runtime_data()->ClearAll(); |
| 2413 | 2427 |
| 2414 // TODO(erikkay) should there be a notification for this? We can't use | 2428 // TODO(erikkay) should there be a notification for this? We can't use |
| 2415 // EXTENSION_UNLOADED since that implies that the extension has been disabled | 2429 // EXTENSION_UNLOADED since that implies that the extension has been disabled |
| 2416 // or uninstalled. | 2430 // or uninstalled. |
| 2417 } | 2431 } |
| OLD | NEW |