Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 557953005: Allow the user to "repair" a corrupted extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest Master Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // |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
693 // managed extensions. 693 // managed extensions.
694 // Shared modules being uninstalled will also set |external_uninstall| to true 694 // Shared modules being uninstalled will also set |external_uninstall| to true
695 // 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.
696 // (crbug.com/273300) 696 // (crbug.com/273300)
697 // 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
698 // 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
699 // we don't do this. 699 // we don't do this.
700 bool external_uninstall = 700 bool external_uninstall =
701 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || 701 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) ||
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 !system_->management_policy()->UserMayModifySettings(
708 extension.get(), error)) { 709 extension.get(), error)) {
709 content::NotificationService::current()->Notify( 710 content::NotificationService::current()->Notify(
710 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, 711 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED,
711 content::Source<Profile>(profile_), 712 content::Source<Profile>(profile_),
712 content::Details<const Extension>(extension.get())); 713 content::Details<const Extension>(extension.get()));
713 return false; 714 return false;
714 } 715 }
715 716
716 syncer::SyncChange sync_change; 717 syncer::SyncChange sync_change;
717 if (extension_sync_service_) { 718 // Don't sync the uninstall if we're going to reinstall the extension
719 // momentarily.
720 if (extension_sync_service_ &&
721 reason != extensions::UNINSTALL_REASON_REINSTALL) {
718 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension( 722 sync_change = extension_sync_service_->PrepareToSyncUninstallExtension(
719 extension.get(), is_ready()); 723 extension.get(), is_ready());
720 } 724 }
721 725
722 system_->install_verifier()->Remove(extension->id()); 726 system_->install_verifier()->Remove(extension->id());
723 727
724 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType", 728 UMA_HISTOGRAM_ENUMERATION("Extensions.UninstallType",
725 extension->GetType(), 100); 729 extension->GetType(), 100);
726 RecordPermissionMessagesHistogram(extension.get(), 730 RecordPermissionMessagesHistogram(extension.get(),
727 "Extensions.Permissions_Uninstall2"); 731 "Extensions.Permissions_Uninstall2");
(...skipping 20 matching lines...) Expand all
748 UntrackTerminatedExtension(extension->id()); 752 UntrackTerminatedExtension(extension->id());
749 753
750 // Notify interested parties that we've uninstalled this extension. 754 // Notify interested parties that we've uninstalled this extension.
751 content::NotificationService::current()->Notify( 755 content::NotificationService::current()->Notify(
752 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 756 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
753 content::Source<Profile>(profile_), 757 content::Source<Profile>(profile_),
754 content::Details<const Extension>(extension.get())); 758 content::Details<const Extension>(extension.get()));
755 ExtensionRegistry::Get(profile_) 759 ExtensionRegistry::Get(profile_)
756 ->TriggerOnUninstalled(extension.get(), reason); 760 ->TriggerOnUninstalled(extension.get(), reason);
757 761
758 if (extension_sync_service_) { 762 if (sync_change.IsValid()) {
759 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(), 763 extension_sync_service_->ProcessSyncUninstallExtension(extension->id(),
760 sync_change); 764 sync_change);
761 } 765 }
762 766
763 delayed_installs_.Remove(extension->id()); 767 delayed_installs_.Remove(extension->id());
764 768
765 extension_prefs_->OnExtensionUninstalled( 769 extension_prefs_->OnExtensionUninstalled(
766 extension->id(), extension->location(), external_uninstall); 770 extension->id(), extension->location(), external_uninstall);
767 771
768 // Track the uninstallation. 772 // Track the uninstallation.
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2351 } 2355 }
2352 2356
2353 void ExtensionService::OnProfileDestructionStarted() { 2357 void ExtensionService::OnProfileDestructionStarted() {
2354 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2358 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2355 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2359 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2356 it != ids_to_unload.end(); 2360 it != ids_to_unload.end();
2357 ++it) { 2361 ++it) {
2358 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2362 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2359 } 2363 }
2360 } 2364 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.cc ('k') | chrome/browser/extensions/webstore_installer_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698