| 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 |
| (...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 // |external_uninstall| to true so this is the only way to uninstall | 711 // |external_uninstall| to true so this is the only way to uninstall |
| 712 // managed extensions. | 712 // managed extensions. |
| 713 // Shared modules being uninstalled will also set |external_uninstall| to true | 713 // Shared modules being uninstalled will also set |external_uninstall| to true |
| 714 // so that we can guarantee users don't uninstall a shared module. | 714 // so that we can guarantee users don't uninstall a shared module. |
| 715 // (crbug.com/273300) | 715 // (crbug.com/273300) |
| 716 // TODO(rdevlin.cronin): This is probably not right. We should do something | 716 // TODO(rdevlin.cronin): This is probably not right. We should do something |
| 717 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so | 717 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so |
| 718 // we don't do this. | 718 // we don't do this. |
| 719 bool external_uninstall = | 719 bool external_uninstall = |
| 720 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || | 720 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || |
| 721 (reason == extensions::UNINSTALL_REASON_REINSTALL) || |
| 721 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || | 722 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || |
| 722 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || | 723 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || |
| 723 (reason == extensions::UNINSTALL_REASON_SYNC && | 724 (reason == extensions::UNINSTALL_REASON_SYNC && |
| 724 extension->was_installed_by_custodian()); | 725 extension->was_installed_by_custodian()); |
| 725 if (!external_uninstall && | 726 if (!external_uninstall && |
| 726 !system_->management_policy()->UserMayModifySettings( | 727 !system_->management_policy()->UserMayModifySettings( |
| 727 extension.get(), error)) { | 728 extension.get(), error)) { |
| 728 content::NotificationService::current()->Notify( | 729 content::NotificationService::current()->Notify( |
| 729 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, | 730 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
| 730 content::Source<Profile>(profile_), | 731 content::Source<Profile>(profile_), |
| 731 content::Details<const Extension>(extension.get())); | 732 content::Details<const Extension>(extension.get())); |
| 732 return false; | 733 return false; |
| 733 } | 734 } |
| 734 | 735 |
| 735 syncer::SyncChange sync_change; | 736 syncer::SyncChange sync_change; |
| 736 if (extension_sync_service_) { | 737 // Don't sync the uninstall if we're going to reinstall the extension |
| 738 // momentarily. |
| 739 if (extension_sync_service_ && |
| 740 reason != extensions::UNINSTALL_REASON_REINSTALL) { |
| 737 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension( | 741 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension( |
| 738 extension.get(), is_ready()); | 742 extension.get(), is_ready()); |
| 739 } | 743 } |
| 740 | 744 |
| 741 system_->install_verifier()->Remove(extension->id()); | 745 system_->install_verifier()->Remove(extension->id()); |
| 742 | 746 |
| 743 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", | 747 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
| 744 extension->GetType(), 100); | 748 extension->GetType(), 100); |
| 745 RecordPermissionMessagesHistogram(extension.get(), | 749 RecordPermissionMessagesHistogram(extension.get(), |
| 746 "Extensions.Permissions_Uninstall2"); | 750 "Extensions.Permissions_Uninstall2"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 767 UntrackTerminatedExtension(extension->id()); | 771 UntrackTerminatedExtension(extension->id()); |
| 768 | 772 |
| 769 // Notify interested parties that we've uninstalled this extension. | 773 // Notify interested parties that we've uninstalled this extension. |
| 770 content::NotificationService::current()->Notify( | 774 content::NotificationService::current()->Notify( |
| 771 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | 775 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, |
| 772 content::Source<Profile>(profile_), | 776 content::Source<Profile>(profile_), |
| 773 content::Details<const Extension>(extension.get())); | 777 content::Details<const Extension>(extension.get())); |
| 774 ExtensionRegistry::Get(profile_) | 778 ExtensionRegistry::Get(profile_) |
| 775 ->TriggerOnUninstalled(extension.get(), reason); | 779 ->TriggerOnUninstalled(extension.get(), reason); |
| 776 | 780 |
| 777 if (extension_sync_service_) { | 781 if (sync_change.IsValid()) { |
| 778 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(), | 782 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(), |
| 779 sync_change); | 783 sync_change); |
| 780 } | 784 } |
| 781 | 785 |
| 782 delayed_installs_.Remove(extension->id()); | 786 delayed_installs_.Remove(extension->id()); |
| 783 | 787 |
| 784 extension_prefs_->OnExtensionUninstalled( | 788 extension_prefs_->OnExtensionUninstalled( |
| 785 extension->id(), extension->location(), external_uninstall); | 789 extension->id(), extension->location(), external_uninstall); |
| 786 | 790 |
| 787 // Track the uninstallation. | 791 // Track the uninstallation. |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 } | 2358 } |
| 2355 | 2359 |
| 2356 void ExtensionService::OnProfileDestructionStarted() { | 2360 void ExtensionService::OnProfileDestructionStarted() { |
| 2357 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2361 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2358 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2362 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2359 it != ids_to_unload.end(); | 2363 it != ids_to_unload.end(); |
| 2360 ++it) { | 2364 ++it) { |
| 2361 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2365 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2362 } | 2366 } |
| 2363 } | 2367 } |
| OLD | NEW |