| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/win/i18n.h" | 5 #include "base/win/i18n.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 const char kThreadLanguagesFunctionName[] = "GetThreadPreferredUILanguages"; | 25 const char kThreadLanguagesFunctionName[] = "GetThreadPreferredUILanguages"; |
| 26 | 26 |
| 27 // Keep this array in sync with enum LanguageFunction. | 27 // Keep this array in sync with enum LanguageFunction. |
| 28 const char *const kLanguageFunctionNames[] = { | 28 const char *const kLanguageFunctionNames[] = { |
| 29 &kSystemLanguagesFunctionName[0], | 29 &kSystemLanguagesFunctionName[0], |
| 30 &kUserLanguagesFunctionName[0], | 30 &kUserLanguagesFunctionName[0], |
| 31 &kProcessLanguagesFunctionName[0], | 31 &kProcessLanguagesFunctionName[0], |
| 32 &kThreadLanguagesFunctionName[0] | 32 &kThreadLanguagesFunctionName[0] |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 COMPILE_ASSERT(NUM_FUNCTIONS == arraysize(kLanguageFunctionNames), | 35 static_assert(NUM_FUNCTIONS == arraysize(kLanguageFunctionNames), |
| 36 language_function_enum_and_names_out_of_sync); | 36 "LanguageFunction enum and kLanguageFunctionNames array must be " |
| 37 "kept in sync"); |
| 37 | 38 |
| 38 // Calls one of the MUI Get*PreferredUILanguages functions, placing the result | 39 // Calls one of the MUI Get*PreferredUILanguages functions, placing the result |
| 39 // in |languages|. |function| identifies the function to call and |flags| is | 40 // in |languages|. |function| identifies the function to call and |flags| is |
| 40 // the function-specific flags (callers must not specify MUI_LANGUAGE_ID or | 41 // the function-specific flags (callers must not specify MUI_LANGUAGE_ID or |
| 41 // MUI_LANGUAGE_NAME). Returns true if at least one language is placed in | 42 // MUI_LANGUAGE_NAME). Returns true if at least one language is placed in |
| 42 // |languages|. | 43 // |languages|. |
| 43 bool GetMUIPreferredUILanguageList(LanguageFunction function, ULONG flags, | 44 bool GetMUIPreferredUILanguageList(LanguageFunction function, ULONG flags, |
| 44 std::vector<wchar_t>* languages) { | 45 std::vector<wchar_t>* languages) { |
| 45 DCHECK(0 <= function && NUM_FUNCTIONS > function); | 46 DCHECK(0 <= function && NUM_FUNCTIONS > function); |
| 46 DCHECK_EQ(0U, (flags & (MUI_LANGUAGE_ID | MUI_LANGUAGE_NAME))); | 47 DCHECK_EQ(0U, (flags & (MUI_LANGUAGE_ID | MUI_LANGUAGE_NAME))); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 bool GetThreadPreferredUILanguageList(std::vector<std::wstring>* languages) { | 161 bool GetThreadPreferredUILanguageList(std::vector<std::wstring>* languages) { |
| 161 DCHECK(languages); | 162 DCHECK(languages); |
| 162 return GetPreferredUILanguageList( | 163 return GetPreferredUILanguageList( |
| 163 THREAD_LANGUAGES, MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK, | 164 THREAD_LANGUAGES, MUI_MERGE_SYSTEM_FALLBACK | MUI_MERGE_USER_FALLBACK, |
| 164 languages); | 165 languages); |
| 165 } | 166 } |
| 166 | 167 |
| 167 } // namespace i18n | 168 } // namespace i18n |
| 168 } // namespace win | 169 } // namespace win |
| 169 } // namespace base | 170 } // namespace base |
| OLD | NEW |