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

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

Issue 9355044: Added KioskModeAppPack proto. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 10 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros_settings.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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>
11 11
12 #include "base/callback_forward.h"
12 #include "base/hash_tables.h" 13 #include "base/hash_tables.h"
13 #include "base/memory/singleton.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "base/threading/non_thread_safe.h" 15 #include "base/threading/non_thread_safe.h"
16 #include "chrome/browser/chromeos/cros_settings_names.h" 16 #include "chrome/browser/chromeos/cros_settings_names.h"
17 #include "chrome/browser/chromeos/cros_settings_provider.h"
18 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
19 18
20 namespace base { 19 namespace base {
21 template <typename T> struct DefaultLazyInstanceTraits; 20 template <typename T> struct DefaultLazyInstanceTraits;
22 class ListValue; 21 class ListValue;
23 class Value; 22 class Value;
24 } 23 }
25 24
26 namespace chromeos { 25 namespace chromeos {
27 26
28 // A class manages per-device/global settings. 27 class CrosSettingsProvider;
28
29 // This class manages per-device/global settings.
29 class CrosSettings : public base::NonThreadSafe { 30 class CrosSettings : public base::NonThreadSafe {
30 public: 31 public:
31 // Class factory. 32 // Class factory.
32 static CrosSettings* Get(); 33 static CrosSettings* Get();
33 34
34 // Helper function to test if given path is a value cros settings name. 35 // Helper function to test if the given |path| is a valid cros setting.
35 static bool IsCrosSettings(const std::string& path); 36 static bool IsCrosSettings(const std::string& path);
36 37
37 // Sets |in_value| to given |path| in cros settings. 38 // Sets |in_value| to given |path| in cros settings.
38 void Set(const std::string& path, const base::Value& in_value); 39 void Set(const std::string& path, const base::Value& in_value);
39 40
40 // Gets settings value of given |path| to |out_value|. 41 // Returns setting value for the given |path|.
41 const base::Value* GetPref(const std::string& path) const; 42 const base::Value* GetPref(const std::string& path) const;
42 43
43 // Starts a fetch from the trusted store for the value of |path| if not loaded 44 // Starts a fetch from the trusted store for the value of |path| if not loaded
44 // yet. It will call the |callback| function upon completion if a new fetch 45 // yet. It will call the |callback| function upon completion if a new fetch
45 // was needed in which case the return value is false. Else it will return 46 // was needed in which case the return value is false. Else it will return
46 // true and won't call the |callback|. 47 // true and won't call the |callback|.
47 bool GetTrusted(const std::string& path, 48 bool GetTrusted(const std::string& path,
48 const base::Closure& callback) const; 49 const base::Closure& callback) const;
49 50
50 // Convenience forms of Set(). These methods will replace any existing 51 // Convenience forms of Set(). These methods will replace any existing
51 // value at that path, even if it has a different type. 52 // value at that |path|, even if it has a different type.
52 void SetBoolean(const std::string& path, bool in_value); 53 void SetBoolean(const std::string& path, bool in_value);
53 void SetInteger(const std::string& path, int in_value); 54 void SetInteger(const std::string& path, int in_value);
54 void SetDouble(const std::string& path, double in_value); 55 void SetDouble(const std::string& path, double in_value);
55 void SetString(const std::string& path, const std::string& in_value); 56 void SetString(const std::string& path, const std::string& in_value);
56 57
57 // Convenience functions for manipulating lists. 58 // Convenience functions for manipulating lists.
58 void AppendToList(const std::string& path, const base::Value* value); 59 void AppendToList(const std::string& path, const base::Value* value);
59 void RemoveFromList(const std::string& path, const base::Value* value); 60 void RemoveFromList(const std::string& path, const base::Value* value);
60 61
61 // These are convenience forms of Get(). The value will be retrieved 62 // These are convenience forms of Get(). The value will be retrieved
62 // and the return value will be true if the path is valid and the value at 63 // and the return value will be true if the |path| is valid and the value at
63 // the end of the path can be returned in the form specified. 64 // the end of the path can be returned in the form specified.
64 bool GetBoolean(const std::string& path, bool* out_value) const; 65 bool GetBoolean(const std::string& path, bool* out_value) const;
65 bool GetInteger(const std::string& path, int* out_value) const; 66 bool GetInteger(const std::string& path, int* out_value) const;
66 bool GetDouble(const std::string& path, double* out_value) const; 67 bool GetDouble(const std::string& path, double* out_value) const;
67 bool GetString(const std::string& path, std::string* out_value) const; 68 bool GetString(const std::string& path, std::string* out_value) const;
68 bool GetList(const std::string& path, 69 bool GetList(const std::string& path,
69 const base::ListValue** out_value) const; 70 const base::ListValue** out_value) const;
70 71
71 // Helper function for the whitelist op. Implemented here because we will need 72 // Helper function for the whitelist op. Implemented here because we will need
72 // this in a few places. The functions searches for |email| in the pref |path| 73 // this in a few places. The functions searches for |email| in the pref |path|
73 // It respects whitelists so foo@bar.baz will match *@bar.baz too. 74 // It respects whitelists so foo@bar.baz will match *@bar.baz too.
74 bool FindEmailInList(const std::string& path, const std::string& email) const; 75 bool FindEmailInList(const std::string& path, const std::string& email) const;
75 76
76 // adding/removing of providers 77 // Adding/removing of providers.
77 bool AddSettingsProvider(CrosSettingsProvider* provider); 78 bool AddSettingsProvider(CrosSettingsProvider* provider);
78 bool RemoveSettingsProvider(CrosSettingsProvider* provider); 79 bool RemoveSettingsProvider(CrosSettingsProvider* provider);
79 80
80 // If the pref at the given path changes, we call the observer's Observe 81 // If the pref at the given |path| changes, we call the observer's Observe
81 // method with PREF_CHANGED. 82 // method with NOTIFICATION_SYSTEM_SETTING_CHANGED.
82 void AddSettingsObserver(const char* path, 83 void AddSettingsObserver(const char* path,
83 content::NotificationObserver* obs); 84 content::NotificationObserver* obs);
84 void RemoveSettingsObserver(const char* path, 85 void RemoveSettingsObserver(const char* path,
85 content::NotificationObserver* obs); 86 content::NotificationObserver* obs);
86 87
87 // Returns the provider that handles settings with the path or prefix. 88 // Returns the provider that handles settings with the |path| or prefix.
88 CrosSettingsProvider* GetProvider(const std::string& path) const; 89 CrosSettingsProvider* GetProvider(const std::string& path) const;
89 90
90 // Forces all providers to reload their caches from the respective backing 91 // Forces all providers to reload their caches from the respective backing
91 // stores if they have any. 92 // stores if they have any.
92 void ReloadProviders(); 93 void ReloadProviders();
93 94
94 private: 95 private:
95 friend struct base::DefaultLazyInstanceTraits<CrosSettings>; 96 friend struct base::DefaultLazyInstanceTraits<CrosSettings>;
96 97
97 // List of ChromeOS system settings providers. 98 // List of ChromeOS system settings providers.
(...skipping 11 matching lines...) Expand all
109 110
110 // Fires system setting change notification. 111 // Fires system setting change notification.
111 void FireObservers(const std::string& path); 112 void FireObservers(const std::string& path);
112 113
113 DISALLOW_COPY_AND_ASSIGN(CrosSettings); 114 DISALLOW_COPY_AND_ASSIGN(CrosSettings);
114 }; 115 };
115 116
116 } // namespace chromeos 117 } // namespace chromeos
117 118
118 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_ 119 #endif // CHROME_BROWSER_CHROMEOS_CROS_SETTINGS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/cros_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698