1 // Copyright (c) 2012 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. 4 5 #include "chrome/browser/chromeos/settings/cros_settings_provider.h" 6 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 "chrome/common/chrome_switches.h" 12 #include "chromeos/chromeos_switches.h" 13 14 namespace chromeos { 15 16 CrosSettingsProvider::CrosSettingsProvider( 17 const NotifyObserversCallback& notify_cb) 18 : notify_cb_(notify_cb) { 19 } 20 21 CrosSettingsProvider::~CrosSettingsProvider() { 22 } 23 24 void CrosSettingsProvider::Set(const std::string& path, 25 const base::Value& value) { 26 // We don't allow changing any of the cros settings without prefix 27 // "cros.session." in the guest mode. 28 // It should not reach here from UI in the guest mode, but just in case. 29 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession) && 30 !::StartsWithASCII(path, "cros.session.", true)) { 31 LOG(ERROR) << "Ignoring the guest request to change: " << path; 32 return; 33 } 34 DoSet(path, value); 35 } 36 37 void CrosSettingsProvider::NotifyObservers(const std::string& path) { 38 if (!notify_cb_.is_null()) 39 notify_cb_.Run(path); 40 } 41 42 void CrosSettingsProvider::SetNotifyObserversCallback( 43 const NotifyObserversCallback& notify_cb) { 44 notify_cb_ = notify_cb; 45 } 46 47 }; // namespace chromeos 48