| 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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 const base::Closure& deletion_done_callback, | 680 const base::Closure& deletion_done_callback, |
| 681 base::string16* error) { | 681 base::string16* error) { |
| 682 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 682 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 683 | 683 |
| 684 scoped_refptr<const Extension> extension = | 684 scoped_refptr<const Extension> extension = |
| 685 GetInstalledExtension(transient_extension_id); | 685 GetInstalledExtension(transient_extension_id); |
| 686 | 686 |
| 687 // Callers should not send us nonexistent extensions. | 687 // Callers should not send us nonexistent extensions. |
| 688 CHECK(extension.get()); | 688 CHECK(extension.get()); |
| 689 | 689 |
| 690 ManagementPolicy* by_policy = system_->management_policy(); |
| 690 // Policy change which triggers an uninstall will always set | 691 // Policy change which triggers an uninstall will always set |
| 691 // |external_uninstall| to true so this is the only way to uninstall | 692 // |external_uninstall| to true so this is the only way to uninstall |
| 692 // managed extensions. | 693 // managed extensions. |
| 693 // Shared modules being uninstalled will also set |external_uninstall| to true | 694 // Shared modules being uninstalled will also set |external_uninstall| to true |
| 694 // so that we can guarantee users don't uninstall a shared module. | 695 // so that we can guarantee users don't uninstall a shared module. |
| 695 // (crbug.com/273300) | 696 // (crbug.com/273300) |
| 696 // TODO(rdevlin.cronin): This is probably not right. We should do something | 697 // TODO(rdevlin.cronin): This is probably not right. We should do something |
| 697 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so | 698 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so |
| 698 // we don't do this. | 699 // we don't do this. |
| 699 bool external_uninstall = | 700 bool external_uninstall = |
| 700 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || | 701 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || |
| 701 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || | 702 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || |
| 702 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || | 703 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || |
| 703 (reason == extensions::UNINSTALL_REASON_SYNC && | 704 (reason == extensions::UNINSTALL_REASON_SYNC && |
| 704 extension->was_installed_by_custodian()); | 705 extension->was_installed_by_custodian()); |
| 705 if (!external_uninstall && | 706 if (!external_uninstall && |
| 706 !system_->management_policy()->UserMayModifySettings( | 707 (!by_policy->UserMayModifySettings(extension.get(), error) || |
| 707 extension.get(), error)) { | 708 by_policy->MustRemainInstalled(extension.get(), error))) { |
| 708 content::NotificationService::current()->Notify( | 709 content::NotificationService::current()->Notify( |
| 709 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, | 710 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
| 710 content::Source<Profile>(profile_), | 711 content::Source<Profile>(profile_), |
| 711 content::Details<const Extension>(extension.get())); | 712 content::Details<const Extension>(extension.get())); |
| 712 return false; | 713 return false; |
| 713 } | 714 } |
| 714 | 715 |
| 715 syncer::SyncChange sync_change; | 716 syncer::SyncChange sync_change; |
| 716 if (extension_sync_service_) { | 717 if (extension_sync_service_) { |
| 717 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension( | 718 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension( |
| (...skipping 1632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2350 } | 2351 } |
| 2351 | 2352 |
| 2352 void ExtensionService::OnProfileDestructionStarted() { | 2353 void ExtensionService::OnProfileDestructionStarted() { |
| 2353 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2354 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2354 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2355 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2355 it != ids_to_unload.end(); | 2356 it != ids_to_unload.end(); |
| 2356 ++it) { | 2357 ++it) { |
| 2357 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2358 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2358 } | 2359 } |
| 2359 } | 2360 } |
| OLD | NEW |