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 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 // from the |locale| and the currently active input method. | 149 // from the |locale| and the currently active input method. |
150 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( | 150 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( |
151 locale, | 151 locale, |
152 session_manager->GetDefaultIMEState(profile)->GetCurrentInputMethod(), | 152 session_manager->GetDefaultIMEState(profile)->GetCurrentInputMethod(), |
153 &input_method_ids); | 153 &input_method_ids); |
154 } | 154 } |
155 | 155 |
156 // Save the input methods in the user's preferences. | 156 // Save the input methods in the user's preferences. |
157 StringPrefMember language_preload_engines; | 157 StringPrefMember language_preload_engines; |
158 language_preload_engines.Init(prefs::kLanguagePreloadEngines, prefs); | 158 language_preload_engines.Init(prefs::kLanguagePreloadEngines, prefs); |
159 language_preload_engines.SetValue(JoinString(input_method_ids, ',')); | 159 language_preload_engines.SetValue(base::JoinString(input_method_ids, ",")); |
160 BootTimesRecorder::Get()->AddLoginTimeMarker("IMEStarted", false); | 160 BootTimesRecorder::Get()->AddLoginTimeMarker("IMEStarted", false); |
161 | 161 |
162 // Second, we'll set kLanguagePreferredLanguages. | 162 // Second, we'll set kLanguagePreferredLanguages. |
163 std::vector<std::string> language_codes; | 163 std::vector<std::string> language_codes; |
164 | 164 |
165 // The current locale should be on the top. | 165 // The current locale should be on the top. |
166 language_codes.push_back(locale); | 166 language_codes.push_back(locale); |
167 | 167 |
168 // Add input method IDs based on the input methods, as there may be | 168 // Add input method IDs based on the input methods, as there may be |
169 // input methods that are unrelated to the current locale. Example: the | 169 // input methods that are unrelated to the current locale. Example: the |
170 // hardware keyboard layout xkb:us::eng is used for logging in, but the | 170 // hardware keyboard layout xkb:us::eng is used for logging in, but the |
171 // UI language is set to French. In this case, we should set "fr,en" | 171 // UI language is set to French. In this case, we should set "fr,en" |
172 // to the preferred languages preference. | 172 // to the preferred languages preference. |
173 std::vector<std::string> candidates; | 173 std::vector<std::string> candidates; |
174 manager->GetInputMethodUtil()->GetLanguageCodesFromInputMethodIds( | 174 manager->GetInputMethodUtil()->GetLanguageCodesFromInputMethodIds( |
175 input_method_ids, &candidates); | 175 input_method_ids, &candidates); |
176 for (size_t i = 0; i < candidates.size(); ++i) { | 176 for (size_t i = 0; i < candidates.size(); ++i) { |
177 const std::string& candidate = candidates[i]; | 177 const std::string& candidate = candidates[i]; |
178 // Skip if it's already in language_codes. | 178 // Skip if it's already in language_codes. |
179 if (std::count(language_codes.begin(), language_codes.end(), | 179 if (std::count(language_codes.begin(), language_codes.end(), |
180 candidate) == 0) { | 180 candidate) == 0) { |
181 language_codes.push_back(candidate); | 181 language_codes.push_back(candidate); |
182 } | 182 } |
183 } | 183 } |
184 | 184 |
185 // Save the preferred languages in the user's preferences. | 185 // Save the preferred languages in the user's preferences. |
186 prefs->SetString(prefs::kLanguagePreferredLanguages, | 186 prefs->SetString(prefs::kLanguagePreferredLanguages, |
187 JoinString(language_codes, ',')); | 187 base::JoinString(language_codes, ",")); |
188 | 188 |
189 // Indicate that we need to merge the syncable input methods when we sync, | 189 // Indicate that we need to merge the syncable input methods when we sync, |
190 // since we have not applied the synced prefs before. | 190 // since we have not applied the synced prefs before. |
191 prefs->SetBoolean(prefs::kLanguageShouldMergeInputMethods, true); | 191 prefs->SetBoolean(prefs::kLanguageShouldMergeInputMethods, true); |
192 } | 192 } |
193 | 193 |
194 #if defined(ENABLE_RLZ) | 194 #if defined(ENABLE_RLZ) |
195 // Flag file that disables RLZ tracking, when present. | 195 // Flag file that disables RLZ tracking, when present. |
196 const base::FilePath::CharType kRLZDisabledFlagName[] = | 196 const base::FilePath::CharType kRLZDisabledFlagName[] = |
197 FILE_PATH_LITERAL(".rlz_disabled"); | 197 FILE_PATH_LITERAL(".rlz_disabled"); |
(...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 token_handle_util_.reset(); | 1723 token_handle_util_.reset(); |
1724 } | 1724 } |
1725 | 1725 |
1726 void UserSessionManager::CreateTokenUtilIfMissing() { | 1726 void UserSessionManager::CreateTokenUtilIfMissing() { |
1727 if (!token_handle_util_.get()) | 1727 if (!token_handle_util_.get()) |
1728 token_handle_util_.reset( | 1728 token_handle_util_.reset( |
1729 new TokenHandleUtil(user_manager::UserManager::Get())); | 1729 new TokenHandleUtil(user_manager::UserManager::Get())); |
1730 } | 1730 } |
1731 | 1731 |
1732 } // namespace chromeos | 1732 } // namespace chromeos |
OLD | NEW |