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

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

Issue 7044044: Add pinyin-dv support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_TCVN_INPUT_METHOD }, 166 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_TCVN_INPUT_METHOD },
167 { "telex (m17n)", 167 { "telex (m17n)",
168 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_TELEX_INPUT_METHOD }, 168 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_TELEX_INPUT_METHOD },
169 { "viqr (m17n)", 169 { "viqr (m17n)",
170 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_VIQR_INPUT_METHOD }, 170 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_VIQR_INPUT_METHOD },
171 { "vni (m17n)", 171 { "vni (m17n)",
172 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_VNI_INPUT_METHOD }, 172 IDS_OPTIONS_SETTINGS_LANGUAGES_M17N_VIETNAMESE_VNI_INPUT_METHOD },
173 { "Mozc Chewing (Chewing)", 173 { "Mozc Chewing (Chewing)",
174 IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_INPUT_METHOD }, 174 IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_INPUT_METHOD },
175 { "Pinyin", IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_INPUT_METHOD }, 175 { "Pinyin", IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_INPUT_METHOD },
176 { "Pinyin (for US Dvorak keyboard)",
177 IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_DV_INPUT_METHOD },
176 { "Mozc (US keyboard layout)", 178 { "Mozc (US keyboard layout)",
177 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_MOZC_US_INPUT_METHOD }, 179 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_MOZC_US_INPUT_METHOD },
178 { "Mozc (US Dvorak keyboard layout)", 180 { "Mozc (US Dvorak keyboard layout)",
179 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_MOZC_US_DV_INPUT_METHOD }, 181 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_MOZC_US_DV_INPUT_METHOD },
180 { "Mozc (Japanese keyboard layout)", 182 { "Mozc (Japanese keyboard layout)",
181 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_MOZC_JP_INPUT_METHOD }, 183 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_MOZC_JP_INPUT_METHOD },
182 { "Google Japanese Input (US keyboard layout)", 184 { "Google Japanese Input (US keyboard layout)",
183 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_GOOGLE_US_INPUT_METHOD }, 185 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_GOOGLE_US_INPUT_METHOD },
184 { "Google Japanese Input (US Dvorak keyboard layout)", 186 { "Google Japanese Input (US Dvorak keyboard layout)",
185 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_GOOGLE_US_DV_INPUT_METHOD }, 187 IDS_OPTIONS_SETTINGS_LANGUAGES_JAPANESE_GOOGLE_US_DV_INPUT_METHOD },
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 bool IsKeyboardLayout(const std::string& input_method_id) { 445 bool IsKeyboardLayout(const std::string& input_method_id) {
444 const bool kCaseInsensitive = false; 446 const bool kCaseInsensitive = false;
445 return StartsWithASCII(input_method_id, "xkb:", kCaseInsensitive); 447 return StartsWithASCII(input_method_id, "xkb:", kCaseInsensitive);
446 } 448 }
447 449
448 std::string GetLanguageCodeFromDescriptor( 450 std::string GetLanguageCodeFromDescriptor(
449 const InputMethodDescriptor& descriptor) { 451 const InputMethodDescriptor& descriptor) {
450 // Handle some Chinese input methods as zh-CN/zh-TW, rather than zh. 452 // Handle some Chinese input methods as zh-CN/zh-TW, rather than zh.
451 // TODO: we should fix this issue in engines rather than here. 453 // TODO: we should fix this issue in engines rather than here.
452 if (descriptor.language_code == "zh") { 454 if (descriptor.language_code == "zh") {
453 if (descriptor.id == "pinyin") { 455 if (descriptor.id == "pinyin" || descriptor.id == "pinyin-dv") {
454 return "zh-CN"; 456 return "zh-CN";
455 } else if (descriptor.id == "mozc-chewing" || 457 } else if (descriptor.id == "mozc-chewing" ||
456 descriptor.id == "m17n:zh:cangjie" || 458 descriptor.id == "m17n:zh:cangjie" ||
457 descriptor.id == "m17n:zh:quick") { 459 descriptor.id == "m17n:zh:quick") {
458 return "zh-TW"; 460 return "zh-TW";
459 } 461 }
462 LOG(ERROR) << "Unhandled Chinese engine: " << descriptor.id;
460 } 463 }
461 464
462 std::string language_code = NormalizeLanguageCode(descriptor.language_code); 465 std::string language_code = NormalizeLanguageCode(descriptor.language_code);
463 466
464 // Add country codes to language codes of some XKB input methods to make 467 // Add country codes to language codes of some XKB input methods to make
465 // these compatible with Chrome's application locale codes like "en-US". 468 // these compatible with Chrome's application locale codes like "en-US".
466 // TODO(satorux): Maybe we need to handle "es" for "es-419". 469 // TODO(satorux): Maybe we need to handle "es" for "es-419".
467 // TODO: We should not rely on the format of the engine name. Should we add 470 // TODO: We should not rely on the format of the engine name. Should we add
468 // |country_code| in InputMethodDescriptor? 471 // |country_code| in InputMethodDescriptor?
469 if (IsKeyboardLayout(descriptor.id) && 472 if (IsKeyboardLayout(descriptor.id) &&
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 void ReloadInternalMaps() { 737 void ReloadInternalMaps() {
735 IdMaps::GetInstance()->ReloadMaps(); 738 IdMaps::GetInstance()->ReloadMaps();
736 } 739 }
737 740
738 void OnLocaleChanged() { 741 void OnLocaleChanged() {
739 ReloadInternalMaps(); 742 ReloadInternalMaps();
740 } 743 }
741 744
742 } // namespace input_method 745 } // namespace input_method
743 } // namespace chromeos 746 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698