diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-15 13:22:07 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-07-15 13:22:07 +0000 |
commit | e434c89824290cdd49c606ce5c3cd2d488373554 (patch) | |
tree | c49746b3217b692193c62b8714c84c93aac5ada8 | |
parent | 6d5d988bf7e1d8996929f976e96d8cae1c6731ff (diff) | |
download | chromium_src-e434c89824290cdd49c606ce5c3cd2d488373554.zip chromium_src-e434c89824290cdd49c606ce5c3cd2d488373554.tar.gz chromium_src-e434c89824290cdd49c606ce5c3cd2d488373554.tar.bz2 |
Remove keyboard overlay ID from C++ code.
Originally the mapping from input method ID to keyboard overlay ID was written
in ibus_input_methods.txt.
I moved this to gen_keyboard_overlay_data.py and made the deta be generated in
keyboard_overlay_data.js.
I also modified gen_keyboard_overlay_data.py to generate a list of input method
IDs that shouldn't remap the right alt key in xkeyboard.cc instead of a list of
keyboard overlay IDs.
These changes make the two functions related to keyboard overlay ID in
input_method_util.{h,cc} unnecessary.
I also deleted keyboard overlay data for en_fr_hybrid_CA, ar_fr, id and fil, which was unused.
BUG=chromium-os:17592
TEST=Ran unit_tests and manually tested on the chromebook
Review URL: http://codereview.chromium.org/7370001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92687 0039d316-1c4b-4281-b951-d872f2087c98
9 files changed, 339 insertions, 1372 deletions
diff --git a/chrome/browser/chromeos/input_method/gen_ibus_input_methods.py b/chrome/browser/chromeos/input_method/gen_ibus_input_methods.py index 1b78b605..fe98658 100644 --- a/chrome/browser/chromeos/input_method/gen_ibus_input_methods.py +++ b/chrome/browser/chromeos/input_method/gen_ibus_input_methods.py @@ -58,14 +58,13 @@ struct IBusEngineInfo { const char* input_method_id; const char* language_code; const char* xkb_layout_id; - const char* keyboard_overlay_id; }; const IBusEngineInfo kIBusEngines[] = { """ CPP_FORMAT = '#if %s\n' ENGINE_FORMAT = (' {"%(input_method_id)s", "%(language_code)s", ' + - '"%(xkb_layout_id)s", "%(keyboard_overlay_id)s"},\n') + '"%(xkb_layout_id)s"},\n') OUTPUT_FOOTER = """ }; @@ -107,14 +106,13 @@ def main(argv): if not line or re.match(r'#', line): continue columns = line.split() - assert len(columns) == 4 or len(columns) == 5, "Invalid format: " + line + assert len(columns) == 3 or len(columns) == 4, "Invalid format: " + line engine = {} engine['input_method_id'] = columns[0] engine['xkb_layout_id'] = columns[1] - engine['keyboard_overlay_id'] = columns[2] - engine['language_code'] = columns[3] - if len(columns) == 5: - engine['if'] = columns[4] + engine['language_code'] = columns[2] + if len(columns) == 4: + engine['if'] = columns[3] engines.append(engine) output = CreateEngineHeader(engines) diff --git a/chrome/browser/chromeos/input_method/ibus_input_methods.txt b/chrome/browser/chromeos/input_method/ibus_input_methods.txt index bb60d6b..8bf24cd 100644 --- a/chrome/browser/chromeos/input_method/ibus_input_methods.txt +++ b/chrome/browser/chromeos/input_method/ibus_input_methods.txt @@ -28,119 +28,127 @@ # # 1) The input method ID used by IBus. (ex. "xkb:ca::fra") # 2) The keyboard layout ID used by XKB. (ex. "ca", "handwriting-vk,jp") -# 3) The keyboard overlay ID. (ex. "fra_CA") *1 -# 4) The language code (ex. "fra") -# 5) [optional] The #if condition for the input method. +# 3) The language code (ex. "fra") +# 4) [optional] The #if condition for the input method. # (ex. "defined(A)", "!defined(A)||defined(B)") # # Notes: -# *1 For some complicated reason, we use different IDs for 2) and 3). Ask -# mazda for why. +# When adding a line to this list, please also add a mapping from the input +# method ID to the keyboard overlay ID to INPUT_METHOD_ID_TO_OVERLAY_ID in +# +# * tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py +# +# and update the following files by running this script. +# +# * chrome/app/generated_resources.grd +# * chrome/browser/chromeos/input_method/xkeyboard.cc +# * chrome/browser/resources/keyboard_overlay_data.js +# * chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc # U.S. English -xkb:us::eng us en_US eng -xkb:us:intl:eng us(intl) en_US_intl eng -xkb:us:altgr-intl:eng us(altgr-intl) en_US_altgr_intl eng -xkb:us:dvorak:eng us(dvorak) en_US_dvorak eng -xkb:us:colemak:eng us(colemak) en_US_colemak eng +xkb:us::eng us eng +xkb:us:intl:eng us(intl) eng +xkb:us:altgr-intl:eng us(altgr-intl) eng +xkb:us:dvorak:eng us(dvorak) eng +xkb:us:colemak:eng us(colemak) eng # U.S. English entiries have to be above the Dutch entry so that xkb:us:intl:eng # will be selected as the default keyboard when the UI language is set to Dutch. # Dutch -xkb:be::nld be nl nld +xkb:be::nld be nld # We don't support xkb:nl::nld. See b/4430951. # French -xkb:fr::fra fr fr fra -xkb:be::fra be fr fra -xkb:ca::fra ca fr_CA fra -xkb:ch:fr:fra ch(fr) fr fra +xkb:fr::fra fr fra +xkb:be::fra be fra +xkb:ca::fra ca fra +xkb:ch:fr:fra ch(fr) fra # German -xkb:de::ger de de ger -xkb:de:neo:ger de(neo) de_neo ger -xkb:be::ger be de ger -xkb:ch::ger ch de ger +xkb:de::ger de ger +xkb:de:neo:ger de(neo) ger +xkb:be::ger be ger +xkb:ch::ger ch ger # Japanese -mozc us en_US ja -mozc-jp jp ja ja -mozc-dv us(dvorak) en_US_dvorak ja -xkb:jp::jpn jp ja jpn -zinnia-japanese handwriting-vk,jp ja ja defined(TOUCH_UI) +mozc us ja +mozc-jp jp ja +mozc-dv us(dvorak) ja +xkb:jp::jpn jp jpn +zinnia-japanese handwriting-vk,jp ja defined(TOUCH_UI) # Russian -xkb:ru::rus ru ru rus -xkb:ru:phonetic:rus ru(phonetic) ru rus +xkb:ru::rus ru rus +xkb:ru:phonetic:rus ru(phonetic) rus # Thai -m17n:th:kesmanee us th th -m17n:th:pattachote us th th -m17n:th:tis820 us th th +m17n:th:kesmanee us th +m17n:th:pattachote us th +m17n:th:tis820 us th # Simplified Chinese -pinyin us zh_CN zh-CN -pinyin-dv us(dvorak) en_US_dvorak zh-CN +pinyin us zh-CN +pinyin-dv us(dvorak) zh-CN # TODO(yusukes): Define zh_CN_dvorak if it's *really* necessary. # Traditional Chinese -mozc-chewing us zh_TW zh_TW -m17n:zh:cangjie us zh_TW zh -m17n:zh:quick us zh_TW zh +mozc-chewing us zh_TW +m17n:zh:cangjie us zh +m17n:zh:quick us zh # TODO(suzhe): Add CantonHK and Stroke5 if (it's really) necessary. # Vietnamese -m17n:vi:tcvn us vi vi -m17n:vi:telex us vi vi -m17n:vi:viqr us vi vi -m17n:vi:vni us vi vi +m17n:vi:tcvn us vi +m17n:vi:telex us vi +m17n:vi:viqr us vi +m17n:vi:vni us vi # Note: Since ibus-m17n does not support "get-surrounding-text" feature yet, # Vietnames input methods, except 4 input methods above, in m17n-db should # not work fine. The 4 input methods in m17n-db (>= 1.6.0) don't require the # feature. # Other languages -hangul kr(kr104) ko ko +hangul kr(kr104) ko # ibus-m17n input methods. -m17n:ar:kbd us ar ar -m17n:hi:itrans us hi hi +m17n:ar:kbd us ar +m17n:hi:itrans us hi # Note: the m17n-contrib package has some more Hindi definitions. -m17n:fa:isiri us ar fa +m17n:fa:isiri us fa # TODO(yusukes,jshin): Check if we can use ibux-xkb-layouts for these languages. # ibux-xkb-layouts input methods (keyboard layouts). -xkb:br::por br pt_BR por -xkb:bg::bul bg bg bul -xkb:bg:phonetic:bul bg(phonetic) bg bul -xkb:ca:eng:eng ca(eng) ca eng -xkb:cz::cze cz cs cze -xkb:ee::est ee et est -xkb:es::spa es es spa -xkb:es:cat:cat es(cat) ca cat -xkb:dk::dan dk da dan -xkb:gr::gre gr el gre -xkb:il::heb il iw heb -xkb:kr:kr104:kor kr(kr104) ko kor -xkb:latam::spa latam es_419 spa -xkb:lt::lit lt lt lit -xkb:lv:apostrophe:lav lv(apostrophe) lv lav -xkb:hr::scr hr hr scr -xkb:gb:extd:eng gb(extd) en_GB eng -xkb:gb:dvorak:eng gb(dvorak) en_GB_dvorak eng -xkb:fi::fin fi fi fin -xkb:hu::hun hu hu hun -xkb:it::ita it it ita -xkb:no::nob no no nob -xkb:pl::pol pl pl pol -xkb:pt::por pt pt_PT por -xkb:ro::rum ro ro rum -xkb:se::swe se sv swe -xkb:sk::slo sk sk slo -xkb:si::slv si sl slv -xkb:rs::srp rs sr srp -xkb:tr::tur tr tr tur -xkb:ua::ukr ua uk ukr +xkb:br::por br por +xkb:bg::bul bg bul +xkb:bg:phonetic:bul bg(phonetic) bul +xkb:ca:eng:eng ca(eng) eng +xkb:cz::cze cz cze +xkb:ee::est ee est +xkb:es::spa es spa +xkb:es:cat:cat es(cat) cat +xkb:dk::dan dk dan +xkb:gr::gre gr gre +xkb:il::heb il heb +xkb:kr:kr104:kor kr(kr104) kor +xkb:latam::spa latam spa +xkb:lt::lit lt lit +xkb:lv:apostrophe:lav lv(apostrophe) lav +xkb:hr::scr hr scr +xkb:gb:extd:eng gb(extd) eng +xkb:gb:dvorak:eng gb(dvorak) eng +xkb:fi::fin fi fin +xkb:hu::hun hu hun +xkb:it::ita it ita +xkb:no::nob no nob +xkb:pl::pol pl pol +xkb:pt::por pt por +xkb:ro::rum ro rum +xkb:se::swe se swe +xkb:sk::slo sk slo +xkb:si::slv si slv +xkb:rs::srp rs srp +xkb:tr::tur tr tur +xkb:ua::ukr ua ukr # TODO(yusukes): Support xkb:latam:deadtilde:spa and/or xkb:latam:nodeadkeys:spa # if necessary. diff --git a/chrome/browser/chromeos/input_method/input_method_util.cc b/chrome/browser/chromeos/input_method/input_method_util.cc index cb5e0fe..7bac1ce 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.cc +++ b/chrome/browser/chromeos/input_method/input_method_util.cc @@ -38,14 +38,11 @@ typedef std::multimap<std::string, std::string> LanguageCodeToIdsMap; // Map from input method ID to associated input method descriptor. typedef std::map<std::string, InputMethodDescriptor> InputMethodIdToDescriptorMap; -// Map from layout name to associated overlay ID -typedef std::map<std::string, std::string> InputMethodNameToOverlayIdMap; struct IdMaps { scoped_ptr<LanguageCodeToIdsMap> language_code_to_ids; scoped_ptr<std::map<std::string, std::string> > id_to_language_code; scoped_ptr<InputMethodIdToDescriptorMap> id_to_descriptor; - scoped_ptr<std::map<std::string, std::string> > name_to_overlay_id; // Returns the singleton instance. static IdMaps* GetInstance() { @@ -64,7 +61,6 @@ struct IdMaps { language_code_to_ids->clear(); id_to_language_code->clear(); id_to_descriptor->clear(); - name_to_overlay_id->clear(); for (size_t i = 0; i < supported_input_methods->size(); ++i) { const InputMethodDescriptor& input_method = @@ -99,8 +95,7 @@ struct IdMaps { private: IdMaps() : language_code_to_ids(new LanguageCodeToIdsMap), id_to_language_code(new std::map<std::string, std::string>), - id_to_descriptor(new InputMethodIdToDescriptorMap), - name_to_overlay_id(new std::map<std::string, std::string>) { + id_to_descriptor(new InputMethodIdToDescriptorMap) { ReloadMaps(); } @@ -497,24 +492,6 @@ std::string GetKeyboardLayoutName(const std::string& input_method_id) { "" : iter->second.keyboard_layout(); } -std::string GetKeyboardOverlayId(const std::string& input_method_id) { - for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { - if (kIBusEngines[i].input_method_id == input_method_id) { - return kIBusEngines[i].keyboard_overlay_id; - } - } - return ""; -} - -std::string GetKeyboardOverlayIdFromXkb(const std::string& xkb_layout_id) { - for (size_t i = 0; i < arraysize(kIBusEngines); ++i) { - if (kIBusEngines[i].xkb_layout_id == xkb_layout_id) { - return kIBusEngines[i].keyboard_overlay_id; - } - } - return ""; -} - std::string GetInputMethodDisplayNameFromId( const std::string& input_method_id) { const std::string display_name = diff --git a/chrome/browser/chromeos/input_method/input_method_util.h b/chrome/browser/chromeos/input_method/input_method_util.h index 6a729a8..2b13f42 100644 --- a/chrome/browser/chromeos/input_method/input_method_util.h +++ b/chrome/browser/chromeos/input_method/input_method_util.h @@ -83,26 +83,6 @@ std::string GetLanguageCodeFromDescriptor( // "pinyin" => "us" (because Pinyin uses US keyboard layout) std::string GetKeyboardLayoutName(const std::string& input_method_id); -// Gets the ID for the keyboard overlay from the given input method ID. -// If the ID is invalid, an empty string will be returned. -// -// Examples: -// -// "xkb:us::eng" => "en_US" -// "xkb:us:dvorak:eng" => "en_US_dvorak" -// "xkb:gb::eng" => "en_GB" -std::string GetKeyboardOverlayId(const std::string& input_method_id); - -// Gets the ID for the keyboard overlay from the given xkb layout ID. -// If the ID is invalid, an empty string will be returned. -// -// Examples: -// -// "us" => "en_US" -// "us(dvorak)" => "en_US_dvorak" -// "gb(extd)" => "en_GB" -std::string GetKeyboardOverlayIdFromXkb(const std::string& xkb_layout_id); - // Converts an input method ID to a language code of the IME. Returns "Eng" // when |input_method_id| is unknown. // Example: "hangul" => "ko" diff --git a/chrome/browser/chromeos/input_method/xkeyboard.cc b/chrome/browser/chromeos/input_method/xkeyboard.cc index cafea2b..ef3245f 100644 --- a/chrome/browser/chromeos/input_method/xkeyboard.cc +++ b/chrome/browser/chromeos/input_method/xkeyboard.cc @@ -6,6 +6,8 @@ #include <queue> #include <utility> +#include <set> +#include <string> #include <X11/XKBlib.h> #include <X11/Xlib.h> @@ -13,6 +15,7 @@ #include <stdlib.h> #include <string.h> +#include "base/memory/scoped_ptr.h" #include "base/memory/singleton.h" #include "base/logging.h" #include "base/string_util.h" @@ -39,69 +42,95 @@ ModifierKey kCustomizableKeys[] = { }; // These arrays are generated by 'gen_keyboard_overlay_data.py --altgr' -// These are the overlay names of layouts that shouldn't -// remap the right alt key. -const char* kKeepRightAltOverlays[] = { - "el", - "ca", - "it", - "iw", - "es_419", - "cs", - "et", - "es", - "en_US_altgr_intl", - "de_neo", - "nl", - "no", - "tr", - "lt", - "pt_PT", - "en_GB_dvorak", - "fr", - "bg", - "pt_BR", - "en_fr_hybrid_CA", - "hr", - "da", - "fi", - "fr_CA", - "ko", - "sv", - "sk", - "de", - "en_GB", - "pl", - "uk", - "sl", - "en_US_intl", +// These are the input method IDs that shouldn't remap the right alt key. +const char* kKeepRightAltInputMethods[] = { + "xkb:de:neo:ger", + "xkb:il::heb", + "xkb:gb:extd:eng", + "xkb:fr::fra", + "xkb:be::nld", + "xkb:no::nob", + "xkb:fi::fin", + "xkb:sk::slo", + "xkb:ca:eng:eng", + "xkb:es::spa", + "xkb:it::ita", + "hangul", + "xkb:ua::ukr", + "xkb:ch:fr:fra", + "xkb:bg::bul", + "xkb:de::ger", + "xkb:be::ger", + "xkb:latam::spa", + "xkb:pl::pol", + "xkb:bg:phonetic:bul", + "xkb:ee::est", + "xkb:gr::gre", + "xkb:tr::tur", + "xkb:br::por", + "xkb:es:cat:cat", + "xkb:pt::por", + "xkb:be::fra", + "xkb:si::slv", + "xkb:ch::ger", + "xkb:se::swe", + "xkb:hr::scr", + "xkb:ca::fra", + "xkb:lt::lit", + "xkb:kr:kr104:kor", + "xkb:gb:dvorak:eng", + "xkb:us:altgr-intl:eng", + "xkb:cz::cze", + "xkb:dk::dan", + "xkb:us:intl:eng", }; // These are the overlay names with caps lock remapped const char* kCapsLockRemapped[] = { - "de_neo", - "en_US_colemak", + "xkb:de:neo:ger", + "xkb:us:colemak:eng", }; -bool KeepRightAlt(const std::string& xkb_layout_name) { - const std::string overlay_id = GetKeyboardOverlayIdFromXkb(xkb_layout_name); - for (size_t c = 0; c < arraysize(kKeepRightAltOverlays); ++c) { - if (overlay_id == kKeepRightAltOverlays[c]) { - return true; - } +class XkbLayoutSets { + public: + // Returns the singleton instance. + static XkbLayoutSets* GetInstance() { + return Singleton<XkbLayoutSets>::get(); } - return false; -} -bool KeepCapsLock(const std::string& xkb_layout_name) { - const std::string overlay_id = GetKeyboardOverlayIdFromXkb(xkb_layout_name); - for (size_t c = 0; c < arraysize(kCapsLockRemapped); ++c) { - if (overlay_id == kCapsLockRemapped[c]) { - return true; + static bool KeepRightAlt(const std::string& xkb_layout_name) { + const std::set<std::string>* layouts = XkbLayoutSets::GetInstance()-> + keep_right_alt_xkb_layout_names_.get(); + return layouts->find(xkb_layout_name) != layouts->end(); + } + + static bool KeepCapsLock(const std::string& xkb_layout_name) { + const std::set<std::string>* layouts = XkbLayoutSets::GetInstance()-> + caps_lock_remapped_xkb_layout_names_.get(); + return layouts->find(xkb_layout_name) != layouts->end(); + } + + private: + XkbLayoutSets() + : keep_right_alt_xkb_layout_names_(new std::set<std::string>), + caps_lock_remapped_xkb_layout_names_(new std::set<std::string>) { + for (size_t i = 0; i < arraysize(kKeepRightAltInputMethods); ++i) { + keep_right_alt_xkb_layout_names_->insert( + GetKeyboardLayoutName(kKeepRightAltInputMethods[i])); + } + for (size_t i = 0; i < arraysize(kCapsLockRemapped); ++i) { + caps_lock_remapped_xkb_layout_names_->insert( + GetKeyboardLayoutName(kCapsLockRemapped[i])); } } - return false; -} + + scoped_ptr<std::set<std::string> > keep_right_alt_xkb_layout_names_; + scoped_ptr<std::set<std::string> > caps_lock_remapped_xkb_layout_names_; + + friend struct DefaultSingletonTraits<XkbLayoutSets>; + + DISALLOW_COPY_AND_ASSIGN(XkbLayoutSets); +}; // A singleton class which wraps the setxkbmap command. class XKeyboard { @@ -349,7 +378,7 @@ std::string CreateFullXkbLayoutName(const std::string& layout_name, return ""; } - if (KeepCapsLock(layout_name)) { + if (XkbLayoutSets::KeepCapsLock(layout_name)) { use_search_key_as_str = ModifierKeyToString(kSearchKey); } @@ -358,7 +387,7 @@ std::string CreateFullXkbLayoutName(const std::string& layout_name, use_search_key_as_str.c_str(), use_left_control_key_as_str.c_str(), use_left_alt_key_as_str.c_str(), - KeepRightAlt(layout_name) ? "_keepralt" : ""); + XkbLayoutSets::KeepRightAlt(layout_name) ? "_keepralt" : ""); if ((full_xkb_layout_name.substr(0, 3) != "us+") && (full_xkb_layout_name.substr(0, 3) != "us(")) { diff --git a/chrome/browser/resources/keyboard_overlay.js b/chrome/browser/resources/keyboard_overlay.js index 4a6119e..d73caaf 100644 --- a/chrome/browser/resources/keyboard_overlay.js +++ b/chrome/browser/resources/keyboard_overlay.js @@ -433,19 +433,24 @@ function initIdentifierMap(remap) { console.error('Invalid label map element: ' + key + ', ' + val); } } - chrome.send('getKeyboardOverlayId'); + chrome.send('getInputMethodId'); } /** * Initializes the global keyboad overlay ID and the layout of keys. - * Called after sending the 'getKeyboardOverlayId' message. + * Called after sending the 'getInputMethodId' message. */ -function initKeyboardOverlayId(overlayId) { +function initKeyboardOverlayId(inputMethodId) { // Libcros returns an empty string when it cannot find the keyboard overlay ID // corresponding to the current input method. // In such a case, fallback to the default ID (en_US). - if (overlayId) { - keyboardOverlayId = overlayId; + var inputMethodIdToOverlayId = keyboardOverlayData['inputMethodIdToOverlayId'] + if (inputMethodId) { + keyboardOverlayId = inputMethodIdToOverlayId[inputMethodId]; + } + if (!keyboardOverlayId) { + console.error('No keyboard overlay ID for ' + inputMethodId); + keyboardOverlayId = 'en_US'; } while(document.body.firstChild) { document.body.removeChild(document.body.firstChild); diff --git a/chrome/browser/resources/keyboard_overlay_data.js b/chrome/browser/resources/keyboard_overlay_data.js index 9cfab93..05a390d 100644 --- a/chrome/browser/resources/keyboard_overlay_data.js +++ b/chrome/browser/resources/keyboard_overlay_data.js @@ -3,6 +3,76 @@ // found in the LICENSE file. var keyboardOverlayData = { + "inputMethodIdToOverlayId": { + "hangul": "ko", + "m17n:ar:kbd": "ar", + "m17n:fa:isiri": "ar", + "m17n:hi:itrans": "hi", + "m17n:th:kesmanee": "th", + "m17n:th:pattachote": "th", + "m17n:th:tis820": "th", + "m17n:vi:tcvn": "vi", + "m17n:vi:telex": "vi", + "m17n:vi:viqr": "vi", + "m17n:vi:vni": "vi", + "m17n:zh:cangjie": "zh_TW", + "m17n:zh:quick": "zh_TW", + "mozc": "en_US", + "mozc-chewing": "zh_TW", + "mozc-dv": "en_US_dvorak", + "mozc-jp": "ja", + "pinyin": "zh_CN", + "pinyin-dv": "en_US_dvorak", + "xkb:be::fra": "fr", + "xkb:be::ger": "de", + "xkb:be::nld": "nl", + "xkb:bg::bul": "bg", + "xkb:bg:phonetic:bul": "bg", + "xkb:br::por": "pt_BR", + "xkb:ca::fra": "fr_CA", + "xkb:ca:eng:eng": "ca", + "xkb:ch::ger": "de", + "xkb:ch:fr:fra": "fr", + "xkb:cz::cze": "cs", + "xkb:de::ger": "de", + "xkb:de:neo:ger": "de_neo", + "xkb:dk::dan": "da", + "xkb:ee::est": "et", + "xkb:es::spa": "es", + "xkb:es:cat:cat": "ca", + "xkb:fi::fin": "fi", + "xkb:fr::fra": "fr", + "xkb:gb:dvorak:eng": "en_GB_dvorak", + "xkb:gb:extd:eng": "en_GB", + "xkb:gr::gre": "el", + "xkb:hr::scr": "hr", + "xkb:hu::hun": "hu", + "xkb:il::heb": "iw", + "xkb:it::ita": "it", + "xkb:jp::jpn": "ja", + "xkb:kr:kr104:kor": "ko", + "xkb:latam::spa": "es_419", + "xkb:lt::lit": "lt", + "xkb:lv:apostrophe:lav": "lv", + "xkb:no::nob": "no", + "xkb:pl::pol": "pl", + "xkb:pt::por": "pt_PT", + "xkb:ro::rum": "ro", + "xkb:rs::srp": "sr", + "xkb:ru::rus": "ru", + "xkb:ru:phonetic:rus": "ru", + "xkb:se::swe": "sv", + "xkb:si::slv": "sl", + "xkb:sk::slo": "sk", + "xkb:tr::tur": "tr", + "xkb:ua::ukr": "uk", + "xkb:us::eng": "en_US", + "xkb:us:altgr-intl:eng": "en_US_altgr_intl", + "xkb:us:colemak:eng": "en_US_colemak", + "xkb:us:dvorak:eng": "en_US_dvorak", + "xkb:us:intl:eng": "en_US_intl", + "zinnia-japanese": "ja" + }, "keyboardGlyph": { "ar": { "keys": { @@ -336,326 +406,6 @@ var keyboardOverlayData = { }, "layoutName": "U" }, - "ar_fr": { - "keys": { - "00": { - "label": "power" - }, - "01": { - "format": "smaller", - "label": "esc" - }, - "02": { - "p1": "21", - "p7": "31" - }, - "03": { - "p1": "40", - "p7": "32" - }, - "04": { - "p1": "23", - "p7": "33" - }, - "05": { - "p1": "24", - "p7": "34" - }, - "06": { - "p1": "66A", - "p7": "35" - }, - "07": { - "p1": "5E", - "p7": "36" - }, - "08": { - "p1": "26", - "p7": "37" - }, - "09": { - "p1": "66D", - "p7": "38" - }, - "0A": { - "p1": "28", - "p7": "39" - }, - "0B": { - "p1": "29", - "p7": "30" - }, - "0C": { - "p1": "5F", - "p7": "2D" - }, - "0D": { - "p1": "2B", - "p7": "3D" - }, - "0E": { - "format": "right", - "label": "backspace" - }, - "0F": { - "format": "left", - "label": "tab" - }, - "10": { - "p1": "064E", - "p5": "71", - "p7": "FEBF" - }, - "11": { - "p1": "064B", - "p5": "77", - "p7": "FEBB" - }, - "12": { - "p1": "064F", - "p5": "65", - "p7": "FE9B" - }, - "13": { - "p1": "064C", - "p5": "72", - "p7": "FED7" - }, - "14": { - "p1": "FEF9", - "p5": "74", - "p7": "FED3" - }, - "15": { - "p1": "FE87", - "p5": "79", - "p7": "FECF" - }, - "16": { - "p1": "60", - "p5": "75", - "p7": "FECB" - }, - "17": { - "p1": "F7", - "p5": "69", - "p7": "FEEB" - }, - "18": { - "p1": "D7", - "p5": "6F", - "p7": "FEA7" - }, - "19": { - "p1": "61B", - "p5": "70", - "p7": "FEA3" - }, - "1A": { - "p1": "3C", - "p7": "FE9F" - }, - "1B": { - "p1": "3E", - "p7": "FEA9" - }, - "1C": { - "format": "right", - "label": "enter" - }, - "1D": { - "format": "left", - "label": "ctrl" - }, - "1E": { - "p1": "650", - "p5": "61", - "p7": "FEB7" - }, - "1F": { - "p1": "064D", - "p5": "73", - "p7": "FEB3" - }, - "20": { - "p1": "005B", - "p5": "64", - "p7": "FEF3" - }, - "21": { - "p1": "005D", - "p5": "66", - "p7": "FE91" - }, - "22": { - "p1": "FEF7", - "p5": "67", - "p7": "FEDF" - }, - "23": { - "p1": "FE83", - "p5": "68", - "p7": "FE8D" - }, - "24": { - "p1": "640", - "p5": "6A", - "p7": "FE97" - }, - "25": { - "p1": "060C", - "p5": "6B", - "p7": "FEE7" - }, - "26": { - "p1": "002F", - "p5": "6C", - "p7": "FEE3" - }, - "27": { - "p1": "003A", - "p7": "FEDB" - }, - "28": { - "p1": "22", - "p7": "FEC3" - }, - "29": { - "p1": "FE7C", - "p7": "FEAB" - }, - "2A": { - "format": "left", - "label": "shift" - }, - "2B": { - "p1": "007c", - "p7": "005c" - }, - "2C": { - "p1": "007E", - "p5": "7A", - "p7": "FE8B" - }, - "2D": { - "p1": "FE7E", - "p5": "78", - "p7": "FE80" - }, - "2E": { - "p1": "007B", - "p5": "63", - "p7": "FE85" - }, - "2F": { - "p1": "007D", - "p5": "76", - "p7": "FEAD" - }, - "30": { - "p1": "FEF5", - "p5": "62", - "p7": "FEFB" - }, - "31": { - "p1": "FE81", - "p5": "6E", - "p7": "FEEF" - }, - "32": { - "p1": "27", - "p5": "6D", - "p7": "FE93" - }, - "33": { - "p1": "002C", - "p7": "FEED" - }, - "34": { - "p1": "002E", - "p7": "FEAF" - }, - "35": { - "p1": "61F", - "p7": "FEC7" - }, - "36": { - "format": "right", - "label": "shift" - }, - "37": {}, - "38": { - "format": "left", - "label": "alt" - }, - "39": { - "label": "space" - }, - "3B": { - "label": "back" - }, - "3C": { - "label": "forward" - }, - "3D": { - "label": "maximize" - }, - "3E": { - "label": "full screen" - }, - "3F": { - "label": "tools" - }, - "40": { - "label": "bright down" - }, - "41": { - "label": "bright up" - }, - "42": { - "label": "mute" - }, - "43": { - "label": "vol. down" - }, - "44": { - "label": "vol. up" - }, - "73": {}, - "79": { - "format": "smaller" - }, - "7B": { - "format": "smaller" - }, - "7D": {}, - "E0 1D": { - "format": "smaller", - "label": "ctrl" - }, - "E0 38": { - "format": "smaller", - "label": "alt" - }, - "E0 48": { - "label": "up" - }, - "E0 4B": { - "label": "left" - }, - "E0 4D": { - "label": "right" - }, - "E0 50": { - "label": "down" - }, - "E0 5B": { - "format": "left", - "label": "search" - } - }, - "layoutName": "U" - }, "bg": { "keys": { "00": { @@ -4543,313 +4293,6 @@ var keyboardOverlayData = { }, "layoutName": "U" }, - "en_fr_hybrid_CA": { - "keys": { - "00": { - "label": "power" - }, - "01": { - "format": "smaller", - "label": "esc" - }, - "02": { - "p1": "21", - "p5": "31", - "p9": "B1" - }, - "03": { - "p1": "40", - "p3": "22", - "p5": "32", - "p9": "40" - }, - "04": { - "p1": "23", - "p3": "2F", - "p5": "33", - "p9": "A3" - }, - "05": { - "p1": "24", - "p5": "34", - "p9": "A2" - }, - "06": { - "p1": "25", - "p5": "35", - "p9": "A4" - }, - "07": { - "p1": "005E", - "p3": "3F", - "p5": "36", - "p9": "AC" - }, - "08": { - "p1": "26", - "p5": "37", - "p9": "A6" - }, - "09": { - "p1": "2A", - "p5": "38", - "p9": "B2" - }, - "0A": { - "p1": "28", - "p5": "39", - "p9": "B3" - }, - "0B": { - "p1": "29", - "p5": "30", - "p9": "BC" - }, - "0C": { - "p1": "5F", - "p5": "2D", - "p9": "BD" - }, - "0D": { - "p1": "2B", - "p5": "3D", - "p9": "BE" - }, - "0E": { - "format": "right", - "label": "backspace" - }, - "0F": { - "format": "left", - "label": "tab" - }, - "10": { - "p5": "71" - }, - "11": { - "p5": "77" - }, - "12": { - "p5": "65" - }, - "13": { - "p5": "72" - }, - "14": { - "p5": "74" - }, - "15": { - "p5": "79" - }, - "16": { - "p5": "75" - }, - "17": { - "p5": "69" - }, - "18": { - "p5": "006F", - "p9": "00A7" - }, - "19": { - "p5": "70", - "p9": "00B6" - }, - "1A": { - "p1": "7B", - "p3": "5E", - "p7": "5B", - "p8": "5B", - "p9": "5E" - }, - "1B": { - "p1": "7D", - "p3": "A8", - "p7": "5D", - "p8": "5D", - "p9": "B8" - }, - "1C": { - "format": "right", - "label": "enter" - }, - "1D": { - "format": "left", - "label": "ctrl" - }, - "1E": { - "p5": "61" - }, - "1F": { - "p5": "73" - }, - "20": { - "p5": "64" - }, - "21": { - "p5": "66" - }, - "22": { - "p5": "67" - }, - "23": { - "p5": "68" - }, - "24": { - "p5": "6A" - }, - "25": { - "p5": "6B" - }, - "26": { - "p5": "6C" - }, - "27": { - "p1": "3A", - "p5": "3B", - "p9": "7E" - }, - "28": { - "p1": "22", - "p3": "60", - "p7": "27", - "p8": "7B", - "p9": "60" - }, - "29": { - "p1": "7E", - "p3": "7C", - "p7": "60", - "p8": "5C", - "p9": "23" - }, - "2A": { - "format": "left", - "label": "shift" - }, - "2B": { - "p1": "00A6", - "p3": "3E", - "p7": "005C", - "p8": "7D", - "p9": "3C" - }, - "2C": { - "p5": "7A" - }, - "2D": { - "p5": "78" - }, - "2E": { - "p5": "63" - }, - "2F": { - "p5": "76" - }, - "30": { - "p5": "62" - }, - "31": { - "p5": "6E" - }, - "32": { - "p5": "6D", - "p9": "00B5" - }, - "33": { - "p1": "3C", - "p3": "27", - "p7": "2C", - "p8": "AF", - "p9": "2C" - }, - "34": { - "p1": "3E", - "p3": "2E", - "p7": "2E", - "p9": "2E" - }, - "35": { - "p1": "3F", - "p3": "C9", - "p7": "2F", - "p9": "B4" - }, - "36": { - "format": "right", - "label": "shift" - }, - "38": { - "format": "left", - "label": "alt" - }, - "39": { - "label": "space" - }, - "3B": { - "label": "back" - }, - "3C": { - "label": "forward" - }, - "3D": { - "label": "maximize" - }, - "3E": { - "label": "full screen" - }, - "3F": { - "label": "tools" - }, - "40": { - "label": "bright down" - }, - "41": { - "label": "bright up" - }, - "42": { - "label": "mute" - }, - "43": { - "label": "vol. down" - }, - "44": { - "label": "vol. up" - }, - "56": { - "p1": "7C", - "p3": "BB", - "p7": "005C", - "p8": "B0", - "p9": "AB" - }, - "E0 1D": { - "format": "smaller", - "label": "ctrl" - }, - "E0 38": { - "format": "smaller", - "label": "alt car" - }, - "E0 48": { - "label": "up" - }, - "E0 4B": { - "label": "left" - }, - "E0 4D": { - "label": "right" - }, - "E0 50": { - "label": "down" - }, - "E0 5B": { - "format": "left", - "label": "search" - } - }, - "layoutName": "E" - }, "es": { "keys": { "00": { @@ -5950,274 +5393,6 @@ var keyboardOverlayData = { }, "layoutName": "E" }, - "fil": { - "keys": { - "00": { - "label": "power" - }, - "01": { - "format": "smaller", - "label": "esc" - }, - "02": { - "p2": "21", - "p8": "31" - }, - "03": { - "p2": "40", - "p8": "32" - }, - "04": { - "p2": "23", - "p8": "33" - }, - "05": { - "p2": "24", - "p8": "34" - }, - "06": { - "p2": "25", - "p8": "35" - }, - "07": { - "p2": "005E", - "p8": "36" - }, - "08": { - "p2": "26", - "p8": "37" - }, - "09": { - "p2": "002A", - "p8": "38" - }, - "0A": { - "p2": "28", - "p8": "39" - }, - "0B": { - "p2": "29", - "p8": "30" - }, - "0C": { - "p2": "005F", - "p8": "002D" - }, - "0D": { - "p2": "002B", - "p8": "003D" - }, - "0E": { - "format": "right", - "label": "backspace" - }, - "0F": { - "format": "left", - "label": "tab" - }, - "10": { - "p5": "71" - }, - "11": { - "p5": "77" - }, - "12": { - "p5": "65" - }, - "13": { - "p5": "72" - }, - "14": { - "p5": "74" - }, - "15": { - "p5": "79" - }, - "16": { - "p5": "75" - }, - "17": { - "p5": "69" - }, - "18": { - "p5": "006F" - }, - "19": { - "p5": "70" - }, - "1A": { - "p2": "007B", - "p8": "005B" - }, - "1B": { - "p2": "007D", - "p8": "005D" - }, - "1C": { - "format": "right", - "label": "enter" - }, - "1D": { - "format": "left", - "label": "ctrl" - }, - "1E": { - "p5": "61" - }, - "1F": { - "p5": "73" - }, - "20": { - "p5": "64" - }, - "21": { - "p5": "66" - }, - "22": { - "p5": "67" - }, - "23": { - "p5": "68" - }, - "24": { - "p5": "006A" - }, - "25": { - "p5": "006B" - }, - "26": { - "p5": "006C" - }, - "27": { - "p2": "3A", - "p8": "3B" - }, - "28": { - "p2": "22", - "p8": "27" - }, - "29": { - "p2": "007E", - "p8": "60" - }, - "2A": { - "format": "left", - "label": "shift" - }, - "2B": { - "p2": "007C", - "p8": "005C" - }, - "2C": { - "p5": "007A" - }, - "2D": { - "p5": "78" - }, - "2E": { - "p5": "63" - }, - "2F": { - "p5": "76" - }, - "30": { - "p5": "62" - }, - "31": { - "p5": "006E" - }, - "32": { - "p5": "006D" - }, - "33": { - "p2": "3C", - "p8": "2C" - }, - "34": { - "p2": "3E", - "p8": "2E" - }, - "35": { - "p2": "3F", - "p8": "2F" - }, - "36": { - "format": "right", - "label": "shift" - }, - "37": {}, - "38": { - "format": "left", - "label": "alt" - }, - "39": { - "label": "space" - }, - "3B": { - "label": "back" - }, - "3C": { - "label": "forward" - }, - "3D": { - "label": "maximize" - }, - "3E": { - "label": "full screen" - }, - "3F": { - "label": "tools" - }, - "40": { - "label": "bright down" - }, - "41": { - "label": "bright up" - }, - "42": { - "label": "mute" - }, - "43": { - "label": "vol. down" - }, - "44": { - "label": "vol. up" - }, - "73": {}, - "79": { - "format": "smaller" - }, - "7B": { - "format": "smaller" - }, - "7D": {}, - "E0 1D": { - "format": "smaller", - "label": "ctrl" - }, - "E0 38": { - "format": "smaller", - "label": "alt" - }, - "E0 48": { - "label": "up" - }, - "E0 4B": { - "label": "left" - }, - "E0 4D": { - "label": "right" - }, - "E0 50": { - "label": "down" - }, - "E0 5B": { - "format": "left", - "label": "search" - } - }, - "layoutName": "U" - }, "fr": { "keys": { "00": { @@ -7728,274 +6903,6 @@ var keyboardOverlayData = { }, "layoutName": "E" }, - "id": { - "keys": { - "00": { - "label": "power" - }, - "01": { - "format": "smaller", - "label": "esc" - }, - "02": { - "p2": "21", - "p8": "31" - }, - "03": { - "p2": "40", - "p8": "32" - }, - "04": { - "p2": "23", - "p8": "33" - }, - "05": { - "p2": "24", - "p8": "34" - }, - "06": { - "p2": "25", - "p8": "35" - }, - "07": { - "p2": "5E", - "p8": "36" - }, - "08": { - "p2": "26", - "p8": "37" - }, - "09": { - "p2": "2A", - "p8": "38" - }, - "0A": { - "p2": "28", - "p8": "39" - }, - "0B": { - "p2": "29", - "p8": "30" - }, - "0C": { - "p2": "5F", - "p8": "2D" - }, - "0D": { - "p2": "2B", - "p8": "3D" - }, - "0E": { - "format": "right", - "label": "backspace" - }, - "0F": { - "format": "left", - "label": "tab" - }, - "10": { - "p5": "71" - }, - "11": { - "p5": "77" - }, - "12": { - "p5": "65" - }, - "13": { - "p5": "72" - }, - "14": { - "p5": "74" - }, - "15": { - "p5": "79" - }, - "16": { - "p5": "75" - }, - "17": { - "p5": "69" - }, - "18": { - "p5": "6F" - }, - "19": { - "p5": "70" - }, - "1A": { - "p2": "7B", - "p8": "5B" - }, - "1B": { - "p2": "7D", - "p8": "5D" - }, - "1C": { - "format": "right", - "label": "enter" - }, - "1D": { - "format": "left", - "label": "ctrl" - }, - "1E": { - "p5": "61" - }, - "1F": { - "p5": "73" - }, - "20": { - "p5": "64" - }, - "21": { - "p5": "66" - }, - "22": { - "p5": "67" - }, - "23": { - "p5": "68" - }, - "24": { - "p5": "6A" - }, - "25": { - "p5": "6B" - }, - "26": { - "p5": "6C" - }, - "27": { - "p2": "3A", - "p8": "3B" - }, - "28": { - "p2": "22", - "p8": "27" - }, - "29": { - "p2": "7E", - "p8": "60" - }, - "2A": { - "format": "left", - "label": "shift" - }, - "2B": { - "p2": "7C", - "p8": "5C" - }, - "2C": { - "p5": "7A" - }, - "2D": { - "p5": "78" - }, - "2E": { - "p5": "63" - }, - "2F": { - "p5": "76" - }, - "30": { - "p5": "62" - }, - "31": { - "p5": "6E" - }, - "32": { - "p5": "6D" - }, - "33": { - "p2": "3C", - "p8": "2C" - }, - "34": { - "p2": "3E", - "p8": "2E" - }, - "35": { - "p2": "3F", - "p8": "2F" - }, - "36": { - "format": "right", - "label": "shift" - }, - "37": {}, - "38": { - "format": "left", - "label": "alt" - }, - "39": { - "label": "space" - }, - "3B": { - "label": "back" - }, - "3C": { - "label": "forward" - }, - "3D": { - "label": "maximize" - }, - "3E": { - "label": "full screen" - }, - "3F": { - "label": "tools" - }, - "40": { - "label": "bright down" - }, - "41": { - "label": "bright up" - }, - "42": { - "label": "mute" - }, - "43": { - "label": "vol. down" - }, - "44": { - "label": "vol. up" - }, - "73": {}, - "79": { - "format": "smaller" - }, - "7B": { - "format": "smaller" - }, - "7D": {}, - "E0 1D": { - "format": "smaller", - "label": "ctrl" - }, - "E0 38": { - "format": "smaller", - "label": "alt" - }, - "E0 48": { - "label": "up" - }, - "E0 4B": { - "label": "left" - }, - "E0 4D": { - "label": "right" - }, - "E0 50": { - "label": "down" - }, - "E0 5B": { - "format": "left", - "label": "search" - } - }, - "layoutName": "U" - }, "it": { "keys": { "00": { diff --git a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc index 583246f..58e42b2 100644 --- a/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc +++ b/chrome/browser/ui/webui/chromeos/keyboard_overlay_ui.cc @@ -8,7 +8,6 @@ #include "base/memory/weak_ptr.h" #include "base/values.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h" -#include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/chromeos/input_method/xkeyboard.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" @@ -191,9 +190,9 @@ class KeyboardOverlayHandler virtual void RegisterMessages(); private: - // Called when the page requires the keyboard overaly ID corresponding to the + // Called when the page requires the input method ID corresponding to the // current input method or keyboard layout during initialization. - void GetKeyboardOverlayId(const ListValue* args); + void GetInputMethodId(const ListValue* args); // Called when the page requres the information of modifier key remapping // during the initialization. @@ -256,20 +255,18 @@ WebUIMessageHandler* KeyboardOverlayHandler::Attach(WebUI* web_ui) { void KeyboardOverlayHandler::RegisterMessages() { DCHECK(web_ui_); - web_ui_->RegisterMessageCallback("getKeyboardOverlayId", - NewCallback(this, &KeyboardOverlayHandler::GetKeyboardOverlayId)); + web_ui_->RegisterMessageCallback("getInputMethodId", + NewCallback(this, &KeyboardOverlayHandler::GetInputMethodId)); web_ui_->RegisterMessageCallback("getLabelMap", NewCallback(this, &KeyboardOverlayHandler::GetLabelMap)); } -void KeyboardOverlayHandler::GetKeyboardOverlayId(const ListValue* args) { +void KeyboardOverlayHandler::GetInputMethodId(const ListValue* args) { chromeos::input_method::InputMethodManager* manager = chromeos::input_method::InputMethodManager::GetInstance(); const chromeos::input_method::InputMethodDescriptor& descriptor = manager->current_input_method(); - const std::string keyboard_overlay_id = - chromeos::input_method::GetKeyboardOverlayId(descriptor.id()); - StringValue param(keyboard_overlay_id); + StringValue param(descriptor.id()); web_ui_->CallJavascriptFunction("initKeyboardOverlayId", param); } diff --git a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py index 9da16e2..c04dfa3 100755 --- a/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py +++ b/tools/gen_keyboard_overlay_data/gen_keyboard_overlay_data.py @@ -91,6 +91,77 @@ LABEL_MAP = { 'glyph_volume_up': 'vol. up', }; +INPUT_METHOD_ID_TO_OVERLAY_ID = { + 'hangul': 'ko', + 'm17n:ar:kbd': 'ar', + 'm17n:fa:isiri': 'ar', + 'm17n:hi:itrans': 'hi', + 'm17n:th:kesmanee': 'th', + 'm17n:th:pattachote': 'th', + 'm17n:th:tis820': 'th', + 'm17n:vi:tcvn': 'vi', + 'm17n:vi:telex': 'vi', + 'm17n:vi:viqr': 'vi', + 'm17n:vi:vni': 'vi', + 'm17n:zh:cangjie': 'zh_TW', + 'm17n:zh:quick': 'zh_TW', + 'mozc': 'en_US', + 'mozc-chewing': 'zh_TW', + 'mozc-dv': 'en_US_dvorak', + 'mozc-jp': 'ja', + 'pinyin': 'zh_CN', + 'pinyin-dv': 'en_US_dvorak', + 'xkb:be::fra': 'fr', + 'xkb:be::ger': 'de', + 'xkb:be::nld': 'nl', + 'xkb:bg::bul': 'bg', + 'xkb:bg:phonetic:bul': 'bg', + 'xkb:br::por': 'pt_BR', + 'xkb:ca::fra': 'fr_CA', + 'xkb:ca:eng:eng': 'ca', + 'xkb:ch::ger': 'de', + 'xkb:ch:fr:fra': 'fr', + 'xkb:cz::cze': 'cs', + 'xkb:de::ger': 'de', + 'xkb:de:neo:ger': 'de_neo', + 'xkb:dk::dan': 'da', + 'xkb:ee::est': 'et', + 'xkb:es::spa': 'es', + 'xkb:es:cat:cat': 'ca', + 'xkb:fi::fin': 'fi', + 'xkb:fr::fra': 'fr', + 'xkb:gb:dvorak:eng': 'en_GB_dvorak', + 'xkb:gb:extd:eng': 'en_GB', + 'xkb:gr::gre': 'el', + 'xkb:hr::scr': 'hr', + 'xkb:hu::hun': 'hu', + 'xkb:il::heb': 'iw', + 'xkb:it::ita': 'it', + 'xkb:jp::jpn': 'ja', + 'xkb:kr:kr104:kor': 'ko', + 'xkb:latam::spa': 'es_419', + 'xkb:lt::lit': 'lt', + 'xkb:lv:apostrophe:lav': 'lv', + 'xkb:no::nob': 'no', + 'xkb:pl::pol': 'pl', + 'xkb:pt::por': 'pt_PT', + 'xkb:ro::rum': 'ro', + 'xkb:rs::srp': 'sr', + 'xkb:ru::rus': 'ru', + 'xkb:ru:phonetic:rus': 'ru', + 'xkb:se::swe': 'sv', + 'xkb:si::slv': 'sl', + 'xkb:sk::slo': 'sk', + 'xkb:tr::tur': 'tr', + 'xkb:ua::ukr': 'uk', + 'xkb:us::eng': 'en_US', + 'xkb:us:altgr-intl:eng': 'en_US_altgr_intl', + 'xkb:us:colemak:eng': 'en_US_colemak', + 'xkb:us:dvorak:eng': 'en_US_dvorak', + 'xkb:us:intl:eng': 'en_US_intl', + 'zinnia-japanese': 'ja', +} + COPYRIGHT_HEADER_TEMPLATE=( """// Copyright (c) %s The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be @@ -107,9 +178,9 @@ GRD_SNIPPET_TEMPLATE=""" <message name="%s" desc="%s"> CC_SNIPPET_TEMPLATE=""" { "%s", %s }, """ -ALTGR_TEMPLATE="""// These are the overlay names of layouts that shouldn't -// remap the right alt key. -const char* kKeepRightAltOverlays[] = { +ALTGR_TEMPLATE=( +"""// These are the input method IDs that shouldn't remap the right alt key. +const char* kKeepRightAltInputMethods[] = { %s }; @@ -119,7 +190,7 @@ const char* kCapsLockRemapped[] = { }; -""" +""") def SplitBehavior(behavior): """Splits the behavior to compose a message or i18n-content value. @@ -272,17 +343,11 @@ def FetchSpreadsheetFeeds(client, key, sheets, cols): def FetchKeyboardGlyphData(client): """Fetches the keyboard glyph data from the spreadsheet.""" - languages = ['en_US', 'en_US_colemak', 'en_US_dvorak', 'en_US_intl', - 'en_US_altgr_intl', 'ar', 'ar_fr', 'bg', 'ca', 'cs', 'da', - 'de', 'de_neo', 'el', 'en_fr_hybrid_CA', 'en_GB', 'en_GB_dvorak', - 'es', 'es_419', 'et', 'fi', 'fil', 'fr', 'fr_CA', 'hi', - 'hr', 'hu', 'id', 'it', 'iw', 'ja', 'ko', 'lt', 'lv', 'nl', 'no', - 'pl', 'pt_BR', 'pt_PT', 'ro', 'ru', 'sk', 'sl', 'sr', 'sv', 'th', - 'tr', 'uk', 'vi', 'zh_CN', 'zh_TW'] glyph_cols = ['scancode', 'p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'label', 'format', 'notes'] keyboard_glyph_data = FetchSpreadsheetFeeds( - client, KEYBOARD_GLYPH_SPREADSHEET_KEY, languages, glyph_cols) + client, KEYBOARD_GLYPH_SPREADSHEET_KEY, + INPUT_METHOD_ID_TO_OVERLAY_ID.values(), glyph_cols) ret = {} for lang in keyboard_glyph_data: ret[lang] = {} @@ -374,7 +439,8 @@ def OutputJson(keyboard_glyph_data, hotkey_data, layouts, var_name, outdir): action_to_id[action] = i18nContent data = {'keyboardGlyph': keyboard_glyph_data, 'shortcut': action_to_id, - 'layouts': layouts} + 'layouts': layouts, + 'inputMethodIdToOverlayId': INPUT_METHOD_ID_TO_OVERLAY_ID} if outdir: outpath = os.path.join(outdir, JS_FILENAME) else: @@ -441,21 +507,21 @@ def OutputAltGr(keyboard_glyph_data, outdir): altgr_output = [] caps_lock_output = [] - for layout in keyboard_glyph_data.keys(): + for input_method_id, layout in INPUT_METHOD_ID_TO_OVERLAY_ID.iteritems(): try: # If left and right alt have different values, this layout to the list of # layouts that don't remap the right alt key. right_alt = keyboard_glyph_data[layout]["keys"]["E0 38"]["label"].strip() left_alt = keyboard_glyph_data[layout]["keys"]["38"]["label"].strip() if right_alt.lower() != left_alt.lower(): - altgr_output.append(' "%s",' % layout) + altgr_output.append(' "%s",' % input_method_id) except KeyError: pass try: caps_lock = keyboard_glyph_data[layout]["keys"]["E0 5B"]["label"].strip() if caps_lock.lower() != "search": - caps_lock_output.append(' "%s",' % layout) + caps_lock_output.append(' "%s",' % input_method_id) except KeyError: pass snippet = ALTGR_TEMPLATE % ("\n".join(altgr_output), |