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

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 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 // |external_uninstall| to true so this is the only way to uninstall 688 // |external_uninstall| to true so this is the only way to uninstall
689 // managed extensions. 689 // managed extensions.
690 // Shared modules being uninstalled will also set |external_uninstall| to true 690 // Shared modules being uninstalled will also set |external_uninstall| to true
691 // so that we can guarantee users don't uninstall a shared module. 691 // so that we can guarantee users don't uninstall a shared module.
692 // (crbug.com/273300) 692 // (crbug.com/273300)
693 // TODO(rdevlin.cronin): This is probably not right. We should do something 693 // TODO(rdevlin.cronin): This is probably not right. We should do something
694 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so 694 // else, like include an enum IS_INTERNAL_UNINSTALL or IS_USER_UNINSTALL so
695 // we don't do this. 695 // we don't do this.
696 bool external_uninstall = 696 bool external_uninstall =
697 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) || 697 (reason == extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT) ||
698 (reason == extensions::UNINSTALL_REASON_COMPONENT) ||
698 (reason == extensions::UNINSTALL_REASON_REINSTALL) || 699 (reason == extensions::UNINSTALL_REASON_REINSTALL) ||
699 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) || 700 (reason == extensions::UNINSTALL_REASON_ORPHANED_EXTERNAL_EXTENSION) ||
700 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) || 701 (reason == extensions::UNINSTALL_REASON_ORPHANED_SHARED_MODULE) ||
701 (reason == extensions::UNINSTALL_REASON_SYNC && 702 (reason == extensions::UNINSTALL_REASON_SYNC &&
702 extension->was_installed_by_custodian()); 703 extension->was_installed_by_custodian());
703 if (!external_uninstall && 704 if (!external_uninstall &&
704 (!by_policy->UserMayModifySettings(extension.get(), error) || 705 (!by_policy->UserMayModifySettings(extension.get(), error) ||
705 by_policy->MustRemainInstalled(extension.get(), error))) { 706 by_policy->MustRemainInstalled(extension.get(), error))) {
706 content::NotificationService::current()->Notify( 707 content::NotificationService::current()->Notify(
707 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, 708 extensions::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED,
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 const std::string& extension_id) { 1388 const std::string& extension_id) {
1388 scoped_refptr<const Extension> extension( 1389 scoped_refptr<const Extension> extension(
1389 GetExtensionById(extension_id, false)); 1390 GetExtensionById(extension_id, false));
1390 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL); 1391 UnloadExtension(extension_id, UnloadedExtensionInfo::REASON_UNINSTALL);
1391 if (extension.get()) { 1392 if (extension.get()) {
1392 content::NotificationService::current()->Notify( 1393 content::NotificationService::current()->Notify(
1393 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, 1394 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED,
1394 content::Source<Profile>(profile_), 1395 content::Source<Profile>(profile_),
1395 content::Details<const Extension>(extension.get())); 1396 content::Details<const Extension>(extension.get()));
1396 ExtensionRegistry::Get(profile_)->TriggerOnUninstalled( 1397 ExtensionRegistry::Get(profile_)->TriggerOnUninstalled(
1397 extension.get(), extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT); 1398 extension.get(), extensions::UNINSTALL_REASON_COMPONENT);
1398 } 1399 }
1399 } 1400 }
1400 1401
1401 void ExtensionService::UnloadAllExtensionsForTest() { 1402 void ExtensionService::UnloadAllExtensionsForTest() {
1402 UnloadAllExtensionsInternal(); 1403 UnloadAllExtensionsInternal();
1403 } 1404 }
1404 1405
1405 void ExtensionService::ReloadExtensionsForTest() { 1406 void ExtensionService::ReloadExtensionsForTest() {
1406 // Calling UnloadAllExtensionsForTest here triggers a false-positive presubmit 1407 // Calling UnloadAllExtensionsForTest here triggers a false-positive presubmit
1407 // warning about calling test code in production. 1408 // warning about calling test code in production.
(...skipping 1139 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