diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 12:56:21 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-12 12:56:21 +0000 |
commit | 5227056258ea0db058dbe20dd9a898d2ed51df6b (patch) | |
tree | 5360d6741dfdb4e9e4a0c180df4d7e84b4bdcf10 | |
parent | 19999313aff414186305448b2363bdbefc12c63b (diff) | |
download | chromium_src-5227056258ea0db058dbe20dd9a898d2ed51df6b.zip chromium_src-5227056258ea0db058dbe20dd9a898d2ed51df6b.tar.gz chromium_src-5227056258ea0db058dbe20dd9a898d2ed51df6b.tar.bz2 |
Revert "Use libcros to convert input method ID to keyboard overlay ID."
This reverts commit 1d5eb805e2ca9cc97355cd73250f9838a5240a49.
TBR=satorux@chromium.org
BUG=chromium-os:9682
TEST=none
Review URL: http://codereview.chromium.org/6176007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71160 0039d316-1c4b-4281-b951-d872f2087c98
6 files changed, 97 insertions, 102 deletions
diff --git a/chrome/browser/chromeos/cros/input_method_library.cc b/chrome/browser/chromeos/cros/input_method_library.cc index ab2dc48..861230a 100644 --- a/chrome/browser/chromeos/cros/input_method_library.cc +++ b/chrome/browser/chromeos/cros/input_method_library.cc @@ -191,13 +191,6 @@ class InputMethodLibraryImpl : public InputMethodLibrary, return current_ime_properties_; } - virtual std::string GetKeyboardOverlayId(const std::string& input_method_id) { - if (EnsureLoadedAndStarted()) { - return chromeos::GetKeyboardOverlayId(input_method_id); - } - return ""; - } - private: // Starts input method processes based on the |defer_ime_startup_| flag and // input method configuration being updated. |section| is a section name of @@ -685,9 +678,7 @@ class InputMethodLibraryStubImpl : public InputMethodLibrary { public: InputMethodLibraryStubImpl() : previous_input_method_("", "", "", ""), - current_input_method_("", "", "", ""), - keyboard_overlay_map_( - CreateRealisticKeyboardOverlayMap()) { + current_input_method_("", "", "", "") { } ~InputMethodLibraryStubImpl() {} @@ -745,16 +736,7 @@ class InputMethodLibraryStubImpl : public InputMethodLibrary { virtual void SetDeferImeStartup(bool defer) {} virtual void SetEnableAutoImeShutdown(bool enable) {} - virtual std::string GetKeyboardOverlayId(const std::string& input_method_id) { - KeyboardOverlayMap::const_iterator iter = - keyboard_overlay_map_->find(input_method_id); - return (iter != keyboard_overlay_map_->end()) ? - iter->second : ""; - } - private: - typedef std::map<std::string, std::string> KeyboardOverlayMap; - // Creates realistic input method descriptors that can be used for // testing Chrome OS version of chrome on regular Linux desktops. InputMethodDescriptors* CreateRealisticInputMethodDescriptors() { @@ -883,83 +865,9 @@ class InputMethodLibraryStubImpl : public InputMethodLibrary { return descriptions; } - std::map<std::string, std::string>* CreateRealisticKeyboardOverlayMap() { - KeyboardOverlayMap* keyboard_overlay_map = - new KeyboardOverlayMap; - (*keyboard_overlay_map)["xkb:nl::nld"] = "nl"; - (*keyboard_overlay_map)["xkb:be::nld"] = "nl"; - (*keyboard_overlay_map)["xkb:fr::fra"] = "fr"; - (*keyboard_overlay_map)["xkb:be::fra"] = "fr"; - (*keyboard_overlay_map)["xkb:ca::fra"] = "fr_CA"; - (*keyboard_overlay_map)["xkb:ch:fr:fra"] = "fr"; - (*keyboard_overlay_map)["xkb:de::ger"] = "de"; - (*keyboard_overlay_map)["xkb:be::ger"] = "de"; - (*keyboard_overlay_map)["xkb:ch::ger"] = "de"; - (*keyboard_overlay_map)["mozc"] = "en_US"; - (*keyboard_overlay_map)["mozc-jp"] = "ja"; - (*keyboard_overlay_map)["mozc-dv"] = "en_US_dvorak"; - (*keyboard_overlay_map)["xkb:jp::jpn"] = "ja"; - (*keyboard_overlay_map)["xkb:ru::rus"] = "ru"; - (*keyboard_overlay_map)["xkb:ru:phonetic:rus"] = "ru"; - (*keyboard_overlay_map)["m17n:th:kesmanee"] = "th"; - (*keyboard_overlay_map)["m17n:th:pattachote"] = "th"; - (*keyboard_overlay_map)["m17n:th:tis820"] = "th"; - (*keyboard_overlay_map)["chewing"] = "zh_TW"; - (*keyboard_overlay_map)["m17n:zh:cangjie"] = "zh_TW"; - (*keyboard_overlay_map)["m17n:zh:quick"] = "zh_TW"; - (*keyboard_overlay_map)["m17n:vi:tcvn"] = "vi"; - (*keyboard_overlay_map)["m17n:vi:telex"] = "vi"; - (*keyboard_overlay_map)["m17n:vi:viqr"] = "vi"; - (*keyboard_overlay_map)["m17n:vi:vni"] = "vi"; - (*keyboard_overlay_map)["xkb:us::eng"] = "en_US"; - (*keyboard_overlay_map)["xkb:us:intl:eng"] = "en_US"; - (*keyboard_overlay_map)["xkb:us:altgr-intl:eng"] = "en_US"; - (*keyboard_overlay_map)["xkb:us:dvorak:eng"] = - "en_US_dvorak"; - (*keyboard_overlay_map)["xkb:us:colemak:eng"] = - "en_US"; - (*keyboard_overlay_map)["hangul"] = "ko"; - (*keyboard_overlay_map)["pinyin"] = "zh_CN"; - (*keyboard_overlay_map)["m17n:ar:kbd"] = "ar"; - (*keyboard_overlay_map)["m17n:hi:itrans"] = "hi"; - (*keyboard_overlay_map)["m17n:fa:isiri"] = "ar"; - (*keyboard_overlay_map)["xkb:br::por"] = "pt_BR"; - (*keyboard_overlay_map)["xkb:bg::bul"] = "bg"; - (*keyboard_overlay_map)["xkb:bg:phonetic:bul"] = "bg"; - (*keyboard_overlay_map)["xkb:ca:eng:eng"] = "ca"; - (*keyboard_overlay_map)["xkb:cz::cze"] = "cs"; - (*keyboard_overlay_map)["xkb:ee::est"] = "et"; - (*keyboard_overlay_map)["xkb:es::spa"] = "es"; - (*keyboard_overlay_map)["xkb:es:cat:cat"] = "ca"; - (*keyboard_overlay_map)["xkb:dk::dan"] = "da"; - (*keyboard_overlay_map)["xkb:gr::gre"] = "el"; - (*keyboard_overlay_map)["xkb:il::heb"] = "iw"; - (*keyboard_overlay_map)["xkb:kr:kr104:kor"] = "ko"; - (*keyboard_overlay_map)["xkb:latam::spa"] = "es_419"; - (*keyboard_overlay_map)["xkb:lt::lit"] = "lt"; - (*keyboard_overlay_map)["xkb:lv:apostrophe:lav"] = "lv"; - (*keyboard_overlay_map)["xkb:hr::scr"] = "hr"; - (*keyboard_overlay_map)["xkb:gb:extd:eng"] = "en_GB"; - (*keyboard_overlay_map)["xkb:fi::fin"] = "fi"; - (*keyboard_overlay_map)["xkb:hu::hun"] = "hu"; - (*keyboard_overlay_map)["xkb:it::ita"] = "it"; - (*keyboard_overlay_map)["xkb:no::nob"] = "no"; - (*keyboard_overlay_map)["xkb:pl::pol"] = "pl"; - (*keyboard_overlay_map)["xkb:pt::por"] = "pt_PT"; - (*keyboard_overlay_map)["xkb:ro::rum"] = "ro"; - (*keyboard_overlay_map)["xkb:se::swe"] = "sv"; - (*keyboard_overlay_map)["xkb:sk::slo"] = "sk"; - (*keyboard_overlay_map)["xkb:si::slv"] = "sl"; - (*keyboard_overlay_map)["xkb:rs::srp"] = "sr"; - (*keyboard_overlay_map)["xkb:tr::tur"] = "tr"; - (*keyboard_overlay_map)["xkb:ua::ukr"] = "uk"; - return keyboard_overlay_map; - } - InputMethodDescriptor previous_input_method_; InputMethodDescriptor current_input_method_; ImePropertyList current_ime_properties_; - scoped_ptr<KeyboardOverlayMap> keyboard_overlay_map_; DISALLOW_COPY_AND_ASSIGN(InputMethodLibraryStubImpl); }; diff --git a/chrome/browser/chromeos/cros/input_method_library.h b/chrome/browser/chromeos/cros/input_method_library.h index 26df7a7..0c62ead 100644 --- a/chrome/browser/chromeos/cros/input_method_library.h +++ b/chrome/browser/chromeos/cros/input_method_library.h @@ -101,11 +101,6 @@ class InputMethodLibrary { const std::string& config_name, const ImeConfigValue& value) = 0; - // Returns the keyboard overlay ID corresponding to |input_method_id|. - // Returns an empty string if there is no corresponding keyboard overlay ID. - virtual std::string GetKeyboardOverlayId( - const std::string& input_method_id) = 0; - // Sets the IME state to enabled, and launches its processes if needed. virtual void StartInputMethodProcesses() = 0; diff --git a/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc b/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc index d168190..9a2c0ce 100644 --- a/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc +++ b/chrome/browser/chromeos/dom_ui/keyboard_overlay_ui.cc @@ -269,12 +269,12 @@ void KeyboardOverlayHandler::RegisterMessages() { } void KeyboardOverlayHandler::GetKeyboardOverlayId(const ListValue* args) { - chromeos::InputMethodLibrary* library = + const chromeos::InputMethodLibrary* library = chromeos::CrosLibrary::Get()->GetInputMethodLibrary(); const chromeos::InputMethodDescriptor& descriptor = library->current_input_method(); const std::string keyboard_overlay_id = - library->GetKeyboardOverlayId(descriptor.id); + chromeos::input_method::GetKeyboardOverlayId(descriptor.id); StringValue param(keyboard_overlay_id); dom_ui_->CallJavascriptFunction(L"initKeyboardOverlayId", param); } diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index 28ca1c5..ced79ea 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -109,6 +109,7 @@ struct IdMaps { scoped_ptr<LanguageCodeToIdsMap> language_code_to_ids; scoped_ptr<std::map<std::string, std::string> > id_to_language_code; scoped_ptr<std::map<std::string, std::string> > id_to_display_name; + scoped_ptr<std::map<std::string, std::string> > id_to_keyboard_overlay_id; // Returns the singleton instance. static IdMaps* GetInstance() { @@ -128,6 +129,7 @@ struct IdMaps { language_code_to_ids->clear(); id_to_language_code->clear(); id_to_display_name->clear(); + id_to_keyboard_overlay_id->clear(); // Build the id to descriptor map for handling kExtraLanguages later. typedef std::map<std::string, @@ -145,6 +147,13 @@ struct IdMaps { std::make_pair(input_method.id, &input_method)); } + for (size_t i = 0; i < arraysize(kInputMethodIdToKeyboardOverlayId); ++i) { + InputMethodIdToKeyboardOverlayId id_pair = + kInputMethodIdToKeyboardOverlayId[i]; + id_to_keyboard_overlay_id->insert( + std::make_pair(id_pair.input_method_id, id_pair.keyboard_overlay_id)); + } + // Go through the languages listed in kExtraLanguages. using chromeos::input_method::kExtraLanguages; for (size_t i = 0; i < arraysize(kExtraLanguages); ++i) { @@ -163,7 +172,8 @@ struct IdMaps { private: IdMaps() : language_code_to_ids(new LanguageCodeToIdsMap), id_to_language_code(new std::map<std::string, std::string>), - id_to_display_name(new std::map<std::string, std::string>) { + id_to_display_name(new std::map<std::string, std::string>), + id_to_keyboard_overlay_id(new std::map<std::string, std::string>) { ReloadMaps(); } @@ -551,6 +561,14 @@ std::string GetKeyboardLayoutName(const std::string& input_method_id) { return (splitted_id.size() > 1) ? splitted_id[1] : ""; } +std::string GetKeyboardOverlayId(const std::string& input_method_id) { + const std::map<std::string, std::string>& id_map = + *(IdMaps::GetInstance()->id_to_keyboard_overlay_id); + std::map<std::string, std::string>::const_iterator iter = + id_map.find(input_method_id); + return (iter == id_map.end() ? "" : iter->second); +} + std::string GetInputMethodDisplayNameFromId( const std::string& input_method_id) { static const char kDefaultDisplayName[] = "USA"; diff --git a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc index fbcdd98..55cf34b 100644 --- a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc @@ -137,6 +137,80 @@ TEST(InputMethodUtilTest, GetKeyboardLayoutName) { EXPECT_EQ("us", GetKeyboardLayoutName("xkb:us:colemak:eng")); } +TEST(InputMethodUtilTest, GetKeyboardOverlayId) { + // Invalid IDs + EXPECT_EQ("", GetKeyboardOverlayId("")); + EXPECT_EQ("", GetKeyboardOverlayId("aaa")); + + // Valid IDs + EXPECT_EQ("nl", GetKeyboardOverlayId("xkb:nl::nld")); + EXPECT_EQ("nl", GetKeyboardOverlayId("xkb:be::nld")); + EXPECT_EQ("fr", GetKeyboardOverlayId("xkb:fr::fra")); + EXPECT_EQ("fr", GetKeyboardOverlayId("xkb:be::fra")); + EXPECT_EQ("fr_CA", GetKeyboardOverlayId("xkb:ca::fra")); + EXPECT_EQ("fr", GetKeyboardOverlayId("xkb:ch:fr:fra")); + EXPECT_EQ("de", GetKeyboardOverlayId("xkb:de::ger")); + EXPECT_EQ("de", GetKeyboardOverlayId("xkb:be::ger")); + EXPECT_EQ("de", GetKeyboardOverlayId("xkb:ch::ger")); + EXPECT_EQ("en_US", GetKeyboardOverlayId("mozc")); + EXPECT_EQ("ja", GetKeyboardOverlayId("mozc-jp")); + EXPECT_EQ("en_US_dvorak", GetKeyboardOverlayId("mozc-dv")); + EXPECT_EQ("ja", GetKeyboardOverlayId("xkb:jp::jpn")); + EXPECT_EQ("ru", GetKeyboardOverlayId("xkb:ru::rus")); + EXPECT_EQ("ru", GetKeyboardOverlayId("xkb:ru:phonetic:rus")); + EXPECT_EQ("th", GetKeyboardOverlayId("m17n:th:kesmanee")); + EXPECT_EQ("th", GetKeyboardOverlayId("m17n:th:pattachote")); + EXPECT_EQ("th", GetKeyboardOverlayId("m17n:th:tis820")); + EXPECT_EQ("zh_TW", GetKeyboardOverlayId("chewing")); + EXPECT_EQ("zh_TW", GetKeyboardOverlayId("m17n:zh:cangjie")); + EXPECT_EQ("zh_TW", GetKeyboardOverlayId("m17n:zh:quick")); + EXPECT_EQ("vi", GetKeyboardOverlayId("m17n:vi:tcvn")); + EXPECT_EQ("vi", GetKeyboardOverlayId("m17n:vi:telex")); + EXPECT_EQ("vi", GetKeyboardOverlayId("m17n:vi:viqr")); + EXPECT_EQ("vi", GetKeyboardOverlayId("m17n:vi:vni")); + EXPECT_EQ("en_US", GetKeyboardOverlayId("xkb:us::eng")); + EXPECT_EQ("en_US", GetKeyboardOverlayId("xkb:us:intl:eng")); + EXPECT_EQ("en_US", GetKeyboardOverlayId("xkb:us:altgr-intl:eng")); + EXPECT_EQ("en_US_dvorak", GetKeyboardOverlayId("xkb:us:dvorak:eng")); + // TODO(mazda): Add keyboard overlay definition for US Colemak. + EXPECT_EQ("en_US", GetKeyboardOverlayId("xkb:us:colemak:eng")); + EXPECT_EQ("ko", GetKeyboardOverlayId("hangul")); + EXPECT_EQ("zh_CN", GetKeyboardOverlayId("pinyin")); + EXPECT_EQ("ar", GetKeyboardOverlayId("m17n:ar:kbd")); + EXPECT_EQ("hi", GetKeyboardOverlayId("m17n:hi:itrans")); + EXPECT_EQ("ar", GetKeyboardOverlayId("m17n:fa:isiri")); + EXPECT_EQ("pt_BR", GetKeyboardOverlayId("xkb:br::por")); + EXPECT_EQ("bg", GetKeyboardOverlayId("xkb:bg::bul")); + EXPECT_EQ("bg", GetKeyboardOverlayId("xkb:bg:phonetic:bul")); + EXPECT_EQ("ca", GetKeyboardOverlayId("xkb:ca:eng:eng")); + EXPECT_EQ("cs", GetKeyboardOverlayId("xkb:cz::cze")); + EXPECT_EQ("et", GetKeyboardOverlayId("xkb:ee::est")); + EXPECT_EQ("es", GetKeyboardOverlayId("xkb:es::spa")); + EXPECT_EQ("ca", GetKeyboardOverlayId("xkb:es:cat:cat")); + EXPECT_EQ("da", GetKeyboardOverlayId("xkb:dk::dan")); + EXPECT_EQ("el", GetKeyboardOverlayId("xkb:gr::gre")); + EXPECT_EQ("iw", GetKeyboardOverlayId("xkb:il::heb")); + EXPECT_EQ("ko", GetKeyboardOverlayId("xkb:kr:kr104:kor")); + EXPECT_EQ("es_419", GetKeyboardOverlayId("xkb:latam::spa")); + EXPECT_EQ("lt", GetKeyboardOverlayId("xkb:lt::lit")); + EXPECT_EQ("lv", GetKeyboardOverlayId("xkb:lv:apostrophe:lav")); + EXPECT_EQ("hr", GetKeyboardOverlayId("xkb:hr::scr")); + EXPECT_EQ("en_GB", GetKeyboardOverlayId("xkb:gb:extd:eng")); + EXPECT_EQ("fi", GetKeyboardOverlayId("xkb:fi::fin")); + EXPECT_EQ("hu", GetKeyboardOverlayId("xkb:hu::hun")); + EXPECT_EQ("it", GetKeyboardOverlayId("xkb:it::ita")); + EXPECT_EQ("no", GetKeyboardOverlayId("xkb:no::nob")); + EXPECT_EQ("pl", GetKeyboardOverlayId("xkb:pl::pol")); + EXPECT_EQ("pt_PT", GetKeyboardOverlayId("xkb:pt::por")); + EXPECT_EQ("ro", GetKeyboardOverlayId("xkb:ro::rum")); + EXPECT_EQ("sv", GetKeyboardOverlayId("xkb:se::swe")); + EXPECT_EQ("sk", GetKeyboardOverlayId("xkb:sk::slo")); + EXPECT_EQ("sl", GetKeyboardOverlayId("xkb:si::slv")); + EXPECT_EQ("sr", GetKeyboardOverlayId("xkb:rs::srp")); + EXPECT_EQ("tr", GetKeyboardOverlayId("xkb:tr::tur")); + EXPECT_EQ("uk", GetKeyboardOverlayId("xkb:ua::ukr")); +} + TEST(InputMethodUtilTest, GetLanguageDisplayNameFromCode) { EXPECT_EQ(UTF8ToUTF16("Finnish"), GetLanguageDisplayNameFromCode("fi")); } diff --git a/tools/cros.DEPS/DEPS b/tools/cros.DEPS/DEPS index 166cf36..aa3d1a9 100644 --- a/tools/cros.DEPS/DEPS +++ b/tools/cros.DEPS/DEPS @@ -4,5 +4,5 @@ vars = { deps = { "src/third_party/cros": - Var("chromium_git") + "/cros.git@e9730f8a", + Var("chromium_git") + "/cros.git@09abaf51", } |