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

Unified Diff: chrome/browser/extensions/extension_management.cc

Issue 2509753006: Revert of Plumbing for login apps device policy to extensions. (Closed)
Patch Set: Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_management.cc
diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc
index 3e2fac38480a9da4a9bb6d03a11c951afc1a54cf..aff5c2cb2c75b9a6016709762e0dd03eb11ec2fe 100644
--- a/chrome/browser/extensions/extension_management.cc
+++ b/chrome/browser/extensions/extension_management.cc
@@ -51,8 +51,6 @@
pref_change_callback);
pref_change_registrar_.Add(pref_names::kInstallForceList,
pref_change_callback);
- pref_change_registrar_.Add(pref_names::kInstallSigninList,
- pref_change_callback);
pref_change_registrar_.Add(pref_names::kAllowedInstallSites,
pref_change_callback);
pref_change_registrar_.Add(pref_names::kAllowedTypes, pref_change_callback);
@@ -112,27 +110,33 @@
}
std::unique_ptr<base::DictionaryValue>
-ExtensionManagement::GetInstallListByMode(
- InstallationMode installation_mode) const {
- std::unique_ptr<base::DictionaryValue> extension_dict(
- new base::DictionaryValue);
- for (const SettingsIdMap::value_type& it : settings_by_id_) {
- if (it.second->installation_mode == installation_mode) {
- ExternalPolicyLoader::AddExtension(extension_dict.get(), it.first,
- it.second->update_url);
- }
- }
- return extension_dict;
-}
-
-std::unique_ptr<base::DictionaryValue>
ExtensionManagement::GetForceInstallList() const {
- return GetInstallListByMode(INSTALLATION_FORCED);
+ std::unique_ptr<base::DictionaryValue> install_list(
+ new base::DictionaryValue());
+ for (SettingsIdMap::const_iterator it = settings_by_id_.begin();
+ it != settings_by_id_.end();
+ ++it) {
+ if (it->second->installation_mode == INSTALLATION_FORCED) {
+ ExternalPolicyLoader::AddExtension(
+ install_list.get(), it->first, it->second->update_url);
+ }
+ }
+ return install_list;
}
std::unique_ptr<base::DictionaryValue>
ExtensionManagement::GetRecommendedInstallList() const {
- return GetInstallListByMode(INSTALLATION_RECOMMENDED);
+ std::unique_ptr<base::DictionaryValue> install_list(
+ new base::DictionaryValue());
+ for (SettingsIdMap::const_iterator it = settings_by_id_.begin();
+ it != settings_by_id_.end();
+ ++it) {
+ if (it->second->installation_mode == INSTALLATION_RECOMMENDED) {
+ ExternalPolicyLoader::AddExtension(
+ install_list.get(), it->first, it->second->update_url);
+ }
+ }
+ return install_list;
}
bool ExtensionManagement::IsInstallationExplicitlyAllowed(
@@ -255,9 +259,6 @@
const base::DictionaryValue* forced_list_pref =
static_cast<const base::DictionaryValue*>(LoadPreference(
pref_names::kInstallForceList, true, base::Value::TYPE_DICTIONARY));
- const base::DictionaryValue* signin_list_pref =
- static_cast<const base::DictionaryValue*>(LoadPreference(
- pref_names::kInstallSigninList, true, base::Value::TYPE_DICTIONARY));
const base::ListValue* install_sources_pref =
static_cast<const base::ListValue*>(LoadPreference(
pref_names::kAllowedInstallSites, true, base::Value::TYPE_LIST));
@@ -318,8 +319,22 @@
}
}
- UpdateForcedExtensions(forced_list_pref);
- UpdateForcedExtensions(signin_list_pref);
+ if (forced_list_pref) {
+ std::string update_url;
+ for (base::DictionaryValue::Iterator it(*forced_list_pref); !it.IsAtEnd();
+ it.Advance()) {
+ if (!crx_file::id_util::IdIsValid(it.key()))
+ continue;
+ const base::DictionaryValue* dict_value = NULL;
+ if (it.value().GetAsDictionary(&dict_value) &&
+ dict_value->GetStringWithoutPathExpansion(
+ ExternalProviderImpl::kExternalUpdateUrl, &update_url)) {
+ internal::IndividualSettings* by_id = AccessById(it.key());
+ by_id->installation_mode = INSTALLATION_FORCED;
+ by_id->update_url = update_url;
+ }
+ }
+ }
if (install_sources_pref) {
global_settings_->has_restricted_install_sources = true;
@@ -427,27 +442,6 @@
observer.OnExtensionManagementSettingsChanged();
}
-void ExtensionManagement::UpdateForcedExtensions(
- const base::DictionaryValue* extension_dict) {
- if (!extension_dict)
- return;
-
- std::string update_url;
- for (base::DictionaryValue::Iterator it(*extension_dict); !it.IsAtEnd();
- it.Advance()) {
- if (!crx_file::id_util::IdIsValid(it.key()))
- continue;
- const base::DictionaryValue* dict_value = nullptr;
- if (it.value().GetAsDictionary(&dict_value) &&
- dict_value->GetStringWithoutPathExpansion(
- ExternalProviderImpl::kExternalUpdateUrl, &update_url)) {
- internal::IndividualSettings* by_id = AccessById(it.key());
- by_id->installation_mode = INSTALLATION_FORCED;
- by_id->update_url = update_url;
- }
- }
-}
-
internal::IndividualSettings* ExtensionManagement::AccessById(
const ExtensionId& id) {
DCHECK(crx_file::id_util::IdIsValid(id)) << "Invalid ID: " << id;
« no previous file with comments | « chrome/browser/extensions/extension_management.h ('k') | chrome/browser/extensions/extension_system_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698