summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-21 07:50:36 +0000
committerbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-21 07:50:36 +0000
commitb42f8d9072bbabbcb5d04042fe4334f1fd4bff6a (patch)
tree34d99d9000d347cc54b263ad39a03e1f470ae19a /ui
parente45a2307a2d8caaba731ae6b02808c379bc459fa (diff)
downloadchromium_src-b42f8d9072bbabbcb5d04042fe4334f1fd4bff6a.zip
chromium_src-b42f8d9072bbabbcb5d04042fe4334f1fd4bff6a.tar.gz
chromium_src-b42f8d9072bbabbcb5d04042fe4334f1fd4bff6a.tar.bz2
Insert text directly from the virtual keyboard.
This allows the insertion of text that does not directly correspond to key codes. The new API introduced is a temporary solution to allow us to continue prototyping the virtual keyboard and understanding how the implementation will interact with IMEs until proper IME integration can be achieved. BUG=237533 Review URL: https://chromiumcodereview.appspot.com/16972006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207752 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/events/key_identifier_conversion.cc343
-rw-r--r--ui/base/events/key_identifier_conversion.h25
-rw-r--r--ui/base/events/key_identifier_conversion_unittest.cc63
-rw-r--r--ui/keyboard/keyboard_ui_handler.cc26
-rw-r--r--ui/keyboard/keyboard_ui_handler.h8
-rw-r--r--ui/keyboard/keyboard_util.cc151
-rw-r--r--ui/keyboard/keyboard_util.h23
-rw-r--r--ui/keyboard/resources/api_adapter.js9
-rw-r--r--ui/keyboard/resources/elements/kb-keyboard.html15
-rw-r--r--ui/keyboard/resources/keysets.html36
-rw-r--r--ui/keyboard/resources/main.js18
-rw-r--r--ui/keyboard/resources/voice_input.js4
-rw-r--r--ui/keyboard/resources/webui/api_adapter.js7
-rw-r--r--ui/keyboard/resources/webui/keysets.html36
-rw-r--r--ui/ui.gyp4
-rw-r--r--ui/ui_unittests.gypi2
16 files changed, 110 insertions, 660 deletions
diff --git a/ui/base/events/key_identifier_conversion.cc b/ui/base/events/key_identifier_conversion.cc
deleted file mode 100644
index ac71c48..0000000
--- a/ui/base/events/key_identifier_conversion.cc
+++ /dev/null
@@ -1,343 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/events/key_identifier_conversion.h"
-
-#include <string.h>
-#include <utility>
-
-#include "base/basictypes.h"
-#include "base/containers/hash_tables.h"
-#include "ui/base/events/event.h"
-#include "ui/base/keycodes/keyboard_codes.h"
-
-namespace {
-
-const int kNumIdentifierTypes = 3;
-
-typedef struct KeyIdentifier {
- // In order: key identifier, character and unicode codepoint. They are
- // searched in that order as well.
- // These are all placed into a single array as they are treated uniformly and
- // we never refer to a specific type of identifier. This reduces code
- // duplication below.
- const char* identifiers[kNumIdentifierTypes];
- const ui::KeyboardCode key_code;
- const int event_flags;
-} KeyIdentifier;
-
-// Taken from Section 6.3.3 here:
-// http://www.w3.org/TR/DOM-Level-3-Events/#keyset-keyidentifiers
-// WARNING: keycodes could be wrong, as they are based soley on keydown
-const KeyIdentifier kKeyIdentifiers[] = {
- { {"Accept", "", ""}, ui::VKEY_ACCEPT, 0 },
- { {"Add", "", ""}, ui::VKEY_ADD, 0 },
- { {"Again", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"AllCandidates", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Alphanumeric", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Alt", "", ""}, ui::VKEY_MENU, 0 },
- { {"AltGraph", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Apps", "", ""}, ui::VKEY_APPS, 0 },
- { {"Attn", "", ""}, ui::VKEY_ATTN, 0 },
- { {"BrowserBack", "", ""}, ui::VKEY_BROWSER_BACK, 0 },
- { {"BrowserFavorites", "", ""}, ui::VKEY_BROWSER_FAVORITES, 0 },
- { {"BrowserForward", "", ""}, ui::VKEY_BROWSER_FORWARD, 0 },
- { {"BrowserHome", "", ""}, ui::VKEY_BROWSER_HOME, 0 },
- { {"BrowserRefresh", "", ""}, ui::VKEY_BROWSER_REFRESH, 0 },
- { {"BrowserSearch", "", ""}, ui::VKEY_BROWSER_SEARCH, 0 },
- { {"BrowserStop", "", ""}, ui::VKEY_BROWSER_STOP, 0 },
- { {"CapsLock", "", ""}, ui::VKEY_CAPITAL, 0 },
- { {"Clear", "", ""}, ui::VKEY_OEM_CLEAR, 0 },
- { {"CodeInput", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Compose", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Control", "", ""}, ui::VKEY_CONTROL, 0 },
- { {"Crsel", "", ""}, ui::VKEY_CRSEL, 0 },
- { {"Convert", "", ""}, ui::VKEY_CONVERT, 0 },
- { {"Copy", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Cut", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Decimal", "", ""}, ui::VKEY_DECIMAL, 0 },
- { {"Divide", "", ""}, ui::VKEY_DIVIDE, 0 },
- { {"Down", "", ""}, ui::VKEY_DOWN, 0 },
- { {"DownLeft", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"DownRight", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"End", "", ""}, ui::VKEY_END, 0 },
- { {"Enter", "", ""}, ui::VKEY_RETURN, 0 },
- { {"EraseEof", "", ""}, ui::VKEY_EREOF, 0 },
- { {"Execute", "", ""}, ui::VKEY_EXECUTE, 0 },
- { {"Exsel", "", ""}, ui::VKEY_EXSEL, 0 },
- { {"Fn", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"F1", "", ""}, ui::VKEY_F1, 0 },
- { {"F2", "", ""}, ui::VKEY_F2, 0 },
- { {"F3", "", ""}, ui::VKEY_F3, 0 },
- { {"F4", "", ""}, ui::VKEY_F4, 0 },
- { {"F5", "", ""}, ui::VKEY_F5, 0 },
- { {"F6", "", ""}, ui::VKEY_F6, 0 },
- { {"F7", "", ""}, ui::VKEY_F7, 0 },
- { {"F8", "", ""}, ui::VKEY_F8, 0 },
- { {"F9", "", ""}, ui::VKEY_F9, 0 },
- { {"F10", "", ""}, ui::VKEY_F10, 0 },
- { {"F11", "", ""}, ui::VKEY_F11, 0 },
- { {"F12", "", ""}, ui::VKEY_F12, 0 },
- { {"F13", "", ""}, ui::VKEY_F13, 0 },
- { {"F14", "", ""}, ui::VKEY_F14, 0 },
- { {"F15", "", ""}, ui::VKEY_F15, 0 },
- { {"F16", "", ""}, ui::VKEY_F16, 0 },
- { {"F17", "", ""}, ui::VKEY_F17, 0 },
- { {"F18", "", ""}, ui::VKEY_F18, 0 },
- { {"F19", "", ""}, ui::VKEY_F19, 0 },
- { {"F20", "", ""}, ui::VKEY_F20, 0 },
- { {"F21", "", ""}, ui::VKEY_F21, 0 },
- { {"F22", "", ""}, ui::VKEY_F22, 0 },
- { {"F23", "", ""}, ui::VKEY_F23, 0 },
- { {"F24", "", ""}, ui::VKEY_F24, 0 },
- { {"FinalMode", "", ""}, ui::VKEY_FINAL, 0 },
- { {"Find", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"FullWidth", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"HalfWidth", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"HangulMode", "", ""}, ui::VKEY_HANGUL, 0 },
- { {"HanjaMode", "", ""}, ui::VKEY_HANJA, 0 },
- { {"Help", "", ""}, ui::VKEY_HELP, 0 },
- { {"Hiragana", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Home", "", ""}, ui::VKEY_HOME, 0 },
- { {"Insert", "", ""}, ui::VKEY_INSERT, 0 },
- { {"JapaneseHiragana", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"JapaneseKatakana", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"JapaneseRomaji", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"JunjaMode", "", ""}, ui::VKEY_JUNJA, 0 },
- { {"KanaMode", "", ""}, ui::VKEY_KANA, 0 },
- { {"KanjiMode", "", ""}, ui::VKEY_KANJI, 0 },
- { {"Katakana", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"LaunchApplication1", "", ""}, ui::VKEY_MEDIA_LAUNCH_APP1, 0 },
- { {"LaunchApplication2", "", ""}, ui::VKEY_MEDIA_LAUNCH_APP2, 0 },
- { {"LaunchMail", "", ""}, ui::VKEY_MEDIA_LAUNCH_MAIL, 0 },
- { {"Left", "", ""}, ui::VKEY_LEFT, 0 },
- { {"Menu", "", ""}, ui::VKEY_MENU, 0 },
- { {"Meta", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"MediaNextTrack", "", ""}, ui::VKEY_MEDIA_NEXT_TRACK, 0 },
- { {"MediaPlayPause", "", ""}, ui::VKEY_MEDIA_PLAY_PAUSE, 0 },
- { {"MediaPreviousTrack", "", ""}, ui::VKEY_MEDIA_PREV_TRACK, 0 },
- { {"MediaStop", "", ""}, ui::VKEY_MEDIA_STOP, 0 },
- { {"ModeChange", "", ""}, ui::VKEY_MODECHANGE, 0 },
- { {"Multiply", "", ""}, ui::VKEY_MULTIPLY, 0 },
- { {"NextCandidate", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Nonconvert", "", ""}, ui::VKEY_NONCONVERT, 0 },
- { {"NumLock", "", ""}, ui::VKEY_NUMLOCK, 0 },
- { {"PageDown", "", ""}, ui::VKEY_NEXT, 0 },
- { {"PageUp", "", ""}, ui::VKEY_PRIOR, 0 },
- { {"Paste", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Pause", "", ""}, ui::VKEY_PAUSE, 0 },
- { {"Play", "", ""}, ui::VKEY_PLAY, 0 },
- { {"PreviousCandidate", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"PrintScreen", "", ""}, ui::VKEY_SNAPSHOT, 0 },
- { {"Process", "", ""}, ui::VKEY_PROCESSKEY, 0 },
- { {"Props", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Right", "", ""}, ui::VKEY_RIGHT, 0 },
- { {"RomanCharacters", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Scroll", "", ""}, ui::VKEY_SCROLL, 0 },
- { {"Select", "", ""}, ui::VKEY_SELECT, 0 },
- { {"SelectMedia", "", ""}, ui::VKEY_MEDIA_LAUNCH_MEDIA_SELECT, 0 },
- { {"Separator", "", ""}, ui::VKEY_SEPARATOR, 0 },
- { {"Shift", "", ""}, ui::VKEY_SHIFT, 0 },
- { {"Soft1", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Soft2", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Soft3", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Soft4", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Stop", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Subtract", "", ""}, ui::VKEY_SUBTRACT, 0 },
- { {"Up", "", ""}, ui::VKEY_UP, 0 },
- { {"UpLeft", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"UpRight", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"Undo", "", ""}, ui::VKEY_UNKNOWN, 0 },
- { {"VolumeDown", "", ""}, ui::VKEY_VOLUME_DOWN, 0 },
- { {"VolumeMute", "", ""}, ui::VKEY_VOLUME_MUTE, 0 },
- { {"VolumeUp", "", ""}, ui::VKEY_VOLUME_UP, 0 },
- { {"Win", "", ""}, ui::VKEY_LWIN, 0 },
- { {"Zoom", "", ""}, ui::VKEY_ZOOM, 0 },
- { {"Backspace", "", "U+0008"}, ui::VKEY_BACK, 0 },
- { {"Tab", "", "U+0009"}, ui::VKEY_TAB, 0 },
- { {"Cancel", "", "U+0018"}, ui::VKEY_UNKNOWN, 0 },
- { {"Esc", "", "U+001B"}, ui::VKEY_ESCAPE, 0 },
- { {"Spacebar", " ", "U+0020"}, ui::VKEY_SPACE, 0 },
- { {"Exclamation", "!", "U+0021"}, ui::VKEY_1, ui::EF_SHIFT_DOWN },
- { {"DoubleQuote", "\"", "U+0022"},
- ui::VKEY_OEM_7, ui::EF_SHIFT_DOWN },
- { {"Hash", "#", "U+0023"}, ui::VKEY_3, ui::EF_SHIFT_DOWN },
- { {"Dollar", "$", "U+0024"}, ui::VKEY_4, ui::EF_SHIFT_DOWN },
- { {"Ampersand", "&", "U+0026"}, ui::VKEY_7, ui::EF_SHIFT_DOWN },
- { {"Apostrophe", "\'", "U+0027"}, ui::VKEY_OEM_7, 0 },
- { {"LeftParen", "(", "U+0028"}, ui::VKEY_9, ui::EF_SHIFT_DOWN },
- { {"RightParen", ")", "U+0029"}, ui::VKEY_0, ui::EF_SHIFT_DOWN },
- { {"Asterisk", "*", "U+002A"}, ui::VKEY_8, ui::EF_SHIFT_DOWN },
- { {"Plus", "+", "U+002B"}, ui::VKEY_OEM_PLUS, ui::EF_SHIFT_DOWN },
- { {"Percent", "%", "U+0025"}, ui::VKEY_5, ui::EF_SHIFT_DOWN },
- { {"Comma", ",", "U+002C"}, ui::VKEY_OEM_COMMA, 0 },
- { {"HyphenMinus", "-", "U+002D"}, ui::VKEY_OEM_MINUS, 0 },
- { {"Period", ".", "U+002E"}, ui::VKEY_OEM_PERIOD, 0 },
- { {"Solidus", "/", "U+002F"}, ui::VKEY_OEM_2, 0 },
- { {"", "0", "U+0030"}, ui::VKEY_0, 0 },
- { {"", "1", "U+0031"}, ui::VKEY_1, 0 },
- { {"", "2", "U+0032"}, ui::VKEY_2, 0 },
- { {"", "3", "U+0033"}, ui::VKEY_3, 0 },
- { {"", "4", "U+0034"}, ui::VKEY_4, 0 },
- { {"", "5", "U+0035"}, ui::VKEY_5, 0 },
- { {"", "6", "U+0036"}, ui::VKEY_6, 0 },
- { {"", "7", "U+0037"}, ui::VKEY_7, 0 },
- { {"", "8", "U+0038"}, ui::VKEY_8, 0 },
- { {"", "9", "U+0039"}, ui::VKEY_9, 0 },
- { {"Colon", ":", "U+003A"}, ui::VKEY_OEM_1, ui::EF_SHIFT_DOWN },
- { {"Semicolon", ";", "U+003B"}, ui::VKEY_OEM_1, 0 },
- { {"LessThan", "<", "U+003C"},
- ui::VKEY_OEM_COMMA, ui::EF_SHIFT_DOWN },
- { {"Equals", "=", "U+003D"}, ui::VKEY_OEM_PLUS, 0 },
- { {"GreaterThan", ">", "U+003E"},
- ui::VKEY_OEM_PERIOD, ui::EF_SHIFT_DOWN },
- { {"QuestionMark", "?", "U+003F"},
- ui::VKEY_OEM_2, ui::EF_SHIFT_DOWN },
- { {"At", "@", "U+0040"}, ui::VKEY_2, ui::EF_SHIFT_DOWN },
- { {"", "A", "U+0041"}, ui::VKEY_A, ui::EF_SHIFT_DOWN },
- { {"", "B", "U+0042"}, ui::VKEY_B, ui::EF_SHIFT_DOWN },
- { {"", "C", "U+0043"}, ui::VKEY_C, ui::EF_SHIFT_DOWN },
- { {"", "D", "U+0044"}, ui::VKEY_D, ui::EF_SHIFT_DOWN },
- { {"", "E", "U+0045"}, ui::VKEY_E, ui::EF_SHIFT_DOWN },
- { {"", "F", "U+0046"}, ui::VKEY_F, ui::EF_SHIFT_DOWN },
- { {"", "G", "U+0047"}, ui::VKEY_G, ui::EF_SHIFT_DOWN },
- { {"", "H", "U+0048"}, ui::VKEY_H, ui::EF_SHIFT_DOWN },
- { {"", "I", "U+0049"}, ui::VKEY_I, ui::EF_SHIFT_DOWN },
- { {"", "J", "U+004A"}, ui::VKEY_J, ui::EF_SHIFT_DOWN },
- { {"", "K", "U+004B"}, ui::VKEY_K, ui::EF_SHIFT_DOWN },
- { {"", "L", "U+004C"}, ui::VKEY_L, ui::EF_SHIFT_DOWN },
- { {"", "M", "U+004D"}, ui::VKEY_M, ui::EF_SHIFT_DOWN },
- { {"", "N", "U+004E"}, ui::VKEY_N, ui::EF_SHIFT_DOWN },
- { {"", "O", "U+004F"}, ui::VKEY_O, ui::EF_SHIFT_DOWN },
- { {"", "P", "U+0050"}, ui::VKEY_P, ui::EF_SHIFT_DOWN },
- { {"", "Q", "U+0051"}, ui::VKEY_Q, ui::EF_SHIFT_DOWN },
- { {"", "R", "U+0052"}, ui::VKEY_R, ui::EF_SHIFT_DOWN },
- { {"", "S", "U+0053"}, ui::VKEY_S, ui::EF_SHIFT_DOWN },
- { {"", "T", "U+0054"}, ui::VKEY_T, ui::EF_SHIFT_DOWN },
- { {"", "U", "U+0055"}, ui::VKEY_U, ui::EF_SHIFT_DOWN },
- { {"", "V", "U+0056"}, ui::VKEY_V, ui::EF_SHIFT_DOWN },
- { {"", "W", "U+0057"}, ui::VKEY_W, ui::EF_SHIFT_DOWN },
- { {"", "X", "U+0058"}, ui::VKEY_X, ui::EF_SHIFT_DOWN },
- { {"", "Y", "U+0059"}, ui::VKEY_Y, ui::EF_SHIFT_DOWN },
- { {"", "Z", "U+005A"}, ui::VKEY_Z, ui::EF_SHIFT_DOWN },
- { {"", "a", "U+0061"}, ui::VKEY_A, 0 },
- { {"", "b", "U+0062"}, ui::VKEY_B, 0 },
- { {"", "c", "U+0063"}, ui::VKEY_C, 0 },
- { {"", "d", "U+0064"}, ui::VKEY_D, 0 },
- { {"", "e", "U+0065"}, ui::VKEY_E, 0 },
- { {"", "f", "U+0066"}, ui::VKEY_F, 0 },
- { {"", "g", "U+0067"}, ui::VKEY_G, 0 },
- { {"", "h", "U+0068"}, ui::VKEY_H, 0 },
- { {"", "i", "U+0069"}, ui::VKEY_I, 0 },
- { {"", "j", "U+006A"}, ui::VKEY_J, 0 },
- { {"", "k", "U+006B"}, ui::VKEY_K, 0 },
- { {"", "l", "U+006C"}, ui::VKEY_L, 0 },
- { {"", "m", "U+006D"}, ui::VKEY_M, 0 },
- { {"", "n", "U+006E"}, ui::VKEY_N, 0 },
- { {"", "o", "U+006F"}, ui::VKEY_O, 0 },
- { {"", "p", "U+0070"}, ui::VKEY_P, 0 },
- { {"", "q", "U+0071"}, ui::VKEY_Q, 0 },
- { {"", "r", "U+0072"}, ui::VKEY_R, 0 },
- { {"", "s", "U+0073"}, ui::VKEY_S, 0 },
- { {"", "t", "U+0074"}, ui::VKEY_T, 0 },
- { {"", "u", "U+0075"}, ui::VKEY_U, 0 },
- { {"", "v", "U+0076"}, ui::VKEY_V, 0 },
- { {"", "w", "U+0077"}, ui::VKEY_W, 0 },
- { {"", "x", "U+0078"}, ui::VKEY_X, 0 },
- { {"", "y", "U+0079"}, ui::VKEY_Y, 0 },
- { {"", "z", "U+007A"}, ui::VKEY_Z, 0 },
- { {"LeftSquareBracket", "[", "U+005B"}, ui::VKEY_OEM_4, 0 },
- { {"Backslash", "\\", "U+005C"}, ui::VKEY_OEM_5, 0 },
- { {"RightSquareBracket", "]", "U+005D"}, ui::VKEY_OEM_6, 0 },
- { {"Circumflex", "^", "U+005E"}, ui::VKEY_6, ui::EF_SHIFT_DOWN },
- { {"Underscore", "_", "U+005F"},
- ui::VKEY_OEM_MINUS, ui::EF_SHIFT_DOWN },
- { {"Grave", "`", "U+0060"}, ui::VKEY_OEM_3, 0 },
- { {"Tilde", "~", "U+007E"}, ui::VKEY_OEM_3, ui::EF_SHIFT_DOWN },
- { {"LeftCurlyBracket", "{", "U+007B"},
- ui::VKEY_OEM_4, ui::EF_SHIFT_DOWN },
- { {"Pipe", "|", "U+007C"}, ui::VKEY_OEM_5, ui::EF_SHIFT_DOWN },
- { {"RightCurlyBracket", "}", "U+007D"},
- ui::VKEY_OEM_6, ui::EF_SHIFT_DOWN },
- { {"Del", "", "U+007F"}, ui::VKEY_DELETE, 0 },
- { {"InvertedExclamation", "", "U+00A1"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadGrave", "", "U+0300"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadEacute", "", "U+0301"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadCircumflex", "", "U+0302"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadTilde", "", "U+0303"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadMacron", "", "U+0304"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadBreve", "", "U+0306"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadAboveDot", "", "U+0307"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadUmlaut", "", "U+0308"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadAboveRing", "", "U+030A"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadDoubleacute", "", "U+030B"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadCaron", "", "U+030C"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadCedilla", "", "U+0327"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadOgonek", "", "U+0328"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadIota", "", "U+0345"}, ui::VKEY_UNKNOWN, 0 },
- { {"Euro", "", "U+20AC"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadVoicedSound", "", "U+3099"}, ui::VKEY_UNKNOWN, 0 },
- { {"DeadSemivoicedSound", "", "U+309A"}, ui::VKEY_UNKNOWN, 0 }
-};
-
-const int kNumKeyIdentifiers = arraysize(kKeyIdentifiers);
-
-typedef base::hash_map<std::string, const ui::KeyEvent*> IdentifierMap;
-typedef std::pair<std::string, const ui::KeyEvent*> IdentifierPair;
-IdentifierMap* identifierMaps[kNumIdentifierTypes] = { NULL };
-
-ui::KeyEvent* kUnknownKeyEvent = NULL;
-
-void InitializeMaps() {
- if (identifierMaps[0])
- return;
-
- kUnknownKeyEvent = new ui::KeyEvent(ui::ET_KEY_PRESSED,
- ui::VKEY_UNKNOWN,
- 0,
- false);
-
- for (int i = 0; i < kNumIdentifierTypes; ++i)
- identifierMaps[i] = new IdentifierMap;
-
- for (int i = 0; i < kNumKeyIdentifiers; ++i) {
- const KeyIdentifier& key = kKeyIdentifiers[i];
-
- ui::KeyEvent* event = new ui::KeyEvent(ui::ET_KEY_PRESSED,
- key.key_code,
- key.event_flags,
- false);
- for (int j = 0; j < kNumIdentifierTypes; ++j) {
- if (key.identifiers[j][0] != '\0') {
- std::pair<IdentifierMap::iterator, bool> result =
- identifierMaps[j]->insert(
- IdentifierPair(key.identifiers[j], event));
- DCHECK(result.second);
- }
- }
- }
-}
-
-} // namespace
-
-namespace ui {
-
-const ui::KeyEvent& KeyEventFromKeyIdentifier(
- const std::string& key_identifier) {
- // This lazily initializes lookup tables for the conversion. To prevent
- // races, it should only ever be called from a single thread.
- InitializeMaps();
-
- for (int i = 0; i < kNumIdentifierTypes; ++i) {
- const IdentifierMap& map = *identifierMaps[i];
-
- IdentifierMap::const_iterator iter = map.find(key_identifier);
- if (iter != map.end())
- return *iter->second;
- }
-
- return *kUnknownKeyEvent;
-}
-
-} // namespace ui
diff --git a/ui/base/events/key_identifier_conversion.h b/ui/base/events/key_identifier_conversion.h
deleted file mode 100644
index 9e708ad..0000000
--- a/ui/base/events/key_identifier_conversion.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_BASE_EVENTS_KEY_IDENTIFIER_CONVERSION_H_
-#define UI_BASE_EVENTS_KEY_IDENTIFIER_CONVERSION_H_
-
-#include <string>
-
-#include "ui/base/ui_export.h"
-
-namespace ui {
-
-class KeyEvent;
-
-// Convert a KeyIdentifer (see Section 6.3.3 here:
-// http://www.w3.org/TR/DOM-Level-3-Events/#keyset-keyidentifiers)
-// to a ui::KeyEvent.
-// This should only be called from the UI thread.
-UI_EXPORT const ui::KeyEvent& KeyEventFromKeyIdentifier(
- const std::string& key_identifier);
-
-} // namespace ui
-
-#endif // UI_BASE_EVENTS_KEY_IDENTIFIER_CONVERSION_H_
diff --git a/ui/base/events/key_identifier_conversion_unittest.cc b/ui/base/events/key_identifier_conversion_unittest.cc
deleted file mode 100644
index cd86213..0000000
--- a/ui/base/events/key_identifier_conversion_unittest.cc
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/events/key_identifier_conversion.h"
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/base/events/event.h"
-#include "ui/base/keycodes/keyboard_codes.h"
-
-namespace ui {
-
-TEST(KeyEventFromKeyIdentifierTest, MatchOnIdentifier) {
- EXPECT_EQ(ui::VKEY_APPS, KeyEventFromKeyIdentifier("Apps").key_code());
- EXPECT_EQ(ui::VKEY_UNKNOWN,
- KeyEventFromKeyIdentifier("Nonsense").key_code());
-}
-
-TEST(KeyEventFromKeyIdentifierTest, MatchOnCharacter) {
- EXPECT_EQ(ui::VKEY_A, KeyEventFromKeyIdentifier("a").key_code());
- EXPECT_EQ(ui::VKEY_A, KeyEventFromKeyIdentifier("A").key_code());
- EXPECT_EQ(ui::VKEY_OEM_PERIOD, KeyEventFromKeyIdentifier(">").key_code());
-
- std::string non_printing_char(" ");
- non_printing_char[0] = static_cast<char>(1);
- EXPECT_EQ(ui::VKEY_UNKNOWN,
- KeyEventFromKeyIdentifier(non_printing_char).key_code());
-}
-
-TEST(KeyEventFromKeyIdentifierTest, MatchOnUnicodeCodepoint) {
- EXPECT_EQ(ui::VKEY_A, KeyEventFromKeyIdentifier("U+0041").key_code());
- EXPECT_EQ(ui::VKEY_A, KeyEventFromKeyIdentifier("U+0061").key_code());
- EXPECT_EQ(ui::VKEY_DELETE, KeyEventFromKeyIdentifier("U+007F").key_code());
-
- // this one exists in the map, but has no valid ui::VKEY
- EXPECT_EQ(ui::VKEY_UNKNOWN, KeyEventFromKeyIdentifier("U+030A").key_code());
-
- // this one is not in the map
- EXPECT_EQ(ui::VKEY_UNKNOWN, KeyEventFromKeyIdentifier("U+0001").key_code());
-}
-
-TEST(KeyEventFromKeyIdentifierTest, DoesNotMatchEmptyString) {
- EXPECT_EQ(ui::VKEY_UNKNOWN, KeyEventFromKeyIdentifier("").key_code());
-}
-
-TEST(KeyEventFromKeyIdentifierTest, ShiftModifiersAreSet) {
- EXPECT_EQ(0, KeyEventFromKeyIdentifier("1").flags());
-
- const char* keys_with_shift[] = {
- "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+",
- "{", "}", "|", ":", "<", ">", "?", "\""
- };
- int kNumKeysWithShift = arraysize(keys_with_shift);
-
- for (int i = 0; i < kNumKeysWithShift; ++i) {
- EXPECT_EQ(ui::EF_SHIFT_DOWN,
- KeyEventFromKeyIdentifier(keys_with_shift[i]).flags());
- }
-}
-
-} // namespace ui
diff --git a/ui/keyboard/keyboard_ui_handler.cc b/ui/keyboard/keyboard_ui_handler.cc
index 291f3a0..0c41267 100644
--- a/ui/keyboard/keyboard_ui_handler.cc
+++ b/ui/keyboard/keyboard_ui_handler.cc
@@ -8,12 +8,11 @@
#include "base/bind.h"
#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
+#include "base/values.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/web_ui.h"
-#include "ui/aura/root_window.h"
-#include "ui/base/events/event.h"
+#include "ui/aura/window.h"
#include "ui/keyboard/keyboard_util.h"
namespace keyboard {
@@ -26,22 +25,27 @@ KeyboardUIHandler::~KeyboardUIHandler() {
void KeyboardUIHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
- "sendKeyEvent",
- base::Bind(&KeyboardUIHandler::HandleSendKeyEventMessage,
+ "insertText",
+ base::Bind(&KeyboardUIHandler::HandleInsertTextMessage,
base::Unretained(this)));
}
-void KeyboardUIHandler::HandleSendKeyEventMessage(const base::ListValue* args) {
- std::string error;
- scoped_ptr<ui::KeyEvent> event(keyboard::KeyEventFromArgs(args, &error));
- if (!event) {
- LOG(ERROR) << "sendKeyEvent failed: " << error;
+void KeyboardUIHandler::HandleInsertTextMessage(const base::ListValue* args) {
+ string16 text;
+ if (!args->GetString(0, &text)) {
+ LOG(ERROR) << "insertText failed: bad argument";
return;
}
aura::RootWindow* root_window =
web_ui()->GetWebContents()->GetView()->GetNativeView()->GetRootWindow();
- root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(event.get());
+ if (!root_window) {
+ LOG(ERROR) << "insertText failed: no root window";
+ return;
+ }
+
+ if (!keyboard::InsertText(text, root_window))
+ LOG(ERROR) << "insertText failed";
}
} // namespace keyboard
diff --git a/ui/keyboard/keyboard_ui_handler.h b/ui/keyboard/keyboard_ui_handler.h
index 0aaac83..0800453 100644
--- a/ui/keyboard/keyboard_ui_handler.h
+++ b/ui/keyboard/keyboard_ui_handler.h
@@ -11,8 +11,8 @@
namespace keyboard {
-// The WebUI handler for chrome://keyboard. Delivers events to the
-// aura::RootWindow associated with the WebUI.
+// The WebUI handler for chrome://keyboard. Inserts text into the currently
+// focused TextInputClient.
class KeyboardUIHandler : public content::WebUIMessageHandler {
public:
KeyboardUIHandler();
@@ -22,8 +22,8 @@ class KeyboardUIHandler : public content::WebUIMessageHandler {
// |content::WebUIMessageHandler| implementation:
virtual void RegisterMessages() OVERRIDE;
- // Callback for the "sendKeyEvent" message.
- void HandleSendKeyEventMessage(const base::ListValue* args);
+ // Callback for the "insertText" message.
+ void HandleInsertTextMessage(const base::ListValue* args);
DISALLOW_COPY_AND_ASSIGN(KeyboardUIHandler);
};
diff --git a/ui/keyboard/keyboard_util.cc b/ui/keyboard/keyboard_util.cc
index 12c2c8c..bacf1fe 100644
--- a/ui/keyboard/keyboard_util.cc
+++ b/ui/keyboard/keyboard_util.cc
@@ -8,65 +8,13 @@
#include "base/command_line.h"
#include "base/logging.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_util.h"
-#include "base/values.h"
-#include "ui/base/events/event.h"
-#include "ui/base/events/event_constants.h"
-#include "ui/base/events/key_identifier_conversion.h"
+#include "base/strings/string16.h"
+#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/root_window.h"
+#include "ui/base/ime/input_method.h"
+#include "ui/base/ime/text_input_client.h"
#include "ui/keyboard/keyboard_switches.h"
-namespace {
-
-// KeyEvent dictionary keys
-const char kType[] = "type";
-const char kKeyIdentifier[] = "keyIdentifier";
-const char kAlt[] = "altKey";
-const char kCtrl[] = "ctrlKey";
-const char kMeta[] = "metaKey";
-const char kShift[] = "shiftKey";
-const char kKeyDown[] = "keydown";
-const char kKeyUp[] = "keyup";
-
-// Errors.
-const char kInvalidArgumentsListError[] =
- "Argument list does not contain a dictionary.";
-const char kInvalidKeyEventMissingKeyIdentifierError[] =
- "KeyEvent object is missing the keyIdentifier field";
-const char kInvalidKeyEventMissingTypeError[] =
- "KeyEvent object is missing the type field";
-const char kUnknownKeyEventTypeError[] =
- "Unknown event type in KeyEvent.";
-const char kUnknownOrUnsupportedKeyIdentiferError[] =
- "Unknown or unsupported key identifier.";
-const char kUnsupportedModifierError[] =
- "Unsupported modifier (meta).";
-
-ui::EventType GetTypeFromString(const std::string& type) {
- if (type == kKeyDown) {
- return ui::ET_KEY_PRESSED;
- } else if (type == kKeyUp) {
- return ui::ET_KEY_RELEASED;
- }
- return ui::ET_UNKNOWN;
-}
-
-// Converts a hex string "U+NNNN" to uint16. Returns 0 on error.
-uint16 UnicodeIdentifierStringToInt(const std::string& key_identifier) {
- int character = 0;
- if ((key_identifier.length() == 6) &&
- (key_identifier.substr(0, 2) == "U+") &&
- (key_identifier.substr(2).find_first_not_of("0123456789abcdefABCDEF") ==
- std::string::npos)) {
- const bool result =
- base::HexStringToInt(key_identifier.substr(2), &character);
- DCHECK(result) << key_identifier;
- }
- return character;
-}
-
-} // namespace
-
namespace keyboard {
bool IsKeyboardEnabled() {
@@ -74,69 +22,44 @@ bool IsKeyboardEnabled() {
switches::kEnableVirtualKeyboard);
}
-ui::KeyEvent* KeyEventFromArgs(const base::ListValue* args,
- std::string* error) {
- const DictionaryValue* key_event;
- if (!args->GetDictionary(0, &key_event)) {
- *error = kInvalidArgumentsListError;
- return NULL;
- }
-
- std::string type_name;
- if (!key_event->GetString(kType, &type_name)) {
- *error = kInvalidKeyEventMissingTypeError;
- return NULL;
- }
-
- ui::EventType type = GetTypeFromString(type_name);
- if (type == ui::ET_UNKNOWN) {
- *error = kUnknownKeyEventTypeError;
- return NULL;
- }
-
- std::string identifier;
- if (!key_event->GetString(kKeyIdentifier, &identifier)) {
- *error = kInvalidKeyEventMissingKeyIdentifierError;
- return NULL;
- }
- TrimWhitespaceASCII(identifier, TRIM_ALL, &identifier);
-
- const ui::KeyEvent& prototype_event =
- ui::KeyEventFromKeyIdentifier(identifier);
- uint16 character = 0;
- if (prototype_event.key_code() == ui::VKEY_UNKNOWN) {
- character = UnicodeIdentifierStringToInt(identifier);
- if (!character) {
- *error = kUnknownOrUnsupportedKeyIdentiferError;
- return NULL;
+bool InsertText(const base::string16& text, aura::RootWindow* root_window) {
+ if (!root_window)
+ return false;
+
+ // Handle Backspace and Enter specially: using TextInputClient::InsertText is
+ // very unreliable for these characters.
+ // TODO(bryeung): remove this code once virtual keyboards are able to send
+ // these events directly via the Input Injection API.
+ if (text.length() == 1) {
+ ui::KeyboardCode code = ui::VKEY_UNKNOWN;
+ if (text[0] == L'\n')
+ code = ui::VKEY_RETURN;
+ else if (text[0] == L'\b')
+ code = ui::VKEY_BACK;
+
+ if (code != ui::VKEY_UNKNOWN) {
+ ui::KeyEvent press_event(ui::ET_KEY_PRESSED, code, 0, 0);
+ root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&press_event);
+
+ ui::KeyEvent release_event(ui::ET_KEY_RELEASED, code, 0, 0);
+ root_window->AsRootWindowHostDelegate()->OnHostKeyEvent(&release_event);
+
+ return true;
}
}
- int flags = 0;
- if (prototype_event.key_code() != ui::VKEY_UNKNOWN)
- flags = prototype_event.flags();
+ ui::InputMethod* input_method = root_window->GetProperty(
+ aura::client::kRootWindowInputMethodKey);
+ if (!input_method)
+ return false;
- bool flag = false;
- if (key_event->GetBoolean(kAlt, &flag) && flag)
- flags |= ui::EF_ALT_DOWN;
- if (key_event->GetBoolean(kCtrl, &flag) && flag)
- flags |= ui::EF_CONTROL_DOWN;
- if (key_event->GetBoolean(kShift, &flag) && flag)
- flags |= ui::EF_SHIFT_DOWN;
- if (key_event->GetBoolean(kMeta, &flag) && flag) {
- // ui::KeyEvent does not have a Meta flag, so return an error for now.
- *error = kUnsupportedModifierError;
- return NULL;
- }
+ ui::TextInputClient* tic = input_method->GetTextInputClient();
+ if (!tic || tic->GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE)
+ return false;
- ui::KeyEvent* event = new ui::KeyEvent(
- type, prototype_event.key_code(), flags, prototype_event.is_char());
- if (character) {
- event->set_character(character);
- event->set_unmodified_character(character);
- }
+ tic->InsertText(text);
- return event;
+ return true;
}
} // namespace keyboard
diff --git a/ui/keyboard/keyboard_util.h b/ui/keyboard/keyboard_util.h
index 0674fa1..1245f97 100644
--- a/ui/keyboard/keyboard_util.h
+++ b/ui/keyboard/keyboard_util.h
@@ -7,14 +7,11 @@
#include <string>
+#include "base/strings/string16.h"
#include "ui/keyboard/keyboard_export.h"
-namespace base {
-class ListValue;
-}
-
-namespace ui {
-class KeyEvent;
+namespace aura {
+class RootWindow;
}
namespace keyboard {
@@ -22,14 +19,12 @@ namespace keyboard {
// Returns true if the virtual keyboard is enabled.
KEYBOARD_EXPORT bool IsKeyboardEnabled();
-// Creates a ui::KeyEvent from the argument base::ListValue that is passed to
-// the synthetic input APIs (either the Extension API or the WebUI API). The
-// returned ui::KeyEvent is owned by the caller. If an error occurs, NULL is
-// returned and |error| will be populated with a description of the error. For
-// a description of the expected input, please see
-// chrome/common/extensions/api/experimental_input_virtual_keyboard.json
-KEYBOARD_EXPORT ui::KeyEvent* KeyEventFromArgs(const base::ListValue* args,
- std::string* error);
+// Insert |text| into the active TextInputClient associated with |root_window|,
+// if there is one. Returns true if |text| was successfully inserted. Note
+// that this may convert |text| into ui::KeyEvents for injection in some
+// special circumstances (i.e. VKEY_RETURN, VKEY_BACK).
+KEYBOARD_EXPORT bool InsertText(const base::string16& text,
+ aura::RootWindow* root_window);
} // namespace keyboard
diff --git a/ui/keyboard/resources/api_adapter.js b/ui/keyboard/resources/api_adapter.js
index 1f69be4..cd64f57 100644
--- a/ui/keyboard/resources/api_adapter.js
+++ b/ui/keyboard/resources/api_adapter.js
@@ -8,11 +8,6 @@ function logIfError() {
}
}
-function sendKeyEvent(keyEvent) {
- keyEvent.type = 'keydown';
- chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(keyEvent,
- logIfError);
- keyEvent.type = 'keyup';
- chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(keyEvent,
- logIfError);
+function insertText(text) {
+ chrome.experimental.input.virtualKeyboard.insertText(text, logIfError);
}
diff --git a/ui/keyboard/resources/elements/kb-keyboard.html b/ui/keyboard/resources/elements/kb-keyboard.html
index 0f19ccd..9bda726 100644
--- a/ui/keyboard/resources/elements/kb-keyboard.html
+++ b/ui/keyboard/resources/elements/kb-keyboard.html
@@ -95,12 +95,12 @@
this.lastPressedKey.classList.add('active');
repeatKey.cancel();
if (detail.repeat) {
- sendKey(detail.char);
+ insertText(detail.char);
repeatKey.key = this.lastPressedKey;
repeatKey.timer = setTimeout(function() {
repeatKey.timer = undefined;
repeatKey.interval = setInterval(function() {
- sendKey(detail.char);
+ insertText(detail.char);
}, REPEAT_INTERVAL_MSEC);
}, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC));
}
@@ -127,7 +127,7 @@
var char = detail.char;
if (enterUpperOnSpace) {
enterUpperOnSpace = false;
- if (char == 'Spacebar')
+ if (char == ' ')
this.keyset = 'upper';
}
switch(char) {
@@ -141,17 +141,10 @@
case '!':
enterUpperOnSpace = true;
break;
- case 'Tab':
- case 'Spacebar':
- case 'Enter':
- sendKey(char);
- return;
default:
break;
}
- for (var i = 0; i < char.length; i++) {
- sendKey(char.charAt(i));
- }
+ insertText(char);
}
});
</script>
diff --git a/ui/keyboard/resources/keysets.html b/ui/keyboard/resources/keysets.html
index 256cbbd..78e55a3 100644
--- a/ui/keyboard/resources/keysets.html
+++ b/ui/keyboard/resources/keysets.html
@@ -7,18 +7,18 @@
<template>
<kb-keyset id="upper" toKeyset="lower">
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key><kb-key>Q</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key><kb-key>Q</kb-key>
<kb-key>W</kb-key><kb-key>E</kb-key><kb-key>R</kb-key><kb-key>T</kb-key>
<kb-key>Y</kb-key><kb-key>U</kb-key><kb-key>I</kb-key><kb-key>O</kb-key>
<kb-key>P</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="symbol dark" toKeyset="symbol" char="Invalid">#123</kb-key>
<kb-key>A</kb-key><kb-key>S</kb-key><kb-key>D</kb-key><kb-key>F</kb-key>
<kb-key>G</kb-key><kb-key>H</kb-key><kb-key>J</kb-key><kb-key>K</kb-key>
<kb-key>L</kb-key><kb-key>\</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
<kb-row>
<kb-key class="left-shift dark" toKeyset="lower" char="Invalid">shift</kb-key>
@@ -30,7 +30,7 @@
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key char="Spacebar" class="space dark" toKeyset="upper"></kb-key>
+ <kb-key char=" " class="space dark" toKeyset="upper"></kb-key>
<kb-key class="dark">@</kb-key>
<kb-key class="hide dark"></kb-key>
</kb-row>
@@ -38,18 +38,18 @@
<kb-keyset id="lower">
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key><kb-key>q</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key><kb-key>q</kb-key>
<kb-key>w</kb-key><kb-key>e</kb-key><kb-key>r</kb-key><kb-key>t</kb-key>
<kb-key>y</kb-key><kb-key>u</kb-key><kb-key>i</kb-key><kb-key>o</kb-key>
<kb-key>p</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="symbol dark" toKeyset="symbol" char="Invalid">#123</kb-key>
<kb-key>a</kb-key><kb-key>s</kb-key><kb-key>d</kb-key><kb-key>f</kb-key>
<kb-key>g</kb-key><kb-key>h</kb-key><kb-key>j</kb-key><kb-key>k</kb-key>
<kb-key>l</kb-key><kb-key>;</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
<kb-row>
<kb-key class="left-shift dark" toKeyset="upper" char="Invalid">shift</kb-key>
@@ -61,7 +61,7 @@
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
<kb-key class="hide dark"></kb-key>
</kb-row>
@@ -69,18 +69,18 @@
<kb-keyset id="symbol">
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key><kb-key>1</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key><kb-key>1</kb-key>
<kb-key>2</kb-key><kb-key>3</kb-key><kb-key>4</kb-key><kb-key>5</kb-key>
<kb-key>6</kb-key><kb-key>7</kb-key><kb-key>8</kb-key><kb-key>9</kb-key>
<kb-key>0</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="symbol dark" toKeyset="lower" char="Invalid">abc</kb-key>
<kb-key>!</kb-key><kb-key>@</kb-key><kb-key>#</kb-key><kb-key>$</kb-key>
<kb-key>%</kb-key><kb-key>^</kb-key><kb-key>&</kb-key><kb-key>*</kb-key>
<kb-key>(</kb-key><kb-key>)</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
<kb-row>
<kb-key class="left-more dark" toKeyset="more" char="Invalid">more</kb-key>
@@ -92,7 +92,7 @@
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
<kb-key class="hide dark"></kb-key>
</kb-row>
@@ -100,18 +100,18 @@
<kb-keyset id="more">
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key><kb-key>`</kb-key>
- <kb-key>~</kb-key><kb-key>&#60</kb-key><kb-key>&#62</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key><kb-key>`</kb-key>
+ <kb-key>~</kb-key><kb-key>&#x003c;</kb-key><kb-key>&#x003E;</kb-key>
<kb-key>[</kb-key><kb-key>]</kb-key><kb-key>{</kb-key><kb-key>}</kb-key>
<kb-key>\</kb-key><kb-key>|</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="symbol dark" toKeyset="lower" char="Invalid">abc</kb-key>
- <kb-key>+</kb-key><kb-key>=</kb-key><kb-key></kb-key><kb-key></kb-key>
+ <kb-key>+</kb-key><kb-key>=</kb-key><kb-key>€</kb-key><kb-key></kb-key>
<kb-key></kb-key><kb-key></kb-key><kb-key></kb-key><kb-key></kb-key>
<kb-key></kb-key><kb-key></kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
<kb-row>
<kb-key class="left-more dark" toKeyset="symbol" char="Invalid">#123</kb-key>
@@ -123,7 +123,7 @@
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
<kb-key class="hide dark"></kb-key>
</kb-row>
diff --git a/ui/keyboard/resources/main.js b/ui/keyboard/resources/main.js
index 9ae319b..6b73a50 100644
--- a/ui/keyboard/resources/main.js
+++ b/ui/keyboard/resources/main.js
@@ -11,24 +11,6 @@ var onResize = function() {
keyboard.style.fontSize = (height / FONT_SIZE_RATIO / ROW_LENGTH) + 'px';
};
-/**
- * Send the given key to chrome.
- */
-function sendKey(key) {
- var keyIdentifier = key;
-
- // Fix up some keys to their respective identifiers for convenience.
- if (keyIdentifier == ' ') {
- keyIdentifier = 'Spacebar';
- }
-
- var keyEvent = {
- keyIdentifier: keyIdentifier
- };
-
- sendKeyEvent(keyEvent);
-};
-
addEventListener('WebComponentsReady', function() {
keyboard.appendChild(
keysets.content.body.firstElementChild.createInstance());
diff --git a/ui/keyboard/resources/voice_input.js b/ui/keyboard/resources/voice_input.js
index bb8d9f7..c6a2bb9 100644
--- a/ui/keyboard/resources/voice_input.js
+++ b/ui/keyboard/resources/voice_input.js
@@ -46,9 +46,7 @@ VoiceInput.prototype = {
if (e.results[i].isFinal)
this.finalResult_ = e.results[i][0].transcript;
}
- for (var i = 0; i < this.finalResult_.length; i++) {
- sendKey(this.finalResult_.charAt(i));
- }
+ insertText(this.finalResult_);
},
/**
diff --git a/ui/keyboard/resources/webui/api_adapter.js b/ui/keyboard/resources/webui/api_adapter.js
index e336b25..1d24ba6 100644
--- a/ui/keyboard/resources/webui/api_adapter.js
+++ b/ui/keyboard/resources/webui/api_adapter.js
@@ -2,9 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-function sendKeyEvent(keyEvent) {
- keyEvent.type = 'keydown';
- chrome.send('sendKeyEvent', [ keyEvent ]);
- keyEvent.type = 'keyup';
- chrome.send('sendKeyEvent', [ keyEvent ]);
+function insertText(text) {
+ chrome.send('insertText', [ text ]);
}
diff --git a/ui/keyboard/resources/webui/keysets.html b/ui/keyboard/resources/webui/keysets.html
index 91c7bf2..67a9eac 100644
--- a/ui/keyboard/resources/webui/keysets.html
+++ b/ui/keyboard/resources/webui/keysets.html
@@ -12,7 +12,7 @@
<kb-key>O</kb-key><kb-key>P</kb-key>
</kb-row>
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key>
<kb-key>A</kb-key><kb-key>S</kb-key><kb-key>D</kb-key><kb-key>F</kb-key>
<kb-key>G</kb-key><kb-key>H</kb-key><kb-key>J</kb-key><kb-key>K</kb-key>
<kb-key>L</kb-key>
@@ -21,15 +21,15 @@
<kb-key class="left-shift dark" toKeyset="lower" char="Invalid">shift</kb-key>
<kb-key>Z</kb-key><kb-key>X</kb-key><kb-key>C</kb-key><kb-key>V</kb-key>
<kb-key>B</kb-key><kb-key>N</kb-key><kb-key>M</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="symbol dark" toKeyset="symbol" char="Invalid">#123</kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
</kb-keyset>
@@ -40,7 +40,7 @@
<kb-key>o</kb-key><kb-key>p</kb-key>
</kb-row>
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key>
<kb-key>a</kb-key><kb-key>s</kb-key><kb-key>d</kb-key><kb-key>f</kb-key>
<kb-key>g</kb-key><kb-key>h</kb-key><kb-key>j</kb-key><kb-key>k</kb-key>
<kb-key>l</kb-key>
@@ -49,15 +49,15 @@
<kb-key class="left-shift dark" toKeyset="upper" char="Invalid">shift</kb-key>
<kb-key>z</kb-key><kb-key>x</kb-key><kb-key>c</kb-key><kb-key>v</kb-key>
<kb-key>b</kb-key><kb-key>n</kb-key><kb-key>m</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="symbol dark" toKeyset="symbol" char="Invalid">#123</kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
</kb-keyset>
@@ -68,7 +68,7 @@
<kb-key>9</kb-key><kb-key>0</kb-key>
</kb-row>
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key>
<kb-key>!</kb-key><kb-key>@</kb-key><kb-key>#</kb-key><kb-key>$</kb-key>
<kb-key>%</kb-key><kb-key>^</kb-key><kb-key>&</kb-key><kb-key>*</kb-key>
<kb-key>(</kb-key>
@@ -77,27 +77,27 @@
<kb-key class="left-more dark" toKeyset="more" char="Invalid">more</kb-key>
<kb-key>)</kb-key><kb-key>/</kb-key><kb-key>-</kb-key><kb-key>'</kb-key>
<kb-key>"</kb-key><kb-key>:</kb-key><kb-key>;</kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="symbol dark" toKeyset="lower" char="Invalid">abc</kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
</kb-keyset>
<kb-keyset id="more">
<kb-row>
<kb-key>_</kb-key><kb-key>`</kb-key><kb-key>~</kb-key>
- <kb-key>&#60</kb-key><kb-key>&#62</kb-key><kb-key>[</kb-key>
+ <kb-key>&#x003C;</kb-key><kb-key>&#x003E;</kb-key><kb-key>[</kb-key>
<kb-key>]</kb-key><kb-key>{</kb-key><kb-key>}</kb-key><kb-key>\</kb-key>
</kb-row>
<kb-row>
- <kb-key class="tab dark" char="Tab">tab</kb-key>
- <kb-key>|</kb-key><kb-key>+</kb-key><kb-key>=</kb-key><kb-key></kb-key>
+ <kb-key class="tab dark" char="&#x0009;">tab</kb-key>
+ <kb-key>|</kb-key><kb-key>+</kb-key><kb-key>=</kb-key><kb-key>€</kb-key>
<kb-key></kb-key><kb-key></kb-key><kb-key></kb-key><kb-key></kb-key>
<kb-key></kb-key>
</kb-row>
@@ -105,15 +105,15 @@
<kb-key class="left-more dark" toKeyset="symbol" char="Invalid">#123</kb-key>
<kb-key></kb-key><kb-key></kb-key><kb-key></kb-key><kb-key></kb-key>
<kb-key></kb-key><kb-key></kb-key><kb-key></kb-key>
- <kb-key class="backspace dark" char="Backspace" repeat>backspace</kb-key>
+ <kb-key class="backspace dark" char="&#x0008;" repeat>backspace</kb-key>
</kb-row>
<kb-row>
<kb-key class="mic dark" char="Mic"></kb-key>
<kb-key class="symbol dark" toKeyset="lower" char="Invalid">abc</kb-key>
<kb-key class="dark">.com</kb-key>
- <kb-key class="space dark" char="Spacebar"></kb-key>
+ <kb-key class="space dark" char=" "></kb-key>
<kb-key class="dark">@</kb-key>
- <kb-key class='return dark' char="Enter">enter</kb-key>
+ <kb-key class='return dark' char="&#x000A;">enter</kb-key>
</kb-row>
</kb-keyset>
</template>
diff --git a/ui/ui.gyp b/ui/ui.gyp
index 775eafe..00e0954 100644
--- a/ui/ui.gyp
+++ b/ui/ui.gyp
@@ -186,8 +186,6 @@
'base/events/event_target.h',
'base/events/event_utils.cc',
'base/events/event_utils.h',
- 'base/events/key_identifier_conversion.cc',
- 'base/events/key_identifier_conversion.h',
'base/gestures/gesture_configuration.cc',
'base/gestures/gesture_configuration.h',
'base/gestures/gesture_point.cc',
@@ -869,8 +867,6 @@
'base/events/event_handler.h',
'base/events/event_target.cc',
'base/events/event_target.h',
- 'base/events/key_identifier_conversion.cc',
- 'base/events/key_identifier_conversion.h',
'base/x/events_x.cc',
],
}],
diff --git a/ui/ui_unittests.gypi b/ui/ui_unittests.gypi
index 7735fcc..53b54a8 100644
--- a/ui/ui_unittests.gypi
+++ b/ui/ui_unittests.gypi
@@ -150,7 +150,6 @@
'base/cocoa/tracking_area_unittest.mm',
'base/events/event_dispatcher_unittest.cc',
'base/events/event_unittest.cc',
- 'base/events/key_identifier_conversion_unittest.cc',
'base/gtk/gtk_expanded_container_unittest.cc',
'base/gtk/gtk_im_context_util_unittest.cc',
'base/gtk/menu_label_accelerator_util_unittest.cc',
@@ -303,7 +302,6 @@
'sources!': [
'base/events/event_dispatcher_unittest.cc',
'base/events/event_unittest.cc',
- 'base/events/key_identifier_conversion_unittest.cc',
],
}],
['use_aura==1', {