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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 extension_prefs_->IsExtensionBlacklisted(extension_id)) | 864 extension_prefs_->IsExtensionBlacklisted(extension_id)) |
| 865 return; | 865 return; |
| 866 const Extension* extension = | 866 const Extension* extension = |
| 867 registry_->disabled_extensions().GetByID(extension_id); | 867 registry_->disabled_extensions().GetByID(extension_id); |
| 868 | 868 |
| 869 ManagementPolicy* policy = system_->management_policy(); | 869 ManagementPolicy* policy = system_->management_policy(); |
| 870 if (extension && policy->MustRemainDisabled(extension, nullptr, nullptr)) { | 870 if (extension && policy->MustRemainDisabled(extension, nullptr, nullptr)) { |
| 871 UMA_HISTOGRAM_COUNTS_100("Extensions.EnableDeniedByPolicy", 1); | 871 UMA_HISTOGRAM_COUNTS_100("Extensions.EnableDeniedByPolicy", 1); |
| 872 return; | 872 return; |
| 873 } | 873 } |
| 874 | |
|
Devlin
2017/02/14 23:17:09
nit: remove extraneous change
nrpeter
2017/03/22 23:47:38
Done.
| |
| 875 extension_prefs_->SetExtensionEnabled(extension_id); | 874 extension_prefs_->SetExtensionEnabled(extension_id); |
| 876 | 875 |
| 877 // This can happen if sync enables an extension that is not installed yet. | 876 // This can happen if sync enables an extension that is not installed yet. |
| 878 if (!extension) | 877 if (!extension) |
| 879 return; | 878 return; |
| 880 | 879 |
| 881 // Move it over to the enabled list. | 880 // Move it over to the enabled list. |
| 882 registry_->AddEnabled(make_scoped_refptr(extension)); | 881 registry_->AddEnabled(make_scoped_refptr(extension)); |
| 883 registry_->RemoveDisabled(extension->id()); | 882 registry_->RemoveDisabled(extension->id()); |
| 884 | 883 |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 if (!system_->management_policy()->UserMayLoad(extension.get(), nullptr)) | 1204 if (!system_->management_policy()->UserMayLoad(extension.get(), nullptr)) |
| 1206 to_unload.push_back(extension->id()); | 1205 to_unload.push_back(extension->id()); |
| 1207 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; | 1206 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; |
| 1208 if (system_->management_policy()->MustRemainDisabled( | 1207 if (system_->management_policy()->MustRemainDisabled( |
| 1209 extension.get(), &disable_reason, nullptr)) | 1208 extension.get(), &disable_reason, nullptr)) |
| 1210 to_disable[extension->id()] = disable_reason; | 1209 to_disable[extension->id()] = disable_reason; |
| 1211 } | 1210 } |
| 1212 | 1211 |
| 1213 extensions::ExtensionManagement* management = | 1212 extensions::ExtensionManagement* management = |
| 1214 extensions::ExtensionManagementFactory::GetForBrowserContext(profile()); | 1213 extensions::ExtensionManagementFactory::GetForBrowserContext(profile()); |
| 1214 for (const auto& extension : registry_->enabled_extensions()) { | |
| 1215 extensions::PermissionsUpdater(profile()).SetPolicyHostRestrictions( | |
| 1216 extension.get(), management->GetRuntimeBlockedHosts(extension.get()), | |
| 1217 management->GetRuntimeAllowedHosts(extension.get()), | |
| 1218 management->UsesDefaultRuntimeHostRestrictions(extension.get())); | |
| 1219 } | |
| 1220 extensions::PermissionsUpdater(profile()).SetDefaultPolicyHostRestrictions( | |
| 1221 management->GetDefaultRuntimeBlockedHosts(), | |
| 1222 management->GetDefaultRuntimeAllowedHosts()); | |
| 1215 | 1223 |
| 1216 // Loop through the disabled extension list, find extensions to re-enable | 1224 // Loop through the disabled extension list, find extensions to re-enable |
| 1217 // automatically. These extensions are exclusive from the |to_disable| and | 1225 // automatically. These extensions are exclusive from the |to_disable| and |
| 1218 // |to_unload| lists constructed above, since disabled_extensions() and | 1226 // |to_unload| lists constructed above, since disabled_extensions() and |
| 1219 // enabled_extensions() are supposed to be mutually exclusive. | 1227 // enabled_extensions() are supposed to be mutually exclusive. |
| 1220 for (const auto& extension : registry_->disabled_extensions()) { | 1228 for (const auto& extension : registry_->disabled_extensions()) { |
| 1221 // Find all disabled extensions disabled due to minimum version requirement, | 1229 // Find all disabled extensions disabled due to minimum version requirement, |
| 1222 // but now satisfying it. | 1230 // but now satisfying it. |
| 1223 if (management->CheckMinimumVersion(extension.get(), nullptr) && | 1231 if (management->CheckMinimumVersion(extension.get(), nullptr) && |
| 1224 extension_prefs_->HasDisableReason( | 1232 extension_prefs_->HasDisableReason( |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1453 void ExtensionService::AddExtension(const Extension* extension) { | 1461 void ExtensionService::AddExtension(const Extension* extension) { |
| 1454 // TODO(jstritar): We may be able to get rid of this branch by overriding the | 1462 // TODO(jstritar): We may be able to get rid of this branch by overriding the |
| 1455 // default extension state to DISABLED when the --disable-extensions flag | 1463 // default extension state to DISABLED when the --disable-extensions flag |
| 1456 // is set (http://crbug.com/29067). | 1464 // is set (http://crbug.com/29067). |
| 1457 if (!extensions_enabled() && !extension->is_theme() && | 1465 if (!extensions_enabled() && !extension->is_theme() && |
| 1458 extension->location() != Manifest::COMPONENT && | 1466 extension->location() != Manifest::COMPONENT && |
| 1459 !Manifest::IsExternalLocation(extension->location()) && | 1467 !Manifest::IsExternalLocation(extension->location()) && |
| 1460 disable_flag_exempted_extensions_.count(extension->id()) == 0) { | 1468 disable_flag_exempted_extensions_.count(extension->id()) == 0) { |
| 1461 return; | 1469 return; |
| 1462 } | 1470 } |
| 1463 | |
|
Devlin
2017/02/14 23:17:09
remove extraneous change
nrpeter
2017/03/22 23:47:38
Done.
| |
| 1464 bool is_extension_upgrade = false; | 1471 bool is_extension_upgrade = false; |
| 1465 bool is_extension_loaded = false; | 1472 bool is_extension_loaded = false; |
| 1466 const Extension* old = GetInstalledExtension(extension->id()); | 1473 const Extension* old = GetInstalledExtension(extension->id()); |
| 1467 if (old) { | 1474 if (old) { |
| 1468 is_extension_loaded = true; | 1475 is_extension_loaded = true; |
| 1469 int version_compare_result = | 1476 int version_compare_result = |
| 1470 extension->version()->CompareTo(*(old->version())); | 1477 extension->version()->CompareTo(*(old->version())); |
| 1471 is_extension_upgrade = version_compare_result > 0; | 1478 is_extension_upgrade = version_compare_result > 0; |
| 1472 // Other than for unpacked extensions, CrxInstaller should have guaranteed | 1479 // Other than for unpacked extensions, CrxInstaller should have guaranteed |
| 1473 // that we aren't downgrading. | 1480 // that we aren't downgrading. |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2477 } | 2484 } |
| 2478 | 2485 |
| 2479 void ExtensionService::OnProfileDestructionStarted() { | 2486 void ExtensionService::OnProfileDestructionStarted() { |
| 2480 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2487 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2481 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2488 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2482 it != ids_to_unload.end(); | 2489 it != ids_to_unload.end(); |
| 2483 ++it) { | 2490 ++it) { |
| 2484 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2491 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2485 } | 2492 } |
| 2486 } | 2493 } |
| OLD | NEW |