Index: chrome/browser/extensions/extension_management.cc |
diff --git a/chrome/browser/extensions/extension_management.cc b/chrome/browser/extensions/extension_management.cc |
index 1e8904b00fe0916a33dc1cc589e455a6678c71cc..91577b9349641f4a47424ba3dcc4782ac94f5193 100644 |
--- a/chrome/browser/extensions/extension_management.cc |
+++ b/chrome/browser/extensions/extension_management.cc |
@@ -36,13 +36,16 @@ |
#include "extensions/common/url_pattern.h" |
#include "url/gurl.h" |
+#if defined(OS_CHROMEOS) |
+#include "chrome/browser/chromeos/profiles/profile_helper.h" |
+#endif |
+ |
namespace extensions { |
-ExtensionManagement::ExtensionManagement(PrefService* pref_service) |
- : pref_service_(pref_service) { |
+ExtensionManagement::ExtensionManagement(Profile* profile) : profile_(profile) { |
TRACE_EVENT0("browser,startup", |
"ExtensionManagement::ExtensionManagement::ctor"); |
- pref_change_registrar_.Init(pref_service_); |
+ pref_change_registrar_.Init(profile_->GetPrefs()); |
base::Closure pref_change_callback = base::Bind( |
&ExtensionManagement::OnExtensionPrefChanged, base::Unretained(this)); |
pref_change_registrar_.Add(pref_names::kInstallAllowList, |
@@ -51,6 +54,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::kInstallLoginScreenAppList, |
+ pref_change_callback); |
pref_change_registrar_.Add(pref_names::kAllowedInstallSites, |
pref_change_callback); |
pref_change_registrar_.Add(pref_names::kAllowedTypes, pref_change_callback); |
@@ -71,7 +76,7 @@ ExtensionManagement::~ExtensionManagement() { |
void ExtensionManagement::Shutdown() { |
pref_change_registrar_.RemoveAll(); |
- pref_service_ = nullptr; |
+ profile_ = nullptr; |
} |
void ExtensionManagement::AddObserver(Observer* observer) { |
@@ -110,29 +115,26 @@ ExtensionManagement::InstallationMode ExtensionManagement::GetInstallationMode( |
} |
std::unique_ptr<base::DictionaryValue> |
-ExtensionManagement::GetForceInstallList() const { |
- std::unique_ptr<base::DictionaryValue> install_list( |
- new base::DictionaryValue()); |
+ExtensionManagement::GetInstallListByMode( |
Devlin
2017/03/03 17:24:47
implementation order should (try) to match the dec
achuithb
2017/03/06 15:25:31
Done.
|
+ InstallationMode installation_mode) const { |
+ auto extension_dict = base::MakeUnique<base::DictionaryValue>(); |
for (const auto& entry : settings_by_id_) { |
- if (entry.second->installation_mode == INSTALLATION_FORCED) { |
- ExternalPolicyLoader::AddExtension(install_list.get(), entry.first, |
+ if (entry.second->installation_mode == installation_mode) { |
+ ExternalPolicyLoader::AddExtension(extension_dict.get(), entry.first, |
entry.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 (const auto& entry : settings_by_id_) { |
- if (entry.second->installation_mode == INSTALLATION_RECOMMENDED) { |
- ExternalPolicyLoader::AddExtension(install_list.get(), entry.first, |
- entry.second->update_url); |
- } |
- } |
- return install_list; |
+ return GetInstallListByMode(INSTALLATION_RECOMMENDED); |
} |
bool ExtensionManagement::IsInstallationExplicitlyAllowed( |
@@ -255,6 +257,12 @@ void ExtensionManagement::Refresh() { |
const base::DictionaryValue* forced_list_pref = |
static_cast<const base::DictionaryValue*>(LoadPreference( |
pref_names::kInstallForceList, true, base::Value::Type::DICTIONARY)); |
+#if defined(OS_CHROMEOS) |
+ const base::DictionaryValue* login_screen_app_list_pref = |
+ static_cast<const base::DictionaryValue*>( |
+ LoadPreference(pref_names::kInstallLoginScreenAppList, true, |
Devlin
2017/03/03 17:24:48
Can we gate loading this on whether or not this is
achuithb
2017/03/06 15:25:31
Done. I've moved up the IsSigninProfile check to h
|
+ base::Value::Type::DICTIONARY)); |
+#endif |
const base::ListValue* install_sources_pref = |
static_cast<const base::ListValue*>(LoadPreference( |
pref_names::kAllowedInstallSites, true, base::Value::Type::LIST)); |
@@ -315,22 +323,11 @@ 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); |
+#if defined(OS_CHROMEOS) |
+ if (chromeos::ProfileHelper::IsSigninProfile(profile_)) |
+ UpdateForcedExtensions(login_screen_app_list_pref); |
+#endif |
if (install_sources_pref) { |
global_settings_->has_restricted_install_sources = true; |
@@ -415,10 +412,10 @@ const base::Value* ExtensionManagement::LoadPreference( |
const char* pref_name, |
bool force_managed, |
base::Value::Type expected_type) { |
- if (!pref_service_) |
+ if (!profile_) |
return nullptr; |
const PrefService::Preference* pref = |
- pref_service_->FindPreference(pref_name); |
+ profile_->GetPrefs()->FindPreference(pref_name); |
if (pref && !pref->IsDefaultValue() && |
(!force_managed || pref->IsManaged())) { |
const base::Value* value = pref->GetValue(); |
@@ -438,6 +435,27 @@ void ExtensionManagement::NotifyExtensionManagementPrefChanged() { |
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; |
@@ -484,8 +502,7 @@ KeyedService* ExtensionManagementFactory::BuildServiceInstanceFor( |
content::BrowserContext* context) const { |
TRACE_EVENT0("browser,startup", |
"ExtensionManagementFactory::BuildServiceInstanceFor"); |
- return new ExtensionManagement( |
- Profile::FromBrowserContext(context)->GetPrefs()); |
+ return new ExtensionManagement(Profile::FromBrowserContext(context)); |
} |
content::BrowserContext* ExtensionManagementFactory::GetBrowserContextToUse( |