OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_INPUT_METHOD_INPUT_METHOD_SYNCER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_SYNCER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_SYNCER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_SYNCER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "components/prefs/pref_member.h" | 12 #include "components/prefs/pref_member.h" |
13 #include "components/syncable_prefs/pref_service_syncable_observer.h" | 13 #include "components/sync_preferences/pref_service_syncable_observer.h" |
14 #include "ui/base/ime/chromeos/input_method_manager.h" | 14 #include "ui/base/ime/chromeos/input_method_manager.h" |
15 | 15 |
16 namespace syncable_prefs { | 16 namespace sync_preferences { |
17 class PrefServiceSyncable; | 17 class PrefServiceSyncable; |
18 } | 18 } |
19 | 19 |
20 namespace user_prefs { | 20 namespace user_prefs { |
21 class PrefRegistrySyncable; | 21 class PrefRegistrySyncable; |
22 } | 22 } |
23 | 23 |
24 namespace chromeos { | 24 namespace chromeos { |
25 namespace input_method { | 25 namespace input_method { |
26 | 26 |
27 // Helper class to handle syncing of language and input method preferences. | 27 // Helper class to handle syncing of language and input method preferences. |
28 // Changes to local preferences are handed up to the sync server. But Chrome OS | 28 // Changes to local preferences are handed up to the sync server. But Chrome OS |
29 // should not locally apply the corresponding preferences from the sync server, | 29 // should not locally apply the corresponding preferences from the sync server, |
30 // except once: when the user first logs into the device. | 30 // except once: when the user first logs into the device. |
31 // Thus, the user's most recent changes to language and input method preferences | 31 // Thus, the user's most recent changes to language and input method preferences |
32 // will be brought down when signing in to a new device but not in future syncs. | 32 // will be brought down when signing in to a new device but not in future syncs. |
33 class InputMethodSyncer : public syncable_prefs::PrefServiceSyncableObserver { | 33 class InputMethodSyncer : public sync_preferences::PrefServiceSyncableObserver { |
34 public: | 34 public: |
35 InputMethodSyncer( | 35 InputMethodSyncer( |
36 syncable_prefs::PrefServiceSyncable* prefs, | 36 sync_preferences::PrefServiceSyncable* prefs, |
37 scoped_refptr<input_method::InputMethodManager::State> ime_state); | 37 scoped_refptr<input_method::InputMethodManager::State> ime_state); |
38 ~InputMethodSyncer() override; | 38 ~InputMethodSyncer() override; |
39 | 39 |
40 // Registers the syncable input method prefs. | 40 // Registers the syncable input method prefs. |
41 static void RegisterProfilePrefs( | 41 static void RegisterProfilePrefs( |
42 user_prefs::PrefRegistrySyncable* registry); | 42 user_prefs::PrefRegistrySyncable* registry); |
43 | 43 |
44 // Must be called after InputMethodSyncer is created. | 44 // Must be called after InputMethodSyncer is created. |
45 void Initialize(); | 45 void Initialize(); |
46 | 46 |
(...skipping 11 matching lines...) Expand all Loading... |
58 const std::string& synced_pref, | 58 const std::string& synced_pref, |
59 const char* pref_name); | 59 const char* pref_name); |
60 | 60 |
61 // Sets prefs::kLanguagePreferredLanguages and sets |merging_| to false. | 61 // Sets prefs::kLanguagePreferredLanguages and sets |merging_| to false. |
62 void FinishMerge(const std::string& languages); | 62 void FinishMerge(const std::string& languages); |
63 | 63 |
64 // Callback method for preference changes. Updates the syncable prefs using | 64 // Callback method for preference changes. Updates the syncable prefs using |
65 // the local pref values. | 65 // the local pref values. |
66 void OnPreferenceChanged(const std::string& pref_name); | 66 void OnPreferenceChanged(const std::string& pref_name); |
67 | 67 |
68 // syncable_prefs::PrefServiceSyncableObserver implementation. | 68 // sync_preferences::PrefServiceSyncableObserver implementation. |
69 void OnIsSyncingChanged() override; | 69 void OnIsSyncingChanged() override; |
70 | 70 |
71 StringPrefMember preferred_languages_; | 71 StringPrefMember preferred_languages_; |
72 StringPrefMember preload_engines_; | 72 StringPrefMember preload_engines_; |
73 StringPrefMember enabled_extension_imes_; | 73 StringPrefMember enabled_extension_imes_; |
74 // These are syncable variants which don't change the device settings. We can | 74 // These are syncable variants which don't change the device settings. We can |
75 // set these to keep track of the user's most recent choices. That way, after | 75 // set these to keep track of the user's most recent choices. That way, after |
76 // the initial sync, we can add the user's synced choices to the values that | 76 // the initial sync, we can add the user's synced choices to the values that |
77 // have already been chosen at OOBE. | 77 // have already been chosen at OOBE. |
78 StringPrefMember preferred_languages_syncable_; | 78 StringPrefMember preferred_languages_syncable_; |
79 StringPrefMember preload_engines_syncable_; | 79 StringPrefMember preload_engines_syncable_; |
80 StringPrefMember enabled_extension_imes_syncable_; | 80 StringPrefMember enabled_extension_imes_syncable_; |
81 | 81 |
82 syncable_prefs::PrefServiceSyncable* prefs_; | 82 sync_preferences::PrefServiceSyncable* prefs_; |
83 scoped_refptr<input_method::InputMethodManager::State> ime_state_; | 83 scoped_refptr<input_method::InputMethodManager::State> ime_state_; |
84 | 84 |
85 // Used to ignore PrefChanged events while InputMethodManager is merging. | 85 // Used to ignore PrefChanged events while InputMethodManager is merging. |
86 bool merging_; | 86 bool merging_; |
87 | 87 |
88 base::WeakPtrFactory<InputMethodSyncer> weak_factory_; | 88 base::WeakPtrFactory<InputMethodSyncer> weak_factory_; |
89 }; | 89 }; |
90 | 90 |
91 } // namespace input_method | 91 } // namespace input_method |
92 } // namespace chromeos | 92 } // namespace chromeos |
93 | 93 |
94 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_SYNCER_H_ | 94 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_SYNCER_H_ |
OLD | NEW |