| 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 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 "Extensions.Permissions_Uninstall"); | 744 "Extensions.Permissions_Uninstall"); |
| 744 | 745 |
| 745 // Unload before doing more cleanup to ensure that nothing is hanging on to | 746 // Unload before doing more cleanup to ensure that nothing is hanging on to |
| 746 // any of these resources. | 747 // any of these resources. |
| 747 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UNINSTALL); | 748 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UNINSTALL); |
| 748 | 749 |
| 749 // Tell the backend to start deleting installed extensions on the file thread. | 750 // Tell the backend to start deleting installed extensions on the file thread. |
| 750 if (!Manifest::IsUnpackedLocation(extension->location())) { | 751 if (!Manifest::IsUnpackedLocation(extension->location())) { |
| 751 if (!GetFileTaskRunner()->PostTask( | 752 if (!GetFileTaskRunner()->PostTask( |
| 752 FROM_HERE, | 753 FROM_HERE, |
| 753 base::Bind(&extensions::file_util::UninstallExtension, | 754 base::Bind(&ExtensionService::UninstallExtensionOnFileThread, |
| 755 extension->id(), |
| 756 profile_, |
| 754 install_directory_, | 757 install_directory_, |
| 755 extension->id()))) | 758 extension->path()))) |
| 756 NOTREACHED(); | 759 NOTREACHED(); |
| 757 } | 760 } |
| 758 | 761 |
| 759 // Do not remove the data of ephemeral apps. They will be garbage collected by | 762 // Do not remove the data of ephemeral apps. They will be garbage collected by |
| 760 // EphemeralAppService. | 763 // EphemeralAppService. |
| 761 if (!extension_prefs_->IsEphemeralApp(extension->id())) | 764 if (!extension_prefs_->IsEphemeralApp(extension->id())) |
| 762 extensions::DataDeleter::StartDeleting(profile_, extension.get()); | 765 extensions::DataDeleter::StartDeleting(profile_, extension.get()); |
| 763 | 766 |
| 764 UntrackTerminatedExtension(extension->id()); | 767 UntrackTerminatedExtension(extension->id()); |
| 765 | 768 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 779 | 782 |
| 780 extension_prefs_->OnExtensionUninstalled( | 783 extension_prefs_->OnExtensionUninstalled( |
| 781 extension->id(), extension->location(), external_uninstall); | 784 extension->id(), extension->location(), external_uninstall); |
| 782 | 785 |
| 783 // Track the uninstallation. | 786 // Track the uninstallation. |
| 784 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); | 787 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); |
| 785 | 788 |
| 786 return true; | 789 return true; |
| 787 } | 790 } |
| 788 | 791 |
| 792 // static |
| 793 void ExtensionService::UninstallExtensionOnFileThread( |
| 794 const std::string& id, |
| 795 Profile* profile, |
| 796 const base::FilePath& install_dir, |
| 797 const base::FilePath& extension_path) { |
| 798 extensions::ExtensionAssetsManager* assets_manager = |
| 799 extensions::ExtensionAssetsManager::GetInstance(); |
| 800 assets_manager->UninstallExtension(id, profile, install_dir, extension_path); |
| 801 } |
| 802 |
| 789 bool ExtensionService::IsExtensionEnabled( | 803 bool ExtensionService::IsExtensionEnabled( |
| 790 const std::string& extension_id) const { | 804 const std::string& extension_id) const { |
| 791 if (registry_->enabled_extensions().Contains(extension_id) || | 805 if (registry_->enabled_extensions().Contains(extension_id) || |
| 792 registry_->terminated_extensions().Contains(extension_id)) { | 806 registry_->terminated_extensions().Contains(extension_id)) { |
| 793 return true; | 807 return true; |
| 794 } | 808 } |
| 795 | 809 |
| 796 if (registry_->disabled_extensions().Contains(extension_id) || | 810 if (registry_->disabled_extensions().Contains(extension_id) || |
| 797 registry_->blacklisted_extensions().Contains(extension_id)) { | 811 registry_->blacklisted_extensions().Contains(extension_id)) { |
| 798 return false; | 812 return false; |
| (...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2543 } | 2557 } |
| 2544 | 2558 |
| 2545 void ExtensionService::OnProfileDestructionStarted() { | 2559 void ExtensionService::OnProfileDestructionStarted() { |
| 2546 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2560 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2547 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2561 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2548 it != ids_to_unload.end(); | 2562 it != ids_to_unload.end(); |
| 2549 ++it) { | 2563 ++it) { |
| 2550 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2564 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2551 } | 2565 } |
| 2552 } | 2566 } |
| OLD | NEW |