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

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

Issue 904943003: Fixes component extension commands assignment on reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 // |external_uninstall| to true so this is the only way to uninstall 689 // |external_uninstall| to true so this is the only way to uninstall
690 // managed extensions. 690 // managed extensions.
691 // Shared modules being uninstalled will also set |external_uninstall| to true 691 // Shared modules being uninstalled will also set |external_uninstall| to true
692 // so that we can guarantee users don't uninstall a shared module. 692 // so that we can guarantee users don't uninstall a shared module.
693 // (crbug.com/273300) 693 // (crbug.com/273300)
694 // TODO(rdevlin.cronin): This is probably not right. We should do something 694 // TODO(rdevlin.cronin): This is probably not right. We should do something
695 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so 695 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so
696 // we don't do this. 696 // we don't do this.
697 bool external_uninstall = 697 bool external_uninstall =
698 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || 698 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) ||
699 (reason == extensions::UNINSTALL_REASON_COMPONENT_REMOVED) ||
699 (reason == extensions::UNINSTALL_REASON_REINSTALL) || 700 (reason == extensions::UNINSTALL_REASON_REINSTALL) ||
700 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || 701 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) ||
701 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || 702 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) ||
702 (reason == extensions::UNINSTALL_REASON_SYNC && 703 (reason == extensions::UNINSTALL_REASON_SYNC &&
703 extension->was_installed_by_custodian()); 704 extension->was_installed_by_custodian());
704 if (!external_uninstall && 705 if (!external_uninstall &&
705 (!by_policy->UserMayModifySettings(extension.get(), error) || 706 (!by_policy->UserMayModifySettings(extension.get(), error) ||
706 by_policy->MustRemainInstalled(extension.get(), error))) { 707 by_policy->MustRemainInstalled(extension.get(), error))) {
707 content::NotificationService::current()->Notify( 708 content::NotificationService::current()->Notify(
708 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, 709 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED,
709 content::Source<Profile>(profile_), 710 content::Source<Profile>(profile_),
710 content::Details<const Extension>(extension.get())); 711 content::Details<const Extension>(extension.get()));
711 return false; 712 return false;
712 } 713 }
713 714
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 const std::string& extension_id) { 1389 const std::string& extension_id) {
1389 scoped_refptr<const Extension> extension( 1390 scoped_refptr<const Extension> extension(
1390 GetExtensionById(extension_id, false)); 1391 GetExtensionById(extension_id, false));
1391 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL); 1392 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL);
1392 if (extension.get()) { 1393 if (extension.get()) {
1393 content::NotificationService::current()->Notify( 1394 content::NotificationService::current()->Notify(
1394 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 1395 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
1395 content::Source<Profile>(profile_), 1396 content::Source<Profile>(profile_),
1396 content::Details<const Extension>(extension.get())); 1397 content::Details<const Extension>(extension.get()));
1397 ExtensionRegistry::Get(profile_)->TriggerOnUninstalled( 1398 ExtensionRegistry::Get(profile_)->TriggerOnUninstalled(
1398 extension.get(), extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT); 1399 extension.get(), extensions::UNINSTALL_REASON_COMPONENT_REMOVED);
1399 } 1400 }
1400 } 1401 }
1401 1402
1402 void ExtensionService::UnloadAllExtensionsForTest() { 1403 void ExtensionService::UnloadAllExtensionsForTest() {
1403 UnloadAllExtensionsInternal(); 1404 UnloadAllExtensionsInternal();
1404 } 1405 }
1405 1406
1406 void ExtensionService::ReloadExtensionsForTest() { 1407 void ExtensionService::ReloadExtensionsForTest() {
1407 // Calling UnloadAllExtensionsForTest here triggers a false-positive presubmit 1408 // Calling UnloadAllExtensionsForTest here triggers a false-positive presubmit
1408 // warning about calling test code in production. 1409 // warning about calling test code in production.
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2547 } 2548 }
2548 2549
2549 void ExtensionService::OnProfileDestructionStarted() { 2550 void ExtensionService::OnProfileDestructionStarted() {
2550 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2551 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2551 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2552 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2552 it != ids_to_unload.end(); 2553 it != ids_to_unload.end();
2553 ++it) { 2554 ++it) {
2554 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2555 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2555 } 2556 }
2556 } 2557 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698