blob: 5c1ce022694a70118eaf3ee23615c28ef55f78a0 [file] [log] [blame]
[email protected]73bd67b2010-07-16 16:00:091// Copyright (c) 2010 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#ifndef CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_
6#define CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]73bd67b2010-07-16 16:00:098
9#include <string>
10#include "base/values.h"
11
12#include "chrome/browser/chromeos/cros_settings_names.h"
13
14namespace chromeos {
15
16// A class manages per-device/global settings.
17class CrosSettings {
18 public:
19 // Class factory.
20 static CrosSettings* Get();
21
22 // Helper function to test if given path is a value cros settings name.
23 static bool IsCrosSettings(const std::wstring& path);
24
25 // Sets |in_value| to given |path| in cros settings.
26 // Note that this takes ownership of |in_value|.
27 virtual void Set(const std::wstring& path, Value* in_value) = 0;
28
29 // Gets settings value of given |path| to |out_value|.
30 // Note that |out_value| is still owned by this class.
31 virtual bool Get(const std::wstring& path, Value** out_value) const = 0;
32
33 // Convenience forms of Set(). These methods will replace any existing
34 // value at that path, even if it has a different type.
35 void SetBoolean(const std::wstring& path, bool in_value);
36 void SetInteger(const std::wstring& path, int in_value);
37 void SetReal(const std::wstring& path, double in_value);
38 void SetString(const std::wstring& path, const std::string& in_value);
39
40 // These are convenience forms of Get(). The value will be retrieved
41 // and the return value will be true if the path is valid and the value at
42 // the end of the path can be returned in the form specified.
43 bool GetBoolean(const std::wstring& path, bool* out_value) const;
44 bool GetInteger(const std::wstring& path, int* out_value) const;
45 bool GetReal(const std::wstring& path, double* out_value) const;
46 bool GetString(const std::wstring& path, std::string* out_value) const;
[email protected]46ebf0642010-07-24 02:47:4047
48 protected:
49 virtual ~CrosSettings() {}
[email protected]73bd67b2010-07-16 16:00:0950};
51
52} // namespace chromeos
53
54#endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_