Chromium Code Reviews| 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 installer->set_expected_hash(file.expected_hash); | 532 installer->set_expected_hash(file.expected_hash); |
| 533 int creation_flags = Extension::NO_FLAGS; | 533 int creation_flags = Extension::NO_FLAGS; |
| 534 if (pending_extension_info) { | 534 if (pending_extension_info) { |
| 535 installer->set_install_source(pending_extension_info->install_source()); | 535 installer->set_install_source(pending_extension_info->install_source()); |
| 536 installer->set_allow_silent_install(true); | 536 installer->set_allow_silent_install(true); |
| 537 if (pending_extension_info->remote_install()) | 537 if (pending_extension_info->remote_install()) |
| 538 installer->set_grant_permissions(false); | 538 installer->set_grant_permissions(false); |
| 539 creation_flags = pending_extension_info->creation_flags(); | 539 creation_flags = pending_extension_info->creation_flags(); |
| 540 if (pending_extension_info->mark_acknowledged()) | 540 if (pending_extension_info->mark_acknowledged()) |
| 541 external_install_manager_->AcknowledgeExternalExtension(id); | 541 external_install_manager_->AcknowledgeExternalExtension(id); |
| 542 | |
| 543 // If the extension came in disabled due to a permission increase, then | |
|
not at google - send to devlin
2015/05/12 18:04:17
Is it reasonable to defer this change until after
Marc Treib
2015/05/19 12:12:03
Yup, that makes sense. Reverted this change.
| |
| 544 // don't grant it all the permissions! crbug.com/484214 | |
| 545 if (extensions::ExtensionPrefs::Get(profile_)->HasDisableReason( | |
| 546 id, Extension::DISABLE_PERMISSIONS_INCREASE)) { | |
| 547 installer->set_grant_permissions(false); | |
| 548 } | |
| 542 } else if (extension) { | 549 } else if (extension) { |
| 543 installer->set_install_source(extension->location()); | 550 installer->set_install_source(extension->location()); |
| 544 } | 551 } |
| 545 // If the extension was installed from or has migrated to the webstore, or | 552 // If the extension was installed from or has migrated to the webstore, or |
| 546 // its auto-update URL is from the webstore, treat it as a webstore install. | 553 // its auto-update URL is from the webstore, treat it as a webstore install. |
| 547 // Note that we ignore some older extensions with blank auto-update URLs | 554 // Note that we ignore some older extensions with blank auto-update URLs |
| 548 // because we are mostly concerned with restrictions on NaCl extensions, | 555 // because we are mostly concerned with restrictions on NaCl extensions, |
| 549 // which are newer. | 556 // which are newer. |
| 550 if ((extension && extension->from_webstore()) || | 557 if ((extension && extension->from_webstore()) || |
| 551 (extension && extensions::ManifestURL::UpdatesFromGallery(extension)) || | 558 (extension && extensions::ManifestURL::UpdatesFromGallery(extension)) || |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 862 extensions::NOTIFICATION_EXTENSION_ENABLED, | 869 extensions::NOTIFICATION_EXTENSION_ENABLED, |
| 863 content::Source<Profile>(profile_), | 870 content::Source<Profile>(profile_), |
| 864 content::Details<const Extension>(extension)); | 871 content::Details<const Extension>(extension)); |
| 865 | 872 |
| 866 if (extension_sync_service_) | 873 if (extension_sync_service_) |
| 867 extension_sync_service_->SyncEnableExtension(*extension); | 874 extension_sync_service_->SyncEnableExtension(*extension); |
| 868 } | 875 } |
| 869 | 876 |
| 870 void ExtensionService::DisableExtension( | 877 void ExtensionService::DisableExtension( |
| 871 const std::string& extension_id, | 878 const std::string& extension_id, |
| 872 Extension::DisableReason disable_reason) { | 879 Extension::DisableReason disable_reasons) { |
| 873 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 880 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 874 | 881 |
| 875 // The extension may have been disabled already. Just add a disable reason. | 882 // The extension may have been disabled already. Just add a disable reason. |
| 876 if (!IsExtensionEnabled(extension_id)) { | 883 if (!IsExtensionEnabled(extension_id)) { |
| 877 extension_prefs_->AddDisableReason(extension_id, disable_reason); | 884 extension_prefs_->AddDisableReason(extension_id, disable_reasons); |
|
not at google - send to devlin
2015/05/12 18:04:17
If AddDisableReason() does support multiple reason
Marc Treib
2015/05/19 12:12:03
I've added ExtensionPrefs::AddDisableReasons(int).
| |
| 878 return; | 885 return; |
| 879 } | 886 } |
| 880 | 887 |
| 881 const Extension* extension = GetInstalledExtension(extension_id); | 888 const Extension* extension = GetInstalledExtension(extension_id); |
| 882 // |extension| can be NULL if sync disables an extension that is not | 889 // |extension| can be NULL if sync disables an extension that is not |
| 883 // installed yet. | 890 // installed yet. |
| 884 // EXTERNAL_COMPONENT extensions are not generally modifiable by users, but | 891 // EXTERNAL_COMPONENT extensions are not generally modifiable by users, but |
| 885 // can be uninstalled by the browser if the user sets extension-specific | 892 // can be uninstalled by the browser if the user sets extension-specific |
| 886 // preferences. | 893 // preferences. |
| 887 if (extension && | 894 if (extension && |
| 888 disable_reason != Extension::DISABLE_RELOAD && | 895 !(disable_reasons & Extension::DISABLE_RELOAD) && |
| 889 disable_reason != Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY && | 896 !(disable_reasons & Extension::DISABLE_UPDATE_REQUIRED_BY_POLICY) && |
| 890 !system_->management_policy()->UserMayModifySettings(extension, NULL) && | 897 !system_->management_policy()->UserMayModifySettings(extension, NULL) && |
| 891 extension->location() != Manifest::EXTERNAL_COMPONENT) { | 898 extension->location() != Manifest::EXTERNAL_COMPONENT) { |
| 892 return; | 899 return; |
| 893 } | 900 } |
| 894 | 901 |
| 895 extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED); | 902 extension_prefs_->SetExtensionState(extension_id, Extension::DISABLED); |
| 896 extension_prefs_->AddDisableReason(extension_id, disable_reason); | 903 extension_prefs_->AddDisableReason(extension_id, disable_reasons); |
| 897 | 904 |
| 898 int include_mask = | 905 int include_mask = |
| 899 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::DISABLED; | 906 ExtensionRegistry::EVERYTHING & ~ExtensionRegistry::DISABLED; |
| 900 extension = registry_->GetExtensionById(extension_id, include_mask); | 907 extension = registry_->GetExtensionById(extension_id, include_mask); |
| 901 if (!extension) | 908 if (!extension) |
| 902 return; | 909 return; |
| 903 | 910 |
| 904 // The extension is either enabled or terminated. | 911 // The extension is either enabled or terminated. |
| 905 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || | 912 DCHECK(registry_->enabled_extensions().Contains(extension->id()) || |
| 906 registry_->terminated_extensions().Contains(extension->id())); | 913 registry_->terminated_extensions().Contains(extension->id())); |
| (...skipping 1691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2598 } | 2605 } |
| 2599 | 2606 |
| 2600 void ExtensionService::OnProfileDestructionStarted() { | 2607 void ExtensionService::OnProfileDestructionStarted() { |
| 2601 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2608 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2602 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2609 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2603 it != ids_to_unload.end(); | 2610 it != ids_to_unload.end(); |
| 2604 ++it) { | 2611 ++it) { |
| 2605 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2612 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2606 } | 2613 } |
| 2607 } | 2614 } |
| OLD | NEW |