Prevent a DCHECK when starting a chromeos=1 build with --stub-cros-settings.

This happens because an observer of kAppPack was added in crrev.com/172473.

The fix shares all the setting names with DeviceSettingsProvider to avoid similar issues in the future.

BUG=chromium:108928


Review URL: https://chromiumcodereview.appspot.com/11975009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177205 0039d316-1c4b-4281-b951-d872f2087c98
parent fb67cc69
...@@ -67,11 +67,6 @@ const char* kKnownSettings[] = { ...@@ -67,11 +67,6 @@ const char* kKnownSettings[] = {
// Legacy policy file location. Used to detect migration from pre v12 ChromeOS. // Legacy policy file location. Used to detect migration from pre v12 ChromeOS.
const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences"; const char kLegacyPolicyFile[] = "/var/lib/whitelist/preferences";
bool IsControlledSetting(const std::string& pref_path) {
const char** end = kKnownSettings + arraysize(kKnownSettings);
return std::find(kKnownSettings, end, pref_path) != end;
}
bool HasOldMetricsFile() { bool HasOldMetricsFile() {
// TODO(pastarmovj): Remove this once migration is not needed anymore. // TODO(pastarmovj): Remove this once migration is not needed anymore.
// If the value is not set we should try to migrate legacy consent file. // If the value is not set we should try to migrate legacy consent file.
...@@ -103,6 +98,12 @@ DeviceSettingsProvider::~DeviceSettingsProvider() { ...@@ -103,6 +98,12 @@ DeviceSettingsProvider::~DeviceSettingsProvider() {
device_settings_service_->RemoveObserver(this); device_settings_service_->RemoveObserver(this);
} }
// static
bool DeviceSettingsProvider::IsDeviceSetting(const std::string& name) {
const char** end = kKnownSettings + arraysize(kKnownSettings);
return std::find(kKnownSettings, end, name) != end;
}
void DeviceSettingsProvider::DoSet(const std::string& path, void DeviceSettingsProvider::DoSet(const std::string& path,
const base::Value& in_value) { const base::Value& in_value) {
// Make sure that either the current user is the device owner or the // Make sure that either the current user is the device owner or the
...@@ -116,7 +117,7 @@ void DeviceSettingsProvider::DoSet(const std::string& path, ...@@ -116,7 +117,7 @@ void DeviceSettingsProvider::DoSet(const std::string& path,
return; return;
} }
if (IsControlledSetting(path)) { if (IsDeviceSetting(path)) {
pending_changes_.push_back(PendingQueueElement(path, in_value.DeepCopy())); pending_changes_.push_back(PendingQueueElement(path, in_value.DeepCopy()));
if (!store_callback_factory_.HasWeakPtrs()) if (!store_callback_factory_.HasWeakPtrs())
SetInPolicy(); SetInPolicy();
...@@ -657,7 +658,7 @@ bool DeviceSettingsProvider::MitigateMissingPolicy() { ...@@ -657,7 +658,7 @@ bool DeviceSettingsProvider::MitigateMissingPolicy() {
} }
const base::Value* DeviceSettingsProvider::Get(const std::string& path) const { const base::Value* DeviceSettingsProvider::Get(const std::string& path) const {
if (IsControlledSetting(path)) { if (IsDeviceSetting(path)) {
const base::Value* value; const base::Value* value;
if (values_cache_.GetValue(path, &value)) if (values_cache_.GetValue(path, &value))
return value; return value;
...@@ -677,7 +678,7 @@ DeviceSettingsProvider::TrustedStatus ...@@ -677,7 +678,7 @@ DeviceSettingsProvider::TrustedStatus
} }
bool DeviceSettingsProvider::HandlesSetting(const std::string& path) const { bool DeviceSettingsProvider::HandlesSetting(const std::string& path) const {
return IsControlledSetting(path); return IsDeviceSetting(path);
} }
DeviceSettingsProvider::TrustedStatus DeviceSettingsProvider::TrustedStatus
......
...@@ -37,6 +37,9 @@ class DeviceSettingsProvider : public CrosSettingsProvider, ...@@ -37,6 +37,9 @@ class DeviceSettingsProvider : public CrosSettingsProvider,
DeviceSettingsService* device_settings_service); DeviceSettingsService* device_settings_service);
virtual ~DeviceSettingsProvider(); virtual ~DeviceSettingsProvider();
// Returns true if |path| is handled by this provider.
static bool IsDeviceSetting(const std::string& name);
// CrosSettingsProvider implementation. // CrosSettingsProvider implementation.
virtual const base::Value* Get(const std::string& path) const OVERRIDE; virtual const base::Value* Get(const std::string& path) const OVERRIDE;
virtual TrustedStatus PrepareTrustedValues( virtual TrustedStatus PrepareTrustedValues(
......
...@@ -9,38 +9,10 @@ ...@@ -9,38 +9,10 @@
#include "chrome/browser/chromeos/login/user_manager.h" #include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/settings/cros_settings.h" #include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/settings/cros_settings_names.h" #include "chrome/browser/chromeos/settings/cros_settings_names.h"
#include "chrome/browser/chromeos/settings/device_settings_provider.h"
namespace chromeos { namespace chromeos {
namespace {
const char* kHandledSettings[] = {
kAccountsPrefAllowGuest,
kAccountsPrefAllowNewUser,
kAccountsPrefShowUserNamesOnSignIn,
kAccountsPrefUsers,
kAccountsPrefEphemeralUsersEnabled,
kAccountsPrefDeviceLocalAccounts,
kDeviceOwner,
kPolicyMissingMitigationMode,
kReleaseChannel,
kReportDeviceVersionInfo,
kReportDeviceActivityTimes,
kReportDeviceBootMode,
kReportDeviceLocation,
kSettingProxyEverywhere,
kSignedDataRoamingEnabled,
kStatsReportingPref,
kSystemTimezonePolicy,
// Kiosk mode settings.
kIdleLogoutTimeout,
kIdleLogoutWarningDuration,
kScreenSaverExtensionId,
kScreenSaverTimeout
};
} // namespace
StubCrosSettingsProvider::StubCrosSettingsProvider( StubCrosSettingsProvider::StubCrosSettingsProvider(
const NotifyObserversCallback& notify_cb) const NotifyObserversCallback& notify_cb)
: CrosSettingsProvider(notify_cb) { : CrosSettingsProvider(notify_cb) {
...@@ -71,8 +43,7 @@ CrosSettingsProvider::TrustedStatus ...@@ -71,8 +43,7 @@ CrosSettingsProvider::TrustedStatus
} }
bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const { bool StubCrosSettingsProvider::HandlesSetting(const std::string& path) const {
const char** end = kHandledSettings + arraysize(kHandledSettings); return DeviceSettingsProvider::IsDeviceSetting(path);
return std::find(kHandledSettings, end, path) != end;
} }
void StubCrosSettingsProvider::DoSet(const std::string& path, void StubCrosSettingsProvider::DoSet(const std::string& path,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment