OLD | NEW |
1 // Copyright (c) 2012 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_PREFERENCES_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
6 #define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/prefs/public/pref_observer.h" | |
13 #include "chrome/browser/api/prefs/pref_member.h" | 12 #include "chrome/browser/api/prefs/pref_member.h" |
14 #include "chrome/browser/chromeos/language_preferences.h" | 13 #include "chrome/browser/chromeos/language_preferences.h" |
15 | 14 |
16 class PrefService; | 15 class PrefService; |
17 | 16 |
18 namespace chromeos { | 17 namespace chromeos { |
19 namespace input_method { | 18 namespace input_method { |
20 class InputMethodManager; | 19 class InputMethodManager; |
21 } // namespace input_method | 20 } // namespace input_method |
22 | 21 |
23 // The Preferences class handles Chrome OS preferences. When the class | 22 // The Preferences class handles Chrome OS preferences. When the class |
24 // is first initialized, it will initialize the OS settings to what's stored in | 23 // is first initialized, it will initialize the OS settings to what's stored in |
25 // the preferences. These include touchpad settings, etc. | 24 // the preferences. These include touchpad settings, etc. |
26 // When the preferences change, we change the settings to reflect the new value. | 25 // When the preferences change, we change the settings to reflect the new value. |
27 class Preferences : public PrefObserver { | 26 class Preferences { |
28 public: | 27 public: |
29 Preferences(); | 28 Preferences(); |
30 explicit Preferences( | 29 explicit Preferences( |
31 input_method::InputMethodManager* input_method_manager); // for testing | 30 input_method::InputMethodManager* input_method_manager); // for testing |
32 virtual ~Preferences(); | 31 virtual ~Preferences(); |
33 | 32 |
34 // This method will register the prefs associated with Chrome OS settings. | 33 // This method will register the prefs associated with Chrome OS settings. |
35 static void RegisterUserPrefs(PrefService* prefs); | 34 static void RegisterUserPrefs(PrefService* prefs); |
36 | 35 |
37 // This method will initialize Chrome OS settings to values in user prefs. | 36 // This method will initialize Chrome OS settings to values in user prefs. |
38 void Init(PrefService* prefs); | 37 void Init(PrefService* prefs); |
39 | 38 |
40 // Overridden from PrefObserver: | |
41 virtual void OnPreferenceChanged(PrefServiceBase* service, | |
42 const std::string& pref_name) OVERRIDE; | |
43 | |
44 void InitUserPrefsForTesting(PrefService* prefs); | 39 void InitUserPrefsForTesting(PrefService* prefs); |
45 void SetInputMethodListForTesting(); | 40 void SetInputMethodListForTesting(); |
46 | 41 |
47 private: | 42 private: |
48 // Initializes all member prefs. | 43 // Initializes all member prefs. |
49 void InitUserPrefs(PrefService* prefs); | 44 void InitUserPrefs(PrefService* prefs); |
50 | 45 |
| 46 // Callback method for preference changes. |
| 47 void OnPreferenceChanged(const std::string& pref_name); |
| 48 |
51 // This will set the OS settings when the preference changes. | 49 // This will set the OS settings when the preference changes. |
52 // If this method is called with NULL, it will set all OS settings to what's | 50 // If this method is called with NULL, it will set all OS settings to what's |
53 // stored in the preferences. | 51 // stored in the preferences. |
54 void NotifyPrefChanged(const std::string* pref_name); | 52 void NotifyPrefChanged(const std::string* pref_name); |
55 | 53 |
56 // Writes boolean |value| to the input method (IBus) configuration daemon. | 54 // Writes boolean |value| to the input method (IBus) configuration daemon. |
57 // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should | 55 // |section| (e.g. "general") and |name| (e.g. "use_global_engine") should |
58 // not be NULL. | 56 // not be NULL. |
59 void SetLanguageConfigBoolean(const char* section, | 57 void SetLanguageConfigBoolean(const char* section, |
60 const char* name, | 58 const char* name, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 BooleanPrefMember enable_screen_lock_; | 146 BooleanPrefMember enable_screen_lock_; |
149 | 147 |
150 BooleanPrefMember enable_drm_; | 148 BooleanPrefMember enable_drm_; |
151 | 149 |
152 DISALLOW_COPY_AND_ASSIGN(Preferences); | 150 DISALLOW_COPY_AND_ASSIGN(Preferences); |
153 }; | 151 }; |
154 | 152 |
155 } // namespace chromeos | 153 } // namespace chromeos |
156 | 154 |
157 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ | 155 #endif // CHROME_BROWSER_CHROMEOS_PREFERENCES_H_ |
OLD | NEW |