| 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 if (!external_uninstall && | 736 if (!external_uninstall && |
| 737 (!by_policy->UserMayModifySettings(extension.get(), error) || | 737 (!by_policy->UserMayModifySettings(extension.get(), error) || |
| 738 by_policy->MustRemainInstalled(extension.get(), error))) { | 738 by_policy->MustRemainInstalled(extension.get(), error))) { |
| 739 content::NotificationService::current()->Notify( | 739 content::NotificationService::current()->Notify( |
| 740 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, | 740 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
| 741 content::Source<Profile>(profile_), | 741 content::Source<Profile>(profile_), |
| 742 content::Details<const Extension>(extension.get())); | 742 content::Details<const Extension>(extension.get())); |
| 743 return false; | 743 return false; |
| 744 } | 744 } |
| 745 | 745 |
| 746 syncer::SyncData sync_data; | |
| 747 // Don't sync the uninstall if we're going to reinstall the extension | |
| 748 // momentarily. | |
| 749 if (extension_sync_service_ && | |
| 750 reason != extensions::UNINSTALL_REASON_REINSTALL) { | |
| 751 sync_data = extension_sync_service_->PrepareToSyncUninstallExtension( | |
| 752 *extension); | |
| 753 } | |
| 754 | |
| 755 InstallVerifier::Get(GetBrowserContext())->Remove(extension->id()); | 746 InstallVerifier::Get(GetBrowserContext())->Remove(extension->id()); |
| 756 | 747 |
| 757 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", | 748 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", |
| 758 extension->GetType(), 100); | 749 extension->GetType(), 100); |
| 759 RecordPermissionMessagesHistogram(extension.get(), "Uninstall"); | 750 RecordPermissionMessagesHistogram(extension.get(), "Uninstall"); |
| 760 | 751 |
| 761 // Unload before doing more cleanup to ensure that nothing is hanging on to | 752 // Unload before doing more cleanup to ensure that nothing is hanging on to |
| 762 // any of these resources. | 753 // any of these resources. |
| 763 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UNINSTALL); | 754 UnloadExtension(extension->id(), UnloadedExtensionInfo::REASON_UNINSTALL); |
| 764 | 755 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 776 | 767 |
| 777 extensions::DataDeleter::StartDeleting( | 768 extensions::DataDeleter::StartDeleting( |
| 778 profile_, extension.get(), deletion_done_callback); | 769 profile_, extension.get(), deletion_done_callback); |
| 779 | 770 |
| 780 UntrackTerminatedExtension(extension->id()); | 771 UntrackTerminatedExtension(extension->id()); |
| 781 | 772 |
| 782 // Notify interested parties that we've uninstalled this extension. | 773 // Notify interested parties that we've uninstalled this extension. |
| 783 ExtensionRegistry::Get(profile_) | 774 ExtensionRegistry::Get(profile_) |
| 784 ->TriggerOnUninstalled(extension.get(), reason); | 775 ->TriggerOnUninstalled(extension.get(), reason); |
| 785 | 776 |
| 786 if (sync_data.IsValid()) { | 777 // Don't sync the uninstall if we're going to reinstall the extension |
| 787 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(), | 778 // momentarily. |
| 788 sync_data); | 779 if (extension_sync_service_ && |
| 780 reason != extensions::UNINSTALL_REASON_REINSTALL) { |
| 781 extension_sync_service_->SyncUninstallExtension(*extension); |
| 789 } | 782 } |
| 790 | 783 |
| 791 delayed_installs_.Remove(extension->id()); | 784 delayed_installs_.Remove(extension->id()); |
| 792 | 785 |
| 793 extension_prefs_->OnExtensionUninstalled( | 786 extension_prefs_->OnExtensionUninstalled( |
| 794 extension->id(), extension->location(), external_uninstall); | 787 extension->id(), extension->location(), external_uninstall); |
| 795 | 788 |
| 796 // Track the uninstallation. | 789 // Track the uninstallation. |
| 797 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); | 790 UMA_HISTOGRAM_ENUMERATION("Extensions.ExtensionUninstalled", 1, 2); |
| 798 | 791 |
| (...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2585 } | 2578 } |
| 2586 | 2579 |
| 2587 void ExtensionService::OnProfileDestructionStarted() { | 2580 void ExtensionService::OnProfileDestructionStarted() { |
| 2588 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2581 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2589 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2582 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2590 it != ids_to_unload.end(); | 2583 it != ids_to_unload.end(); |
| 2591 ++it) { | 2584 ++it) { |
| 2592 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2585 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2593 } | 2586 } |
| 2594 } | 2587 } |
| OLD | NEW |