Chromium Code Reviews| Index: chrome/browser/extensions/extension_management.cc |
| diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc |
| index 025b861603b93919440811713e01bdf8c0007e47..008dc68f7941a68eef99fdbfce2697be68b711af 100644 |
| --- a/chrome/browser/extensions/extension_management.cc |
| +++ b/chrome/browser/extensions/extension_management.cc |
| @@ -50,6 +50,8 @@ ExtensionManagement::ExtensionManagement(PrefService* pref_service) |
| pref_change_callback); |
| pref_change_registrar_.Add(pref_names::kInstallForceList, |
| pref_change_callback); |
| + pref_change_registrar_.Add(pref_names::kInstallLoginList, |
| + pref_change_callback); |
| pref_change_registrar_.Add(pref_names::kAllowedInstallSites, |
| pref_change_callback); |
| pref_change_registrar_.Add(pref_names::kAllowedTypes, pref_change_callback); |
| @@ -107,33 +109,27 @@ ExtensionManagement::InstallationMode ExtensionManagement::GetInstallationMode( |
| } |
| std::unique_ptr<base::DictionaryValue> |
| -ExtensionManagement::GetForceInstallList() const { |
| - 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); |
| +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 install_list; |
| + return extension_dict; |
| +} |
| + |
| +std::unique_ptr<base::DictionaryValue> |
| +ExtensionManagement::GetForceInstallList() const { |
| + return GetInstallListByMode(INSTALLATION_FORCED); |
| } |
| std::unique_ptr<base::DictionaryValue> |
| ExtensionManagement::GetRecommendedInstallList() const { |
| - 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; |
| + return GetInstallListByMode(INSTALLATION_RECOMMENDED); |
| } |
| bool ExtensionManagement::IsInstallationExplicitlyAllowed( |
| @@ -256,6 +252,9 @@ void ExtensionManagement::Refresh() { |
| const base::DictionaryValue* forced_list_pref = |
| static_cast<const base::DictionaryValue*>(LoadPreference( |
| pref_names::kInstallForceList, true, base::Value::TYPE_DICTIONARY)); |
| + const base::DictionaryValue* login_list_pref = |
| + static_cast<const base::DictionaryValue*>(LoadPreference( |
| + pref_names::kInstallLoginList, 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)); |
| @@ -316,22 +315,8 @@ void ExtensionManagement::Refresh() { |
| } |
| } |
| - 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; |
| - } |
| - } |
| - } |
| + UpdateForcedExtensions(forced_list_pref); |
| + UpdateForcedExtensions(login_list_pref); |
|
emaxx
2016/07/15 13:22:31
I think this line should be performed only if the
achuithb
2016/07/21 00:16:05
Done.
|
| if (install_sources_pref) { |
| global_settings_->has_restricted_install_sources = true; |
| @@ -439,6 +424,27 @@ void ExtensionManagement::NotifyExtensionManagementPrefChanged() { |
| Observer, observer_list_, 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; |