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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 const base::Closure& deletion_done_callback, | 673 const base::Closure& deletion_done_callback, |
674 base::string16* error) { | 674 base::string16* error) { |
675 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 675 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
676 | 676 |
677 scoped_refptr<const Extension> extension = | 677 scoped_refptr<const Extension> extension = |
678 GetInstalledExtension(transient_extension_id); | 678 GetInstalledExtension(transient_extension_id); |
679 | 679 |
680 // Callers should not send us nonexistent extensions. | 680 // Callers should not send us nonexistent extensions. |
681 CHECK(extension.get()); | 681 CHECK(extension.get()); |
682 | 682 |
| 683 ManagementPolicy* by_policy = system_->management_policy(); |
683 // Policy change which triggers an uninstall will always set | 684 // Policy change which triggers an uninstall will always set |
684 // |external_uninstall| to true so this is the only way to uninstall | 685 // |external_uninstall| to true so this is the only way to uninstall |
685 // managed extensions. | 686 // managed extensions. |
686 // Shared modules being uninstalled will also set |external_uninstall| to true | 687 // Shared modules being uninstalled will also set |external_uninstall| to true |
687 // so that we can guarantee users don't uninstall a shared module. | 688 // so that we can guarantee users don't uninstall a shared module. |
688 // (crbug.com/273300) | 689 // (crbug.com/273300) |
689 // TODO(rdevlin.cronin): This is probably not right. We should do something | 690 // TODO(rdevlin.cronin): This is probably not right. We should do something |
690 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so | 691 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so |
691 // we don't do this. | 692 // we don't do this. |
692 bool external_uninstall = | 693 bool external_uninstall = |
693 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || | 694 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || |
694 (reason == extensions::UNINSTALL_REASON_REINSTALL) || | 695 (reason == extensions::UNINSTALL_REASON_REINSTALL) || |
695 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || | 696 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || |
696 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || | 697 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || |
697 (reason == extensions::UNINSTALL_REASON_SYNC && | 698 (reason == extensions::UNINSTALL_REASON_SYNC && |
698 extension->was_installed_by_custodian()); | 699 extension->was_installed_by_custodian()); |
699 if (!external_uninstall && | 700 if (!external_uninstall && |
700 !system_->management_policy()->UserMayModifySettings( | 701 (!by_policy->UserMayModifySettings(extension.get(), error) || |
701 extension.get(), error)) { | 702 by_policy->MustRemainInstalled(extension.get(), error))) { |
702 content::NotificationService::current()->Notify( | 703 content::NotificationService::current()->Notify( |
703 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, | 704 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
704 content::Source<Profile>(profile_), | 705 content::Source<Profile>(profile_), |
705 content::Details<const Extension>(extension.get())); | 706 content::Details<const Extension>(extension.get())); |
706 return false; | 707 return false; |
707 } | 708 } |
708 | 709 |
709 syncer::SyncChange sync_change; | 710 syncer::SyncChange sync_change; |
710 // Don't sync the uninstall if we're going to reinstall the extension | 711 // Don't sync the uninstall if we're going to reinstall the extension |
711 // momentarily. | 712 // momentarily. |
(...skipping 1655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2367 } | 2368 } |
2368 | 2369 |
2369 void ExtensionService::OnProfileDestructionStarted() { | 2370 void ExtensionService::OnProfileDestructionStarted() { |
2370 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2371 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2371 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2372 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2372 it != ids_to_unload.end(); | 2373 it != ids_to_unload.end(); |
2373 ++it) { | 2374 ++it) { |
2374 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2375 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2375 } | 2376 } |
2376 } | 2377 } |
OLD | NEW |