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_REINSTALL) || | 702 (reason == extensions::UNINSTALL_REASON_REINSTALL) || |
702 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || | 703 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || |
703 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || | 704 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || |
704 (reason == extensions::UNINSTALL_REASON_SYNC && | 705 (reason == extensions::UNINSTALL_REASON_SYNC && |
705 extension->was_installed_by_custodian()); | 706 extension->was_installed_by_custodian()); |
706 if (!external_uninstall && | 707 if (!external_uninstall && |
707 !system_->management_policy()->UserMayModifySettings( | 708 by_policy->MustRemainInstalled(extension.get(), error)) { |
708 extension.get(), error)) { | |
709 content::NotificationService::current()->Notify( | 709 content::NotificationService::current()->Notify( |
710 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, | 710 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
711 content::Source<Profile>(profile_), | 711 content::Source<Profile>(profile_), |
712 content::Details<const Extension>(extension.get())); | 712 content::Details<const Extension>(extension.get())); |
713 return false; | 713 return false; |
714 } | 714 } |
715 | 715 |
716 syncer::SyncChange sync_change; | 716 syncer::SyncChange sync_change; |
717 // Don't sync the uninstall if we're going to reinstall the extension | 717 // Don't sync the uninstall if we're going to reinstall the extension |
718 // momentarily. | 718 // momentarily. |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2354 } | 2354 } |
2355 | 2355 |
2356 void ExtensionService::OnProfileDestructionStarted() { | 2356 void ExtensionService::OnProfileDestructionStarted() { |
2357 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2357 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2358 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2358 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2359 it != ids_to_unload.end(); | 2359 it != ids_to_unload.end(); |
2360 ++it) { | 2360 ++it) { |
2361 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2361 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2362 } | 2362 } |
2363 } | 2363 } |
OLD | NEW |