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 // This file defines a helper class for selecting a supported language from a | 5 // This file defines a helper class for selecting a supported language from a |
6 // set of candidates. | 6 // set of candidates. |
7 | 7 |
8 #include "chrome/installer/util/language_selector.h" | 8 #include "chrome/installer/util/language_selector.h" |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <functional> | 11 #include <functional> |
12 | 12 |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/strings/string16.h" |
14 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
15 #include "base/win/i18n.h" | 16 #include "base/win/i18n.h" |
16 #include "chrome/installer/util/google_update_settings.h" | 17 #include "chrome/installer/util/google_update_settings.h" |
17 | 18 |
18 #include "installer_util_strings.h" | 19 #include "installer_util_strings.h" |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 struct LangToOffset { | 23 struct LangToOffset { |
23 const wchar_t* language; | 24 const wchar_t* language; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 &kLanguageToOffsetWildcards[0], | 184 &kLanguageToOffsetWildcards[0], |
184 &kLanguageToOffsetWildcards[arraysize(kLanguageToOffsetWildcards)], | 185 &kLanguageToOffsetWildcards[arraysize(kLanguageToOffsetWildcards)], |
185 primary_language, offset); | 186 primary_language, offset); |
186 } | 187 } |
187 | 188 |
188 // Adds to |candidates| the eligible languages on the system. Any language | 189 // Adds to |candidates| the eligible languages on the system. Any language |
189 // setting specified by Omaha takes precedence over the operating system's | 190 // setting specified by Omaha takes precedence over the operating system's |
190 // configured languages. | 191 // configured languages. |
191 void GetCandidatesFromSystem(std::vector<std::wstring>* candidates) { | 192 void GetCandidatesFromSystem(std::vector<std::wstring>* candidates) { |
192 DCHECK(candidates); | 193 DCHECK(candidates); |
193 std::wstring language; | 194 base::string16 language; |
194 | 195 |
195 // Omaha gets first pick. | 196 // Omaha gets first pick. |
196 GoogleUpdateSettings::GetLanguage(&language); | 197 GoogleUpdateSettings::GetLanguage(&language); |
197 if (!language.empty()) { | 198 if (!language.empty()) { |
198 candidates->push_back(language); | 199 candidates->push_back(language); |
199 } | 200 } |
200 | 201 |
201 // Now try the Windows UI languages. Use the thread preferred since that will | 202 // Now try the Windows UI languages. Use the thread preferred since that will |
202 // kindly return us a list of all kinds of fallbacks. | 203 // kindly return us a list of all kinds of fallbacks. |
203 base::win::i18n::GetThreadPreferredUILanguageList(candidates); | 204 base::win::i18n::GetThreadPreferredUILanguageList(candidates); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 VLOG(1) << "No suitable language found for any candidates."; | 287 VLOG(1) << "No suitable language found for any candidates."; |
287 | 288 |
288 // Our fallback is "en-us" | 289 // Our fallback is "en-us" |
289 matched_candidate_.assign(&kFallbackLanguage[0], | 290 matched_candidate_.assign(&kFallbackLanguage[0], |
290 arraysize(kFallbackLanguage) - 1); | 291 arraysize(kFallbackLanguage) - 1); |
291 offset_ = kFallbackLanguageOffset; | 292 offset_ = kFallbackLanguageOffset; |
292 } | 293 } |
293 } | 294 } |
294 | 295 |
295 } // namespace installer | 296 } // namespace installer |
OLD | NEW |