Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: chrome/browser/chromeos/input_method/input_method_util.cc

Issue 10960060: fix "IME changed" notification uses a wrong field of IME (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix name: mappint to mapping Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 { "english-m", "??" }, 39 { "english-m", "??" },
40 { "xkb:de:neo:ger", "NEO" }, 40 { "xkb:de:neo:ger", "NEO" },
41 // To distinguish from "xkb:es::spa" 41 // To distinguish from "xkb:es::spa"
42 { "xkb:es:cat:cat", "CAS" }, 42 { "xkb:es:cat:cat", "CAS" },
43 // To distinguish from "xkb:gb::eng" 43 // To distinguish from "xkb:gb::eng"
44 { "xkb:gb:dvorak:eng", "DV" }, 44 { "xkb:gb:dvorak:eng", "DV" },
45 // To distinguish from "xkb:jp::jpn" 45 // To distinguish from "xkb:jp::jpn"
46 { "mozc", "\xe3\x81\x82" }, // U+3042, Japanese Hiragana letter A in UTF-8. 46 { "mozc", "\xe3\x81\x82" }, // U+3042, Japanese Hiragana letter A in UTF-8.
47 { "mozc-dv", "\xe3\x81\x82" }, 47 { "mozc-dv", "\xe3\x81\x82" },
48 { "mozc-jp", "\xe3\x81\x82" }, 48 { "mozc-jp", "\xe3\x81\x82" },
49 { "zinnia-japanese", "\xe6\x89\x8b" }, // U+624B, "hand" 49 { "zinnia-japanese", "\xe6\x89\x8b" }, // U+624B, "hand"
Yusuke Sato 2012/09/24 22:00:50 not your fault at all, but please remove this line
sschmitz 2012/09/25 01:41:43 Done.
50 // For simplified Chinese input methods 50 // For simplified Chinese input methods
51 { "pinyin", "\xe6\x8b\xbc" }, // U+62FC 51 { "pinyin", "\xe6\x8b\xbc" }, // U+62FC
52 { "pinyin-dv", "\xe6\x8b\xbc" }, 52 { "pinyin-dv", "\xe6\x8b\xbc" },
53 // For traditional Chinese input methods 53 // For traditional Chinese input methods
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 } kMappingFromIdToMediumLengthName[] = {
72 { "mozc", "\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e" },
Yusuke Sato 2012/09/24 22:00:50 Two requests: 1. Please use chrome/app/generated_
sschmitz 2012/09/24 22:48:14 I can do that. Who will translate? And, for each o
Yusuke Sato 2012/09/24 23:15:24 L10N folks will take care of that for you: http://
sschmitz 2012/09/25 01:41:43 Done.
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" },
Jun Mukai 2012/09/24 21:48:32 It would be fine for Japanese, but what about othe
Daniel Erat 2012/09/24 21:50:27 Is this a suggestion to make all of these instead
Yusuke Sato 2012/09/24 22:00:50 ditto. please remove zinnia.
Yusuke Sato 2012/09/24 22:03:44 +1 for translatable string for kMappingFromIdToMed
sschmitz 2012/09/25 01:41:43 I followed Yusuke's advice and left the way for sh
76 };
77 const size_t kMappingFromIdToMediumLengthNameLen =
78 ARRAYSIZE_UNSAFE(kMappingFromIdToMediumLengthName);
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
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(
Daniel Erat 2012/09/24 21:31:29 nit: make the order here match that in the header
sschmitz 2012/09/25 01:41:43 Done.
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 < kMappingFromIdToMediumLengthNameLen; ++i) {
410 if (kMappingFromIdToMediumLengthName[i].input_method_id ==
411 input_method.id())
412 return
413 UTF8ToUTF16(kMappingFromIdToMediumLengthName[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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698