Chromium Code Reviews| 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 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 { "mozc-chewing", "\xe9\x85\xb7" }, // U+9177 | 54 { "mozc-chewing", "\xe9\x85\xb7" }, // U+9177 |
| 55 { "m17n:zh:cangjie", "\xe5\x80\x89" }, // U+5009 | 55 { "m17n:zh:cangjie", "\xe5\x80\x89" }, // U+5009 |
| 56 { "m17n:zh:quick", "\xe9\x80\x9f" }, // U+901F | 56 { "m17n:zh:quick", "\xe9\x80\x9f" }, // U+901F |
| 57 // For Hangul input method. | 57 // For Hangul input method. |
| 58 { "mozc-hangul", "\xed\x95\x9c" }, // U+D55C | 58 { "mozc-hangul", "\xed\x95\x9c" }, // U+D55C |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 const size_t kMappingFromIdToIndicatorTextLen = | 61 const size_t kMappingFromIdToIndicatorTextLen = |
| 62 ARRAYSIZE_UNSAFE(kMappingFromIdToIndicatorText); | 62 ARRAYSIZE_UNSAFE(kMappingFromIdToIndicatorText); |
| 63 | 63 |
| 64 // A mapping from an input method id to a medium length language indicator. | |
| 65 // For those languages that want to display a slightly longer text in the | |
| 66 // "Your input method has changed to..." bubble than in the status tray. | |
| 67 // If an entry is not found in this table the short name is used. | |
| 68 const struct { | |
| 69 const char* input_method_id; | |
| 70 const char* medium_length_name; | |
| 71 } kMappintFromIdToMediumLengthName[] = { | |
|
Daniel Erat
2012/09/24 20:48:00
s/Mappint/Mapping/
sschmitz
2012/09/24 21:28:16
OMG (wrong in several locations). Great eyes.
Don
| |
| 72 { "mozc", "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" }, | |
| 73 { "mozc-dv", "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" }, | |
| 74 { "mozc-jp", "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" }, | |
| 75 { "zinnia-japanese", "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" }, | |
| 76 }; | |
| 77 const size_t kMappintFromIdToMediumLengthNameLen = | |
| 78 ARRAYSIZE_UNSAFE(kMappintFromIdToMediumLengthName); | |
| 79 | |
| 64 string16 GetLanguageName(const std::string& language_code) { | 80 string16 GetLanguageName(const std::string& language_code) { |
| 65 const string16 language_name = l10n_util::GetDisplayNameForLocale( | 81 const string16 language_name = l10n_util::GetDisplayNameForLocale( |
| 66 language_code, g_browser_process->GetApplicationLocale(), true); | 82 language_code, g_browser_process->GetApplicationLocale(), true); |
| 67 return language_name; | 83 return language_name; |
| 68 } | 84 } |
| 69 | 85 |
| 70 } | 86 } |
| 71 | 87 |
| 72 namespace chromeos { | 88 namespace chromeos { |
| 73 | 89 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 const std::string& input_method_id) const { | 394 const std::string& input_method_id) const { |
| 379 string16 display_name; | 395 string16 display_name; |
| 380 if (!IsExtensionInputMethod(input_method_id) && | 396 if (!IsExtensionInputMethod(input_method_id) && |
| 381 TranslateStringInternal(input_method_id, &display_name)) { | 397 TranslateStringInternal(input_method_id, &display_name)) { |
| 382 return UTF16ToUTF8(display_name); | 398 return UTF16ToUTF8(display_name); |
| 383 } | 399 } |
| 384 // Return an empty string if the display name is not found. | 400 // Return an empty string if the display name is not found. |
| 385 return ""; | 401 return ""; |
| 386 } | 402 } |
| 387 | 403 |
| 404 string16 InputMethodUtil::GetInputMethodMediumName( | |
| 405 const InputMethodDescriptor& input_method) const { | |
| 406 // For the "Your input method has changed to..." bubble. In most cases | |
| 407 // it uses the same name as the short name, unless found in a table | |
| 408 // for medium length names. | |
| 409 for (size_t i = 0; i < kMappintFromIdToMediumLengthNameLen; ++i) { | |
| 410 if (kMappintFromIdToMediumLengthName[i].input_method_id == | |
| 411 input_method.id()) | |
| 412 return | |
| 413 UTF8ToUTF16(kMappintFromIdToMediumLengthName[i].medium_length_name); | |
| 414 } | |
| 415 return GetInputMethodShortName(input_method); | |
| 416 } | |
| 417 | |
| 388 string16 InputMethodUtil::GetInputMethodShortName( | 418 string16 InputMethodUtil::GetInputMethodShortName( |
| 389 const InputMethodDescriptor& input_method) const { | 419 const InputMethodDescriptor& input_method) const { |
| 390 // For the status area, we use two-letter, upper-case language code like | 420 // For the status area, we use two-letter, upper-case language code like |
| 391 // "US" and "JP". | 421 // "US" and "JP". |
| 392 string16 text; | 422 string16 text; |
| 393 | 423 |
| 394 // Check special cases first. | 424 // Check special cases first. |
| 395 for (size_t i = 0; i < kMappingFromIdToIndicatorTextLen; ++i) { | 425 for (size_t i = 0; i < kMappingFromIdToIndicatorTextLen; ++i) { |
| 396 if (kMappingFromIdToIndicatorText[i].input_method_id == input_method.id()) { | 426 if (kMappingFromIdToIndicatorText[i].input_method_id == input_method.id()) { |
| 397 text = UTF8ToUTF16(kMappingFromIdToIndicatorText[i].indicator_text); | 427 text = UTF8ToUTF16(kMappingFromIdToIndicatorText[i].indicator_text); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 690 ReloadInternalMaps(); | 720 ReloadInternalMaps(); |
| 691 } | 721 } |
| 692 | 722 |
| 693 void InputMethodUtil::SetHardwareInputMethodIdForTesting( | 723 void InputMethodUtil::SetHardwareInputMethodIdForTesting( |
| 694 const std::string& input_method_id) { | 724 const std::string& input_method_id) { |
| 695 hardware_input_method_id_for_testing_ = input_method_id; | 725 hardware_input_method_id_for_testing_ = input_method_id; |
| 696 } | 726 } |
| 697 | 727 |
| 698 } // namespace input_method | 728 } // namespace input_method |
| 699 } // namespace chromeos | 729 } // namespace chromeos |
| OLD | NEW |