Add device_type to SharedPageState as a prelude to removing user_agent_type from...
[chromium-blink-merge.git] / chromeos / settings / cros_settings_provider.cc
blob98faf718ca788efd615b7daeff331ddc8e26d115
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/settings/cros_settings_provider.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/strings/string_util.h"
10 #include "base/values.h"
11 #include "chromeos/chromeos_switches.h"
13 namespace chromeos {
15 CrosSettingsProvider::CrosSettingsProvider(
16 const NotifyObserversCallback& notify_cb)
17 : notify_cb_(notify_cb) {
20 CrosSettingsProvider::~CrosSettingsProvider() {
23 void CrosSettingsProvider::Set(const std::string& path,
24 const base::Value& value) {
25 // We don't allow changing any of the cros settings without prefix
26 // "cros.session." in the guest mode.
27 // It should not reach here from UI in the guest mode, but just in case.
28 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
29 switches::kGuestSession) &&
30 !::StartsWithASCII(path, "cros.session.", true)) {
31 LOG(ERROR) << "Ignoring the guest request to change: " << path;
32 return;
34 DoSet(path, value);
37 void CrosSettingsProvider::NotifyObservers(const std::string& path) {
38 if (!notify_cb_.is_null())
39 notify_cb_.Run(path);
42 void CrosSettingsProvider::SetNotifyObserversCallback(
43 const NotifyObserversCallback& notify_cb) {
44 notify_cb_ = notify_cb;
47 }; // namespace chromeos