Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: chrome/browser/chromeos/cros_settings.h

Issue 8091002: PART2: Make SignedSettings use proper Value types instead of string all around the place. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased on ToT and made clang happy. Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ 6 #define CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 17 matching lines...) Expand all
28 // A class manages per-device/global settings. 28 // A class manages per-device/global settings.
29 class CrosSettings : public base::NonThreadSafe { 29 class CrosSettings : public base::NonThreadSafe {
30 public: 30 public:
31 // Class factory. 31 // Class factory.
32 static CrosSettings* Get(); 32 static CrosSettings* Get();
33 33
34 // Helper function to test if given path is a value cros settings name. 34 // Helper function to test if given path is a value cros settings name.
35 static bool IsCrosSettings(const std::string& path); 35 static bool IsCrosSettings(const std::string& path);
36 36
37 // Sets |in_value| to given |path| in cros settings. 37 // Sets |in_value| to given |path| in cros settings.
38 // Note that this takes ownership of |in_value|. 38 void Set(const std::string& path, const base::Value& in_value);
Denis Lagno 2011/10/04 17:01:50 AFAIU base::Values are intended to be created via
pastarmovj 2011/10/05 08:42:31 This is true because the usual pref stores take ow
Denis Lagno 2011/10/05 17:50:10 So you use const reference as a signal that owners
pastarmovj 2011/10/13 11:25:06 Actually my interface exactly mimics the interface
39 void Set(const std::string& path, base::Value* in_value);
40 39
41 // Fires system setting change notification. 40 // Fires system setting change notification.
42 // TODO(pastarmovj): Consider to remove this function from the public 41 // TODO(pastarmovj): Consider to remove this function from the public
43 // interface. 42 // interface.
44 void FireObservers(const char* path); 43 void FireObservers(const char* path);
45 44
46 // Gets settings value of given |path| to |out_value|. 45 // Gets settings value of given |path| to |out_value|.
47 const base::Value* GetPref(const std::string& path) const; 46 const base::Value* GetPref(const std::string& path) const;
48 47
49 // Gets settings value of given |path| from the trusted store. It will call 48 // Gets settings value of given |path| from the trusted store. It will call
50 // the |callback| function with the value of the setting or NULL if it could 49 // the |callback| function with the value of the setting or NULL if it could
51 // not be retrieved. 50 // not be retrieved.
52 bool GetTrusted(const std::string& path, 51 bool GetTrusted(const std::string& path,
53 const base::Closure& callback) const; 52 const base::Closure& callback) const;
54 53
55 // Convenience forms of Set(). These methods will replace any existing 54 // Convenience forms of Set(). These methods will replace any existing
56 // value at that path, even if it has a different type. 55 // value at that path, even if it has a different type.
57 void SetBoolean(const std::string& path, bool in_value); 56 void SetBoolean(const std::string& path, bool in_value);
58 void SetInteger(const std::string& path, int in_value); 57 void SetInteger(const std::string& path, int in_value);
59 void SetDouble(const std::string& path, double in_value); 58 void SetDouble(const std::string& path, double in_value);
60 void SetString(const std::string& path, const std::string& in_value); 59 void SetString(const std::string& path, const std::string& in_value);
61 60
61 // Convenience functions for manipulating lists.
62 void AppendToList(const std::string& path, const base::Value& value);
63 void RemoveFromList(const std::string& path, const base::Value& value);
64
62 // These are convenience forms of Get(). The value will be retrieved 65 // These are convenience forms of Get(). The value will be retrieved
63 // and the return value will be true if the path is valid and the value at 66 // and the return value will be true if the path is valid and the value at
64 // the end of the path can be returned in the form specified. 67 // the end of the path can be returned in the form specified.
65 bool GetBoolean(const std::string& path, bool* out_value) const; 68 bool GetBoolean(const std::string& path, bool* out_value) const;
66 bool GetInteger(const std::string& path, int* out_value) const; 69 bool GetInteger(const std::string& path, int* out_value) const;
67 bool GetDouble(const std::string& path, double* out_value) const; 70 bool GetDouble(const std::string& path, double* out_value) const;
68 bool GetString(const std::string& path, std::string* out_value) const; 71 bool GetString(const std::string& path, std::string* out_value) const;
69 bool GetList(const std::string& path, 72 bool GetList(const std::string& path,
70 const base::ListValue** out_value) const; 73 const base::ListValue** out_value) const;
71 74
(...skipping 23 matching lines...) Expand all
95 CrosSettings(); 98 CrosSettings();
96 ~CrosSettings(); 99 ~CrosSettings();
97 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; 100 friend struct base::DefaultLazyInstanceTraits<CrosSettings>;
98 101
99 DISALLOW_COPY_AND_ASSIGN(CrosSettings); 102 DISALLOW_COPY_AND_ASSIGN(CrosSettings);
100 }; 103 };
101 104
102 } // namespace chromeos 105 } // namespace chromeos
103 106
104 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ 107 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698