diff options
author | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-22 05:55:15 +0000 |
---|---|---|
committer | yusukes@google.com <yusukes@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-22 05:55:15 +0000 |
commit | da5f1955339764e021b24ac0e9abfb89e3160ded (patch) | |
tree | 9ebc58f5208307f15903bb05b43614afd50fb5bd | |
parent | bbbe7f464b4c47292a44076ed9e06a1a437ce08b (diff) | |
download | chromium_src-da5f1955339764e021b24ac0e9abfb89e3160ded.zip chromium_src-da5f1955339764e021b24ac0e9abfb89e3160ded.tar.gz chromium_src-da5f1955339764e021b24ac0e9abfb89e3160ded.tar.bz2 |
Remove virtual keyboard support:
1. common.gypi: use_virtual_keyboard define
2. Any code controlled by that define
3. chrome/browser/ui/virtual_keyboard/*
4. chrome/browser/resources/keyboard/*
5. experimental extension APIs for virtual keyboard
No user-visible changes.
BUG=128295
TEST=try
Review URL: https://chromiumcodereview.appspot.com/10399046
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138223 0039d316-1c4b-4281-b951-d872f2087c98
97 files changed, 58 insertions, 6777 deletions
diff --git a/build/common.gypi b/build/common.gypi index 5407b85..d4d1cbb 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -32,8 +32,7 @@ # Use OpenSSL instead of NSS. Under development: see http://crbug.com/62803 'use_openssl%': 0, - # Disable Virtual keyboard support by default. - 'use_virtual_keyboard%': 0, + 'use_ibus%': 0, # Disable viewport meta tag by default. 'enable_viewport%': 0, @@ -68,7 +67,7 @@ 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', 'use_openssl%': '<(use_openssl)', - 'use_virtual_keyboard%': '<(use_virtual_keyboard)', + 'use_ibus%': '<(use_ibus)', 'enable_viewport%': '<(enable_viewport)', 'enable_hidpi%': '<(enable_hidpi)', 'enable_touch_ui%': '<(enable_touch_ui)', @@ -131,7 +130,7 @@ 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', 'use_openssl%': '<(use_openssl)', - 'use_virtual_keyboard%': '<(use_virtual_keyboard)', + 'use_ibus%': '<(use_ibus)', 'enable_viewport%': '<(enable_viewport)', 'enable_hidpi%': '<(enable_hidpi)', 'enable_touch_ui%': '<(enable_touch_ui)', @@ -517,6 +516,7 @@ 'use_aura%': '<(use_aura)', 'use_ash%': '<(use_ash)', 'use_openssl%': '<(use_openssl)', + 'use_ibus%': '<(use_ibus)', 'use_nss%': '<(use_nss)', 'os_bsd%': '<(os_bsd)', 'os_posix%': '<(os_posix)', @@ -529,7 +529,6 @@ 'enable_pepper_threading%': '<(enable_pepper_threading)', 'build_ppapi_ipc_proxy_untrusted%': '<(build_ppapi_ipc_proxy_untrusted)', 'chromeos%': '<(chromeos)', - 'use_virtual_keyboard%': '<(use_virtual_keyboard)', 'enable_viewport%': '<(enable_viewport)', 'enable_hidpi%': '<(enable_hidpi)', 'enable_touch_ui%': '<(enable_touch_ui)', @@ -1060,9 +1059,6 @@ ['use_nss==1', { 'grit_defines': ['-D', 'use_nss'], }], - ['use_virtual_keyboard==1', { - 'grit_defines': ['-D', 'use_virtual_keyboard'], - }], ['file_manager_extension==1', { 'grit_defines': ['-D', 'file_manager_extension'], }], @@ -1113,13 +1109,6 @@ ], }], - # Set use_ibus to 1 to enable ibus support. - ['use_virtual_keyboard==1 and chromeos==1', { - 'use_ibus%': 1, - }, { - 'use_ibus%': 0, - }], - ['enable_web_intents_tag==1', { 'grit_defines': ['-D', 'enable_web_intents_tag'], }], @@ -1310,9 +1299,6 @@ ['chromeos==1', { 'defines': ['OS_CHROMEOS=1'], }], - ['use_virtual_keyboard==1', { - 'defines': ['USE_VIRTUAL_KEYBOARD=1'], - }], ['use_xi2_mt!=0', { 'defines': ['USE_XI2_MT=<(use_xi2_mt)'], }], diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index b94d3a1..103600c 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -8509,26 +8509,6 @@ The following plug-in is unresponsive: <ph name="PLUGIN_NAME">$1 Restart </message> </if> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_BUTTON" - desc="The label for the virtual keyboard button for customizing virtual keyboard settings"> - Change on-screen keyboard settings... - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_SETTINGS_TITLE" - desc="The label for the virtual keyboard manager page"> - On-screen keyboard settings - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_LAYOUT_COLUMN_TITLE" - desc="The label for the virtual keyboard manager page"> - Keyboard - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_KEYBOARD_COLUMN_TITLE" - desc="The label for the virtual keyboard manager page"> - On-screen keyboard - </message> - <message name="IDS_OPTIONS_SETTINGS_LANGUAGES_DEFAULT_VIRTUAL_KEYBOARD" - desc="The label for a default virtual keyboard in a drop down menu"> - Default - </message> <message name="IDS_OPTIONS_LANGUAGES_ADD_TITLE" desc="The title for the add language dialog."> Add language </message> diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index 947d4b6..28a9d02 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -74,7 +74,6 @@ <include name="IDR_INSPECT_CSS" file="resources\inspect\inspect.css" flattenhtml="true" type="BINDATA" /> <include name="IDR_INSPECT_HTML" file="resources\inspect\inspect.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_INSPECT_JS" file="resources\inspect\inspect.js" flattenhtml="true" type="BINDATA" /> - <include name="IDR_KEYBOARD_MANIFEST" file="resources\keyboard\manifest.json" type="BINDATA" /> <include name="IDR_MEDIA_INTERNALS_HTML" file="resources\media_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_MEDIA_INTERNALS_JS" file="resources\media_internals\media_internals.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_PREDICTORS_HTML" file="resources\predictors\predictors.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> diff --git a/chrome/browser/chromeos/input_method/ibus_controller.h b/chrome/browser/chromeos/input_method/ibus_controller.h index c116468..71e12f7 100644 --- a/chrome/browser/chromeos/input_method/ibus_controller.h +++ b/chrome/browser/chromeos/input_method/ibus_controller.h @@ -65,22 +65,6 @@ class IBusController { // Gets the latest input method property send from the system input method // framework. virtual const InputMethodPropertyList& GetCurrentProperties() const = 0; - -#if defined(USE_VIRTUAL_KEYBOARD) - typedef std::vector<std::pair<double, double> > HandwritingStroke; - - // Sends a handwriting stroke to the system input method. The std::pair - // contains x and y coordinates. (0.0, 0.0) represents the top-left corner of - // a handwriting area, and (1.0, 1.0) does the bottom-right. For example, the - // second stroke for U+30ED (Katakana character Ro) would be something like - // [(0,0), (1,0), (1,1)]. stroke.size() should always be >= 2 (i.e. a single - // dot is not allowed). - virtual void SendHandwritingStroke(const HandwritingStroke& stroke) = 0; - - // Clears the last N handwriting strokes. Pass zero for clearing all strokes. - // TODO(yusukes): Currently ibus-daemon only accepts 0 for |n_strokes|. - virtual void CancelHandwriting(int n_strokes) = 0; -#endif }; } // namespace input_method diff --git a/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc b/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc index 17982b5..f51c4c8 100644 --- a/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc +++ b/chrome/browser/chromeos/input_method/ibus_controller_base_unittest.cc @@ -39,12 +39,6 @@ class TestIBusController : public IBusControllerBase { virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE { return true; } -#if defined(USE_VIRTUAL_KEYBOARD) - virtual void SendHandwritingStroke(const HandwritingStroke& stroke) OVERRIDE { - } - virtual void CancelHandwriting(int n_strokes) OVERRIDE { - } -#endif size_t GetObserverCount() const { return observers_.size(); diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc index 788ded4..266ab4c 100644 --- a/chrome/browser/chromeos/input_method/ibus_controller_impl.cc +++ b/chrome/browser/chromeos/input_method/ibus_controller_impl.cc @@ -645,42 +645,6 @@ bool IBusControllerImpl::ActivateInputMethodProperty(const std::string& key) { return true; } -#if defined(USE_VIRTUAL_KEYBOARD) -// IBusController override. -void IBusControllerImpl::SendHandwritingStroke( - const HandwritingStroke& stroke) { - if (stroke.size() < 2) { - DVLOG(1) << "Empty stroke data or a single dot is passed."; - return; - } - - IBusInputContext* context = - GetInputContext(current_input_context_path_, ibus_); - if (!context) - return; - - const size_t raw_stroke_size = stroke.size() * 2; - scoped_array<double> raw_stroke(new double[raw_stroke_size]); - for (size_t n = 0; n < stroke.size(); ++n) { - raw_stroke[n * 2] = stroke[n].first; // x - raw_stroke[n * 2 + 1] = stroke[n].second; // y - } - ibus_input_context_process_hand_writing_event( - context, raw_stroke.get(), raw_stroke_size); - g_object_unref(context); -} - -// IBusController override. -void IBusControllerImpl::CancelHandwriting(int n_strokes) { - IBusInputContext* context = - GetInputContext(current_input_context_path_, ibus_); - if (!context) - return; - ibus_input_context_cancel_hand_writing(context, n_strokes); - g_object_unref(context); -} -#endif - bool IBusControllerImpl::IBusConnectionsAreAlive() { return (ibus_daemon_status_ == IBUS_DAEMON_RUNNING) && ibus_ && ibus_bus_is_connected(ibus_) && ibus_config_; diff --git a/chrome/browser/chromeos/input_method/ibus_controller_impl.h b/chrome/browser/chromeos/input_method/ibus_controller_impl.h index 157fddd..fecc31d 100644 --- a/chrome/browser/chromeos/input_method/ibus_controller_impl.h +++ b/chrome/browser/chromeos/input_method/ibus_controller_impl.h @@ -49,10 +49,6 @@ class IBusControllerImpl : public IBusControllerBase { virtual bool Stop() OVERRIDE; virtual bool ChangeInputMethod(const std::string& id) OVERRIDE; virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE; -#if defined(USE_VIRTUAL_KEYBOARD) - virtual void SendHandwritingStroke(const HandwritingStroke& stroke) OVERRIDE; - virtual void CancelHandwriting(int n_strokes) OVERRIDE; -#endif // Calls <anonymous_namespace>::FindAndUpdateProperty. This method is just for // unit testing. diff --git a/chrome/browser/chromeos/input_method/input_method_descriptor.cc b/chrome/browser/chromeos/input_method/input_method_descriptor.cc index 7b9736f..4a2a91a 100644 --- a/chrome/browser/chromeos/input_method/input_method_descriptor.cc +++ b/chrome/browser/chromeos/input_method/input_method_descriptor.cc @@ -10,6 +10,8 @@ #include "base/string_split.h" #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" +// TODO(yusukes): Remove virtual keyboard support. + namespace chromeos { namespace input_method { diff --git a/chrome/browser/chromeos/input_method/input_method_descriptor_unittest.cc b/chrome/browser/chromeos/input_method/input_method_descriptor_unittest.cc index 4c96b86..14f8b3e 100644 --- a/chrome/browser/chromeos/input_method/input_method_descriptor_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_descriptor_unittest.cc @@ -7,12 +7,6 @@ #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(USE_VIRTUAL_KEYBOARD) -// Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we -// skip the test for now. -#define TestCreateInputMethodDescriptor DISABLED_TestCreateInputMethodDescriptor -#endif // USE_VIRTUAL_KEYBOARD - namespace chromeos { namespace input_method { @@ -63,8 +57,6 @@ TEST_F(InputMethodDescriptorTest, TestCreateInputMethodDescriptor) { EXPECT_EQ(kFallbackLayout, GetDesc("not-supported").keyboard_layout()); EXPECT_EQ(kFallbackLayout, GetDesc(",").keyboard_layout()); EXPECT_EQ(kFallbackLayout, GetDesc("").keyboard_layout()); - - // TODO(yusukes): Add tests for |virtual_keyboard_layout| member. } TEST_F(InputMethodDescriptorTest, TestOperatorEqual) { diff --git a/chrome/browser/chromeos/input_method/input_method_manager.h b/chrome/browser/chromeos/input_method/input_method_manager.h index 70edf59..6170111 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager.h +++ b/chrome/browser/chromeos/input_method/input_method_manager.h @@ -176,8 +176,4 @@ class InputMethodManager { } // namespace input_method } // namespace chromeos -// TODO(yusukes): Adding back the Virtual Keyboard support to somewhere in -// input_method/. Adding it directly to this class is probably not the right -// thing to do. - #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_INPUT_METHOD_MANAGER_H_ diff --git a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc index f5e00bb..c9eacb8 100644 --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc @@ -581,7 +581,6 @@ bool InputMethodManagerImpl::ContainOnlyKeyboardLayout( } void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { -#if !defined(USE_VIRTUAL_KEYBOARD) if (candidate_window_controller_.get()) return; @@ -591,7 +590,6 @@ void InputMethodManagerImpl::MaybeInitializeCandidateWindowController() { candidate_window_controller_->AddObserver(this); else DVLOG(1) << "Failed to initialize the candidate window controller"; -#endif } // static 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 088f572..2eb88cd 100644 --- a/chrome/browser/chromeos/input_method/input_method_util_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_util_unittest.cc @@ -14,22 +14,6 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/base/l10n/l10n_util.h" -#if defined(USE_VIRTUAL_KEYBOARD) -// Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we -// skip the tests for now. -#define TestGetFirstLoginInputMethodIds_Dvorak_And_Ja \ - DISABLED_TestGetFirstLoginInputMethodIds_Dvorak_And_Ja -#define TestGetFirstLoginInputMethodIds_JP_And_Ja \ - DISABLED_TestGetFirstLoginInputMethodIds_JP_And_Ja -#define TestGetFirstLoginInputMethodIds_Us_And_Ru \ - DISABLED_TestGetFirstLoginInputMethodIds_Us_And_Ru -#define TestGetInputMethodDescriptorFromXkbId \ - DISABLED_TestGetInputMethodDescriptorFromXkbId -#define TestGetKeyboardLayoutName DISABLED_TestGetKeyboardLayoutName -#define TestGetLanguageCodesFromInputMethodIds \ - DISABLED_TestGetLanguageCodesFromInputMethodIds -#endif // USE_VIRTUAL_KEYBOARD - namespace chromeos { extern const char* kExtensionImePrefix; diff --git a/chrome/browser/chromeos/input_method/input_method_whitelist_unittest.cc b/chrome/browser/chromeos/input_method/input_method_whitelist_unittest.cc index 705266a..2891d29 100644 --- a/chrome/browser/chromeos/input_method/input_method_whitelist_unittest.cc +++ b/chrome/browser/chromeos/input_method/input_method_whitelist_unittest.cc @@ -6,13 +6,6 @@ #include "chrome/browser/chromeos/input_method/input_method_whitelist.h" #include "testing/gtest/include/gtest/gtest.h" -#if defined(USE_VIRTUAL_KEYBOARD) -// Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we -// skip the tests for now. -#define TestInputMethodIdIsWhitelisted DISABLED_TestInputMethodIdIsWhitelisted -#define TestXkbLayoutIsSupported DISABLED_TestXkbLayoutIsSupported -#endif // USE_VIRTUAL_KEYBOARD - namespace chromeos { namespace input_method { diff --git a/chrome/browser/chromeos/input_method/input_methods.txt b/chrome/browser/chromeos/input_method/input_methods.txt index b4d7794..1e5b69b 100644 --- a/chrome/browser/chromeos/input_method/input_methods.txt +++ b/chrome/browser/chromeos/input_method/input_methods.txt @@ -55,42 +55,41 @@ # U.S. English xkb:us::eng us en-US -xkb:us:intl:eng us(intl) en-US !defined(USE_VIRTUAL_KEYBOARD) -xkb:us:altgr-intl:eng us(altgr-intl) en-US !defined(USE_VIRTUAL_KEYBOARD) -xkb:us:dvorak:eng us(dvorak) en-US !defined(USE_VIRTUAL_KEYBOARD) -xkb:us:colemak:eng us(colemak) en-US !defined(USE_VIRTUAL_KEYBOARD) -english-m us en-US !defined(USE_VIRTUAL_KEYBOARD) +xkb:us:intl:eng us(intl) en-US +xkb:us:altgr-intl:eng us(altgr-intl) en-US +xkb:us:dvorak:eng us(dvorak) en-US +xkb:us:colemak:eng us(colemak) en-US +english-m us en-US # 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 !defined(USE_VIRTUAL_KEYBOARD) +xkb:be::nld be nl # We don't support xkb:nl::nld. See b/4430951. # French xkb:fr::fra fr fr -xkb:be::fra be fr !defined(USE_VIRTUAL_KEYBOARD) -xkb:ca::fra ca fr !defined(USE_VIRTUAL_KEYBOARD) -xkb:ch:fr:fra ch(fr) fr !defined(USE_VIRTUAL_KEYBOARD) +xkb:be::fra be fr +xkb:ca::fra ca fr +xkb:ch:fr:fra ch(fr) fr # German -xkb:de::ger de de !defined(USE_VIRTUAL_KEYBOARD) -xkb:de:neo:ger de(neo) de !defined(USE_VIRTUAL_KEYBOARD) -xkb:be::ger be de !defined(USE_VIRTUAL_KEYBOARD) -xkb:ch::ger ch de !defined(USE_VIRTUAL_KEYBOARD) +xkb:de::ger de de +xkb:de:neo:ger de(neo) de +xkb:be::ger be de +xkb:ch::ger ch de # Japanese mozc us ja -mozc-jp jp ja !defined(USE_VIRTUAL_KEYBOARD) -mozc-dv us(dvorak) ja !defined(USE_VIRTUAL_KEYBOARD) +mozc-jp jp ja +mozc-dv us(dvorak) ja # |kMozcJaInputMethodIds| in ibus_ui_controller.cc should also be updated when # a new Mozc Japanese IME for another keyboard layout is added. -xkb:jp::jpn jp ja !defined(USE_VIRTUAL_KEYBOARD) -zinnia-japanese handwriting-vk,jp ja defined(USE_VIRTUAL_KEYBOARD) +xkb:jp::jpn jp ja # Russian -xkb:ru::rus ru ru !defined(USE_VIRTUAL_KEYBOARD) -xkb:ru:phonetic:rus ru(phonetic) ru !defined(USE_VIRTUAL_KEYBOARD) +xkb:ru::rus ru ru +xkb:ru:phonetic:rus ru(phonetic) ru # Thai m17n:th:kesmanee us th @@ -99,7 +98,7 @@ m17n:th:tis820 us th # Simplified Chinese pinyin us zh-CN -pinyin-dv us(dvorak) zh-CN !defined(USE_VIRTUAL_KEYBOARD) +pinyin-dv us(dvorak) zh-CN # Traditional Chinese mozc-chewing us zh-TW @@ -175,35 +174,35 @@ m17n:kn:itrans us kn m17n:am:sera us am # Keyboard layouts. -xkb:br::por br pt-BR !defined(USE_VIRTUAL_KEYBOARD) -xkb:bg::bul bg bg !defined(USE_VIRTUAL_KEYBOARD) -xkb:bg:phonetic:bul bg(phonetic) bg !defined(USE_VIRTUAL_KEYBOARD) -xkb:ca:eng:eng ca(eng) en-CA !defined(USE_VIRTUAL_KEYBOARD) -xkb:cz::cze cz cs !defined(USE_VIRTUAL_KEYBOARD) -xkb:ee::est ee et !defined(USE_VIRTUAL_KEYBOARD) -xkb:es::spa es es !defined(USE_VIRTUAL_KEYBOARD) -xkb:es:cat:cat es(cat) ca !defined(USE_VIRTUAL_KEYBOARD) -xkb:dk::dan dk da !defined(USE_VIRTUAL_KEYBOARD) -xkb:gr::gre gr el !defined(USE_VIRTUAL_KEYBOARD) -xkb:il::heb il he !defined(USE_VIRTUAL_KEYBOARD) -xkb:latam::spa latam es !defined(USE_VIRTUAL_KEYBOARD) -xkb:lt::lit lt lt !defined(USE_VIRTUAL_KEYBOARD) -xkb:lv:apostrophe:lav lv(apostrophe) lv !defined(USE_VIRTUAL_KEYBOARD) -xkb:hr::scr hr hr !defined(USE_VIRTUAL_KEYBOARD) -xkb:gb:extd:eng gb(extd) en-GB !defined(USE_VIRTUAL_KEYBOARD) -xkb:gb:dvorak:eng gb(dvorak) en-GB !defined(USE_VIRTUAL_KEYBOARD) -xkb:fi::fin fi fi !defined(USE_VIRTUAL_KEYBOARD) -xkb:hu::hun hu hu !defined(USE_VIRTUAL_KEYBOARD) -xkb:it::ita it it !defined(USE_VIRTUAL_KEYBOARD) -xkb:no::nob no nb !defined(USE_VIRTUAL_KEYBOARD) -xkb:pl::pol pl pl !defined(USE_VIRTUAL_KEYBOARD) -xkb:pt::por pt pt-PT !defined(USE_VIRTUAL_KEYBOARD) -xkb:ro::rum ro ro !defined(USE_VIRTUAL_KEYBOARD) -xkb:se::swe se sv !defined(USE_VIRTUAL_KEYBOARD) -xkb:sk::slo sk sk !defined(USE_VIRTUAL_KEYBOARD) -xkb:si::slv si sl !defined(USE_VIRTUAL_KEYBOARD) -xkb:rs::srp rs sr !defined(USE_VIRTUAL_KEYBOARD) -xkb:tr::tur tr tr !defined(USE_VIRTUAL_KEYBOARD) -xkb:ua::ukr ua uk !defined(USE_VIRTUAL_KEYBOARD) +xkb:br::por br pt-BR +xkb:bg::bul bg bg +xkb:bg:phonetic:bul bg(phonetic) bg +xkb:ca:eng:eng ca(eng) en-CA +xkb:cz::cze cz cs +xkb:ee::est ee et +xkb:es::spa es es +xkb:es:cat:cat es(cat) ca +xkb:dk::dan dk da +xkb:gr::gre gr el +xkb:il::heb il he +xkb:latam::spa latam es +xkb:lt::lit lt lt +xkb:lv:apostrophe:lav lv(apostrophe) lv +xkb:hr::scr hr hr +xkb:gb:extd:eng gb(extd) en-GB +xkb:gb:dvorak:eng gb(dvorak) en-GB +xkb:fi::fin fi fi +xkb:hu::hun hu hu +xkb:it::ita it it +xkb:no::nob no nb +xkb:pl::pol pl pl +xkb:pt::por pt pt-PT +xkb:ro::rum ro ro +xkb:se::swe se sv +xkb:sk::slo sk sk +xkb:si::slv si sl +xkb:rs::srp rs sr +xkb:tr::tur tr tr +xkb:ua::ukr ua uk # TODO(yusukes): Support xkb:latam:deadtilde:spa and/or xkb:latam:nodeadkeys:spa # if necessary. diff --git a/chrome/browser/chromeos/input_method/mock_ibus_controller.h b/chrome/browser/chromeos/input_method/mock_ibus_controller.h index 1339ee1..9b1181d 100644 --- a/chrome/browser/chromeos/input_method/mock_ibus_controller.h +++ b/chrome/browser/chromeos/input_method/mock_ibus_controller.h @@ -26,12 +26,6 @@ class MockIBusController : public IBusControllerBase { virtual bool Stop() OVERRIDE; virtual bool ChangeInputMethod(const std::string& id) OVERRIDE; virtual bool ActivateInputMethodProperty(const std::string& key) OVERRIDE; -#if defined(USE_VIRTUAL_KEYBOARD) - virtual void SendHandwritingStroke(const HandwritingStroke& stroke) OVERRIDE { - } - virtual void CancelHandwriting(int n_strokes) OVERRIDE { - } -#endif int start_count_; bool start_return_; diff --git a/chrome/browser/chromeos/input_method/virtual_keyboard_selector.cc b/chrome/browser/chromeos/input_method/virtual_keyboard_selector.cc deleted file mode 100644 index d63da4b..0000000 --- a/chrome/browser/chromeos/input_method/virtual_keyboard_selector.cc +++ /dev/null @@ -1,175 +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 "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" - -#include "base/logging.h" -#include "base/stl_util.h" - -namespace { - -const char kDefaultURLPath[] = "index.html"; -const size_t kDefaultURLPathLen = arraysize(kDefaultURLPath) - 1; - -namespace ime = ::chromeos::input_method; - -// Selects and returns a virtual keyboard extension from |keyboards| which -// supports the |layout|. -const ime::VirtualKeyboard* SelectVirtualKeyboardInternal( - const std::list<const ime::VirtualKeyboard*>& keyboards, - const std::string& layout) { - for (std::list<const ime::VirtualKeyboard*>::const_iterator iter = - keyboards.begin(); iter != keyboards.end(); ++iter) { - const ime::VirtualKeyboard* keyboard = *iter; - if (keyboard->IsLayoutSupported(layout)) - return keyboard; - } - return NULL; -} - -} // namespace - -namespace chromeos { -namespace input_method { - -VirtualKeyboard::VirtualKeyboard(const GURL& url, - const std::string& name, - const std::set<std::string>& supported_layouts, - bool is_system) - : url_(url), - name_(name), - supported_layouts_(supported_layouts), - is_system_(is_system) { -} - -VirtualKeyboard::~VirtualKeyboard() { -} - -GURL VirtualKeyboard::GetURLForLayout(const std::string& layout) const { - if (layout.empty()) { - return url_; - } - url_canon::Replacements<char> replacements; - replacements.SetPath( - kDefaultURLPath, url_parse::Component(0, kDefaultURLPathLen)); - // TODO(yusukes): would be better to URL-encode the |layout|? - replacements.SetRef(layout.c_str(), url_parse::Component(0, layout.length())); - return url_.ReplaceComponents(replacements); -} - -bool VirtualKeyboard::IsLayoutSupported(const std::string& layout) const { - return supported_layouts_.count(layout) > 0; -} - -VirtualKeyboardSelector::VirtualKeyboardSelector() - : current_(NULL) { -} - -VirtualKeyboardSelector::~VirtualKeyboardSelector() { - STLDeleteElements(&keyboards_); - STLDeleteElements(&system_keyboards_); -} - -bool VirtualKeyboardSelector::AddVirtualKeyboard( - const GURL& url, - const std::string& name, - const std::set<std::string>& supported_layouts, - bool is_system) { - if (url_to_keyboard_.count(url)) - return false; // the URL is already in use. - - const VirtualKeyboard* new_keyboard = new VirtualKeyboard(url, - name, - supported_layouts, - is_system); - if (is_system) { - system_keyboards_.push_front(new_keyboard); - } else { - keyboards_.push_front(new_keyboard); - } - - url_to_keyboard_.insert(std::make_pair(url, new_keyboard)); - std::set<std::string>::const_iterator layout_iter; - for (layout_iter = new_keyboard->supported_layouts().begin(); - layout_iter != new_keyboard->supported_layouts().end(); - ++layout_iter) { - const std::string& layout = *layout_iter; - layout_to_keyboard_.insert(std::make_pair(layout, new_keyboard)); - } - - return true; -} - -const VirtualKeyboard* VirtualKeyboardSelector::SelectVirtualKeyboard( - const std::string& layout) { - if (layout.empty()) { - DVLOG(1) << "No layout is specified"; - return NULL; - } - - // First, check the user pref. - std::map<std::string, const VirtualKeyboard*>::const_iterator iter = - user_preference_.find(layout); - if (iter != user_preference_.end() && - iter->second->IsLayoutSupported(layout)) { - current_ = iter->second; - return current_; - } - - // Second, check whether the current keyboard supports the layout. - if (current_ && current_->IsLayoutSupported(layout)) { - return current_; - } - - const VirtualKeyboard* keyboard = - SelectVirtualKeyboardWithoutPreferences(layout); - if (!keyboard) { - DVLOG(1) << "No virtual keyboard for " << layout << " is found"; - return NULL; - } - - current_ = keyboard; - return keyboard; -} - -bool VirtualKeyboardSelector::SetUserPreference( - const std::string& layout, const GURL& url) { - std::map<GURL, const VirtualKeyboard*>::const_iterator iter = - url_to_keyboard_.find(url); - if (iter == url_to_keyboard_.end()) { - DVLOG(1) << "Can't set user preference: unknown URL"; - return false; - } - - const VirtualKeyboard* keyboard = iter->second; - if (!keyboard->IsLayoutSupported(layout)) { - DVLOG(1) << "Requested layout is not supported by requested URL"; - return false; - } - - RemoveUserPreference(layout); - user_preference_.insert(std::make_pair(layout, keyboard)); - return true; -} - -void VirtualKeyboardSelector::RemoveUserPreference(const std::string& layout) { - user_preference_.erase(layout); -} - -void VirtualKeyboardSelector::ClearAllUserPreferences() { - user_preference_.clear(); -} - -const VirtualKeyboard* -VirtualKeyboardSelector::SelectVirtualKeyboardWithoutPreferences( - const std::string& layout) { - const VirtualKeyboard* keyboard = - SelectVirtualKeyboardInternal(keyboards_, layout); - if (!keyboard) - keyboard = SelectVirtualKeyboardInternal(system_keyboards_, layout); - return keyboard; -} - -} // namespace input_method -} // namespace chromeos diff --git a/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h b/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h deleted file mode 100644 index 477cefe..0000000 --- a/chrome/browser/chromeos/input_method/virtual_keyboard_selector.h +++ /dev/null @@ -1,155 +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 CHROME_BROWSER_CHROMEOS_INPUT_METHOD_VIRTUAL_KEYBOARD_SELECTOR_H_ -#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_VIRTUAL_KEYBOARD_SELECTOR_H_ -#pragma once - -#include <list> -#include <map> -#include <set> -#include <string> - -#include "base/basictypes.h" -#include "googleurl/src/gurl.h" - -namespace chromeos { -namespace input_method { - -// A class which represents a virtual keyboard extension. One virtual keyboard -// extension can support more than one keyboard layout. -class VirtualKeyboard { - public: - VirtualKeyboard(const GURL& url, - const std::string& name, - const std::set<std::string>& supported_layouts, - bool is_system); - ~VirtualKeyboard(); - - // Returns URL for displaying the keyboard UI specified by |layout|. - // For example, when |url_| is "http://adcfj..kjhil/" and |layout| is "us", - // the function would return "http://adcfj..kjhil/index.html#us". When - // |layout| is empty, it returns |url_| as-is, which is "http://adcfj..kjhil/" - // in this case. - GURL GetURLForLayout(const std::string& layout) const; - - // Returns true if the virtual keyboard extension supports the |layout|. - bool IsLayoutSupported(const std::string& layout) const; - - const GURL& url() const { return url_; } - const std::string& name() const { return name_; } - const std::set<std::string>& supported_layouts() const { - return supported_layouts_; - } - bool is_system() const { return is_system_; } - - private: - const GURL url_; - const std::string name_; - const std::set<std::string> supported_layouts_; - const bool is_system_; - - DISALLOW_COPY_AND_ASSIGN(VirtualKeyboard); -}; - -// A class which holds all available virtual keyboard extensions. -class VirtualKeyboardSelector { - public: - VirtualKeyboardSelector(); - ~VirtualKeyboardSelector(); - - // Adds a new virtual keyboard extension. If |keyboard.is_system_| is true, - // the virtual keyboard extension will have lower priority than non-system - // keyboard extensions. Returns false if a virtual keyboard extension - // specified by the |url| is already added. - // TODO(yusukes): Add RemoveVirtualKeyboard() as well. - bool AddVirtualKeyboard(const GURL& url, - const std::string& name, - const std::set<std::string>& supported_layouts, - bool is_system); - - // Selects and returns the most suitable virtual keyboard extension for the - // |layout|. Returns NULL if no virtual keyboard extension for the layout - // is found. If a specific virtual keyboard extension for the |layout| is - // already set by SetUserPreference, the virtual keyboard extension is always - // returned. If |current_|, which is the virtual keyboard extension currently - // in use, supports the |layout|, the current one will be returned. Otherwise - // the function scans the list of |keyboards_| and then the list of - // |system_keyboards_|. The most recently added keyboards to each list take - // precedence. - // - // Checking the |current_| keyboard is important for the following use case: - // - If I have installed a VK extension that provides a US and an FR layout - // and I switch from the US layout of the extension (+ English IME) to the - // French IME, then I would like to use the FR layout of the extension I am - // currently using. - const VirtualKeyboard* SelectVirtualKeyboard(const std::string& layout); - - // Sets user preferences on virtual keyboard selection so that the virtual - // keyboard extension specified by the |url| is always selected for the - // |layout|. Returns false if a virtual keyboard extension whose address is - // |url| is not registered, or the extension specified by the |url| does not - // support the |layout|. - bool SetUserPreference(const std::string& layout, const GURL& url); - - // Removes the preference for the |layout| added by SetUserPreference. - void RemoveUserPreference(const std::string& layout); - - // Removes all preferences added by SetUserPreference. - void ClearAllUserPreferences(); - - const std::map<GURL, const VirtualKeyboard*>& url_to_keyboard() const { - return url_to_keyboard_; - } - - const std::multimap< - std::string, const VirtualKeyboard*>& layout_to_keyboard() const { - return layout_to_keyboard_; - } - - protected: - // Selects and returns the most suitable virtual keyboard extension for the - // |layout|. Unlike SelectVirtualKeyboard(), this function only scans - // |keyboards_| and |system_keyboards_| (in this order), and never updates - // |current_|. The function is protected for testability. - const VirtualKeyboard* SelectVirtualKeyboardWithoutPreferences( - const std::string& layout); - - // The function is protected for testability. - const std::map<std::string, const VirtualKeyboard*>& user_preference() const { - return user_preference_; - } - - private: - // A list of third party virtual keyboard extensions. - std::list<const VirtualKeyboard*> keyboards_; - // A list of system virtual keyboard extensions. - std::list<const VirtualKeyboard*> system_keyboards_; - - // A map from layout name to virtual keyboard extension. - std::map<std::string, const VirtualKeyboard*> user_preference_; - - // TODO(yusukes): Support per-site preference. e.g. always use virtual - // keyboard ABC on https://mail.google.com/, XYZ on http://www.google.com/. - - // The virtual keyboard currently in use. - const VirtualKeyboard* current_; - - // A map from URL to virtual keyboard extension. The map is for making - // SetUserPreference() faster. - std::map<GURL, const VirtualKeyboard*> url_to_keyboard_; - - // A *multi* map from layout name to virtual keyboard extension. An example - // value of the variable would be: { "us": extension1, - // "us(dvorak)": extension1, - // "us": extension2 } - std::multimap<std::string, const VirtualKeyboard*> layout_to_keyboard_; - - DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardSelector); -}; - -} // namespace input_method -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_VIRTUAL_KEYBOARD_SELECTOR_H_ diff --git a/chrome/browser/chromeos/input_method/virtual_keyboard_selector_unittest.cc b/chrome/browser/chromeos/input_method/virtual_keyboard_selector_unittest.cc deleted file mode 100644 index 8400d3f..0000000 --- a/chrome/browser/chromeos/input_method/virtual_keyboard_selector_unittest.cc +++ /dev/null @@ -1,739 +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 "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" - -#include "base/logging.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace ime = ::chromeos::input_method; - -// For EXPECT_TRUE calls below. The operator has to be in the global namespace. -static bool operator==( - const ime::VirtualKeyboard& lhs, const ime::VirtualKeyboard& rhs) { - return lhs.GetURLForLayout("") == rhs.GetURLForLayout(""); -} - -namespace { - -typedef std::multimap< - std::string, const ime::VirtualKeyboard*> LayoutToKeyboard; - -// Returns true if [start, end) and |urls| are equal sets. -template <size_t L> bool CheckUrls(LayoutToKeyboard::const_iterator start, - LayoutToKeyboard::const_iterator end, - const char* (&urls)[L]) { - std::set<GURL> expected_url_set; - for (size_t i = 0; i < L; ++i) { - if (!expected_url_set.insert(GURL(urls[i])).second) { - DVLOG(1) << "Duplicated URL: " << urls[i]; - return false; - } - } - - std::set<GURL> actual_url_set; - for (LayoutToKeyboard::const_iterator iter = start; iter != end; ++iter) { - if (!actual_url_set.insert(iter->second->url()).second) { - DVLOG(1) << "Duplicated URL: " << iter->second->url().spec(); - return false; - } - } - - return expected_url_set == actual_url_set; -} - -template <size_t L> -std::set<std::string> CreateLayoutSet(const char* (&layouts)[L]) { - std::set<std::string> result; - for (size_t i = 0; i < L; ++i) { - result.insert(layouts[i]); - } - return result; -} - -} // namespace - -namespace chromeos { -namespace input_method { - -class TestableVirtualKeyboardSelector : public VirtualKeyboardSelector { - public: - // Change access rights. - using VirtualKeyboardSelector::SelectVirtualKeyboardWithoutPreferences; - using VirtualKeyboardSelector::user_preference; -}; - -TEST(VirtualKeyboardSelectorTest, TestNoKeyboard) { - TestableVirtualKeyboardSelector selector; - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("us")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("")); -} - -TEST(VirtualKeyboardSelectorTest, TestAddVirtualKeyboard) { - static const char* layouts[] = { "a", "b", "c" }; - - // The first two keyboards have the same URL. - VirtualKeyboard virtual_keyboard_1( - GURL("http://url1"), "", CreateLayoutSet(layouts), true /* is_system */); - VirtualKeyboard virtual_keyboard_2( - GURL("http://url1"), "", CreateLayoutSet(layouts), false /* is_system */); - VirtualKeyboard virtual_keyboard_3( - GURL("http://url2"), "", CreateLayoutSet(layouts), false /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - - // You can't add the same keyboard twice. - EXPECT_FALSE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - EXPECT_FALSE(selector.AddVirtualKeyboard( - virtual_keyboard_2.url(), - virtual_keyboard_2.name(), - virtual_keyboard_2.supported_layouts(), - virtual_keyboard_2.is_system())); - - EXPECT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_3.url(), - virtual_keyboard_3.name(), - virtual_keyboard_3.supported_layouts(), - virtual_keyboard_3.is_system())); -} - -TEST(VirtualKeyboardSelectorTest, TestSystemKeyboard) { - static const char* layouts[] = { "a", "b", "c" }; - VirtualKeyboard system_virtual_keyboard( - GURL("http://system"), "", CreateLayoutSet(layouts), true /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard.url(), - system_virtual_keyboard.name(), - system_virtual_keyboard.supported_layouts(), - system_virtual_keyboard.is_system())); - - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard == *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - EXPECT_TRUE(system_virtual_keyboard == *selector.SelectVirtualKeyboard("b")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(system_virtual_keyboard == *selector.SelectVirtualKeyboard("c")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("d")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("aa")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("")); -} - -TEST(VirtualKeyboardSelectorTest, TestTwoSystemKeyboards) { - static const char* layouts_1[] = { "a", "b", "c" }; - static const char* layouts_2[] = { "a", "c", "d" }; - - VirtualKeyboard system_virtual_keyboard_1( - GURL("http://system1"), "", CreateLayoutSet(layouts_1), - true /* is_system */); - VirtualKeyboard system_virtual_keyboard_2( - GURL("http://system2"), "", CreateLayoutSet(layouts_2), - true /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_1.url(), - system_virtual_keyboard_1.name(), - system_virtual_keyboard_1.supported_layouts(), - system_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_2.url(), - system_virtual_keyboard_2.name(), - system_virtual_keyboard_2.supported_layouts(), - system_virtual_keyboard_2.is_system())); - - // At this point, system_virtual_keyboard_2 has higher priority since it's - // added later than system_virtual_keyboard_1. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("d")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("d")); - - // Request "b". system_virtual_keyboard_1 should be returned. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("b")); - - // Now system_virtual_keyboard_1 should be selected for 'a' and 'c' since - // it's the current virtual keyboard. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("c")); - - // Request "d" again. system_virtual_keyboard_2 should be returned. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("d")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("d")); - // This time, system_virtual_keyboard_2 should be selected for 'a' and 'c'. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); -} - -TEST(VirtualKeyboardSelectorTest, TestUserKeyboard) { - static const char* layouts[] = { "a", "b", "c" }; - VirtualKeyboard user_virtual_keyboard( - GURL("http://user"), "", CreateLayoutSet(layouts), false /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard.url(), - user_virtual_keyboard.name(), - user_virtual_keyboard.supported_layouts(), - user_virtual_keyboard.is_system())); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard == *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - EXPECT_TRUE(user_virtual_keyboard == *selector.SelectVirtualKeyboard("b")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard == *selector.SelectVirtualKeyboard("c")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("d")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("aa")); - EXPECT_EQ(NULL, selector.SelectVirtualKeyboard("")); -} - -TEST(VirtualKeyboardSelectorTest, TestTwoUserKeyboards) { - static const char* layouts_1[] = { "a", "b", "c" }; - static const char* layouts_2[] = { "a", "c", "d" }; - - VirtualKeyboard user_virtual_keyboard_1( - GURL("http://user1"), "", CreateLayoutSet(layouts_1), - false /* is_system */); - VirtualKeyboard user_virtual_keyboard_2( - GURL("http://user2"), "", CreateLayoutSet(layouts_2), - false /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_1.url(), - user_virtual_keyboard_1.name(), - user_virtual_keyboard_1.supported_layouts(), - user_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_2.url(), - user_virtual_keyboard_2.name(), - user_virtual_keyboard_2.supported_layouts(), - user_virtual_keyboard_2.is_system())); - - // At this point, user_virtual_keyboard_2 has higher priority since it's - // added later than user_virtual_keyboard_1. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("d")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("d")); - - // Request "b". user_virtual_keyboard_1 should be returned. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("b")); - - // Now user_virtual_keyboard_1 should be selected for 'a' and 'c' since - // it's the current virtual keyboard. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("c")); - - // Request "d" again. user_virtual_keyboard_2 should be returned. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("d")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("d")); - // This time, user_virtual_keyboard_2 should be selected for 'a' and 'c'. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); -} - -TEST(VirtualKeyboardSelectorTest, TestUserSystemMixed) { - static const char* ulayouts_1[] = { "a", "b", "c" }; - static const char* ulayouts_2[] = { "a", "c", "d" }; - static const char* layouts_1[] = { "a", "x", "y" }; - static const char* layouts_2[] = { "a", "y", "z" }; - - VirtualKeyboard user_virtual_keyboard_1( - GURL("http://user1"), "", CreateLayoutSet(ulayouts_1), - false /* is_system */); - VirtualKeyboard user_virtual_keyboard_2( - GURL("http://user2"), "", CreateLayoutSet(ulayouts_2), - false /* is_system */); - VirtualKeyboard system_virtual_keyboard_1( - GURL("http://system1"), "", CreateLayoutSet(layouts_1), - true /* is_system */); - VirtualKeyboard system_virtual_keyboard_2( - GURL("http://system2"), "", CreateLayoutSet(layouts_2), - true /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_1.url(), - user_virtual_keyboard_1.name(), - user_virtual_keyboard_1.supported_layouts(), - user_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_2.url(), - user_virtual_keyboard_2.name(), - user_virtual_keyboard_2.supported_layouts(), - user_virtual_keyboard_2.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_1.url(), - system_virtual_keyboard_1.name(), - system_virtual_keyboard_1.supported_layouts(), - system_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_2.url(), - system_virtual_keyboard_2.name(), - system_virtual_keyboard_2.supported_layouts(), - system_virtual_keyboard_2.is_system())); - - // At this point, user_virtual_keyboard_2 has the highest priority. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("d")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("d")); - - // Request "b". user_virtual_keyboard_1 should be returned. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("b")); - // Now user_virtual_keyboard_1 should be selected for 'a' and 'c' since - // it's the current virtual keyboard. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("c")); - - // Request "x". system_virtual_keyboard_2 should be returned (since it's - // added later than system_virtual_keyboard_1). - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("x")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("x")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("y")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("y")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("a")); - - // Switch to system_virtual_keyboard_2. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("z")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("z")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("y")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("y")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - - // Switch back to system_virtual_keyboard_2. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("x")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("x")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("y")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("y")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("a")); - - // Switch back to user_virtual_keyboard_1. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); -} - -TEST(VirtualKeyboardTest, TestUrl) { - static const char* layouts[] = { "a", "b", "c" }; - VirtualKeyboard system_virtual_keyboard( - GURL("http://system"), "", CreateLayoutSet(layouts), true); - - EXPECT_EQ("http://system/index.html#a", - system_virtual_keyboard.GetURLForLayout("a").spec()); - EXPECT_EQ("http://system/index.html#b", - system_virtual_keyboard.GetURLForLayout("b").spec()); - EXPECT_EQ("http://system/index.html#c", - system_virtual_keyboard.GetURLForLayout("c").spec()); - EXPECT_EQ("http://system/index.html#not-supported", - system_virtual_keyboard.GetURLForLayout("not-supported").spec()); - EXPECT_EQ("http://system/index.html#not(supported)", - system_virtual_keyboard.GetURLForLayout("not(supported)").spec()); - EXPECT_EQ("http://system/", - system_virtual_keyboard.GetURLForLayout("").spec()); -} - -TEST(VirtualKeyboardSelectorTest, TestSetUserPreference1) { - static const char* layouts[] = { "a", "b", "c" }; - - VirtualKeyboard user_virtual_keyboard( - GURL("http://user"), "", CreateLayoutSet(layouts), false /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard.url(), - user_virtual_keyboard.name(), - user_virtual_keyboard.supported_layouts(), - user_virtual_keyboard.is_system())); - - EXPECT_EQ(0U, selector.user_preference().size()); - EXPECT_FALSE(selector.SetUserPreference("bad_layout", GURL("http://user"))); - EXPECT_EQ(0U, selector.user_preference().size()); - EXPECT_FALSE(selector.SetUserPreference("a", GURL("http://bad_url"))); - EXPECT_EQ(0U, selector.user_preference().size()); - EXPECT_TRUE(selector.SetUserPreference("a", GURL("http://user"))); - EXPECT_EQ(1U, selector.user_preference().size()); - EXPECT_TRUE(selector.SetUserPreference("b", GURL("http://user"))); - EXPECT_EQ(2U, selector.user_preference().size()); - EXPECT_TRUE(selector.SetUserPreference("c", GURL("http://user"))); - EXPECT_EQ(3U, selector.user_preference().size()); -} - -TEST(VirtualKeyboardSelectorTest, TestSetUserPreference2) { - static const char* layouts[] = { "a", "b", "c" }; - - VirtualKeyboard system_virtual_keyboard( - GURL("http://system"), "", CreateLayoutSet(layouts), - true /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard.url(), - system_virtual_keyboard.name(), - system_virtual_keyboard.supported_layouts(), - system_virtual_keyboard.is_system())); - - EXPECT_EQ(0U, selector.user_preference().size()); - EXPECT_FALSE(selector.SetUserPreference("bad_layout", GURL("http://system"))); - EXPECT_EQ(0U, selector.user_preference().size()); - EXPECT_FALSE(selector.SetUserPreference("a", GURL("http://bad_url"))); - EXPECT_EQ(0U, selector.user_preference().size()); - EXPECT_TRUE(selector.SetUserPreference("a", GURL("http://system"))); - EXPECT_EQ(1U, selector.user_preference().size()); - EXPECT_TRUE(selector.SetUserPreference("b", GURL("http://system"))); - EXPECT_EQ(2U, selector.user_preference().size()); - EXPECT_TRUE(selector.SetUserPreference("c", GURL("http://system"))); - EXPECT_EQ(3U, selector.user_preference().size()); -} - -TEST(VirtualKeyboardSelectorTest, TestRemoveUserPreference) { - static const char* layouts[] = { "a", "b", "c" }; - - VirtualKeyboard user_virtual_keyboard_1( - GURL("http://user1"), "", CreateLayoutSet(layouts), - false /* is_system */); - VirtualKeyboard user_virtual_keyboard_2( - GURL("http://user2"), "", CreateLayoutSet(layouts), - false /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_1.url(), - user_virtual_keyboard_1.name(), - user_virtual_keyboard_1.supported_layouts(), - user_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_2.url(), - user_virtual_keyboard_2.name(), - user_virtual_keyboard_2.supported_layouts(), - user_virtual_keyboard_2.is_system())); - - EXPECT_TRUE(selector.SetUserPreference("a", GURL("http://user1"))); - EXPECT_TRUE(selector.SetUserPreference("b", GURL("http://user1"))); - EXPECT_TRUE(selector.SetUserPreference("c", GURL("http://user1"))); - EXPECT_EQ(3U, selector.user_preference().size()); - - selector.RemoveUserPreference("b"); - EXPECT_EQ(2U, selector.user_preference().size()); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - // user_virtual_keyboard_2 should be selected here since the keyboard is - // added most recently and the user preference on "b" is already removed. - EXPECT_TRUE(user_virtual_keyboard_2 == *selector.SelectVirtualKeyboard("b")); - - selector.ClearAllUserPreferences(); - EXPECT_EQ(0U, selector.user_preference().size()); -} - -TEST(VirtualKeyboardSelectorTest, TestSetUserPreferenceUserSystemMixed) { - static const char* ulayouts_1[] = { "a", "b", "c" }; - static const char* ulayouts_2[] = { "a", "c", "d" }; - static const char* layouts_1[] = { "a", "x", "y" }; - static const char* layouts_2[] = { "a", "y", "z" }; - - VirtualKeyboard user_virtual_keyboard_1( - GURL("http://user1"), "", CreateLayoutSet(ulayouts_1), - false /* is_system */); - VirtualKeyboard user_virtual_keyboard_2( - GURL("http://user2"), "", CreateLayoutSet(ulayouts_2), - false /* is_system */); - VirtualKeyboard system_virtual_keyboard_1( - GURL("http://system1"), "", CreateLayoutSet(layouts_1), - true /* is_system */); - VirtualKeyboard system_virtual_keyboard_2( - GURL("http://system2"), "", CreateLayoutSet(layouts_2), - true /* is_system */); - - TestableVirtualKeyboardSelector selector; - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_1.url(), - user_virtual_keyboard_1.name(), - user_virtual_keyboard_1.supported_layouts(), - user_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_2.url(), - user_virtual_keyboard_2.name(), - user_virtual_keyboard_2.supported_layouts(), - user_virtual_keyboard_2.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_1.url(), - system_virtual_keyboard_1.name(), - system_virtual_keyboard_1.supported_layouts(), - system_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_2.url(), - system_virtual_keyboard_2.name(), - system_virtual_keyboard_2.supported_layouts(), - system_virtual_keyboard_2.is_system())); - - // Set and then remove user prefs (=NOP). - EXPECT_TRUE(selector.SetUserPreference("a", GURL("http://system1"))); - EXPECT_TRUE(selector.SetUserPreference("z", GURL("http://system2"))); - selector.ClearAllUserPreferences(); - - // At this point, user_virtual_keyboard_2 has the highest priority. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("d")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("d")); - - // Request "b". user_virtual_keyboard_1 should be returned. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("b")); - EXPECT_TRUE(user_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("b")); - - // Set user pref. - EXPECT_TRUE(selector.SetUserPreference("a", GURL("http://user2"))); - - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == // follow the user pref. - *selector.SelectVirtualKeyboard("a")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); - - // Request "x". system_virtual_keyboard_2 should be returned (since it's - // added later than system_virtual_keyboard_1). - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("x")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("x")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("y")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("y")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == // follow the user pref. - *selector.SelectVirtualKeyboard("a")); - - // Switch to system_virtual_keyboard_2. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("z")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("z")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("y")); - EXPECT_TRUE(system_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("y")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(user_virtual_keyboard_2 == // follow the user pref. - *selector.SelectVirtualKeyboard("a")); - - // Switch back to system_virtual_keyboard_2. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("x")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("x")); - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("y")); - EXPECT_TRUE(system_virtual_keyboard_1 == - *selector.SelectVirtualKeyboard("y")); - - // Remove it. - selector.RemoveUserPreference("a"); - - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("a")); - EXPECT_TRUE(system_virtual_keyboard_1 == // user pref is no longer available - *selector.SelectVirtualKeyboard("a")); - - // Switch back to user_virtual_keyboard_1. - ASSERT_TRUE(selector.SelectVirtualKeyboardWithoutPreferences("c")); - EXPECT_TRUE(user_virtual_keyboard_2 == - *selector.SelectVirtualKeyboard("c")); -} - -TEST(VirtualKeyboardSelectorTest, TestUrlToExtensionMapping) { - static const char* ulayouts_1[] = { "a", "b", "c" }; - static const char* ulayouts_2[] = { "a", "c", "d" }; - static const char* slayouts_1[] = { "a", "x", "y" }; - - VirtualKeyboard user_virtual_keyboard_1( - GURL("http://user1"), "", CreateLayoutSet(ulayouts_1), - false /* is_system */); - VirtualKeyboard user_virtual_keyboard_2( - GURL("http://user2"), "", CreateLayoutSet(ulayouts_2), - false /* is_system */); - VirtualKeyboard system_virtual_keyboard_1( - GURL("http://system1"), "", CreateLayoutSet(slayouts_1), - true /* is_system */); - - TestableVirtualKeyboardSelector selector; - - const std::map<GURL, const VirtualKeyboard*>& result1 = - selector.url_to_keyboard(); - EXPECT_TRUE(result1.empty()); - - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_1.url(), - user_virtual_keyboard_1.name(), - user_virtual_keyboard_1.supported_layouts(), - user_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_2.url(), - user_virtual_keyboard_2.name(), - user_virtual_keyboard_2.supported_layouts(), - user_virtual_keyboard_2.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_1.url(), - system_virtual_keyboard_1.name(), - system_virtual_keyboard_1.supported_layouts(), - system_virtual_keyboard_1.is_system())); - - const std::map<GURL, const VirtualKeyboard*>& result2 = - selector.url_to_keyboard(); - EXPECT_EQ(3U, result2.size()); - ASSERT_EQ(1U, result2.count(GURL("http://user1"))); - EXPECT_TRUE(user_virtual_keyboard_1 == - *result2.find(GURL("http://user1"))->second); - ASSERT_EQ(1U, result2.count(GURL("http://user2"))); - EXPECT_TRUE(user_virtual_keyboard_2 == - *result2.find(GURL("http://user2"))->second); - ASSERT_EQ(1U, result2.count(GURL("http://system1"))); - EXPECT_TRUE(system_virtual_keyboard_1 == - *result2.find(GURL("http://system1"))->second); - EXPECT_EQ(0U, result2.count(GURL("http://system2"))); -} - -TEST(VirtualKeyboardSelectorTest, TestLayoutToExtensionMapping) { - static const char* ulayouts_1[] = { "a", "b", "c" }; - static const char* ulayouts_2[] = { "a", "c", "d" }; - static const char* slayouts_1[] = { "a", "x", "y" }; - static const char* slayouts_2[] = { "a", "y", "z" }; - - VirtualKeyboard user_virtual_keyboard_1( - GURL("http://user1"), "", CreateLayoutSet(ulayouts_1), - false /* is_system */); - VirtualKeyboard user_virtual_keyboard_2( - GURL("http://user2"), "", CreateLayoutSet(ulayouts_2), - false /* is_system */); - VirtualKeyboard system_virtual_keyboard_1( - GURL("http://system1"), "", CreateLayoutSet(slayouts_1), - true /* is_system */); - VirtualKeyboard system_virtual_keyboard_2( - GURL("http://system2"), "", CreateLayoutSet(slayouts_2), - true /* is_system */); - - TestableVirtualKeyboardSelector selector; - - const LayoutToKeyboard& result1 = selector.layout_to_keyboard(); - EXPECT_TRUE(result1.empty()); - - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_1.url(), - user_virtual_keyboard_1.name(), - user_virtual_keyboard_1.supported_layouts(), - user_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - user_virtual_keyboard_2.url(), - user_virtual_keyboard_2.name(), - user_virtual_keyboard_2.supported_layouts(), - user_virtual_keyboard_2.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_1.url(), - system_virtual_keyboard_1.name(), - system_virtual_keyboard_1.supported_layouts(), - system_virtual_keyboard_1.is_system())); - EXPECT_TRUE(selector.AddVirtualKeyboard( - system_virtual_keyboard_2.url(), - system_virtual_keyboard_2.name(), - system_virtual_keyboard_2.supported_layouts(), - system_virtual_keyboard_2.is_system())); - - const LayoutToKeyboard& result2 = selector.layout_to_keyboard(); - EXPECT_EQ(arraysize(ulayouts_1) + - arraysize(ulayouts_2) + - arraysize(slayouts_1) + - arraysize(slayouts_2), - result2.size()); - - std::pair<LayoutToKeyboard::const_iterator, - LayoutToKeyboard::const_iterator> range; - EXPECT_EQ(4U, result2.count("a")); - { - static const char* urls[] = { "http://user1", "http://user2", - "http://system1", "http://system2" }; - range = result2.equal_range("a"); - EXPECT_TRUE(CheckUrls(range.first, range.second, urls)); - } - EXPECT_EQ(2U, result2.count("c")); - { - static const char* urls[] = { "http://user1", "http://user2" }; - range = result2.equal_range("c"); - EXPECT_TRUE(CheckUrls(range.first, range.second, urls)); - } - EXPECT_EQ(1U, result2.count("z")); - { - static const char* urls[] = { "http://system2" }; - range = result2.equal_range("z"); - EXPECT_TRUE(CheckUrls(range.first, range.second, urls)); - } - EXPECT_EQ(0U, result2.count("Z")); -} - -} // namespace input_method -} // namespace chromeos diff --git a/chrome/browser/chromeos/input_method/xkeyboard.cc b/chrome/browser/chromeos/input_method/xkeyboard.cc index ecac256..76cfa46 100644 --- a/chrome/browser/chromeos/input_method/xkeyboard.cc +++ b/chrome/browser/chromeos/input_method/xkeyboard.cc @@ -145,20 +145,11 @@ XKeyboardImpl::XKeyboardImpl(const InputMethodUtil& util) std::string layout; for (size_t i = 0; i < arraysize(kKeepRightAltInputMethods); ++i) { layout = util.GetKeyboardLayoutName(kKeepRightAltInputMethods[i]); - // The empty check is necessary since USE_VIRTUAL_KEYBOARD build does not - // support some of the kKeepRightAltInputMethods elements. For example, - // when USE_VIRTUAL_KEYBOARD is defined, - // util.GetKeyboardLayoutName("xkb:us:intl:eng") would return "". - if (!layout.empty()) { - keep_right_alt_xkb_layout_names_.insert(layout); - } + keep_right_alt_xkb_layout_names_.insert(layout); } for (size_t i = 0; i < arraysize(kCapsLockRemapped); ++i) { layout = util.GetKeyboardLayoutName(kCapsLockRemapped[i]); - // The empty check is for USE_VIRTUAL_KEYBOARD build. See above. - if (!layout.empty()) { - caps_lock_remapped_xkb_layout_names_.insert(layout); - } + caps_lock_remapped_xkb_layout_names_.insert(layout); } } diff --git a/chrome/browser/chromeos/input_method/xkeyboard_unittest.cc b/chrome/browser/chromeos/input_method/xkeyboard_unittest.cc index 814766e..3af9767 100644 --- a/chrome/browser/chromeos/input_method/xkeyboard_unittest.cc +++ b/chrome/browser/chromeos/input_method/xkeyboard_unittest.cc @@ -21,15 +21,6 @@ using content::BrowserThread; -#if defined(USE_VIRTUAL_KEYBOARD) -// Since USE_VIRTUAL_KEYBOARD build only supports a few keyboard layouts, we -// skip the tests for now. -#define TestCreateFullXkbLayoutNameKeepAlt \ - DISABLED_TestCreateFullXkbLayoutNameKeepAlt -#define TestCreateFullXkbLayoutNameKeepCapsLock \ - DISABLED_TestCreateFullXkbLayoutNameKeepCapsLock -#endif // USE_VIRTUAL_KEYBOARD - namespace chromeos { namespace input_method { diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc index eddabe3..61f9b28 100644 --- a/chrome/browser/chromeos/login/login_utils.cc +++ b/chrome/browser/chromeos/login/login_utils.cc @@ -1084,11 +1084,6 @@ std::string LoginUtilsImpl::GetOffTheRecordCommandLine( ::switches::kUIEnablePartialSwap, ::switches::kUseGL, ::switches::kUserDataDir, -#if defined(USE_VIRTUAL_KEYBOARD) - // The virtual keyboard extension (chrome://keyboard) highly relies on - // experimental APIs. - ::switches::kEnableExperimentalExtensionApis, -#endif chromeos::switches::kDbusStub, }; command_line->CopySwitchesFrom(base_command_line, diff --git a/chrome/browser/chromeos/login/webui_login_view.cc b/chrome/browser/chromeos/login/webui_login_view.cc index 49561ee..4930005 100644 --- a/chrome/browser/chromeos/login/webui_login_view.cc +++ b/chrome/browser/chromeos/login/webui_login_view.cc @@ -33,10 +33,6 @@ #include "ui/views/controls/webview/webview.h" #include "ui/views/widget/widget.h" -#if defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" -#endif - using content::NativeWebKeyboardEvent; using content::RenderViewHost; using content::WebContents; @@ -131,10 +127,6 @@ WebUILoginView::WebUILoginView() chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN, content::NotificationService::AllSources()); -#if defined(USE_VIRTUAL_KEYBOARD) - // Make sure the singleton VirtualKeyboardManager object is created. - VirtualKeyboardManager::GetInstance(); -#endif accel_map_[ui::Accelerator(ui::VKEY_Z, ui::EF_CONTROL_DOWN | ui::EF_ALT_DOWN)] = kAccelNameAccessibility; diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index eaa1200..0c42f48 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -234,9 +234,6 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) { language_prefs::kXkbAutoRepeatIntervalInMs, PrefService::UNSYNCABLE_PREF); - prefs->RegisterDictionaryPref(prefs::kLanguagePreferredVirtualKeyboard, - PrefService::SYNCABLE_PREF); - // Screen lock default to off. prefs->RegisterBooleanPref(prefs::kEnableScreenLock, false, @@ -358,9 +355,6 @@ void Preferences::Init(PrefService* prefs) { // Initialize preferences to currently saved state. NotifyPrefChanged(NULL); - // Initialize virtual keyboard settings to currently saved state. - UpdateVirturalKeyboardPreference(prefs); - // If a guest is logged in, initialize the prefs as if this is the first // login. if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { @@ -710,30 +704,4 @@ void Preferences::UpdateAutoRepeatRate() { input_method::XKeyboard::SetAutoRepeatRate(rate); } -// static -void Preferences::UpdateVirturalKeyboardPreference(PrefService* prefs) { - const DictionaryValue* virtual_keyboard_pref = - prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard); - DCHECK(virtual_keyboard_pref); - - // TODO(yusukes): Clear all virtual keyboard preferences here. - std::string url; - std::vector<std::string> layouts_to_remove; - for (DictionaryValue::key_iterator iter = virtual_keyboard_pref->begin_keys(); - iter != virtual_keyboard_pref->end_keys(); - ++iter) { - const std::string& layout_id = *iter; // e.g. "us", "handwriting-vk" - if (!virtual_keyboard_pref->GetString(layout_id, &url)) - continue; - // TODO(yusukes): add the virtual keyboard preferences here. - } - - // Remove invalid prefs. - DictionaryPrefUpdate updater(prefs, prefs::kLanguagePreferredVirtualKeyboard); - DictionaryValue* pref_value = updater.Get(); - for (size_t i = 0; i < layouts_to_remove.size(); ++i) { - pref_value->RemoveWithoutPathExpansion(layouts_to_remove[i], NULL); - } -} - } // namespace chromeos diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h index e26938c..bc161fa 100644 --- a/chrome/browser/chromeos/preferences.h +++ b/chrome/browser/chromeos/preferences.h @@ -35,10 +35,6 @@ class Preferences : public content::NotificationObserver { // This method will register the prefs associated with Chrome OS settings. static void RegisterUserPrefs(PrefService* prefs); - // This method is called when kLanguagePreferredVirtualKeyboard is updated to - // change the virtual keyboard settings to reflect the new value. - static void UpdateVirturalKeyboardPreference(PrefService* prefs); - // This method will initialize Chrome OS settings to values in user prefs. void Init(PrefService* prefs); diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index b077315..cdc9c2e 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -275,10 +275,6 @@ void ComponentLoader::AddDefaultComponentExtensions() { AddFileManagerExtension(); #endif -#if defined(USE_VIRTUAL_KEYBOARD) - Add(IDR_KEYBOARD_MANIFEST, FilePath(FILE_PATH_LITERAL("keyboard"))); -#endif - #if defined(OS_CHROMEOS) Add(IDR_MOBILE_MANIFEST, FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/mobile"))); diff --git a/chrome/browser/extensions/extension_function_registry.cc b/chrome/browser/extensions/extension_function_registry.cc index 31e5a15..9a38f82 100644 --- a/chrome/browser/extensions/extension_function_registry.cc +++ b/chrome/browser/extensions/extension_function_registry.cc @@ -59,10 +59,6 @@ #include "chrome/browser/extensions/extension_input_api.h" #endif -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/extensions/extension_input_ui_api.h" -#endif - #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" #include "chrome/browser/chromeos/extensions/echo_private_api.h" @@ -274,11 +270,6 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<SendKeyboardEventInputFunction>(); #endif -#if defined(USE_VIRTUAL_KEYBOARD) - RegisterFunction<HideKeyboardFunction>(); - RegisterFunction<SetKeyboardHeightFunction>(); -#endif - #if defined(OS_CHROMEOS) // IME RegisterFunction<SetCompositionFunction>(); @@ -291,16 +282,6 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<UpdateMenuItemsFunction>(); RegisterFunction<InputEventHandled>(); -#if defined(USE_VIRTUAL_KEYBOARD) - RegisterFunction<CandidateClickedInputUiFunction>(); - RegisterFunction<CursorUpInputUiFunction>(); - RegisterFunction<CursorDownInputUiFunction>(); - RegisterFunction<PageUpInputUiFunction>(); - RegisterFunction<PageDownInputUiFunction>(); - RegisterFunction<RegisterInputUiFunction>(); - RegisterFunction<PageUpInputUiFunction>(); - RegisterFunction<PageDownInputUiFunction>(); -#endif #endif // Managed mode. @@ -401,12 +382,6 @@ void ExtensionFunctionRegistry::ResetFunctions() { RegisterFunction<SendInputToTerminalProcessFunction>(); RegisterFunction<CloseTerminalProcessFunction>(); RegisterFunction<OnTerminalResizeFunction>(); - -#if defined(USE_VIRTUAL_KEYBOARD) - // Input - RegisterFunction<SendHandwritingStrokeFunction>(); - RegisterFunction<CancelHandwritingStrokesFunction>(); -#endif #endif // Websocket to TCP proxy. Currently noop on anything other than ChromeOS. diff --git a/chrome/browser/extensions/extension_input_api.cc b/chrome/browser/extensions/extension_input_api.cc index cb58af2..6bbb00c 100644 --- a/chrome/browser/extensions/extension_input_api.cc +++ b/chrome/browser/extensions/extension_input_api.cc @@ -19,15 +19,6 @@ #include "ui/views/views_delegate.h" #include "ui/views/widget/widget.h" -#if defined(USE_VIRTUAL_KEYBOARD) -#include "content/public/browser/notification_service.h" -#endif - -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/chromeos/input_method/input_method_manager.h" -#include "chrome/browser/chromeos/login/base_login_display_host.h" -#endif - namespace { // Keys. @@ -73,13 +64,6 @@ uint16 UnicodeIdentifierStringToInt(const std::string& key_identifier) { } views::Widget* GetTopLevelWidget(Browser* browser) { -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) - chromeos::LoginDisplayHost* host = - chromeos::BaseLoginDisplayHost::default_host(); - if (host) - return views::Widget::GetWidgetForNativeWindow(host->GetNativeWindow()); -#endif - if (!browser) return NULL; @@ -156,82 +140,3 @@ bool SendKeyboardEventInputFunction::RunImpl() { return true; } - -#if defined(USE_VIRTUAL_KEYBOARD) -bool HideKeyboardFunction::RunImpl() { - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED, - content::Source<HideKeyboardFunction>(this), - content::NotificationService::NoDetails()); - return true; -} - -bool SetKeyboardHeightFunction::RunImpl() { - int height = 0; - EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &height)); - - if (height < 0) { - error_ = kInvalidHeight; - return false; - } - - // TODO(penghuang) Check the height is not greater than height of browser view - // and set the height of virtual keyboard directly instead of using - // notification. - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, - content::Source<SetKeyboardHeightFunction>(this), - content::Details<int>(&height)); - return true; -} -#endif - -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) -// TODO(yusukes): This part should be moved to extension_input_api_chromeos.cc. -bool SendHandwritingStrokeFunction::RunImpl() { - // TODO(yusukes): Add a parameter for an input context ID. - ListValue* value = NULL; - EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &value)); - - chromeos::input_method::HandwritingStroke stroke; - for (size_t i = 0; i < value->GetSize(); ++i) { - DictionaryValue* dict; - double x = 0.0; - double y = 0.0; - EXTENSION_FUNCTION_VALIDATE(value->GetDictionary(i, &dict)); - EXTENSION_FUNCTION_VALIDATE(dict->GetDouble("x", &x)); - EXTENSION_FUNCTION_VALIDATE(dict->GetDouble("y", &y)); - stroke.push_back(std::make_pair(x, y)); - } - - views::Widget* widget = GetTopLevelWidget(GetCurrentBrowser()); - views::InputMethod* ime = widget ? widget->GetInputMethod() : NULL; - if (ime) { - static const views::KeyEvent* dummy_keydown = new views::KeyEvent( - ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0); - static const views::KeyEvent* dummy_keyup = new views::KeyEvent( - ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, 0); - // These fake key events are necessary for clearing |suppress_next_result_| - // flag in view/ime/input_method_*.cc. Otherwise, clicking a candidate in - // the candidate window might be ignored. - ime->DispatchKeyEvent(*dummy_keydown); - ime->DispatchKeyEvent(*dummy_keyup); - } - - chromeos::input_method::InputMethodManager::GetInstance()-> - SendHandwritingStroke(stroke); - return true; -} - -bool CancelHandwritingStrokesFunction::RunImpl() { - // TODO(yusukes): Add a parameter for an input context ID. - int stroke_count = 0; // zero means 'clear all strokes'. - if (HasOptionalArgument(0)) { - EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &stroke_count)); - EXTENSION_FUNCTION_VALIDATE(stroke_count >= 0); - } - chromeos::input_method::InputMethodManager::GetInstance()-> - CancelHandwritingStrokes(stroke_count); - return true; -} -#endif diff --git a/chrome/browser/extensions/extension_input_api.h b/chrome/browser/extensions/extension_input_api.h index dc0fe8a..6096821 100644 --- a/chrome/browser/extensions/extension_input_api.h +++ b/chrome/browser/extensions/extension_input_api.h @@ -26,58 +26,4 @@ class SendKeyboardEventInputFunction : public SyncExtensionFunction { virtual bool RunImpl() OVERRIDE; }; -#if defined(USE_VIRTUAL_KEYBOARD) -class HideKeyboardFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME( - "experimental.input.virtualKeyboard.hideKeyboard"); - - protected: - virtual ~HideKeyboardFunction() {} - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; -}; - -class SetKeyboardHeightFunction : public AsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME( - "experimental.input.virtualKeyboard.setKeyboardHeight"); - - protected: - virtual ~SetKeyboardHeightFunction() {} - - // ExtensionFunction: - virtual bool RunImpl() OVERRIDE; -}; -#endif - -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) -// Note that these experimental APIs are currently only available for -// versions of Chrome OS built with USE_VIRTUAL_KEYBOARD. Please also note that -// the version of Chrome OS is always built with TOOLKIT_VIEWS. -// -// We may eventually support other platforms, especially versions of ChromeOS -// without USE_VIRTUAL_KEYBOARD. -class SendHandwritingStrokeFunction : public SyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME( - "experimental.input.virtualKeyboard.sendHandwritingStroke"); - - protected: - virtual ~SendHandwritingStrokeFunction() {} - virtual bool RunImpl() OVERRIDE; -}; - -class CancelHandwritingStrokesFunction : public SyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION_NAME( - "experimental.input.virtualKeyboard.cancelHandwritingStrokes"); - - public: - virtual ~CancelHandwritingStrokesFunction() {} - virtual bool RunImpl() OVERRIDE; -}; -#endif - #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_API_H_ diff --git a/chrome/browser/extensions/extension_input_ui_api.cc b/chrome/browser/extensions/extension_input_ui_api.cc deleted file mode 100644 index ac151ea..0000000 --- a/chrome/browser/extensions/extension_input_ui_api.cc +++ /dev/null @@ -1,239 +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 "chrome/browser/extensions/extension_input_ui_api.h" - -#include <algorithm> -#include <string> - -#include "base/json/json_writer.h" -#include "base/logging.h" -#include "base/string_util.h" -#include "base/values.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/extensions/extension_event_router.h" -#include "chrome/browser/profiles/profile.h" -#include "third_party/cros/chromeos_cros_api.h" - -namespace events { - -const char kOnUpdateAuxiliaryText[] = - "experimental.input.ui.onUpdateAuxiliaryText"; -const char kOnUpdateLookupTable[] = "experimental.input.ui.onUpdateLookupTable"; -const char kOnSetCursorLocation[] = "experimental.input.ui.onSetCursorLocation"; - -} // namespace events - -ExtensionInputUiEventRouter* -ExtensionInputUiEventRouter::GetInstance() { - return Singleton<ExtensionInputUiEventRouter>::get(); -} - -ExtensionInputUiEventRouter::ExtensionInputUiEventRouter() - : profile_(NULL), - ibus_ui_controller_(NULL) { -} - -ExtensionInputUiEventRouter::~ExtensionInputUiEventRouter() { -} - -void ExtensionInputUiEventRouter::Init() { - if (ibus_ui_controller_.get() == NULL) { - ibus_ui_controller_.reset( - chromeos::input_method::IBusUiController::Create()); - // The observer should be added before Connect() so we can capture the - // initial connection change. - ibus_ui_controller_->AddObserver(this); - ibus_ui_controller_->Connect(); - } -} - -void ExtensionInputUiEventRouter::Register( - Profile* profile, const std::string& extension_id) { - profile_ = profile; - extension_id_ = extension_id; -} - -void ExtensionInputUiEventRouter::CandidateClicked(Profile* profile, - const std::string& extension_id, int index, int button) { - if (profile_ != profile || extension_id_ != extension_id) { - DLOG(WARNING) << "called from unregistered extension"; - } - ibus_ui_controller_->NotifyCandidateClicked(index, button, 0); -} - -void ExtensionInputUiEventRouter::CursorUp(Profile* profile, - const std::string& extension_id) { - if (profile_ != profile || extension_id_ != extension_id) { - DLOG(WARNING) << "called from unregistered extension"; - } - ibus_ui_controller_->NotifyCursorUp(); -} - -void ExtensionInputUiEventRouter::CursorDown(Profile* profile, - const std::string& extension_id) { - if (profile_ != profile || extension_id_ != extension_id) { - DLOG(WARNING) << "called from unregistered extension"; - } - ibus_ui_controller_->NotifyCursorDown(); -} - -void ExtensionInputUiEventRouter::PageUp(Profile* profile, - const std::string& extension_id) { - if (profile_ != profile || extension_id_ != extension_id) { - DLOG(WARNING) << "called from unregistered extension"; - } - ibus_ui_controller_->NotifyPageUp(); -} - -void ExtensionInputUiEventRouter::PageDown(Profile* profile, - const std::string& extension_id) { - if (profile_ != profile || extension_id_ != extension_id) { - DLOG(WARNING) << "called from unregistered extension"; - } - ibus_ui_controller_->NotifyPageDown(); -} - -void ExtensionInputUiEventRouter::OnHideAuxiliaryText() { - OnUpdateAuxiliaryText("", false); -} - -void ExtensionInputUiEventRouter::OnHideLookupTable() { - if (profile_ == NULL || extension_id_.empty()) - return; - - DictionaryValue* dict = new DictionaryValue(); - dict->SetBoolean("visible", false); - - ListValue *candidates = new ListValue(); - dict->Set("candidates", candidates); - - ListValue args; - args.Append(dict); - - std::string json_args; - base::JSONWriter::Write(&args, &json_args); - profile_->GetExtensionEventRouter()->DispatchEventToExtension( - extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL()); -} - -void ExtensionInputUiEventRouter::OnHidePreeditText() { -} - -void ExtensionInputUiEventRouter::OnSetCursorLocation( - int x, int y, int width, int height) { - - if (profile_ == NULL || extension_id_.empty()) - return; - - ListValue args; - args.Append(Value::CreateIntegerValue(x)); - args.Append(Value::CreateIntegerValue(y)); - args.Append(Value::CreateIntegerValue(width)); - args.Append(Value::CreateIntegerValue(height)); - - std::string json_args; - base::JSONWriter::Write(&args, &json_args); - profile_->GetExtensionEventRouter()->DispatchEventToExtension( - extension_id_, events::kOnSetCursorLocation, json_args, profile_, GURL()); -} - -void ExtensionInputUiEventRouter::OnUpdateAuxiliaryText( - const std::string& utf8_text, - bool visible) { - if (profile_ == NULL || extension_id_.empty()) - return; - - ListValue args; - args.Append(Value::CreateStringValue(visible ? utf8_text : "")); - - std::string json_args; - base::JSONWriter::Write(&args, &json_args); - profile_->GetExtensionEventRouter()->DispatchEventToExtension( - extension_id_, events::kOnUpdateAuxiliaryText, json_args, profile_, GURL()); -} - -void ExtensionInputUiEventRouter::OnUpdateLookupTable( - const chromeos::input_method::InputMethodLookupTable& lookup_table) { - if (profile_ == NULL || extension_id_.empty()) - return; - - DictionaryValue* dict = new DictionaryValue(); - dict->SetBoolean("visible", lookup_table.visible); - - if (lookup_table.visible) { - } - - ListValue *candidates = new ListValue(); - - size_t page = lookup_table.cursor_absolute_index / lookup_table.page_size; - size_t begin = page * lookup_table.page_size; - size_t end = std::min(begin + lookup_table.page_size, - lookup_table.candidates.size()); - - for (size_t i = begin; i < end; i++) { - candidates->Append(Value::CreateStringValue(lookup_table.candidates[i])); - } - - dict->Set("candidates", candidates); - - ListValue args; - args.Append(dict); - - std::string json_args; - base::JSONWriter::Write(&args, &json_args); - profile_->GetExtensionEventRouter()->DispatchEventToExtension( - extension_id_, events::kOnUpdateLookupTable, json_args, profile_, GURL()); -} - -void ExtensionInputUiEventRouter::OnUpdatePreeditText( - const std::string& utf8_text, - unsigned int cursor, - bool visible) { -} - -void ExtensionInputUiEventRouter::OnConnectionChange(bool connected) { -} - -bool RegisterInputUiFunction::RunImpl() { - ExtensionInputUiEventRouter::GetInstance()->Register( - profile(), extension_id()); - return true; -} - -bool CandidateClickedInputUiFunction::RunImpl() { - int index = 0; - int button = 0; - EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &index)); - EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &button)); - - ExtensionInputUiEventRouter::GetInstance()->CandidateClicked( - profile(), extension_id(), index, button); - - return true; -} - -bool CursorUpInputUiFunction::RunImpl() { - ExtensionInputUiEventRouter::GetInstance()->CursorUp( - profile(), extension_id()); - return true; -} - -bool CursorDownInputUiFunction::RunImpl() { - ExtensionInputUiEventRouter::GetInstance()->CursorDown( - profile(), extension_id()); - return true; -} - -bool PageUpInputUiFunction::RunImpl() { - ExtensionInputUiEventRouter::GetInstance()->PageUp( - profile(), extension_id()); - return true; -} - -bool PageDownInputUiFunction::RunImpl() { - ExtensionInputUiEventRouter::GetInstance()->PageDown( - profile(), extension_id()); - return true; -} diff --git a/chrome/browser/extensions/extension_input_ui_api.h b/chrome/browser/extensions/extension_input_ui_api.h deleted file mode 100644 index 351ae93..0000000 --- a/chrome/browser/extensions/extension_input_ui_api.h +++ /dev/null @@ -1,110 +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 CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_UI_API_H_ -#define CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_UI_API_H_ -#pragma once - -#include <string> - -#include "base/compiler_specific.h" -#include "base/memory/singleton.h" -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/chromeos/input_method/ibus_ui_controller.h" -#include "chrome/browser/extensions/extension_function.h" - -class Profile; - -class ExtensionInputUiEventRouter - : public chromeos::input_method::IBusUiController::Observer { - public: - static ExtensionInputUiEventRouter* GetInstance(); - void Init(); - - private: - friend class CandidateClickedInputUiFunction; - friend class CursorUpInputUiFunction; - friend class CursorDownInputUiFunction; - friend class PageUpInputUiFunction; - friend class PageDownInputUiFunction; - friend class RegisterInputUiFunction; - friend struct DefaultSingletonTraits<ExtensionInputUiEventRouter>; - - ExtensionInputUiEventRouter(); - virtual ~ExtensionInputUiEventRouter(); - - void Register(Profile* profile, const std::string& extension_id); - void CandidateClicked(Profile* profile, - const std::string& extension_id, int index, int button); - void CursorUp(Profile* profile, const std::string& extension_id); - void CursorDown(Profile* profile, const std::string& extension_id); - void PageUp(Profile* profile, const std::string& extension_id); - void PageDown(Profile* profile, const std::string& extension_id); - - // IBusUiController overrides. - virtual void OnHideAuxiliaryText() OVERRIDE; - virtual void OnHideLookupTable() OVERRIDE; - virtual void OnHidePreeditText() OVERRIDE; - virtual void OnSetCursorLocation(int x, - int y, - int width, - int height) OVERRIDE; - virtual void OnUpdateAuxiliaryText(const std::string& utf8_text, - bool visible) OVERRIDE; - virtual void OnUpdateLookupTable( - const chromeos::input_method::InputMethodLookupTable& lookup_table) - OVERRIDE; - virtual void OnUpdatePreeditText(const std::string& utf8_text, - unsigned int cursor, - bool visible) OVERRIDE; - virtual void OnConnectionChange(bool connected) OVERRIDE; - - void DispatchEvent(Profile* profile, - const char* event_name, - const std::string& json_args); - - Profile* profile_; - std::string extension_id_; - scoped_ptr<chromeos::input_method::IBusUiController> ibus_ui_controller_; - - DISALLOW_COPY_AND_ASSIGN(ExtensionInputUiEventRouter); -}; - -class RegisterInputUiFunction : public SyncExtensionFunction { - public: - virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ui.register"); -}; - -class CandidateClickedInputUiFunction : public SyncExtensionFunction { - public: - virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ui.candidateClicked"); -}; - -class CursorUpInputUiFunction : public SyncExtensionFunction { - public: - virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ui.cursorUp"); -}; - -class CursorDownInputUiFunction : public SyncExtensionFunction { - public: - virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ui.cursorDown"); -}; - -class PageUpInputUiFunction : public SyncExtensionFunction { - public: - virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ui.pageUp"); -}; - -class PageDownInputUiFunction : public SyncExtensionFunction { - public: - virtual bool RunImpl() OVERRIDE; - DECLARE_EXTENSION_FUNCTION_NAME("experimental.input.ui.pageDown"); -}; - -#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_INPUT_UI_API_H_ diff --git a/chrome/browser/extensions/extension_input_ui_apitest.cc b/chrome/browser/extensions/extension_input_ui_apitest.cc deleted file mode 100644 index 2fe656a..0000000 --- a/chrome/browser/extensions/extension_input_ui_apitest.cc +++ /dev/null @@ -1,17 +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 "chrome/browser/extensions/extension_apitest.h" -#include "chrome/common/chrome_switches.h" - -IN_PROC_BROWSER_TEST_F(ExtensionApiTest, InputUI) { - CommandLine::ForCurrentProcess()->AppendSwitch( - switches::kEnableExperimentalExtensionApis); -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) - ASSERT_TRUE(RunExtensionTest("input_ui/chromeos_virtual_keyboard")) << - message_; -#else - ASSERT_TRUE(RunExtensionTest("input_ui/other")) << message_; -#endif -} diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc index fd63acd..b71c856c 100644 --- a/chrome/browser/extensions/extension_override_apitest.cc +++ b/chrome/browser/extensions/extension_override_apitest.cc @@ -43,18 +43,6 @@ class ExtensionOverrideTest : public ExtensionApiTest { return true; } - -#if defined(USE_VIRTUAL_KEYBOARD) - // Navigate to the keyboard page, and ensure we have arrived at an - // extension URL. - void NavigateToKeyboard() { - ui_test_utils::NavigateToURL(browser(), GURL("chrome://keyboard/")); - WebContents* tab = browser()->GetSelectedWebContents(); - ASSERT_TRUE(tab->GetController().GetActiveEntry()); - EXPECT_TRUE(tab->GetController().GetActiveEntry()->GetURL(). - SchemeIs(chrome::kExtensionScheme)); - } -#endif }; IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) { @@ -153,32 +141,3 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) { ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes()); } - -#if defined(USE_VIRTUAL_KEYBOARD) -IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) { - ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_; - { - ResultCatcher catcher; - NavigateToKeyboard(); - ASSERT_TRUE(catcher.GetNextResult()); - } - - // Load the failing version. This should take precedence. - const extensions::Extension* extension = LoadExtension( - test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails")); - ASSERT_TRUE(extension); - { - ResultCatcher catcher; - NavigateToKeyboard(); - ASSERT_FALSE(catcher.GetNextResult()); - } - - // Unload the failing version. We should be back to passing now. - UnloadExtension(extension->id()); - { - ResultCatcher catcher; - NavigateToKeyboard(); - ASSERT_TRUE(catcher.GetNextResult()); - } -} -#endif diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 9a50210..0f66270 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -123,10 +123,6 @@ #include "webkit/fileapi/file_system_mount_point_provider.h" #endif -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/extensions/extension_input_ui_api.h" -#endif - using base::Time; using content::BrowserContext; using content::BrowserThread; @@ -519,11 +515,6 @@ void ExtensionService::InitEventRouters() { ExtensionMediaPlayerEventRouter::GetInstance()->Init(profile_); ExtensionInputImeEventRouter::GetInstance()->Init(); #endif - -#if defined(OS_CHROMEOS) && defined(USE_VIRTUAL_KEYBOARD) - ExtensionInputUiEventRouter::GetInstance()->Init(); -#endif - #endif // defined(ENABLE_EXTENSIONS) event_routers_initialized_ = true; } @@ -1045,20 +1036,6 @@ void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { ExtensionInputImeEventRouter::GetInstance()->RegisterIme( profile_, extension->id(), *component); } -#if defined(USE_VIRTUAL_KEYBOARD) - if (component->type == Extension::INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD && - !component->layouts.empty()) { - chromeos::input_method::InputMethodManager* input_method_manager = - chromeos::input_method::InputMethodManager::GetInstance(); - const bool is_system_keyboard = - extension->location() == Extension::COMPONENT; - input_method_manager->RegisterVirtualKeyboard( - extension->url(), - component->name, // human-readable name of the keyboard extension. - component->layouts, - is_system_keyboard); - } -#endif } #endif } diff --git a/chrome/browser/metrics/metrics_service_browsertest.cc b/chrome/browser/metrics/metrics_service_browsertest.cc index af81a17..cd12e44 100644 --- a/chrome/browser/metrics/metrics_service_browsertest.cc +++ b/chrome/browser/metrics/metrics_service_browsertest.cc @@ -62,12 +62,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceTest, CloseRenderersNormally) { // Verify that the expected stability metrics were recorded. const PrefService* prefs = g_browser_process->local_state(); EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); -#if defined(USE_VIRTUAL_KEYBOARD) - // The keyboard page loads. - EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); -#else EXPECT_EQ(3, prefs->GetInteger(prefs::kStabilityPageLoadCount)); -#endif EXPECT_EQ(0, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser @@ -97,12 +92,7 @@ IN_PROC_BROWSER_TEST_F(MetricsServiceTest, CrashRenderers) { // Verify that the expected stability metrics were recorded. EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityLaunchCount)); -#if defined(USE_VIRTUAL_KEYBOARD) - // The keyboard page loads. - EXPECT_EQ(5, prefs->GetInteger(prefs::kStabilityPageLoadCount)); -#else EXPECT_EQ(4, prefs->GetInteger(prefs::kStabilityPageLoadCount)); -#endif EXPECT_EQ(1, prefs->GetInteger(prefs::kStabilityRendererCrashCount)); // TODO(isherman): We should also verify that prefs::kStabilityExitedCleanly // is set to true, but this preference isn't set until the browser diff --git a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc index 6331190..3512cab 100644 --- a/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc +++ b/chrome/browser/renderer_host/render_process_host_chrome_browsertest.cc @@ -71,10 +71,6 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, int tab_count = 1; int host_count = 1; -#if defined(USE_VIRTUAL_KEYBOARD) - ++host_count; // For the virtual keyboard. -#endif - GURL page1("data:text/html,hello world1"); browser()->ShowSingletonTab(page1); if (browser()->tab_count() == tab_count) @@ -108,10 +104,6 @@ IN_PROC_BROWSER_TEST_F(ChromeRenderProcessHostTest, int tab_count = 1; int host_count = 1; -#if defined(USE_VIRTUAL_KEYBOARD) - ++host_count; // For the virtual keyboard. -#endif - GURL page1("data:text/html,hello world1"); browser()->ShowSingletonTab(page1); if (browser()->tab_count() == tab_count) diff --git a/chrome/browser/resources/component_extension_resources.grd b/chrome/browser/resources/component_extension_resources.grd index b95b15b..1556119 100644 --- a/chrome/browser/resources/component_extension_resources.grd +++ b/chrome/browser/resources/component_extension_resources.grd @@ -208,10 +208,6 @@ <include name="IDR_FILE_MANAGER_MEDIA_ERROR" file="file_manager/images/media/error.png" type="BINDATA" /> </if> - - <if expr="pp_ifdef('use_virtual_keyboard')"> - <include name="IDR_KEYBOARD_INDEX" file="keyboard/index.html" flattenhtml="true" type="BINDATA" /> - </if> </includes> </release> </grit> diff --git a/chrome/browser/resources/keyboard/chevron.svg b/chrome/browser/resources/keyboard/chevron.svg deleted file mode 100644 index d75deb0..0000000 --- a/chrome/browser/resources/keyboard/chevron.svg +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="-0.042 -8.542 50 50" xml:space="preserve"> -<g> - <path fill="#bababb" d="M24.958,12.318l11.482-6.646v3.801l-11.482,7.904L13.479,9.473V5.672L24.958,12.318z M24.958,22.06l11.482-6.57v3.726 - l-11.482,8.031l-11.479-8.031v-3.701L24.958,22.06z"/> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/common.js b/chrome/browser/resources/keyboard/common.js deleted file mode 100644 index df08592..0000000 --- a/chrome/browser/resources/keyboard/common.js +++ /dev/null @@ -1,972 +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. - -/** - * @fileoverview A simple virtual keyboard implementation. - */ - -var KEY_MODE = 'key'; -var SHIFT_MODE = 'shift'; -var NUMBER_MODE = 'number'; -var SYMBOL_MODE = 'symbol'; -var MODES = [ KEY_MODE, SHIFT_MODE, NUMBER_MODE, SYMBOL_MODE ]; -var currentMode = SHIFT_MODE; -var enterShiftModeOnSpace = false; -var MODE_TRANSITIONS = {}; - -MODE_TRANSITIONS[KEY_MODE + SHIFT_MODE] = SHIFT_MODE; -MODE_TRANSITIONS[KEY_MODE + NUMBER_MODE] = NUMBER_MODE; -MODE_TRANSITIONS[SHIFT_MODE + SHIFT_MODE] = KEY_MODE; -MODE_TRANSITIONS[SHIFT_MODE + NUMBER_MODE] = NUMBER_MODE; -MODE_TRANSITIONS[NUMBER_MODE + SHIFT_MODE] = SYMBOL_MODE; -MODE_TRANSITIONS[NUMBER_MODE + NUMBER_MODE] = KEY_MODE; -MODE_TRANSITIONS[SYMBOL_MODE + SHIFT_MODE] = NUMBER_MODE; -MODE_TRANSITIONS[SYMBOL_MODE + NUMBER_MODE] = KEY_MODE; - -var KEYBOARDS = {}; - -/** - * The long-press delay in milliseconds before long-press handler is invoked. - * @type {number} - */ -var LONGPRESS_DELAY_MSEC = 500; - -/** - * The repeat delay in milliseconds before a key starts repeating. Use the same - * rate as Chromebook. (See chrome/browser/chromeos/language_preferences.cc) - * @type {number} - */ -var REPEAT_DELAY_MSEC = 500; - -/** - * The repeat interval or number of milliseconds between subsequent keypresses. - * Use the same rate as Chromebook. - * @type {number} - */ -var REPEAT_INTERVAL_MSEC = 50; - -/** - * The keyboard layout name currently in use. - * @type {string} - */ -var currentKeyboardLayout = 'us'; - -/** - * The popup keyboard layout name currently in use. - * @type {string} - */ -var currentPopupName = ''; - -/** - * A structure to track the currently repeating key on the keyboard. - */ -var repeatKey = { - /** - * The timer for the delay before repeating behaviour begins. - * @type {number|undefined} - */ - timer: undefined, - - /** - * The interval timer for issuing keypresses of a repeating key. - * @type {number|undefined} - */ - interval: undefined, - - /** - * The key which is currently repeating. - * @type {BaseKey|undefined} - */ - key: undefined, - - /** - * Cancel the repeat timers of the currently active key. - */ - cancel: function() { - clearTimeout(this.timer); - clearInterval(this.interval); - this.timer = undefined; - this.interval = undefined; - this.key = undefined; - } -}; - -/** - * An array to track the currently touched keys on the popup keyboard. - */ -var touchedKeys = []; - -/** - * Set the keyboard mode. - * @param {string} mode The new mode. - * @return {void} - */ -function setMode(mode) { - currentMode = mode; - - var rows = KEYBOARDS[currentKeyboardLayout]['rows']; - for (var i = 0; i < rows.length; ++i) { - rows[i].showMode(currentMode); - } - - if (!currentPopupName) { - return; - } - var popupRows = KEYBOARDS[currentPopupName]['rows']; - for (var i = 0; i < popupRows.length; ++i) { - popupRows[i].showMode(currentMode); - } -} - -/** - * Transition the mode according to the given transition. - * @param {string} transition The transition to take. - * @return {void} - */ -function transitionMode(transition) { - setMode(MODE_TRANSITIONS[currentMode + transition]); -} - -/** - * Send the given key to chrome, via the experimental extension API. - * @param {string} key The key to send. - * @return {void} - */ -function sendKey(key) { - var keyEvent = {'keyIdentifier': key}; - // A keypress event is automatically generated for printable characters - // immediately following the keydown event. - if (chrome.experimental) { - keyEvent.type = 'keydown'; - chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(keyEvent); - keyEvent.type = 'keyup'; - chrome.experimental.input.virtualKeyboard.sendKeyboardEvent(keyEvent); - } - // Exit shift mode after pressing any key but space. - if (currentMode == SHIFT_MODE && key != 'Spacebar') { - transitionMode(SHIFT_MODE); - } - // Enter shift mode after typing a closing punctuation and then a space for a - // new sentence. - if (enterShiftModeOnSpace) { - enterShiftModeOnSpace = false; - if (currentMode != SHIFT_MODE && key == 'Spacebar') { - setMode(SHIFT_MODE); - } - } - if (currentMode != SHIFT_MODE && (key == '.' || key == '?' || key == '!')) { - enterShiftModeOnSpace = true; - } -} - -/** - * Add a child div element that represents the content of the given element. - * A child div element that represents a text content is added if - * opt_textContent is given. Otherwise a child element that represents an image - * content is added. If the given element already has a child, the child element - * is modified. - * @param {Element} element The DOM Element to which the content is added. - * @param {string} opt_textContent The text to be inserted. - * @return {void} - */ -function addContent(element, opt_textContent) { - if (element.childNodes.length > 0) { - var content = element.childNodes[0]; - if (opt_textContent) { - content.textContent = opt_textContent; - } - return; - } - - var content = document.createElement('div'); - if (opt_textContent) { - content.textContent = opt_textContent; - content.className = 'text-key'; - } else { - content.className = 'image-key'; - } - element.appendChild(content); -} - -/** - * Set up the event handlers necessary to respond to mouse and touch events on - * the virtual keyboard. - * @param {BaseKey} key The BaseKey object corresponding to this key. - * @param {Element} element The top-level DOM Element to set event handlers on. - * @param {Object.<string, function()>} handlers The object that contains key - * event handlers in the following form. - * - * { 'up': keyUpHandler, - * 'down': keyDownHandler, - * 'long': keyLongHandler } - * - * keyUpHandler: Called when the key is pressed. This will be called - * repeatedly when holding a repeating key. - * keyDownHandler: Called when the keyis released. This is only called - * once per actual key press. - * keyLongHandler: Called when the key is long-pressed for - * |LONGPRESS_DELAY_MSEC| milliseconds. - * - * The object does not necessarily contain all the handlers above, but - * needs to contain at least one of them. - */ -function setupKeyEventHandlers(key, element, handlers) { - var keyDownHandler = handlers['down']; - var keyUpHandler = handlers['up']; - var keyLongHandler = handlers['long']; - if (!(keyDownHandler || keyUpHandler || keyLongPressHandler)) { - throw new Error('Invalid handlers passed to setupKeyEventHandlers'); - } - - /** - * Handle a key down event on the virtual key. - * @param {UIEvent} evt The UI event which triggered the key down. - */ - var downHandler = function(evt) { - // Prevent any of the system gestures from happening. - evt.preventDefault(); - - // Don't process a key down if the key is already down. - if (key.pressed) { - return; - } - key.pressed = true; - if (keyDownHandler) { - keyDownHandler(); - } - repeatKey.cancel(); - - // Start a repeating timer if there is a repeat interval and a function to - // process key down events. - if (key.repeat && keyDownHandler) { - repeatKey.key = key; - // The timeout for the repeating timer occurs at - // REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC so that the interval - // function can handle all repeat keypresses and will get the first one - // at the correct time. - repeatKey.timer = setTimeout(function() { - repeatKey.timer = undefined; - repeatKey.interval = setInterval(function() { - keyDownHandler(); - }, REPEAT_INTERVAL_MSEC); - }, Math.max(0, REPEAT_DELAY_MSEC - REPEAT_INTERVAL_MSEC)); - } - - if (keyLongHandler) { - // Copy the currentTarget of event, which is neccessary in - // showPopupKeyboard, because |evt| can be modified before - // |keyLongHandler| is called. - var evtCopy = {}; - evtCopy.currentTarget = evt.currentTarget; - key.longPressTimer = setTimeout(function() { - keyLongHandler(evtCopy), - clearTimeout(key.longPressTimer); - delete key.longPressTimer; - key.pressed = false; - }, LONGPRESS_DELAY_MSEC); - } - }; - - /** - * Handle a key up event on the virtual key. - * @param {UIEvent} evt The UI event which triggered the key up. - */ - var upHandler = function(evt) { - // Prevent any of the system gestures from happening. - evt.preventDefault(); - - // Reset long-press timer. - if (key.longPressTimer) { - clearTimeout(key.longPressTimer); - delete key.longPressTimer - } - - // If they key was not actually pressed do not send a key up event. - if (!key.pressed) { - return; - } - key.pressed = false; - - // Cancel running repeat timer for the released key only. - if (repeatKey.key == key) { - repeatKey.cancel(); - } - - if (keyUpHandler) { - keyUpHandler(); - } - }; - - var outHandler = function(evt) { - // Key element contains a div that holds text like this. - // - // <div class="key r1"> - // <div class="text-key">a</div> - // </div> - // - // We are interested in mouseout event sent when mouse cursor moves out of - // the external div, but mouseout event is sent when mouse cursor moves out - // of the internal div or moves into the internal div, too. - // Filter out the last two cases here. - if (evt.target != evt.currentTarget || - evt.toElement.parentNode == evt.fromElement) { - return; - } - // Reset key press state if the point goes out of the element. - key.pressed = false; - // Reset long-press timer. - if (key.longPressTimer) { - clearTimeout(key.longPressTimer); - delete key.longPressTimer - } - } - - // Setup mouse event handlers. - element.addEventListener('mousedown', downHandler); - element.addEventListener('mouseup', upHandler); - element.addEventListener('mouseout', outHandler); - - // Setup touch handlers. - element.addEventListener('touchstart', downHandler); - element.addEventListener('touchend', upHandler); - // TODO(mazda): Add a handler for touchleave once Webkit supports it. - // element.addEventListener('touchleave', outHandler); -} - -/** - * Create closure for the sendKey function. - * @param {string} key The key paramater to sendKey. - * @return {function()} A function which calls sendKey(key). - */ -function sendKeyFunction(key) { - return function() { - sendKey(key); - }; -} - -/** - * Dispatch custom events to the elements at the touch points. - * touchmove_popup events are dispatched responding to a touchmove and - * touchend_popup events responding to a touchend event respectively. - * @param {UIEvent} evt The touch event that contains touch points information. - * @return {void} - */ -function dispatchCustomPopupEvents(evt) { - var type = null; - var touches = null; - if (evt.type == 'touchmove') { - type = 'touchmove_popup'; - touches = evt.touches; - } else if (evt.type == 'touchend') { - type = 'touchend_popup'; - touches = evt.changedTouches; - } else { - return; - } - - for (var i = 0; i < touches.length; ++i) { - var dispatchedEvent = document.createEvent('Event'); - dispatchedEvent.initEvent(type, true, false); - var touch = touches[i]; - var key = document.elementFromPoint(touch.screenX, touch.screenY); - if (key) { - key.dispatchEvent(dispatchedEvent); - } - } -} - -/** - * Handle a touch move event on the key to make changes to the popup keyboard. - * @param {UIEvent} evt The UI event which triggered the touch move. - * @return {void} -*/ -function trackTouchMoveForPopup(evt) { - var previous = touchedKeys; - touchedKeys = []; - dispatchCustomPopupEvents(evt); - for (var i = 0; i < previous.length; ++i) { - if (touchedKeys.indexOf(previous[i]) == -1) { - previous[i].classList.remove('highlighted'); - } - } - for (var i = 0; i < touchedKeys.length; ++i) { - touchedKeys[i].classList.add('highlighted'); - } -} - -/** - * Handle a touch end event on the key to make changes to the popup keyboard. - * @param {UIEvent} evt The UI event which triggered the touch end. - * @return {void} -*/ -function trackTouchEndForPopup(evt) { - for (var i = 0; i < touchedKeys.length; ++i) { - touchedKeys[i].classList.remove('highlighted'); - } - dispatchCustomPopupEvents(evt); - hidePopupKeyboard(); - - touchedKeys = []; - evt.target.removeEventListener('touchmove', trackTouchMoveForPopup); - evt.target.removeEventListener('touchend', trackTouchEndForPopup); -} - -/** - * Show the popup keyboard. - * @param {string} name The name of the popup keyboard. - * @param {UIEvent} evt The UI event which triggered the touch start. - * @return {void} - */ -function showPopupKeyboard(name, evt) { - var popupDiv = document.getElementById('popup'); - if (popupDiv.style.visibility == 'visible') { - return; - } - - // Iitialize the rows of the popup keyboard - initRows(name, popupDiv, true); - currentPopupName = name; - - // Set the mode of the popup keyboard - var popupRows = KEYBOARDS[name]['rows']; - for (var i = 0; i < popupRows.length; ++i) { - popupRows[i].showMode(currentMode); - } - - // Calculate the size of popup keyboard based on the size of the key. - var keyElement = evt.currentTarget; - var keyboard = KEYBOARDS[name]; - var rows = keyboard['definition']; - var height = keyElement.offsetHeight * rows.length; - var aspect = keyboard['aspect']; - var width = aspect * height; - popupDiv.style.width = width + 'px'; - popupDiv.style.height = height + 'px'; - - // Place the popup keyboard above the key - var rect = keyElement.getBoundingClientRect(); - var left = (rect.left + rect.right) / 2 - width / 2; - left = Math.min(Math.max(left, 0), window.innerWidth - width); - var top = rect.top - height; - top = Math.min(Math.max(top, 0), window.innerHeight - height); - popupDiv.style.left = left + 'px'; - popupDiv.style.top = top + 'px'; - popupDiv.style.visibility = 'visible'; - - keyElement.addEventListener('touchmove', trackTouchMoveForPopup); - keyElement.addEventListener('touchend', trackTouchEndForPopup); -} - -/** - * Create closure for the showPopupKeyboard function. - * @param {string} name The name paramater to showPopupKeyboard. - * @return {function()} A function which calls showPopupKeyboard(name, evt). - */ -function showPopupKeyboardFunction(name) { - return function (evt) { - showPopupKeyboard(name, evt); - }; -} - -/** - * Hide the popup keyboard. - * @return {void} - */ -function hidePopupKeyboard() { - // Clean up the popup keyboard - var popupDiv = document.getElementById('popup'); - popupDiv.style.visibility = 'hidden'; - while (popupDiv.firstChild) { - popupDiv.removeChild(popupDiv.firstChild); - } - if (currentPopupName in KEYBOARDS) { - delete KEYBOARDS[currentPopupName].rows; - } - currentPopupName = ''; -} - -/** - * Plain-old-data class to represent a character. - * @param {string} display The HTML to be displayed. - * @param {string} id The key identifier for this Character. - * @constructor - */ -function Character(display, id) { - this.display = display; - this.keyIdentifier = id; -} - -/** - * Convenience function to make the keyboard data more readable. - * @param {string} display The display for the created Character. - * @param {string} opt_id The id for the created Character. - * @return {Character} A character that contains display and opt_id. If - * opt_id is omitted, display is used as the id. - */ -function C(display, opt_id) { - var id = opt_id || display; - return new Character(display, id); -} - -/** - * Convenience function to make the keyboard data more readable. - * @param {string} display The display for the created Character. - * @param {string} opt_id The id for the created Character. - * @param {string} opt_popupName The popup keyboard name for this character. - * @return {Object} An object that contains a Character and the popup keyboard - * name. - */ -function CP(display, opt_id, opt_popupName) { - var result = { character: C(display, opt_id) }; - if (opt_popupName) { - result['popupName'] = opt_popupName; - } - return result; -} - -/** - * An abstract base-class for all keys on the keyboard. - * @constructor - */ -function BaseKey() {} - -BaseKey.prototype = { - /** - * The cell type of this key. Determines the background colour. - * @type {string} - */ - cellType_: '', - - /** - * If true, holding this key will issue repeat keypresses. - * @type {boolean} - */ - repeat_: false, - - /** - * Track the pressed state of the key. This is true if currently pressed. - * @type {boolean} - */ - pressed_: false, - - /** - * Get the repeat behaviour of the key. - * @return {boolean} True if the key will repeat. - */ - get repeat() { - return this.repeat_; - }, - - /** - * Set the repeat behaviour of the key - * @param {boolean} repeat True if the key should repeat. - */ - set repeat(repeat) { - this.repeat_ = repeat; - }, - - /** - * Get the pressed state of the key. - * @return {boolean} True if the key is currently pressed. - */ - get pressed() { - return this.pressed_; - }, - - /** - * Set the pressed state of the key. - * @param {boolean} pressed True if the key is currently pressed. - */ - set pressed(pressed) { - this.pressed_ = pressed; - }, - - /** - * Create the DOM elements for the given keyboard mode. Must be overridden. - * @param {string} mode The keyboard mode to create elements for. - * @return {Element} The top-level DOM Element for the key. - */ - makeDOM: function(mode) { - throw new Error('makeDOM not implemented in BaseKey'); - }, -}; - -/** - * A simple key which displays Characters. - * @param {Object} key The Character and the popup name for KEY_MODE. - * @param {Object} shift The Character and the popup name for SHIFT_MODE. - * @param {Object} num The Character and the popup name for NUMBER_MODE. - * @param {Object} symbol The Character and the popup name for SYMBOL_MODE. - * @constructor - * @extends {BaseKey} - */ -function Key(key, shift, num, symbol) { - this.modeElements_ = {}; - this.cellType_ = ''; - - this.modes_ = {}; - this.modes_[KEY_MODE] = key ? key.character : null; - this.modes_[SHIFT_MODE] = shift ? shift.character : null; - this.modes_[NUMBER_MODE] = num ? num.character : null; - this.modes_[SYMBOL_MODE] = symbol ? symbol.character : null; - - this.popupNames_ = {}; - this.popupNames_[KEY_MODE] = key ? key.popupName : null; - this.popupNames_[SHIFT_MODE] = shift ? shift.popupName : null; - this.popupNames_[NUMBER_MODE] = num ? num.popupName : null; - this.popupNames_[SYMBOL_MODE] = symbol ? symbol.popupName : null; -} - -Key.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - if (!this.modes_[mode]) { - return null; - } - - this.modeElements_[mode] = document.createElement('div'); - var element = this.modeElements_[mode]; - element.className = 'key'; - - addContent(element, this.modes_[mode].display); - - var longHandler = this.popupNames_[mode] ? - showPopupKeyboardFunction(this.popupNames_[mode]) : null; - setupKeyEventHandlers(this, element, - { 'up': sendKeyFunction(this.modes_[mode].keyIdentifier), - 'long': longHandler }); - return element; - } -}; - -/** - * A simple key which displays Characters on the popup keyboard. - * @param {Character} key The Character for KEY_MODE. - * @param {Character} shift The Character for SHIFT_MODE. - * @param {Character} num The Character for NUMBER_MODE. - * @param {Character} symbol The Character for SYMBOL_MODE. - * @constructor - * @extends {BaseKey} - */ -function PopupKey(key, shift, num, symbol) { - this.modeElements_ = {}; - this.cellType_ = ''; - - this.modes_ = {}; - this.modes_[KEY_MODE] = key; - this.modes_[SHIFT_MODE] = shift; - this.modes_[NUMBER_MODE] = num; - this.modes_[SYMBOL_MODE] = symbol; -} - -PopupKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - if (!this.modes_[mode]) { - return null; - } - - this.modeElements_[mode] = document.createElement('div'); - var element = this.modeElements_[mode]; - element.className = 'key popupkey'; - - addContent(element, this.modes_[mode].display); - - var upHandler = sendKeyFunction(this.modes_[mode].keyIdentifier); - element.addEventListener('touchmove_popup', function(evt) { - touchedKeys.push(element); - }); - element.addEventListener('touchend_popup', upHandler); - element.addEventListener('mouseup', upHandler); - element.addEventListener('mouseover', function(evt) { - element.classList.add('highlighted'); - }); - element.addEventListener('mouseout', function(evt) { - element.classList.remove('highlighted'); - }); - return element; - } -}; - -/** - * A key which displays an SVG image. - * @param {string} className The class that provides the image. - * @param {string} keyId The key identifier for the key. - * @param {boolean} opt_repeat True if the key should repeat. - * @constructor - * @extends {BaseKey} - */ -function SvgKey(className, keyId, opt_repeat) { - this.modeElements_ = {}; - this.cellType_ = 'nc'; - this.className_ = className; - this.keyId_ = keyId; - this.repeat_ = opt_repeat || false; -} - -SvgKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key'; - this.modeElements_[mode].classList.add(this.className_); - addContent(this.modeElements_[mode]); - - // send the key event on key down if key repeat is enabled - var handler = this.repeat_ ? { 'down' : sendKeyFunction(this.keyId_) } : - { 'up' : sendKeyFunction(this.keyId_) }; - setupKeyEventHandlers(this, this.modeElements_[mode], handler); - - return this.modeElements_[mode]; - } -}; - -/** - * A Key that remains the same through all modes. - * @param {string} content The display text for the key. - * @param {string} keyId The key identifier for the key. - * @constructor - * @extends {BaseKey} - */ -function SpecialKey(className, content, keyId) { - this.modeElements_ = {}; - this.cellType_ = 'nc'; - this.content_ = content; - this.keyId_ = keyId; - this.className_ = className; -} - -SpecialKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key'; - this.modeElements_[mode].classList.add(this.className_); - addContent(this.modeElements_[mode], this.content_); - - setupKeyEventHandlers(this, this.modeElements_[mode], - { 'up': sendKeyFunction(this.keyId_) }); - - return this.modeElements_[mode]; - } -}; - -/** - * A shift key. - * @constructor - * @extends {BaseKey} - */ -function ShiftKey(className) { - this.modeElements_ = {}; - this.cellType_ = 'nc'; - this.className_ = className; -} - -ShiftKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key shift'; - this.modeElements_[mode].classList.add(this.className_); - - if (mode == KEY_MODE || mode == SHIFT_MODE) { - addContent(this.modeElements_[mode]); - } else if (mode == NUMBER_MODE) { - addContent(this.modeElements_[mode], 'more'); - } else if (mode == SYMBOL_MODE) { - addContent(this.modeElements_[mode], '#123'); - } - - if (mode == SHIFT_MODE || mode == SYMBOL_MODE) { - this.modeElements_[mode].classList.add('moddown'); - } else { - this.modeElements_[mode].classList.remove('moddown'); - } - - setupKeyEventHandlers(this, this.modeElements_[mode], - { 'down': function() { - transitionMode(SHIFT_MODE); - }}); - - return this.modeElements_[mode]; - }, -}; - -/** - * The symbol key: switches the keyboard into symbol mode. - * @constructor - * @extends {BaseKey} - */ -function SymbolKey() { - this.modeElements_ = {} - this.cellType_ = 'nc'; -} - -SymbolKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode, height) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key symbol'; - - if (mode == KEY_MODE || mode == SHIFT_MODE) { - addContent(this.modeElements_[mode], '#123'); - } else if (mode == NUMBER_MODE || mode == SYMBOL_MODE) { - addContent(this.modeElements_[mode], 'abc'); - } - - if (mode == NUMBER_MODE || mode == SYMBOL_MODE) { - this.modeElements_[mode].classList.add('moddown'); - } else { - this.modeElements_[mode].classList.remove('moddown'); - } - - setupKeyEventHandlers(this, this.modeElements_[mode], - { 'down': function() { - transitionMode(NUMBER_MODE); - }}); - - return this.modeElements_[mode]; - } -}; - -/** - * The ".com" key. - * @constructor - * @extends {BaseKey} - */ -function DotComKey() { - this.modeElements_ = {} - this.cellType_ = 'nc'; -} - -DotComKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key com'; - addContent(this.modeElements_[mode], '.com'); - - setupKeyEventHandlers(this, this.modeElements_[mode], - { 'up': function() { - sendKey('.'); - sendKey('c'); - sendKey('o'); - sendKey('m'); - }}); - - return this.modeElements_[mode]; - } -}; - -/** - * The key that hides the keyboard. - * @constructor - * @extends {BaseKey} - */ -function HideKeyboardKey() { - this.modeElements_ = {} - this.cellType_ = 'nc'; -} - -HideKeyboardKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key hide'; - addContent(this.modeElements_[mode]); - - setupKeyEventHandlers(this, this.modeElements_[mode], - { 'down': function() { - if (chrome.experimental) { - chrome.experimental.input.virtualKeyboard.hideKeyboard(); - } - }}); - - return this.modeElements_[mode]; - } -}; - -/** - * A container for keys. - * @param {number} position The position of the row (0-3). - * @param {Array.<BaseKey>} keys The keys in the row. - * @constructor - */ -function Row(position, keys) { - this.position_ = position; - this.keys_ = keys; - this.element_ = null; - this.modeElements_ = {}; -} - -Row.prototype = { - /** - * Create the DOM elements for the row. - * @return {Element} The top-level DOM Element for the row. - */ - makeDOM: function() { - this.element_ = document.createElement('div'); - this.element_.className = 'row'; - for (var i = 0; i < MODES.length; ++i) { - var mode = MODES[i]; - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].style.display = 'none'; - this.element_.appendChild(this.modeElements_[mode]); - } - - for (var j = 0; j < this.keys_.length; ++j) { - var key = this.keys_[j]; - for (var i = 0; i < MODES.length; ++i) { - var keyDom = key.makeDOM(MODES[i]); - if (keyDom) { - this.modeElements_[MODES[i]].appendChild(keyDom); - } - } - } - - for (var i = 0; i < MODES.length; ++i) { - var clearingDiv = document.createElement('div'); - clearingDiv.style.clear = 'both'; - this.modeElements_[MODES[i]].appendChild(clearingDiv); - } - - return this.element_; - }, - - /** - * Shows the given mode. - * @param {string} mode The mode to show. - * @return {void} - */ - showMode: function(mode) { - for (var i = 0; i < MODES.length; ++i) { - this.modeElements_[MODES[i]].style.display = 'none'; - } - this.modeElements_[mode].style.display = '-webkit-box'; - }, - - /** - * Returns the size of keys this row contains. - * @return {number} The size of keys. - */ - get length() { - return this.keys_.length; - } -}; diff --git a/chrome/browser/resources/keyboard/del.svg b/chrome/browser/resources/keyboard/del.svg deleted file mode 100644 index 1f257d5..0000000 --- a/chrome/browser/resources/keyboard/del.svg +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="5 5 40 40" xml:space="preserve"> -<g> - <g> - <path fill="#bababb" d="M20.8,28.75c-0.043,0-0.087-0.012-0.126-0.034l-6-3.5C14.598,25.17,14.55,25.088,14.55,25 - s0.047-0.171,0.124-0.216l6-3.5c0.039-0.023,0.083-0.034,0.126-0.034c0.043,0,0.086,0.011,0.125,0.033 - c0.078,0.044,0.125,0.127,0.125,0.217v7c0,0.09-0.048,0.172-0.125,0.217C20.886,28.739,20.843,28.75,20.8,28.75L20.8,28.75z"/> - <path fill="#bababb" d="M20.8,21.5v7l-6-3.5L20.8,21.5 M20.8,21c-0.087,0-0.174,0.022-0.252,0.068l-6,3.5 - C14.395,24.657,14.3,24.822,14.3,25s0.094,0.342,0.248,0.432l6,3.5C20.626,28.977,20.713,29,20.8,29 - c0.086,0,0.172-0.022,0.249-0.066c0.155-0.089,0.251-0.255,0.251-0.434v-7c0-0.179-0.096-0.344-0.251-0.434 - C20.972,21.021,20.886,21,20.8,21L20.8,21z"/> - </g> - <polygon fill="#bababb" points="33.934,23.5 18.3,23.5 18.3,26.5 35.2,26.5 "/> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/ime.js b/chrome/browser/resources/keyboard/ime.js deleted file mode 100644 index 3652bf0..0000000 --- a/chrome/browser/resources/keyboard/ime.js +++ /dev/null @@ -1,282 +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. - -/** - * @fileoverview An input method UI implementation - */ - -/** - * Const variables - */ -const IME_KEYBOARD_HEIGHT = 300; -const IME_HEIGHT = 48; -const IME_VMARGIN = 12; -const IME_HMARGIN = 16; -const IME_FONTSIZE = IME_HEIGHT - IME_VMARGIN * 2; -const IME_MAX_CANDIDATES = 20; - -/** - * Creates a new button element. - * @param {Object=} opt_propertyBag Optional properties. - * @constructor - * @extends {HTMLButtonElement} - */ -var Button = cr.ui.define('button'); - -Button.prototype = { - __proto__: HTMLButtonElement.prototype, - /** - * Initialized the button element. - */ - decorate: function() { - this.className = 'ime button'; - - this.style.height = IME_HEIGHT + 'px'; - this.style.paddingTop = - this.style.paddingBottom = IME_VMARGIN + 'px'; - this.style.paddingLeft = - this.style.paddingRight = IME_HMARGIN + 'px'; - this.style.fontSize = IME_FONTSIZE + 'px'; - - this.tabIndex = -1; - this.text = ''; - }, - - /** - * Returns the text of the button - * @return {string} - */ - get text() { - return this.innerHTML; - }, - - /** - * Sets the HTML of the button - * @param {string} text in button in HTML format. If text is empty, the - * button will be hidden. - * @return {void} - */ - set text(text) { - this.innerHTML = text; - if (text) { - this.style.display = 'inline-block'; - } else { - this.style.display = 'none'; - } - }, -}; - -/** - * An input method UI - * @param {Object=} opt_propertyBag Optional properties. - * @constructor - * @extends {HTMLDivElement} - */ -var ImeUi = cr.ui.define('div'); - -ImeUi.prototype = { - __proto__: HTMLDivElement.prototype, - - /** - * Initialized the button element. - */ - decorate: function() { - this.className = 'ime panel'; - this.style.height = IME_HEIGHT + 'px'; - - this.auxiliary_ = new Button(); - this.auxiliary_.className += ' auxiliary'; - this.appendChild(this.auxiliary_); - - var that = this; - this.pageUp_ = new Button({'text': ' « '}); - this.pageUp_.onclick = function() { - that.pageUp(); - }; - - this.pageDown_ = new Button({'text': ' » '}); - this.pageDown_.onclick = function() { - that.pageDown(); - }; - - this.appendChild(this.pageUp_); - - // Create candidates - this.candidates_ = []; - /** - * Creates a candidate element. We need this function to create a new scope - * for each candidate buttons, so that they may have different value of - * index. - * @param {number} index - */ - function createCandidateButton(index) { - candidate = new Button(); - candidate.className += ' candidate'; - that.candidates_.push(candidate); - that.appendChild(candidate); - candidate.onclick = function() { - that.candidateClicked(index); - }; - } - for (var i = 0; i < IME_MAX_CANDIDATES; i++) { - createCandidateButton(i); - } - - this.appendChild(this.pageDown_); - this.update(); - }, - - /** - * Returns true if Ime Ui is visible. - * @return {boolean} - */ - get visible() { - return this.style.display != 'none'; - }, - - /** - * Sets the input cursor location. - * @param {number} x The x of the input cursor coordinates. - * @param {number} y The y of the input cursor coordinates. - * @param {number} w The width of the input cursor. - * @param {number} h The height of the input cursor. - * @return {void} - */ - setCursorLocation: function(x, y, w, h) { - // Currently we do nothing. - }, - - /** - * Updates the auxiliary text. - * @param {string} text The auxiliary text. - * @return {void} - */ - updateAuxiliaryText: function(text) { - this.auxiliary_.text = text; - this.update(); - }, - - /** - * Updates the lookup table. - * @param {Object} table The lookup table. - * @return {void} - */ - updateLookupTable : function(table) { - if (table.visible) { - for (var i = 0; - i < IME_MAX_CANDIDATES && i < table.candidates.length; i++) { - this.candidates_[i].text = table.candidates[i]; - } - for (; i < IME_MAX_CANDIDATES; i++) { - this.candidates_[i].text = ''; - } - } else { - for (var i = 0; i < this.candidates_.length; i++) { - this.candidates_[i].text = ''; - } - } - this.table_ = table; - this.update(); - }, - - update : function() { - var visible = - (this.table_ && this.table_.visible) || this.auxiliary_.text_; - - if (visible == this.visible) { - return; - } - - if (visible) { - chrome.experimental.input.setKeyboardHeight( - IME_KEYBOARD_HEIGHT + IME_HEIGHT); - this.style.display = 'inline-block'; - } else { - this.style.display = 'none'; - chrome.experimental.input.setKeyboardHeight(IME_KEYBOARD_HEIGHT); - } - // TODO(penghuang) Adjust the width of all items in ImeUi to fill the width - // of keyboard. - }, - - /** - * Candidate is clicked. - * @param {number} index The index of the candidate. - * @return {void} - */ - candidateClicked: function(index) { - chrome.experimental.input.ui.candidateClicked(index, 1); - }, - - /** - * Go to the previous page of the lookup table. - * @return {void} - */ - pageUp: function() { - chrome.experimental.input.ui.pageUp(); - }, - - /** - * Go to the next page of the lookup table. - * @return {void} - */ - pageDown: function() { - chrome.experimental.input.ui.pageDown(); - }, -}; - -var imeui = null; - -/** - * Initialize Ime Ui - * @param {Element} element The html element which will contain the ImeUi. - * @return {void} - */ -function initIme(element) { - if (imeui) { - // ime ui has been initialized. - return; - } - - try { - // Register self to receive input method UI events. - chrome.experimental.input.ui.register(); - } catch (e) { - // The ime is not enabled in chromium. - return; - } - - imeui = new ImeUi(); - - element.appendChild(imeui); - - // new row - var clearingDiv = document.createElement('div'); - clearingDiv.style.clear = 'both'; - element.appendChild(clearingDiv); - - // Install events handlers. - chrome.experimental.input.ui.onSetCursorLocation.addListener( - function(x, y, w, h) { - imeui.setCursorLocation(x, y, w, h); - }); - chrome.experimental.input.ui.onUpdateAuxiliaryText.addListener( - function(text) { - imeui.updateAuxiliaryText(text); - }); - chrome.experimental.input.ui.onUpdateLookupTable.addListener( - function(table) { - imeui.updateLookupTable(table); - }); -} - -/** - * Updates Ime Ui. It should be called when window is resized. - * @return {void} - */ -function updateIme() { - if (imeui) { - imeui.update(); - } -} diff --git a/chrome/browser/resources/keyboard/index.html b/chrome/browser/resources/keyboard/index.html deleted file mode 100644 index f4cc4e0..0000000 --- a/chrome/browser/resources/keyboard/index.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE HTML> -<html> - <head> - <link rel="stylesheet" href="main.css"> - <script src="chrome://resources/js/cr.js"></script> - <script src="chrome://resources/js/cr/ui.js"></script> - <script src="ime.js"></script> - <script src="common.js"></script> - <!-- TODO(mazda): load layout_<name>.js files only when necessary. --> - <script src="layout_fr.js"></script> - <script src="layout_us.js"></script> - <script src="layout_handwriting_vk.js"></script> - <script src="main.js"></script> - </head> - <body id="b"></body> -</html> diff --git a/chrome/browser/resources/keyboard/keyboard.svg b/chrome/browser/resources/keyboard/keyboard.svg deleted file mode 100644 index b8c7135..0000000 --- a/chrome/browser/resources/keyboard/keyboard.svg +++ /dev/null @@ -1,25 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="50px" height="50px" viewBox="0 0 50 50" xml:space="preserve"> -<g> - <g> - <path fill="#bababb" fill-rule="evenodd" clip-rule="evenodd" d="M41,12H9c-2.209,0-4,1.791-4,4v18c0,2.209,1.791,4,4,4h32c2.209,0,4-1.791,4-4 - V16C45,13.791,43.209,12,41,12z M33,18c0-0.552,0.447-1,1-1h2c0.552,0,1,0.448,1,1v2c0,0.552-0.448,1-1,1h-2c-0.553,0-1-0.448-1-1 - V18z M33,24c0-0.553,0.447-1,1-1h2c0.552,0,1,0.447,1,1v2c0,0.553-0.448,1-1,1h-2c-0.553,0-1-0.447-1-1V24z M28,18 - c0-0.552,0.447-1,1-1h2c0.553,0,1,0.448,1,1v2c0,0.552-0.447,1-1,1h-2c-0.553,0-1-0.448-1-1V18z M28,24c0-0.553,0.447-1,1-1h2 - c0.553,0,1,0.447,1,1v2c0,0.553-0.447,1-1,1h-2c-0.553,0-1-0.447-1-1V24z M23,18c0-0.552,0.447-1,1-1h2c0.553,0,1,0.448,1,1v2 - c0,0.552-0.447,1-1,1h-2c-0.553,0-1-0.448-1-1V18z M23,24c0-0.553,0.447-1,1-1h2c0.553,0,1,0.447,1,1v2c0,0.553-0.447,1-1,1h-2 - c-0.553,0-1-0.447-1-1V24z M18,18c0-0.552,0.447-1,1-1h2c0.553,0,1,0.448,1,1v2c0,0.552-0.447,1-1,1h-2c-0.553,0-1-0.448-1-1V18z - M18,24c0-0.553,0.447-1,1-1h2c0.553,0,1,0.447,1,1v2c0,0.553-0.447,1-1,1h-2c-0.553,0-1-0.447-1-1V24z M13,18 - c0-0.552,0.447-1,1-1h2c0.553,0,1,0.448,1,1v2c0,0.552-0.447,1-1,1h-2c-0.553,0-1-0.448-1-1V18z M8,18c0-0.552,0.447-1,1-1h2 - c0.552,0,1,0.448,1,1v2c0,0.552-0.448,1-1,1H9c-0.553,0-1-0.448-1-1V18z M8,24c0-0.553,0.447-1,1-1h2c0.552,0,1,0.447,1,1v2 - c0,0.553-0.448,1-1,1H9c-0.553,0-1-0.447-1-1V24z M14,32c0,0.553-0.447,1-1,1H9c-0.553,0-1-0.447-1-1v-2c0-0.553,0.447-1,1-1h4 - c0.553,0,1,0.447,1,1V32z M13,26v-2c0-0.553,0.447-1,1-1h2c0.553,0,1,0.447,1,1v2c0,0.553-0.447,1-1,1h-2 - C13.447,27,13,26.553,13,26z M35,32c0,0.553-0.447,1-1,1H16c-0.553,0-1-0.447-1-1v-2c0-0.553,0.447-1,1-1h18c0.553,0,1,0.447,1,1 - V32z M42,32c0,0.553-0.447,1-1,1h-4c-0.553,0-1-0.447-1-1v-2c0-0.553,0.447-1,1-1h4c0.553,0,1,0.447,1,1V32z M42,26 - c0,0.553-0.447,1-1,1h-2c-0.553,0-1-0.447-1-1v-2c0-0.553,0.447-1,1-1h2c0.553,0,1,0.447,1,1V26z M42,20c0,0.552-0.447,1-1,1h-2 - c-0.553,0-1-0.448-1-1v-2c0-0.552,0.447-1,1-1h2c0.553,0,1,0.448,1,1V20z"/> - </g> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/layout_fr.js b/chrome/browser/resources/keyboard/layout_fr.js deleted file mode 100644 index f4d1a2b..0000000 --- a/chrome/browser/resources/keyboard/layout_fr.js +++ /dev/null @@ -1,228 +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. - -// This file is generaged by gen_keyboard_layouts.py - -var KEYS_FR_POPUP_E = [ - [ - new PopupKey(C('\u0117', 'U+0117'), C('\u0116', 'U+0116'), - C('\u0117', 'U+0117'), C('\u0117', 'U+0117')), - new PopupKey(C('\u0113', 'U+0113'), C('\u0112', 'U+0112'), - C('\u0113', 'U+0113'), C('\u0113', 'U+0113')), - ], - [ - new PopupKey(C('\u0119', 'U+0119'), C('\u0118', 'U+0118'), - C('\u0119', 'U+0119'), C('\u0119', 'U+0119')), - new PopupKey(C('\u00ea', 'U+00EA'), C('\u00ca', 'U+00CA'), - C('\u00ea', 'U+00EA'), C('\u00ea', 'U+00EA')), - new PopupKey(C('\u00e9', 'U+00E9'), C('\u00c9', 'U+00C9'), - C('\u00e9', 'U+00E9'), C('\u00e9', 'U+00E9')), - new PopupKey(C('\u00e8', 'U+00E8'), C('\u00c8', 'U+00C8'), - C('\u00e8', 'U+00E8'), C('\u00e8', 'U+00E8')), - new PopupKey(C('\u00eb', 'U+00EB'), C('\u00cb', 'U+00CB'), - C('\u00eb', 'U+00EB'), C('\u00eb', 'U+00EB')), - ], -]; - -KEYBOARDS['fr_popup_e'] = { - 'definition': KEYS_FR_POPUP_E, - 'aspect': 1.5, -}; - -var KEYS_FR = [ - [ - new SvgKey('tab', 'Tab'), - new Key(CP('a', 'a', 'fr_popup_a'), CP('A', 'A', 'fr_popup_a'), CP('1'), - CP('~')), - new Key(CP('z'), CP('Z'), CP('2'), CP('`')), - new Key(CP('e', 'e', 'fr_popup_e'), CP('E', 'E', 'fr_popup_e'), CP('3'), - CP('|')), - new Key(CP('r'), CP('R'), CP('4'), CP('\u2022', 'U+2022')), - new Key(CP('t'), CP('T'), CP('5'), CP('\u221a', 'U+221A')), - new Key(CP('y', 'y', 'fr_popup_y'), CP('Y', 'Y', 'fr_popup_y'), CP('6'), - CP('\u03c0', 'U+03C0')), - new Key(CP('u', 'u', 'fr_popup_u'), CP('U', 'U', 'fr_popup_u'), CP('7'), - CP('\u00f7', 'U+00F7')), - new Key(CP('i', 'i', 'fr_popup_i'), CP('I', 'I', 'fr_popup_i'), CP('8'), - CP('\u00d7', 'U+00D7')), - new Key(CP('o', 'o', 'fr_popup_o'), CP('O', 'O', 'fr_popup_o'), CP('9'), - CP('\u00a7', 'U+00A7')), - new Key(CP('p'), CP('P'), CP('0'), CP('\u0394', 'U+0394')), - new SvgKey('backspace', 'Backspace', true), - ], - [ - new SymbolKey(), - new Key(CP('q'), CP('Q'), CP('#'), CP('\u00a3', 'U+00A3')), - new Key(CP('s'), CP('S'), CP('$'), CP('\u00a2', 'U+00A2')), - new Key(CP('d'), CP('D'), CP('%'), CP('\u20ac', 'U+20AC')), - new Key(CP('f'), CP('F'), CP('&'), CP('\u00a5', 'U+00A5')), - new Key(CP('g'), CP('G'), CP('*'), CP('^')), - new Key(CP('h'), CP('H'), CP('-'), CP('\u00b0', 'U+00B0')), - new Key(CP('j'), CP('J'), CP('+', 'Plus'), CP('\u00b1', 'U+00B1')), - new Key(CP('k'), CP('K'), CP('('), CP('{', 'U+007B')), - new Key(CP('l'), CP('L'), CP(')'), CP('}', 'U+007D')), - new Key(CP('m'), CP('M'), null, null), - new SvgKey('return', 'Enter'), - ], - [ - new ShiftKey('left_shift'), - new Key(CP('w'), CP('W'), CP('<'), CP('\\')), - new Key(CP('x'), CP('X'), CP('>'), CP('\u00a9', 'U+00A9')), - new Key(CP('c', 'c', 'fr_popup_c'), CP('C', 'C', 'fr_popup_c'), - CP('=', 'Equals'), CP('\u00ae', 'U+00AE')), - new Key(CP('v'), CP('V'), CP(':'), CP('\u2122', 'U+2122')), - new Key(CP('b'), CP('B'), CP(';'), CP('\u2105', 'U+2105')), - new Key(CP('n'), CP('N'), CP(','), CP('[')), - new Key(CP('\'', 'Apostrophe'), CP(':'), CP('.'), CP(']')), - new Key(CP(','), CP('!'), CP('!'), CP('\u00a1', 'U+00A1')), - new Key(CP('.'), CP('?'), CP('?'), CP('\u00bf', 'U+00BF')), - new ShiftKey('right_shift'), - ], - [ - new SvgKey('mic', ' '), - new DotComKey(), - new SpecialKey('at', '@', '@'), - new SpecialKey('space', ' ', 'Spacebar'), - new SpecialKey('comma', ',', ','), - new SpecialKey('period', '.', '.'), - new HideKeyboardKey(), - ], -]; - -KEYBOARDS['fr'] = { - 'definition': KEYS_FR, - 'aspect': 3.15, -}; - -var KEYS_FR_POPUP_A = [ - [ - new PopupKey(C('\u0101', 'U+0101'), C('\u0100', 'U+0100'), - C('\u0101', 'U+0101'), C('\u0101', 'U+0101')), - new PopupKey(C('\u00e3', 'U+00E3'), C('\u00c3', 'U+00C3'), - C('\u00e3', 'U+00E3'), C('\u00e3', 'U+00E3')), - new PopupKey(C('\u00e5', 'U+00E5'), C('\u00c5', 'U+00C5'), - C('\u00e5', 'U+00E5'), C('\u00e5', 'U+00E5')), - new PopupKey(C('\u00aa', 'U+00AA'), C('\u00aa', 'U+00AA'), - C('\u00aa', 'U+00AA'), C('\u00aa', 'U+00AA')), - ], - [ - new PopupKey(C('\u00e4', 'U+00E4'), C('\u00c4', 'U+00C4'), - C('\u00e4', 'U+00E4'), C('\u00e4', 'U+00E4')), - new PopupKey(C('\u00e6', 'U+00E6'), C('\u00c6', 'U+00C6'), - C('\u00e6', 'U+00E6'), C('\u00e6', 'U+00E6')), - new PopupKey(C('\u00e0', 'U+00E0'), C('\u00c0', 'U+00C0'), - C('\u00e0', 'U+00E0'), C('\u00e0', 'U+00E0')), - new PopupKey(C('\u00e2', 'U+00E2'), C('\u00c2', 'U+00C2'), - C('\u00e2', 'U+00E2'), C('\u00e2', 'U+00E2')), - new PopupKey(C('\u00e1', 'U+00E1'), C('\u00c1', 'U+00C1'), - C('\u00e1', 'U+00E1'), C('\u00e1', 'U+00E1')), - ], -]; - -KEYBOARDS['fr_popup_a'] = { - 'definition': KEYS_FR_POPUP_A, - 'aspect': 1.5, -}; - -var KEYS_FR_POPUP_C = [ - [ - new PopupKey(C('\u010d', 'U+010D'), C('\u010c', 'U+010C'), - C('\u010d', 'U+010D'), C('\u010d', 'U+010D')), - new PopupKey(C('\u00e7', 'U+00E7'), C('\u00c7', 'U+00C7'), - C('\u00e7', 'U+00E7'), C('\u00e7', 'U+00E7')), - new PopupKey(C('\u0107', 'U+0107'), C('\u0106', 'U+0106'), - C('\u0107', 'U+0107'), C('\u0107', 'U+0107')), - ], -]; - -KEYBOARDS['fr_popup_c'] = { - 'definition': KEYS_FR_POPUP_C, - 'aspect': 1.8, -}; - -var KEYS_FR_POPUP_O = [ - [ - new PopupKey(C('\u014d', 'U+014D'), C('\u014c', 'U+014C'), - C('\u014d', 'U+014D'), C('\u014d', 'U+014D')), - new PopupKey(C('\u00f5', 'U+00F5'), C('\u00d5', 'U+00D5'), - C('\u00f5', 'U+00F5'), C('\u00f5', 'U+00F5')), - new PopupKey(C('\u00f8', 'U+00F8'), C('\u00d8', 'U+00D8'), - C('\u00f8', 'U+00F8'), C('\u00f8', 'U+00F8')), - new PopupKey(C('\u00ba', 'U+00BA'), C('\u00ba', 'U+00BA'), - C('\u00ba', 'U+00BA'), C('\u00ba', 'U+00BA')), - ], - [ - new PopupKey(C('\u00f3', 'U+00F3'), C('\u00f3', 'U+00F3'), - C('\u00f3', 'U+00F3'), C('\u00f3', 'U+00F3')), - new PopupKey(C('\u00f6', 'U+00F6'), C('\u00d6', 'U+00D6'), - C('\u00f6', 'U+00F6'), C('\u00f6', 'U+00F6')), - new PopupKey(C('\u00f4', 'U+00F4'), C('\u00d4', 'U+00D4'), - C('\u00f4', 'U+00F4'), C('\u00f4', 'U+00F4')), - new PopupKey(C('\u0153', 'U+0153'), C('\u0152', 'U+0152'), - C('\u0153', 'U+0153'), C('\u0153', 'U+0153')), - new PopupKey(C('\u00f2', 'U+00F2'), C('\u00d2', 'U+00D2'), - C('\u00f2', 'U+00F2'), C('\u00f2', 'U+00F2')), - ], -]; - -KEYBOARDS['fr_popup_o'] = { - 'definition': KEYS_FR_POPUP_O, - 'aspect': 1.5, -}; - -var KEYS_FR_POPUP_I = [ - [ - new PopupKey(C('\u012b', 'U+012B'), C('\u012a', 'U+012A'), - C('\u012b', 'U+012B'), C('\u012b', 'U+012B')), - ], - [ - new PopupKey(C('\u012f', 'U+012F'), C('\u012e', 'U+012E'), - C('\u012f', 'U+012F'), C('\u012f', 'U+012F')), - new PopupKey(C('\u00ec', 'U+00EC'), C('\u00cc', 'U+00CC'), - C('\u00ec', 'U+00EC'), C('\u00ec', 'U+00EC')), - new PopupKey(C('\u00ee', 'U+00EE'), C('\u00ce', 'U+00CE'), - C('\u00ee', 'U+00EE'), C('\u00ee', 'U+00EE')), - new PopupKey(C('\u00ef', 'U+00EF'), C('\u00cf', 'U+00CF'), - C('\u00ef', 'U+00EF'), C('\u00ef', 'U+00EF')), - new PopupKey(C('\u00ed', 'U+00ED'), C('\u00cd', 'U+00CD'), - C('\u00ed', 'U+00ED'), C('\u00ed', 'U+00ED')), - ], -]; - -KEYBOARDS['fr_popup_i'] = { - 'definition': KEYS_FR_POPUP_I, - 'aspect': 1.5, -}; - -var KEYS_FR_POPUP_U = [ - [ - new PopupKey(C('\u016b', 'U+016B'), C('\u016a', 'U+016A'), - C('\u016b', 'U+016B'), C('\u016b', 'U+016B')), - new PopupKey(C('\u00fc', 'U+00FC'), C('\u00dc', 'U+00DC'), - C('\u00fc', 'U+00FC'), C('\u00fc', 'U+00FC')), - new PopupKey(C('\u00fb', 'U+00FB'), C('\u00db', 'U+00DB'), - C('\u00fb', 'U+00FB'), C('\u00fb', 'U+00FB')), - new PopupKey(C('\u00f9', 'U+00F9'), C('\u00d9', 'U+00D9'), - C('\u00f9', 'U+00F9'), C('\u00f9', 'U+00F9')), - new PopupKey(C('\u00fa', 'U+00FA'), C('\u00da', 'U+00DA'), - C('\u00fa', 'U+00FA'), C('\u00fa', 'U+00FA')), - ], -]; - -KEYBOARDS['fr_popup_u'] = { - 'definition': KEYS_FR_POPUP_U, - 'aspect': 3, -}; - -var KEYS_FR_POPUP_Y = [ - [ - new PopupKey(C('\u00ff', 'U+00FF'), C('\u0178', 'U+0178'), - C('\u00ff', 'U+00FF'), C('\u00ff', 'U+00FF')), - ], -]; - -KEYBOARDS['fr_popup_y'] = { - 'definition': KEYS_FR_POPUP_Y, - 'aspect': 0.6, -}; diff --git a/chrome/browser/resources/keyboard/layout_handwriting_vk.js b/chrome/browser/resources/keyboard/layout_handwriting_vk.js deleted file mode 100644 index 5977813..0000000 --- a/chrome/browser/resources/keyboard/layout_handwriting_vk.js +++ /dev/null @@ -1,233 +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. - -/** - * @fileoverview A handwriting virtual keyboard implementation. - */ - -/** - * Const variables - */ -const HANDWRITING_CANVAS_LINE_COLOR = '#ffffff'; -const HANDWRITING_CANVAS_LINE_WIDTH = 5; -const HANDWRITING_CANVAS_MOUSEMOVE_THRESHOLD_SQ = 15 * 15; // 15px. -const HANDWRITING_CANVAS_ASPECT = 1.0; -const HANDWRITING_CANVAS_ELEMENT_ID = 'handwriting-canvas'; - -/** - * The key that clears the canvas for handwriting. - * @param {number} aspect The aspect ratio of the key. - * @constructor - * @extends {BaseKey} - */ -function ClearHandwritingKey(content) { - this.modeElements_ = {} - this.cellType_ = 'nc'; - this.content_ = content; -} - -ClearHandwritingKey.prototype = { - __proto__: BaseKey.prototype, - - /** @inheritDoc */ - makeDOM: function(mode, height) { - this.modeElements_[mode] = document.createElement('div'); - this.modeElements_[mode].className = 'key handwriting-clear'; - addContent(this.modeElements_[mode], this.content_); - - this.modeElements_[mode].onclick = function() { - var canvas = document.getElementById(HANDWRITING_CANVAS_ELEMENT_ID); - canvas.clear(); - }; - - return this.modeElements_[mode]; - } -}; - -/** - * The canvas element for handwriting. - * @param {Object=} opt_propertyBag Optional properties. - * @constructor - * @extends {HTMLCanvasElement} - */ -var HandwritingCanvas = cr.ui.define('canvas'); - -HandwritingCanvas.prototype = { - __proto__: HTMLCanvasElement.prototype, - - /** - * Creates the DOM element for the canvas. - * @return {Element} The DOM Element. - */ - decorate: function() { - this.id = HANDWRITING_CANVAS_ELEMENT_ID; - this.stroke_ = []; - - var canvas = this; - var context = canvas.getContext('2d'); - - canvas.className = 'handwriting'; - canvas.onmousedown = function(e) { - var coords = canvas.getEventCoordinates(e); - canvas.stroke_ = []; - context.strokeStyle = HANDWRITING_CANVAS_LINE_COLOR; - context.lineWidth = HANDWRITING_CANVAS_LINE_WIDTH; - context.beginPath(); - context.moveTo(coords.x, coords.y); - canvas.addStroke(coords.x, coords.y); - }; - - canvas.onmousemove = function(e) { - var coords = canvas.getEventCoordinates(e); - if (canvas.stroke_.length == 0) { - return; - } - context.lineTo(coords.x, coords.y); - context.stroke(); - canvas.addStroke(coords.x, coords.y); - }; - canvas.ontouchmove = canvas.onmousemove; - - canvas.onmouseup = function(e) { - var coords = canvas.getEventCoordinates(e); - if (canvas.stroke_.length > 0) { - context.lineTo(coords.x, coords.y); - context.stroke(); - canvas.addStroke(coords.x, coords.y); - if (chrome.experimental) { - chrome.experimental.input.virtualKeyboard.sendHandwritingStroke( - canvas.stroke_); - } - canvas.stroke_ = []; - } - }; - canvas.onmouseout = canvas.onmouseup; - - canvas.ontouchstart = canvas.onmousedown; - canvas.ontouchenter = canvas.onmousedown; - canvas.ontouchend = canvas.onmouseup; - canvas.ontouchleave = canvas.onmouseup; - canvas.ontouchcancel = canvas.onmouseup; - - // Clear the canvas when an IME hides the lookup table. - if (chrome.experimental && chrome.experimental.input.ui) { - chrome.experimental.input.ui.onUpdateLookupTable.addListener( - function(table) { - if (!table.visible) { - canvas.clear(); - } - }); - } - return canvas; - }, - - /** - * Updates this.stroke_ unless the posision clicked/touched is too close to - * the previous one. - * @param {number} offsetX x-coordinate of the mouse/touch event. - * @param {number} offsetY y-coordinate of the mouse/touch event. - * @return {void} - */ - addStroke: function(offsetX, offsetY) { - var x = offsetX / this.width; - var y = offsetY / this.height; - - if (this.stroke_.length == 0) { - this.stroke_.push({ x: x, y: y }); - } else { - var delta_x = - (this.stroke_[this.stroke_.length - 1].x - x) * this.width; - var delta_y = - (this.stroke_[this.stroke_.length - 1].y - y) * this.height; - if (delta_x * delta_x + delta_y * delta_y >= - HANDWRITING_CANVAS_MOUSEMOVE_THRESHOLD_SQ) { - // Do not update the array if the distance is less than threshold not - // to send excessive amount of data to an handwriting IME. - this.stroke_.push({ x: x, y: y }); - } - } - }, - - /** - * Gets xy-coordinates of a mouse/touch event. - * @param {Object} event An event object for a mouse/touch event. - * @return {Object} - */ - getEventCoordinates: function(event) { - if (event.changedTouches && event.changedTouches[0]) { - var touch = event.changedTouches[0]; - return { x: touch.clientX - event.currentTarget.offsetLeft, - y: touch.clientY - event.currentTarget.offsetTop }; - } else if (event.offsetX) { - return { x: event.offsetX, y: event.offsetY }; - } - // Unexpected event. Not reached. - return { x: 0, y: 0 }; - }, - - /** - * Resizes the canvas element. - * @param {number} height The height of the canvas. - * @return {void} - */ - resize: function(height) { - var width = height * HANDWRITING_CANVAS_ASPECT; - this.style.height = height + 'px'; - this.style.width = width + 'px'; - this.height = height; - this.width = width; - }, - - /** - * Clears the canvas. - * @return {void} - */ - clear: function() { - var context = this.getContext('2d'); - context.clearRect(0, 0, this.width, this.height); - if (chrome.experimental) { - chrome.experimental.input.virtualKeyboard.cancelHandwritingStrokes(); - } - }, - - /** - * Set the visibility of the canvas. - * @param {boolean} visible True if the canvas should be visible. - * @return {void} - */ - set visible(visible) { - this.hidden = !visible; - } -}; - -/** - * All keys for the rows of the handwriting keyboard. - * NOTE: every row below should have an aspect of 5. - * @type {Array.<Array.<BaseKey>>} - */ -var KEYS_HANDWRITING_VK = [ - [ - new ClearHandwritingKey('CLEAR') - ], - [ - new SvgKey('handwriting-return', 'Enter') - ], - [ - new SpecialKey('handwriting-space', 'SPACE', 'Spacebar'), - new SvgKey('handwriting-backspace', 'Backspace', true /* repeat */) - ], - [ - new SvgKey('handwriting-mic', ''), - new HideKeyboardKey() - ] -]; - -// Add the layout to KEYBOARDS, which is defined in common.js -KEYBOARDS['handwriting-vk'] = { - 'definition': KEYS_HANDWRITING_VK, - 'aspect': 2.1, - // TODO(yusukes): Stop special-casing canvas when mazda's i18n keyboard - // code is ready. - 'canvas': null -}; diff --git a/chrome/browser/resources/keyboard/layout_us.js b/chrome/browser/resources/keyboard/layout_us.js deleted file mode 100644 index 5bb446d..0000000 --- a/chrome/browser/resources/keyboard/layout_us.js +++ /dev/null @@ -1,75 +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. - -/** - * @fileoverview A simple English virtual keyboard implementation. - */ - -/** - * All keys for the rows of the keyboard. - * NOTE: every row below should have an aspect of 12.6. - * @type {Array.<Array.<BaseKey>>} - */ -var KEYS_US = [ - [ - new SvgKey('tab', 'Tab'), - new Key(CP('q'), CP('Q'), CP('1'), CP('`')), - new Key(CP('w'), CP('W'), CP('2'), CP('~')), - new Key(CP('e'), CP('E'), CP('3'), CP('<', 'LessThan')), - new Key(CP('r'), CP('R'), CP('4'), CP('>', 'GreaterThan')), - new Key(CP('t'), CP('T'), CP('5'), CP('[')), - new Key(CP('y'), CP('Y'), CP('6'), CP(']')), - new Key(CP('u'), CP('U'), CP('7'), CP('{')), - new Key(CP('i'), CP('I'), CP('8'), CP('}')), - new Key(CP('o'), CP('O'), CP('9'), CP('\'')), - new Key(CP('p'), CP('P'), CP('0'), CP('|')), - new SvgKey('backspace', 'Backspace', true /* repeat */) - ], - [ - new SymbolKey(), - new Key(CP('a'), CP('A'), CP('!'), CP('+')), - new Key(CP('s'), CP('S'), CP('@'), CP('=')), - new Key(CP('d'), CP('D'), CP('#'), CP(' ')), - new Key(CP('f'), CP('F'), CP('$'), CP(' ')), - new Key(CP('g'), CP('G'), CP('%'), CP(' ')), - new Key(CP('h'), CP('H'), CP('^'), CP(' ')), - new Key(CP('j'), CP('J'), CP('&', 'Ampersand'), CP(' ')), - new Key(CP('k'), CP('K'), CP('*'), CP('#')), - new Key(CP('l'), CP('L'), CP('('), CP(' ')), - new Key(CP('\''), CP('\''), CP(')'), CP(' ')), - new SvgKey('return', 'Enter') - ], - [ - new ShiftKey('left_shift'), - new Key(CP('z'), CP('Z'), CP('/'), CP(' ')), - new Key(CP('x'), CP('X'), CP('-'), CP(' ')), - new Key(CP('c'), CP('C'), CP('\''), CP(' ')), - new Key(CP('v'), CP('V'), CP('"'), CP(' ')), - new Key(CP('b'), CP('B'), CP(':'), CP('.')), - new Key(CP('n'), CP('N'), CP(';'), CP(' ')), - new Key(CP('m'), CP('M'), CP('_'), CP(' ')), - new Key(CP('!'), CP('!'), CP('{'), CP(' ')), - new Key(CP('?'), CP('?'), CP('}'), CP(' ')), - new Key(CP('/'), CP('/'), CP('\\'), CP(' ')), - new ShiftKey() - ], - [ - new SvgKey('mic', ''), - new DotComKey(), - new SpecialKey('at', '@', '@'), - // TODO(bryeung): the spacebar needs to be a little bit more stretchy, - // since this row has only 7 keys (as opposed to 12), the truncation - // can cause it to not be wide enough. - new SpecialKey('space', ' ', 'Spacebar'), - new SpecialKey('comma', ',', ','), - new SpecialKey('period', '.', '.'), - new HideKeyboardKey() - ] -]; - -// Add layout to KEYBOARDS, which is defined in common.js -KEYBOARDS['us'] = { - "definition": KEYS_US, - "aspect": 3.15, -} diff --git a/chrome/browser/resources/keyboard/main.css b/chrome/browser/resources/keyboard/main.css deleted file mode 100644 index e03478c..0000000 --- a/chrome/browser/resources/keyboard/main.css +++ /dev/null @@ -1,223 +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. */ - -body { - -webkit-user-select: none; - background: -webkit-linear-gradient(#bababa, #868686) no-repeat; - color: white; - margin: 0; - overflow: hidden; - padding: 0; -} - -div.main { - -webkit-box-orient: vertical; - display: -webkit-box; - margin: 0 auto; -} - -div.keyboard { - -webkit-box-flex: 1; - display: -webkit-box; - margin: 0 auto; - text-align: center; -} - -div.rows { - -webkit-box-flex: 1; - -webkit-box-orient: vertical; - display: -webkit-box; - margin-bottom: 5px; - text-align: center; -} - -div.row { - -webkit-box-flex: 1; - display: -webkit-box; - margin-right: 5px; - margin-top: 5px; -} - -div.row > div { - -webkit-box-flex: 1; - display: -webkit-box; -} - -.handwritingcanvas { - border: 1px solid gray; - border-radius: 4px; - color: #dbdbdb; - font-family: sans-serif; - margin: 5px 0 0 5px; - text-align: center; -} - -.ime { - border: 1px solid gray; - color: #dbdbdb; - display: inline-block; - font-family: sans-serif; - margin: 0; - text-align: center; - white-space: nowrap; -} - -.panel { - border: 0; - clear: both; - margin-left: 5px; - text-align: left; -} - -.popup { - background: rgba(50, 50, 50, 0.95); - border: 1px solid rgba(50, 50, 50, 0.8); - border-radius: 4px; - box-shadow: 5px 5px 3px rgba(50, 50, 50, 0.3); - padding-right: 5px; - position: absolute; -} - -.button { - background: -webkit-linear-gradient(rgb(90, 97, 111), rgb(80, 86, 98)); -} -.button:active { - background: -webkit-linear-gradient(rgb(80, 86, 98), rgb(90, 97, 111)); -} - -.auxiliary:active { - background: -webkit-linear-gradient(rgb(90, 97, 111), rgb(80, 86, 98)); -} - -.key { - -webkit-box-flex: 1; - background: -webkit-linear-gradient(#fff, #cacaca); - /* Reserving equivalent space to .key:active so - keys don't shift when selected. */ - border: 1px solid transparent; - border-radius: 6px; - /* Do not use box shadow until performance improves - * http://code.google.com/p/chromium/issues/detail?id=99045 - box-shadow: 0 1px 1px #000; - */ - color: #535353; - display: -webkit-box; - font-family: sans-serif; - font-weight: 100; - margin-left: 5px; - position: relative; -} - -.key > div { - bottom: 0; - left: 0; - margin: auto; - position: absolute; - right: 0; - top: 0; -} - -.key.popupkey { - background: rgba(0, 0, 0, 0); - border: 1px solid rgba(0, 0, 0, 0); - box-shadow: 0 0 0 #fff; - color: #fff; -} - -.key.popupkey.highlighted { - background: rgba(20, 20, 200, 0.2); - color: #fff; -} - -.key:active { - background: -webkit-linear-gradient(#d6d6d6, #acacac); - border: 1px solid rgba(125,125,125,0.5); - /* Do not use box shadow until performance improves - * http://code.google.com/p/chromium/issues/detail?id=99045 - box-shadow: 0 0 15px #fff; - */ -} - -div.moddown { - background: -webkit-linear-gradient(#d6d6d6, #acacac); - border-color: rgb(48, 74, 155); -} - -.image-key { - background-position: center center; - background-repeat: no-repeat; - background-size: contain; - height: 100%; - width: 100%; -} - -.text-key { - height: 1.2em; -} - -.backspace > div, -.handwriting-backspace > div { - background-image: url('del.svg'); -} - -.tab > div { - background-image: url('tab.svg'); -} - -.return > div, -.handwriting-return > div { - background-image: url('ret.svg'); -} - -.mic > div, -.handwriting-mic > div { - background-image: url('mic.svg'); -} - -.shift > div.image-key { - background-image: url('shift.svg'); -} - -.moddown.shift > div.image-key { - background-image: url('shift-down.svg'); -} - -.hide > div { - background-image: url('keyboard.svg'); -} - -.at, -.com, -.comma, -.handwriting-backspace, -.hide, -.mic, -.period, -.return, -.symbol { - -webkit-box-flex: 1.3; -} - -.backspace, -.left_shift { - -webkit-box-flex: 1.6; -} - -.space { - -webkit-box-flex: 4.8; -} - -.handwriting-mic, -.handwriting-space { - -webkit-box-flex: 3.7; -} - -.handwriting-clear, -.handwriting-return { - -webkit-box-flex: 5; -} - -.nodisplay { - display: none; -} diff --git a/chrome/browser/resources/keyboard/main.js b/chrome/browser/resources/keyboard/main.js deleted file mode 100644 index 8b7d54d..0000000 --- a/chrome/browser/resources/keyboard/main.js +++ /dev/null @@ -1,252 +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. - -/** - * @fileoverview A simple virtual keyboard implementation. - */ - -/** - * The ratio of the row height to the font size. - * @type {number} - */ -const kFontSizeRatio = 3.5; - -/** - * Return the id attribute of the keyboard element for the given layout. - * @param {string} layout The keyboard layout. - * @return {string} The id attribute of the keyboard element. - */ -function getKeyboardId(layout) { - return 'keyboard_' + layout; -} - -/** - * Return the aspect ratio of the current keyboard. - * @param {string} layout The keyboard layout. - * @return {number} The aspect ratio of the current keyboard. - */ -function getKeyboardAspect() { - return KEYBOARDS[currentKeyboardLayout]['aspect']; -} - -/** - * Calculate the height of the keyboard based on the size of the page. - * @return {number} The height of the keyboard in pixels. - */ -function getKeyboardHeight() { - var x = window.innerWidth; - var y = window.innerHeight - ((imeui && imeui.visible) ? IME_HEIGHT : 0); - return (x > getKeyboardAspect() * y) ? - y : Math.floor(x / getKeyboardAspect()); -} - -/** - * Create a DOM of the keyboard rows for the given keyboard layout. - * Do nothing if the DOM is already created. - * @param {string} layout The keyboard layout for which rows are created. - * @param {Element} element The DOM Element to which rows are appended. - * @param {boolean} autoPadding True if padding needs to be added to both side - * of the rows that have less keys. - * @return {void} - */ -function initRows(layout, element, autoPadding) { - var keyboard = KEYBOARDS[layout]; - if ('rows' in keyboard) { - return; - } - var def = keyboard['definition']; - var rows = []; - for (var i = 0; i < def.length; ++i) { - rows.push(new Row(i, def[i])); - } - keyboard['rows'] = rows; - - var maxRowLength = -1; - for (var i = 0; i < rows.length; ++i) { - if (rows[i].length > maxRowLength) { - maxRowLength = rows[i].length; - } - } - - // A div element which holds rows for the layout. - var rowsDiv = document.createElement('div'); - rowsDiv.className = 'rows'; - for (var i = 0; i < rows.length; ++i) { - var rowDiv = rows[i].makeDOM(); - if (autoPadding && rows[i].length < maxRowLength) { - var padding = 50 * (maxRowLength - rows[i].length) / maxRowLength; - rowDiv.style.paddingLeft = padding + '%'; - rowDiv.style.paddingRight = padding + '%'; - } - rowsDiv.appendChild(rowDiv); - rows[i].showMode(currentMode); - } - keyboard['rowsDiv'] = rowsDiv; - element.appendChild(rowsDiv); -} - -/** - * Create a DOM of the handwriting canvas for the given keyboard layout. - * Do nothing if the DOM is already created or the layout doesn't have canvas. - * @param {string} layout The keyboard layout for which canvas is created. - * @param {Element} The DOM Element to which canvas is appended. - * @return {void} - */ -function initHandwritingCanvas(layout, element) { - var keyboard = KEYBOARDS[layout]; - if (!('canvas' in keyboard) || keyboard['canvas']) { - return; - } - var canvas = new HandwritingCanvas(); - canvas.className = 'handwritingcanvas'; - var border = 1; - var marginTop = 5; - var canvasHeight = getKeyboardHeight() - 2 * border - marginTop; - canvas.resize(canvasHeight); - keyboard['canvas'] = canvas; - element.appendChild(canvas); -} - -/** - * Create a DOM of the keyboard for the given keyboard layout. - * Do nothing if the DOM is already created. - * @param {string} layout The keyboard layout for which keyboard is created. - * @param {Element} The DOM Element to which keyboard is appended. - * @return {void} - */ -function initKeyboard(layout, element) { - var keyboard = KEYBOARDS[layout]; - if (!keyboard || keyboard['keyboardDiv']) { - return; - } - var keyboardDiv = document.createElement('div'); - keyboardDiv.id = getKeyboardId(layout); - keyboardDiv.className = 'keyboard'; - initRows(layout, keyboardDiv); - initHandwritingCanvas(layout, keyboardDiv); - keyboard['keyboardDiv'] = keyboardDiv; - window.onresize(); - element.appendChild(keyboardDiv); -} - -/** - * Create a DOM of the popup keyboard. - * @param {Element} The DOM Element to which the popup keyboard is appended. - * @return {void} - */ -function initPopupKeyboard(element) { - var popupDiv = document.createElement('div'); - popupDiv.id = 'popup'; - popupDiv.className = 'keyboard popup'; - popupDiv.style.visibility = 'hidden'; - element.appendChild(popupDiv); - element.addEventListener('mouseup', function(evt) { - hidePopupKeyboard(evt); - }); -} - -/** - * Resize the keyboard according to the new window size. - * @return {void} - */ -window.onresize = function() { - var keyboardDiv = KEYBOARDS[currentKeyboardLayout]['keyboardDiv']; - var height = getKeyboardHeight(); - keyboardDiv.style.height = height + 'px'; - var mainDiv = document.getElementById('main'); - mainDiv.style.width = Math.floor(getKeyboardAspect() * height) + 'px'; - var rowsLength = KEYBOARDS[currentKeyboardLayout]['rows'].length; - keyboardDiv.style.fontSize = (height / kFontSizeRatio / rowsLength) + 'px'; - updateIme(); -} - -/** - * Init the keyboard. - * @return {void} - */ -window.onload = function() { - var body = document.getElementById('b'); - - // Catch all unhandled touch events and prevent default, to prevent the - // keyboard from responding to gestures like double tap. - function disableGestures(evt) { - evt.preventDefault(); - } - body.addEventListener('touchstart', disableGestures); - body.addEventListener('touchmove', disableGestures); - body.addEventListener('touchend', disableGestures); - - var mainDiv = document.createElement('div'); - mainDiv.className = 'main'; - mainDiv.id = 'main'; - body.appendChild(mainDiv); - - initIme(mainDiv); - initKeyboard(currentKeyboardLayout, mainDiv); - initPopupKeyboard(body); - - window.onhashchange(); - - chrome.experimental.input.virtualKeyboard.onTextInputTypeChanged.addListener( - function(type) { - var newMode = SHIFT_MODE; - switch(type) { - case "text": - newMode = SHIFT_MODE; - break; - case "email": - case "password": - case "search": - case "url": - newMode = KEY_MODE; - break; - case "number": - case "tel": - newMode = NUMBER_MODE; - break; - default: - newMode = KEY_MODE; - break; - } - setMode(newMode); - }); -} -// TODO(bryeung): would be nice to leave less gutter (without causing -// rendering issues with floated divs wrapping at some sizes). - -/** - * Switch the keyboard layout based on the current URL hash. - * @return {void} - */ -window.onhashchange = function() { - var old_layout = currentKeyboardLayout; - var new_layout = location.hash.replace(/^#/, ""); - if (old_layout == new_layout) { - return; - } - - if (KEYBOARDS[new_layout] === undefined) { - // Unsupported layout. - new_layout = "us"; - } - currentKeyboardLayout = new_layout; - - var mainDiv = document.getElementById('main'); - initKeyboard(currentKeyboardLayout, mainDiv); - - [new_layout, old_layout].forEach(function(layout) { - var visible = (layout == new_layout); - var keyboardDiv = KEYBOARDS[layout]['keyboardDiv']; - keyboardDiv.className = visible ? 'keyboard' : 'nodisplay'; - var canvas = KEYBOARDS[layout]['canvas']; - if (canvas !== undefined) { - if (!visible) { - canvas.clear(); - } - } - if (visible) { - window.onresize(); - } - }); -} diff --git a/chrome/browser/resources/keyboard/manifest.json b/chrome/browser/resources/keyboard/manifest.json deleted file mode 100644 index a74b92e..0000000 --- a/chrome/browser/resources/keyboard/manifest.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "key": "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMzY3+qeu4pXSEeSegJLHHhFFiiAq82w8noLxkJqNh+d7Np/scxDr4WkYezIhJTUOIAMxeyP2e//lxU8LTLJFySVWf/dQ5p9xBwzyk4qqJsIsqbrNUrzziN6qk/1Vj8+3qWnG5mSo7Ge4n0OGAVugd29xa/2o79VCFnohgoCHtDdAgMBAAECgYEAnyspGdoK6RyW6h4TtbJ9RaqQ5BnO5P3H+zMo8zQqJ/kDMGgmVAyH1vT6rgzEkAwydrT2GbFQ614THAntKNf9pScL3KmjTeuKCh4t7PJyABOH6Zby/mHN3JJCrX4fLorv7h8CILUrdrmnrAbDvYsF3LTyHkWFeptpgUhZTSysd5UCQQD7O4/yv8a4uvvtdfGNLRb0xfl9JAdq5l+LzN6uSgA74fQoEdcFycjFjxeT2yW7vSzbSXswaSntkdrXin7oqB3/AkEA0Lv7IHEeQ3MkL04ETjgLFJ+UalG51K8gh0X4H4Fqrq24hkqG2xLT+bQ2NvCayqz2xMzqriZagELwXrw+R2tJIwJAYKIwZDbPwQ5rCJNtLdhCFDRyGmhZUgz6g1Nx86gTHvVybFcwVdGfoB3B++U3RlclgdNpxt0se2y2uGFVHzhLEQJAQM4MAp98EN7fnhwvtAUsU4PT9UpYUpLom3b6uPVaJM9kmbTrt3pZ+42aw2Xh+QjIOIOSXO0lberaa98vysahVwJAUmbvLS8ao4FGYkgi0GdskvbudxbVSv1waZuaMttmqenev7xz/94tMyd4Xhsg6AIFf8xpAfPkKF5XlnFje/akUQ==", - "name": "Virtual Keyboard", - "version": "0.1", - "description": "Virtual Keyboard", - "incognito" : "split", - "permissions": [ - "experimental", - "chrome://resources/" - ], - "chrome_url_overrides": { - "keyboard": "index.html" - }, - "input_components": [ - { - "name": "The system virtual keyboard extension", - "description": "The system virtual keyboard extension", - "type": "virtual_keyboard", - "layouts": [ - "fr", "us", "handwriting-vk" - ] - } - ] -} diff --git a/chrome/browser/resources/keyboard/mic.svg b/chrome/browser/resources/keyboard/mic.svg deleted file mode 100644 index 2b5711c..0000000 --- a/chrome/browser/resources/keyboard/mic.svg +++ /dev/null @@ -1,23 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" - width="50px" height="50px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"> -<g> - <line fill="#bababb" stroke="#bababb" stroke-width="10" stroke-linecap="round" x1="25" y1="24.5" x2="25" y2="15.5"/> - <g> - <defs> - <rect id="SVGID_1_" x="-295" y="-214.5" width="640" height="480"/> - </defs> - <clipPath id="SVGID_2_"> - <use xlink:href="#SVGID_1_" overflow="visible"/> - </clipPath> - <path clip-path="url(#SVGID_2_)" fill="none" stroke="#bababb" stroke-width="3" stroke-linecap="round" d="M34,24.5 - c0,4.971-4.029,9-9,9c-4.971,0-9-4.029-9-9"/> - - <line clip-path="url(#SVGID_2_)" fill="#bababb" stroke="#bababb" stroke-width="3" stroke-linecap="round" x1="25" y1="33.5" x2="25" y2="39.5"/> - - <line clip-path="url(#SVGID_2_)" fill="#bababb" stroke="#bababb" stroke-width="3" stroke-linecap="round" x1="29" y1="39.5" x2="21" y2="39.5"/> - </g> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/ret.svg b/chrome/browser/resources/keyboard/ret.svg deleted file mode 100644 index 9f327f95..0000000 --- a/chrome/browser/resources/keyboard/ret.svg +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" enable-background="new 0 0 50 50" xml:space="preserve"> -<g> - <g> - <path fill="#bababb" d="M22.75,31.432c-0.043,0-0.087-0.012-0.126-0.034l-6-3.5c-0.077-0.045-0.124-0.127-0.124-0.216 - s0.047-0.171,0.124-0.216l6-3.5c0.039-0.023,0.083-0.034,0.126-0.034c0.043,0,0.086,0.011,0.125,0.033 - C22.952,24.01,23,24.093,23,24.182v7c0,0.09-0.048,0.172-0.125,0.217C22.835,31.421,22.792,31.432,22.75,31.432L22.75,31.432z"/> - <path fill="#bababb" d="M22.75,24.182v7l-6-3.5L22.75,24.182 M22.75,23.682c-0.087,0-0.174,0.022-0.252,0.068l-6,3.5 - c-0.154,0.089-0.248,0.254-0.248,0.432s0.094,0.342,0.248,0.432l6,3.5c0.078,0.046,0.165,0.068,0.252,0.068 - c0.086,0,0.172-0.022,0.249-0.066c0.155-0.089,0.251-0.255,0.251-0.434v-7c0-0.179-0.096-0.344-0.251-0.434 - C22.921,23.704,22.835,23.682,22.75,23.682L22.75,23.682z"/> - </g> - <path fill="#bababb" d="M30.25,20.083v6.1h-10v3h11.5c0.828,0,1.5-0.672,1.5-1.5v-8.865L30.25,20.083z"/> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/shift-down.svg b/chrome/browser/resources/keyboard/shift-down.svg deleted file mode 100644 index 1e25770..0000000 --- a/chrome/browser/resources/keyboard/shift-down.svg +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="50px" height="50px" viewBox="10 10 30 30"> -<!-- TODO(fsamuel): remove the width and height workaround above after fixing SVG bug --> -<g> - <path fill="#e0e0e0" d="M23,29.25c-0.138,0-0.25-0.112-0.25-0.25v-2.75H20c-0.101,0-0.192-0.061-0.231-0.154 - s-0.017-0.201,0.054-0.272l5-5c0.049-0.049,0.113-0.073,0.177-0.073s0.128,0.024,0.177,0.073l5,5 - c0.071,0.071,0.093,0.179,0.055,0.272c-0.039,0.093-0.13,0.154-0.231,0.154h-2.75V29c0,0.138-0.112,0.25-0.25,0.25H23z"/> - <path fill="#e0e0e0" d="M25,21l5,5h-3v3h-4v-3h-3L25,21 M25,20.5c-0.128,0-0.256,0.049-0.354,0.146l-5,5 - c-0.143,0.143-0.186,0.358-0.108,0.545C19.615,26.377,19.797,26.5,20,26.5h2.5V29c0,0.276,0.224,0.5,0.5,0.5h4 - c0.276,0,0.5-0.224,0.5-0.5v-2.5H30c0.202,0,0.385-0.122,0.462-0.309c0.077-0.187,0.034-0.402-0.108-0.545l-5-5 - C25.255,20.548,25.127,20.5,25,20.5L25,20.5z"/> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/shift.svg b/chrome/browser/resources/keyboard/shift.svg deleted file mode 100644 index 1e5dfa0..0000000 --- a/chrome/browser/resources/keyboard/shift.svg +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="50px" height="50px" viewBox="10 10 30 30"> -<!-- TODO(fsamuel): remove the width and height workaround above after fixing SVG bug --> -<g> - <path fill="#bababb" d="M23,29.25c-0.138,0-0.25-0.112-0.25-0.25v-2.75H20c-0.101,0-0.192-0.061-0.231-0.154 - s-0.017-0.201,0.054-0.272l5-5c0.049-0.049,0.113-0.073,0.177-0.073s0.128,0.024,0.177,0.073l5,5 - c0.071,0.071,0.093,0.179,0.055,0.272c-0.039,0.093-0.13,0.154-0.231,0.154h-2.75V29c0,0.138-0.112,0.25-0.25,0.25H23z"/> - <path fill="#bababb" d="M25,21l5,5h-3v3h-4v-3h-3L25,21 M25,20.5c-0.128,0-0.256,0.049-0.354,0.146l-5,5 - c-0.143,0.143-0.186,0.358-0.108,0.545C19.615,26.377,19.797,26.5,20,26.5h2.5V29c0,0.276,0.224,0.5,0.5,0.5h4 - c0.276,0,0.5-0.224,0.5-0.5v-2.5H30c0.202,0,0.385-0.122,0.462-0.309c0.077-0.187,0.034-0.402-0.108-0.545l-5-5 - C25.255,20.548,25.127,20.5,25,20.5L25,20.5z"/> -</g> -</svg> diff --git a/chrome/browser/resources/keyboard/tab.svg b/chrome/browser/resources/keyboard/tab.svg deleted file mode 100644 index 774e306..0000000 --- a/chrome/browser/resources/keyboard/tab.svg +++ /dev/null @@ -1,14 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 43363) --> -<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> -<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="100%" height="100%" viewBox="5 5 40 40" enable-background="new" xml:space="preserve"> -<g> - <line fill="none" stroke="#bababb" stroke-width="1.7" stroke-linecap="round" x1="36.377" y1="20.5" x2="36.377" y2="29.5"/> - <g> - <path fill="#bababb" d="M27.377,28.75c-0.043,0-0.086-0.011-0.125-0.033c-0.077-0.045-0.125-0.127-0.125-0.217v-7 - c0-0.089,0.048-0.172,0.125-0.217c0.039-0.022,0.082-0.033,0.125-0.033c0.044,0,0.087,0.011,0.126,0.034l6,3.5 - c0.077,0.045,0.124,0.127,0.124,0.216s-0.047,0.171-0.124,0.216l-6,3.5C27.464,28.738,27.421,28.75,27.377,28.75L27.377,28.75z"/> - </g> - <polygon fill="#bababb" points="14.888,23.5 13.623,26.5 29.877,26.5 29.877,23.5 "/> -</g> -</svg> diff --git a/chrome/browser/resources/options2/chromeos/virtual_keyboard.css b/chrome/browser/resources/options2/chromeos/virtual_keyboard.css deleted file mode 100644 index ba903d5..0000000 --- a/chrome/browser/resources/options2/chromeos/virtual_keyboard.css +++ /dev/null @@ -1,22 +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. */ - -.virtual-keyboard-column-headers { - display: -webkit-box; - font-size: 13px; - font-weight: bold; -} - -.virtual-keyboard-layout-column { - -webkit-margin-end: 10px; - -webkit-margin-start: 14px; - width: 250px; -} - -#virtual-keyboard-manager list { - border: solid 1px #D9D9D9; - border-radius: 2px; - margin-bottom: 10px; - margin-top: 4px; -} diff --git a/chrome/browser/resources/options2/chromeos/virtual_keyboard.html b/chrome/browser/resources/options2/chromeos/virtual_keyboard.html deleted file mode 100644 index e56b969..0000000 --- a/chrome/browser/resources/options2/chromeos/virtual_keyboard.html +++ /dev/null @@ -1,21 +0,0 @@ -<div id="virtual-keyboard-manager" class="page" hidden> - <div class="close-button"></div> - <h1 i18n-content="virtualKeyboardPage"></h1> - <div class="content-area"> - <div class="virtual-keyboard-column-headers"> - <div class="virtual-keyboard-layout-column"> - <h3 i18n-content="virtualKeyboardLayoutColumnTitle"></h3> - </div> - <div class="virtual-keyboard-keyboard-column"> - <h3 i18n-content="virtualKeyboardKeyboardColumnTitle"></h3> - </div> - </div> - <list id="virtual-keyboard-per-layout-list"></list> - <!-- TODO(yusukes): Add virtual-keyboards-per-site elements. --> - </div> - <div class="action-area"> - <div class="button-strip"> - <button id="virtual-keyboard-overlay-confirm" i18n-content="ok"></button> - </div> - </div> -</div> diff --git a/chrome/browser/resources/options2/chromeos/virtual_keyboard.js b/chrome/browser/resources/options2/chromeos/virtual_keyboard.js deleted file mode 100644 index b29dc83..0000000 --- a/chrome/browser/resources/options2/chromeos/virtual_keyboard.js +++ /dev/null @@ -1,92 +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. - -cr.define('options', function() { - /** @const */ var OptionsPage = options.OptionsPage; - - ///////////////////////////////////////////////////////////////////////////// - // VirtualKeyboardManager class: - - /** - * Virtual keyboard management page. - * @constructor - */ - function VirtualKeyboardManager() { - this.activeNavTab = null; - OptionsPage.call(this, - 'virtualKeyboards', - loadTimeData.getString('virtualKeyboardPageTabTitle'), - 'virtual-keyboard-manager'); - } - - cr.addSingletonGetter(VirtualKeyboardManager); - - VirtualKeyboardManager.prototype = { - __proto__: OptionsPage.prototype, - - /** - * The virtual keyboards list. - * @type {ItemList} - * @private - */ - virtualKeyboardsList_: null, - - /** @inheritDoc */ - initializePage: function() { - OptionsPage.prototype.initializePage.call(this); - this.createVirtualKeyboardsList_(); - $('virtual-keyboard-overlay-confirm').onclick = - OptionsPage.closeOverlay.bind(OptionsPage); - }, - - /** @inheritDoc */ - didShowPage: function() { - chrome.send('updateVirtualKeyboardList'); - }, - - /** - * Creates, decorates and initializes the keyboards list. - * @private - */ - createVirtualKeyboardsList_: function() { - this.virtualKeyboardsList_ = $('virtual-keyboard-per-layout-list'); - options.VirtualKeyboardsList.decorate(this.virtualKeyboardsList_); - this.virtualKeyboardsList_.autoExpands = true; - }, - }; - - /** - * Sets the list of virtual keyboards shown in the view. This function is - * called by C++ code (e.g. chrome/browser/ui/webui/options/chromeos/). - * @param {Object} list A list of layouts with their registered virtual - * keyboards. - */ - VirtualKeyboardManager.updateVirtualKeyboardList = function(list) { - // See virtual_keyboard_list.js for an example of the format the list should - // take. - var filteredList = list.filter(function(element, index, array) { - // Don't show a layout which is supported by only one virtual keyboard - // extension. - return element.supportedKeyboards.length > 1; - }); - - // Sort the drop-down menu items by name. - filteredList.forEach(function(e) { - e.supportedKeyboards.sort(function(e1, e2) { - return e1.name > e2.name; - }); - }); - - // Sort the list by layout name. - $('virtual-keyboard-per-layout-list').setVirtualKeyboardList( - filteredList.sort(function(e1, e2) { - return e1.layoutName > e2.layoutName; - })); - }; - - // Export - return { - VirtualKeyboardManager: VirtualKeyboardManager, - }; -}); diff --git a/chrome/browser/resources/options2/chromeos/virtual_keyboard_list.js b/chrome/browser/resources/options2/chromeos/virtual_keyboard_list.js deleted file mode 100644 index b1d8075..0000000 --- a/chrome/browser/resources/options2/chromeos/virtual_keyboard_list.js +++ /dev/null @@ -1,144 +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. - -cr.define('options', function() { - /** @const */ var ArrayDataModel = cr.ui.ArrayDataModel; - /** @const */ var List = cr.ui.List; - /** @const */ var ListItem = cr.ui.ListItem; - /** @const */ var VirtualKeyboardOptions = options.VirtualKeyboardOptions; - - /** - * Creates a virtual keyboard list item. - * - * Accepts values in the form - * { layout: 'us(dvorak)', - * layoutName: 'US Dvorak layout', - * preferredKeyboard: 'http://...', [optional] - * supportedKeyboards: [ - * { name: 'Simple Virtual Keyboard', - * isSystem: true, - * url: 'http://...' }, - * { name: '3rd party Virtual Keyboard', - * isSystem: false, - * url: 'http://...' }, - * ..., - * ] - * } - * @param {Object} entry A dictionary describing the virtual keyboards for a - * given layout. - * @constructor - * @extends {cr.ui.ListItem} - */ - function VirtualKeyboardListItem(entry) { - var el = cr.doc.createElement('div'); - el.dataItem = entry; - el.__proto__ = VirtualKeyboardListItem.prototype; - el.decorate(); - return el; - } - - VirtualKeyboardListItem.prototype = { - __proto__: ListItem.prototype, - - buildWidget_: function(data, delegate) { - // Layout name. - var layoutNameElement = document.createElement('div'); - layoutNameElement.textContent = data.layoutName; - layoutNameElement.className = 'virtual-keyboard-layout-column'; - this.appendChild(layoutNameElement); - - // Virtual keyboard selection. - var keyboardElement = document.createElement('div'); - var selectElement = document.createElement('select'); - var defaultOptionElement = document.createElement('option'); - defaultOptionElement.selected = (data.preferredKeyboard == null); - defaultOptionElement.textContent = - loadTimeData.getString('defaultVirtualKeyboard'); - defaultOptionElement.value = -1; - selectElement.appendChild(defaultOptionElement); - - for (var i = 0; i < data.supportedKeyboards.length; ++i) { - var optionElement = document.createElement('option'); - optionElement.selected = - (data.preferredKeyboard != null && - data.preferredKeyboard == data.supportedKeyboards[i].url); - optionElement.textContent = data.supportedKeyboards[i].name; - optionElement.value = i; - selectElement.appendChild(optionElement); - } - - selectElement.addEventListener('change', function(e) { - var index = e.target.value; - if (index == -1) { - // The 'Default' menu item is selected. Delete the preference. - delegate.clearPreference(data.layout); - } else { - delegate.setPreference( - data.layout, data.supportedKeyboards[index].url); - } - }); - - keyboardElement.appendChild(selectElement); - keyboardElement.className = 'virtual-keyboard-keyboard-column'; - this.appendChild(keyboardElement); - }, - - /** @inheritDoc */ - decorate: function() { - ListItem.prototype.decorate.call(this); - - var delegate = { - clearPreference: function(layout) { - // Call a C++ function in chrome/browser/ui/webui/options/chromeos/. - chrome.send('clearVirtualKeyboardPreference', [layout]); - }, - setPreference: function(layout, url) { - chrome.send('setVirtualKeyboardPreference', [layout, url]); - }, - }; - - this.buildWidget_(this.dataItem, delegate); - }, - }; - - /** - * Create a new virtual keyboard list. - * @constructor - * @extends {cr.ui.List} - */ - var VirtualKeyboardsList = cr.ui.define('list'); - - VirtualKeyboardsList.prototype = { - __proto__: List.prototype, - - /** @inheritDoc */ - createItem: function(entry) { - return new VirtualKeyboardListItem(entry); - }, - - /** - * The length of the list. - */ - get length() { - return this.dataModel.length; - }, - - /** - * Set the virtual keyboards displayed by this list. - * See VirtualKeyboardListItem for an example of the format the list should - * take. - * - * @param {Object} list A list of layouts with their registered virtual - * keyboards. - */ - setVirtualKeyboardList: function(list) { - this.dataModel = new ArrayDataModel(list); - }, - }; - - return { - VirtualKeyboardListItem: VirtualKeyboardListItem, - VirtualKeyboardsList: VirtualKeyboardsList, - }; -}); diff --git a/chrome/browser/resources/options2/language_options.html b/chrome/browser/resources/options2/language_options.html index 0220602..c668018 100644 --- a/chrome/browser/resources/options2/language_options.html +++ b/chrome/browser/resources/options2/language_options.html @@ -68,12 +68,6 @@ class="language-options-contents"> </div> </if> -<if expr="pp_ifdef('chromeos') and pp_ifdef('use_virtual_keyboard')"> - <div class="language-options-contents"> - <button id="language-options-virtual-keyboard" - i18n-content="virtual_keyboard_button"></button> - </div> -</if> </div> </if> </div> diff --git a/chrome/browser/resources/options2/language_options.js b/chrome/browser/resources/options2/language_options.js index ac9d532..fa6067e 100644 --- a/chrome/browser/resources/options2/language_options.js +++ b/chrome/browser/resources/options2/language_options.js @@ -118,17 +118,6 @@ cr.define('options', function() { $('language-confirm').onclick = OptionsPage.closeOverlay.bind(OptionsPage); - - // Listen to user clicks on the "Change touch keyboard settings..." - // button (if it exists). - var virtualKeyboardButton = $('language-options-virtual-keyboard'); - if (virtualKeyboardButton) { - // TODO(yusukes): would be better to hide the button if no virtual - // keyboard is registered. - virtualKeyboardButton.onclick = function(e) { - OptionsPage.navigateToPage('virtualKeyboards'); - }; - } }, // The preference is a boolean that enables/disables spell checking. diff --git a/chrome/browser/resources/options2/options.html b/chrome/browser/resources/options2/options.html index 1e310d2..143f568 100644 --- a/chrome/browser/resources/options2/options.html +++ b/chrome/browser/resources/options2/options.html @@ -44,9 +44,6 @@ <if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')"> <link rel="stylesheet" href="chromeos/set_wallpaper_options.css"> </if> -<if expr="pp_ifdef('chromeos') and pp_ifdef('use_virtual_keyboard')"> - <link rel="stylesheet" href="chromeos/virtual_keyboard.css"> -</if> <if expr="not is_win and not is_macosx"> <link rel="stylesheet" href="certificate_manager.css"> <link rel="stylesheet" href="certificate_tree.css"> @@ -125,9 +122,6 @@ <include src="chromeos/language_mozc_options.html"> <include src="chromeos/language_pinyin_options.html"> </if> - <if expr="pp_ifdef('chromeos') and pp_ifdef('use_virtual_keyboard')"> - <include src="chromeos/virtual_keyboard.html"> - </if> <if expr="not is_win and not is_macosx"> <include src="certificate_restore_overlay.html"> <include src="certificate_backup_overlay.html"> diff --git a/chrome/browser/resources/options2/options.js b/chrome/browser/resources/options2/options.js index 032cc78..658e8c2 100644 --- a/chrome/browser/resources/options2/options.js +++ b/chrome/browser/resources/options2/options.js @@ -31,7 +31,6 @@ var SessionRestoreOverlay = options.SessionRestoreOverlay; var SpellingConfirmOverlay = options.SpellingConfirmOverlay; var StartupOverlay = options.StartupOverlay; var SyncSetupOverlay = options.SyncSetupOverlay; -var VirtualKeyboardManager = options.VirtualKeyboardManager; /** * DOMContentLoaded handler, sets up the page. @@ -156,13 +155,6 @@ function load() { loadTimeData.getString('languagePinyinPageTabTitle'), 'languagePinyinPage'), LanguageOptions.getInstance()); - // Only use the VirtualKeyboardManager if the keyboard DOM elements (which - // it will assume exists) are present (i.e. if we were built with - // use_virtual_keyboard=1). - if ($('language-options-virtual-keyboard')) { - OptionsPage.registerOverlay(VirtualKeyboardManager.getInstance(), - LanguageOptions.getInstance()); - } } <if expr="pp_ifdef('chromeos') and pp_ifdef('use_ash')"> diff --git a/chrome/browser/resources/options2/options_bundle.js b/chrome/browser/resources/options2/options_bundle.js index e8fe189..819f1f5 100644 --- a/chrome/browser/resources/options2/options_bundle.js +++ b/chrome/browser/resources/options2/options_bundle.js @@ -30,8 +30,6 @@ <include src="chromeos/accounts_user_name_edit.js"></include> <include src="chromeos/keyboard_overlay.js"></include> <include src="chromeos/pointer_overlay.js"></include> - <include src="chromeos/virtual_keyboard.js"></include> - <include src="chromeos/virtual_keyboard_list.js"></include> var AccountsOptions = options.AccountsOptions; var ChangePictureOptions = options.ChangePictureOptions; var DetailsInternetPage = options.internet.DetailsInternetPage; diff --git a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc index df884f0..db03849 100644 --- a/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/ui/views/frame/opaque_browser_frame_view.cc @@ -42,10 +42,6 @@ #include "ui/views/window/frame_background.h" #include "ui/views/window/window_shape.h" -#if defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" -#endif - using content::WebContents; namespace { @@ -159,11 +155,6 @@ OpaqueBrowserFrameView::OpaqueBrowserFrameView(BrowserFrame* frame, registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, content::NotificationService::AllSources()); } - -#if defined(USE_VIRTUAL_KEYBOARD) - // Make sure the singleton VirtualKeyboardManager object is initialized. - VirtualKeyboardManager::GetInstance(); -#endif } OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { diff --git a/chrome/browser/ui/virtual_keyboard/OWNERS b/chrome/browser/ui/virtual_keyboard/OWNERS deleted file mode 100644 index 93ca4b2..0000000 --- a/chrome/browser/ui/virtual_keyboard/OWNERS +++ /dev/null @@ -1,2 +0,0 @@ -bryeung@chromium.org -sadrul@chromium.org diff --git a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc deleted file mode 100644 index 5b4b483..0000000 --- a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.cc +++ /dev/null @@ -1,536 +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 "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" - -#include "base/json/json_writer.h" -#include "base/values.h" -#include "chrome/browser/extensions/extension_event_router.h" -#include "chrome/browser/extensions/extension_function_dispatcher.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/views/frame/browser_view.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/common/extensions/extension_messages.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/site_instance.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_contents_observer.h" -#include "ui/base/animation/animation_delegate.h" -#include "ui/base/animation/slide_animation.h" -#include "ui/base/ime/text_input_type.h" -#include "ui/compositor/layer.h" -#include "ui/gfx/screen.h" -#include "ui/views/controls/webview/webview.h" -#include "ui/views/ime/text_input_type_tracker.h" -#include "ui/views/widget/widget.h" - -#if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/input_method/input_method_manager.h" -#include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" -#endif - -#if defined(USE_AURA) -#include "ash/shell.h" -#include "ash/shell_window_ids.h" -#include "ui/aura/root_window.h" -#include "ui/aura/root_window_observer.h" -#endif - -using content::WebContents; - -namespace { - -const int kDefaultKeyboardHeight = 300; -const int kKeyboardSlideDuration = 300; // In milliseconds -const char kOnTextInputTypeChanged[] = - "experimental.input.virtualKeyboard.onTextInputTypeChanged"; - -// The default position of the keyboard widget should be at the bottom, -// spanning the entire width of the root window. -gfx::Rect GetKeyboardPosition(int height) { - gfx::Rect area = gfx::Screen::GetPrimaryMonitor().bounds(); - return gfx::Rect(area.x(), area.y() + area.height() - height, - area.width(), height); -} - -} // namespace - -// TODO(sad): Is the default profile always going to be the one we want? - -class KeyboardWidget - : public views::Widget, - public ui::AnimationDelegate, - public content::WebContentsObserver, - public ExtensionFunctionDispatcher::Delegate, -#if defined(OS_CHROMEOS) - public chromeos::input_method::InputMethodManager::VirtualKeyboardObserver, -#endif -#if defined(USE_AURA) - public aura::RootWindowObserver, -#endif - public content::NotificationObserver, - public views::Widget::Observer, - public views::TextInputTypeObserver { - public: - KeyboardWidget(); - virtual ~KeyboardWidget(); - - // Show the keyboard for the target widget. The events from the keyboard will - // be sent to |widget|. - void ShowKeyboardForWidget(views::Widget* widget); - - // Updates the bounds to reflect the current screen/root window bounds. - void ResetBounds(); - - // Overridden from views::Widget - void Hide() OVERRIDE; - - private: - // Sets the target widget, adds/removes Widget::Observer, reparents etc. - void SetTarget(Widget* target); - - // Returns the widget of the active browser, or NULL if there is no such - // widget. - views::Widget* GetBrowserWidget(); - - // Update layer opacity and bounds with values in animation_. - void UpdateForAnimation(); - - // Overridden from views::Widget. - virtual bool OnKeyEvent(const views::KeyEvent& event) OVERRIDE; - - // Overridden from ui::AnimationDelegate. - virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; - - // Overridden from content::WebContentsObserver. - virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; - virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; - void OnRequest(const ExtensionHostMsg_Request_Params& params); - - // Overridden from TextInputTypeObserver. - virtual void TextInputTypeChanged(ui::TextInputType type, - views::Widget *widget) OVERRIDE; - - // Overridden from ExtensionFunctionDispatcher::Delegate. - virtual Browser* GetBrowser() OVERRIDE; - virtual content::WebContents* GetAssociatedWebContents() const OVERRIDE; - -#if defined(OS_CHROMEOS) - // Overridden from input_method::InputMethodManager::VirtualKeyboardObserver. - virtual void VirtualKeyboardChanged( - chromeos::input_method::InputMethodManager* manager, - const chromeos::input_method::VirtualKeyboard& virtual_keyboard, - const std::string& virtual_keyboard_layout); -#endif - -#if defined(USE_AURA) - // Overridden from aura::RootWindowObserver. - virtual void OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& old_size) OVERRIDE; -#endif - - // Overridden from NotificationObserver. - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE; - - // Overridden from views::Widget::Observer. - virtual void OnWidgetClosing(Widget* widget) OVERRIDE; - virtual void OnWidgetVisibilityChanged(Widget* widget, bool visible) OVERRIDE; - virtual void OnWidgetActivationChanged(Widget* widget, bool active) OVERRIDE; - - // The animation. - scoped_ptr<ui::SlideAnimation> animation_; - - GURL keyboard_url_; - - // The WebView to host the keyboard. - views::WebView* web_view_; - - ExtensionFunctionDispatcher extension_dispatcher_; - - // The widget the events from the keyboard should be directed to. - views::Widget* target_; - - // Height of the keyboard. - int keyboard_height_; - - content::NotificationRegistrar registrar_; - - DISALLOW_COPY_AND_ASSIGN(KeyboardWidget); -}; - -KeyboardWidget::KeyboardWidget() - : views::Widget::Widget(), - keyboard_url_(chrome::kChromeUIKeyboardURL), - web_view_(new views::WebView(ProfileManager::GetDefaultProfile()))), - ALLOW_THIS_IN_INITIALIZER_LIST( - extension_dispatcher_(ProfileManager::GetDefaultProfile(), this)), - target_(NULL), - keyboard_height_(kDefaultKeyboardHeight) { - - // Initialize the widget first. - views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); - params.keep_on_top = true; - params.transparent = true; - params.bounds = GetKeyboardPosition(keyboard_height_); -#if defined(USE_AURA) - params.parent = ash::Shell::GetInstance()->GetContainer( - ash::internal::kShellWindowId_MenuContainer); -#endif - Init(params); - - // Setup the DOM view to host the keyboard. - web_view_->CreateWebContentsWithSiteInstance( - content::SiteInstance::CreateForURL(web_view_->browser_context(), - keyboard_url_)); - web_view_->LoadInitialURL(keyboard_url_); - SetContentsView(web_view_); - - // Setup observer so the events from the keyboard can be handled. - content::WebContentsObserver::Observe(web_view_->web_contents()); - - // Initialize the animation. - animation_.reset(new ui::SlideAnimation(this)); - animation_->SetTweenType(ui::Tween::LINEAR); - animation_->SetSlideDuration(kKeyboardSlideDuration); - - views::TextInputTypeTracker::GetInstance()->AddTextInputTypeObserver(this); - registrar_.Add(this, - chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED, - content::NotificationService::AllSources()); - registrar_.Add(this, - chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED, - content::NotificationService::AllSources()); - registrar_.Add(this, - chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, - content::NotificationService::AllSources()); - registrar_.Add(this, - content::NOTIFICATION_APP_TERMINATING, - content::NotificationService::AllSources()); - -#if defined(OS_CHROMEOS) - chromeos::input_method::InputMethodManager* manager = - chromeos::input_method::InputMethodManager::GetInstance(); - manager->AddVirtualKeyboardObserver(this); -#endif - -#if defined(USE_AURA) - ash::Shell::GetRootWindow()->AddRootWindowObserver(this); -#endif -} - -KeyboardWidget::~KeyboardWidget() { - if (target_) - target_->RemoveObserver(this); - views::TextInputTypeTracker::GetInstance()->RemoveTextInputTypeObserver(this); -#if defined(OS_CHROMEOS) - chromeos::input_method::InputMethodManager* manager = - chromeos::input_method::InputMethodManager::GetInstance(); - manager->RemoveVirtualKeyboardObserver(this); -#endif - -#if defined(USE_AURA) - ash::Shell::GetRootWindow()->RemoveRootWindowObserver(this); -#endif - // TODO(sad): Do anything else? -} - -void KeyboardWidget::ShowKeyboardForWidget(views::Widget* widget) { - if (target_ == widget && IsVisible() && !animation_->is_animating()) - return; - SetTarget(widget); - - UpdateForAnimation(); - animation_->Show(); - - Show(); - - bool visible = true; - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, - content::Source<KeyboardWidget>(this), - content::Details<bool>(&visible)); -} - -void KeyboardWidget::ResetBounds() { - SetBounds(GetKeyboardPosition(keyboard_height_)); -} - -void KeyboardWidget::Hide() { - animation_->Hide(); - - bool visible = false; - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, - content::Source<KeyboardWidget>(this), - content::Details<bool>(&visible)); -} - -void KeyboardWidget::SetTarget(views::Widget* target) { - if (target_) - target_->RemoveObserver(this); - - target_ = target; - - if (target_) { - // TODO(sad): Make |target_| the parent widget. - target_->AddObserver(this); - } else if (IsVisible()) { - Hide(); - } -} - -views::Widget* KeyboardWidget::GetBrowserWidget() { - Browser* browser = GetBrowser(); - if (!browser) - return NULL; - BrowserView* view = BrowserView::GetBrowserViewForBrowser(browser); - if (!view) - return NULL; - return view->GetWidget(); -} - -bool KeyboardWidget::OnKeyEvent(const views::KeyEvent& event) { - return target_ ? target_->OnKeyEvent(event) : false; -} - -void KeyboardWidget::UpdateForAnimation() { - float t = static_cast<float>(animation_->GetCurrentValue()); - gfx::Rect bounds = GetKeyboardPosition(keyboard_height_); - bounds.Offset(0, keyboard_height_*(1 - t)); - SetBounds(bounds); - if (GetRootView()->layer()) - GetRootView()->layer()->SetOpacity(t * t); -} - -void KeyboardWidget::AnimationProgressed(const ui::Animation* animation) { - UpdateForAnimation(); -} - -void KeyboardWidget::AnimationEnded(const ui::Animation* animation) { - gfx::Rect keyboard_rect; - if (animation_->GetCurrentValue() < 0.01) - Widget::Hide(); - else - keyboard_rect = GetWindowScreenBounds(); - - content::NotificationService::current()->Notify( - chrome::NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED, - content::Source<KeyboardWidget>(this), - content::Details<gfx::Rect>(&keyboard_rect)); -} - -bool KeyboardWidget::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(KeyboardWidget, message) - IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void KeyboardWidget::RenderViewGone(base::TerminationStatus status) { - if (status != base::TERMINATION_STATUS_NORMAL_TERMINATION) { - // Reload the keyboard if it crashes. - web_view_->LoadInitialURL(keyboard_url_); - web_view_->SchedulePaint(); - } -} - -void KeyboardWidget::OnRequest(const ExtensionHostMsg_Request_Params& request) { - extension_dispatcher_.Dispatch( - request, - web_view_->web_contents()->GetRenderViewHost()); -} - -void KeyboardWidget::TextInputTypeChanged(ui::TextInputType type, - views::Widget *widget) { - // Send onTextInputTypeChanged event to keyboard extension. - ListValue args; - switch (type) { - case ui::TEXT_INPUT_TYPE_NONE: { - args.Append(Value::CreateStringValue("none")); - break; - } - case ui::TEXT_INPUT_TYPE_TEXT: { - args.Append(Value::CreateStringValue("text")); - break; - } - case ui::TEXT_INPUT_TYPE_PASSWORD: { - args.Append(Value::CreateStringValue("password")); - break; - } - case ui::TEXT_INPUT_TYPE_SEARCH: { - args.Append(Value::CreateStringValue("search")); - break; - } - case ui::TEXT_INPUT_TYPE_EMAIL: { - args.Append(Value::CreateStringValue("email")); - break; - } - case ui::TEXT_INPUT_TYPE_NUMBER: { - args.Append(Value::CreateStringValue("number")); - break; - } - case ui::TEXT_INPUT_TYPE_TELEPHONE: { - args.Append(Value::CreateStringValue("tel")); - break; - } - case ui::TEXT_INPUT_TYPE_URL: { - args.Append(Value::CreateStringValue("url")); - break; - } - default: { - NOTREACHED(); - args.Append(Value::CreateStringValue("none")); - break; - } - } - - std::string json_args; - base::JSONWriter::Write(&args, &json_args); - - Profile* profile = Profile::FromBrowserContext(web_view_->browser_context()); - profile->GetExtensionEventRouter()->DispatchEventToRenderers( - kOnTextInputTypeChanged, json_args, NULL, GURL()); - - if (type == ui::TEXT_INPUT_TYPE_NONE) - Hide(); - else - ShowKeyboardForWidget(widget); -} - -Browser* KeyboardWidget::GetBrowser() { - // TODO(sad): Find a better way. Perhaps just return NULL, and fix - // SendKeyboardEventInputFunction::GetTopLevelWidget to somehow interact with - // the WM to find the top level widget? - return BrowserList::GetLastActive(); -} - -content::WebContents* KeyboardWidget::GetAssociatedWebContents() const { - return web_view_->web_contents(); -} - -#if defined(OS_CHROMEOS) -void KeyboardWidget::VirtualKeyboardChanged( - chromeos::input_method::InputMethodManager* manager, - const chromeos::input_method::VirtualKeyboard& virtual_keyboard, - const std::string& virtual_keyboard_layout) { - const GURL& url = virtual_keyboard.GetURLForLayout(virtual_keyboard_layout); - web_view_->LoadInitialURL(url); - VLOG(1) << "VirtualKeyboardChanged: Switched to " << url.spec(); -} -#endif - -#if defined(USE_AURA) -void KeyboardWidget::OnRootWindowResized(const aura::RootWindow* root, - const gfx::Size& old_size) { - ResetBounds(); -} -#endif - -void KeyboardWidget::Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) { - switch (type) { - case chrome::NOTIFICATION_FOCUSED_EDITABLE_NODE_TOUCHED: { - // In case the keyboard hid itself and the focus is still in an editable - // field, and the user touches the field, then we want to show the - // keyboard again. - views::Widget* widget = GetBrowserWidget(); - if (widget) - ShowKeyboardForWidget(widget); - break; - } - - case chrome::NOTIFICATION_HIDE_KEYBOARD_INVOKED: { - Hide(); - break; - } - - case chrome::NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED: { - // The keyboard is resizing itself. - - // TODO(penghuang) Allow extension conrtol the virtual keyboard directly - // instead of using Notification. - int height = *content::Details<int>(details).ptr(); - if (height != keyboard_height_) { - DCHECK_GE(height, 0) << "Keyboard height should not be negative."; - - int old_height = keyboard_height_; - keyboard_height_ = height; - gfx::Rect rect = GetWindowScreenBounds(); - rect.set_y(rect.y() + old_height - keyboard_height_); - rect.set_height(keyboard_height_); - SetBounds(rect); - - // TODO(sad): Notify the target widget that the size has changed so it - // can update its display accordingly if it wanted to. - } - break; - } - - case content::NOTIFICATION_APP_TERMINATING: { - CloseNow(); - break; - } - - default: - NOTREACHED(); - } -} - -void KeyboardWidget::OnWidgetClosing(Widget* widget) { - if (target_ == widget) - SetTarget(NULL); -} - -void KeyboardWidget::OnWidgetVisibilityChanged(Widget* widget, bool visible) { - if (target_ == widget && !visible) - SetTarget(NULL); -} - -void KeyboardWidget::OnWidgetActivationChanged(Widget* widget, bool active) { - if (target_ == widget && !active) - SetTarget(NULL); -} - -VirtualKeyboardManager::VirtualKeyboardManager() - : keyboard_(new KeyboardWidget()) { - keyboard_->AddObserver(this); -} - -VirtualKeyboardManager::~VirtualKeyboardManager() { - DCHECK(!keyboard_); -} - -void VirtualKeyboardManager::ShowKeyboardForWidget(views::Widget* widget) { - keyboard_->ShowKeyboardForWidget(widget); -} - -void VirtualKeyboardManager::Hide() { - keyboard_->Hide(); -} - -views::Widget* VirtualKeyboardManager::keyboard() { - return keyboard_; -} - -void VirtualKeyboardManager::OnWidgetClosing(views::Widget* widget) { - DCHECK_EQ(keyboard_, widget); - keyboard_ = NULL; -} - -// static -VirtualKeyboardManager* VirtualKeyboardManager::GetInstance() { - return Singleton<VirtualKeyboardManager>::get(); -} diff --git a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h deleted file mode 100644 index e833ed9..0000000 --- a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h +++ /dev/null @@ -1,45 +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 CHROME_BROWSER_UI_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_MANAGER_H_ -#define CHROME_BROWSER_UI_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_MANAGER_H_ -#pragma once - -#include "base/memory/singleton.h" -#include "ui/views/widget/widget.h" - -class KeyboardWidget; - -// A singleton object to manage the virtual keyboard. -class VirtualKeyboardManager : public views::Widget::Observer { - public: - // Returns the singleton object. - static VirtualKeyboardManager* GetInstance(); - - // Shows the keyboard for the target widget. The events from the keyboard will - // be sent to |widget|. - // TODO(sad): Allow specifying the type of keyboard to show. - void ShowKeyboardForWidget(views::Widget* widget); - - // Hides the keyboard. - void Hide(); - - // Returns the keyboard Widget. - views::Widget* keyboard(); - - private: - friend struct DefaultSingletonTraits<VirtualKeyboardManager>; - - VirtualKeyboardManager(); - virtual ~VirtualKeyboardManager(); - - // Overridden from views::Widget::Observer. - virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE; - - KeyboardWidget* keyboard_; - - DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardManager); -}; - -#endif // CHROME_BROWSER_UI_VIRTUAL_KEYBOARD_VIRTUAL_KEYBOARD_MANAGER_H_ diff --git a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager_browsertest.cc b/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager_browsertest.cc deleted file mode 100644 index 060cf70..0000000 --- a/chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager_browsertest.cc +++ /dev/null @@ -1,98 +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 "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/virtual_keyboard/virtual_keyboard_manager.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/notification_service.h" -#include "content/public/browser/notification_types.h" -#include "net/base/mock_host_resolver.h" -#include "ui/views/widget/widget.h" - -class VirtualKeyboardManagerTest : public InProcessBrowserTest, - public content::NotificationObserver { - public: - VirtualKeyboardManagerTest() - : InProcessBrowserTest(), - keyboard_visible_(false) { - } - - bool keyboard_visible() const { return keyboard_visible_; } - - void SetupNotificationListener() { - registrar_.Add(this, - chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, - content::NotificationService::AllSources()); - } - - private: - virtual void TearDown() { - registrar_.RemoveAll(); - InProcessBrowserTest::TearDown(); - } - - virtual void Observe(int type, - const content::NotificationSource& source, - const content::NotificationDetails& details) OVERRIDE { - DCHECK_EQ(chrome::NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, type); - keyboard_visible_ = *content::Details<bool>(details).ptr(); - } - - bool keyboard_visible_; - content::NotificationRegistrar registrar_; -}; - -IN_PROC_BROWSER_TEST_F(VirtualKeyboardManagerTest, TestVisibility) { - SetupNotificationListener(); - browser()->window()->Show(); - - // Move focus between the omnibox and the wrench menu a few times. Note that - // it is necessary to RunAllPendingInMessageLoop each time after moving - // focus between the omnibox and the wrench menu because of the task posted in - // AccessiblePaneView::FocusWillChange - - browser()->FocusAppMenu(); - EXPECT_FALSE(keyboard_visible()); - ui_test_utils::RunAllPendingInMessageLoop(); - - browser()->FocusLocationBar(); - EXPECT_TRUE(keyboard_visible()); - ui_test_utils::RunAllPendingInMessageLoop(); - - browser()->FocusAppMenu(); - EXPECT_FALSE(keyboard_visible()); - ui_test_utils::RunAllPendingInMessageLoop(); - - browser()->FocusLocationBar(); - EXPECT_TRUE(keyboard_visible()); - ui_test_utils::RunAllPendingInMessageLoop(); - - // Test with some tabs now - host_resolver()->AddRule("*", "127.0.0.1"); - ASSERT_TRUE(test_server()->Start()); - GURL base_url = test_server()->GetURL("files/keyboard/"); - - // Go to a page that gives focus to a textfield onload. - ui_test_utils::NavigateToURL(browser(), base_url.Resolve("focus.html")); - EXPECT_TRUE(keyboard_visible()); - - // Open a new tab that does not give focus to a textfield onload. - ui_test_utils::WindowedNotificationObserver load_stop_observer( - content::NOTIFICATION_LOAD_STOP, - content::NotificationService::AllSources()); - browser()->AddSelectedTabWithURL(base_url.Resolve("blank.html"), - content::PAGE_TRANSITION_LINK); - load_stop_observer.Wait(); - - // Focus the first tab where the textfield has the focus. - browser()->SelectNextTab(); - EXPECT_TRUE(keyboard_visible()); - - // Focus the next tab again. - browser()->SelectNextTab(); - EXPECT_FALSE(keyboard_visible()); -} diff --git a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc index 4b09549..baa09d9 100644 --- a/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc +++ b/chrome/browser/ui/webui/chrome_url_data_manager_backend.cc @@ -78,9 +78,6 @@ class ChromeURLContentSecurityPolicyExceptionSet insert(chrome::kChromeUISimUnlockHost); insert(chrome::kChromeUISystemInfoHost); #endif -#if defined(USE_VIRTUAL_KEYBOARD) - insert(chrome::kChromeUIKeyboardHost); -#endif #if defined(OS_CHROMEOS) || defined(USE_AURA) insert(chrome::kChromeUICollectedCookiesHost); insert(chrome::kChromeUIHttpAuthHost); diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc index 43a7be2..9e2f07b 100644 --- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc +++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc @@ -75,10 +75,6 @@ #include "chrome/browser/ui/webui/sync_promo/sync_promo_ui.h" #endif -#if defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/ui/webui/keyboard_ui.h" -#endif - #if defined(OS_WIN) #include "chrome/browser/ui/webui/conflicts_ui.h" #endif @@ -291,10 +287,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui, if (url.host() == chrome::kChromeUITaskManagerHost) return &NewWebUI<TaskManagerUI>; #endif // defined(ENABLE_TASK_MANAGER) -#if defined(USE_VIRTUAL_KEYBOARD) - if (url.host() == chrome::kChromeUIKeyboardHost) - return &NewWebUI<KeyboardUI>; -#endif #if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(USE_AURA) if (url.host() == chrome::kChromeUICollectedCookiesHost || diff --git a/chrome/browser/ui/webui/keyboard_ui.cc b/chrome/browser/ui/webui/keyboard_ui.cc deleted file mode 100644 index f86188e..0000000 --- a/chrome/browser/ui/webui/keyboard_ui.cc +++ /dev/null @@ -1,53 +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 "chrome/browser/ui/webui/keyboard_ui.h" - -#include "base/memory/ref_counted_memory.h" -#include "base/memory/singleton.h" -#include "base/message_loop.h" -#include "base/string_piece.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "chrome/common/url_constants.h" -#include "content/public/browser/web_contents.h" -#include "content/public/browser/web_ui.h" -#include "ui/base/resource/resource_bundle.h" - -using content::WebContents; - -/////////////////////////////////////////////////////////////////////////////// -// KeyboardUI - -KeyboardUI::KeyboardUI(content::WebUI* web_ui) - : WebUIController(web_ui) { - KeyboardHTMLSource* html_source = new KeyboardHTMLSource(); - Profile* profile = Profile::FromWebUI(web_ui); - ChromeURLDataManager::AddDataSource(profile, html_source); -} - -KeyboardUI::~KeyboardUI() { -} - -/////////////////////////////////////////////////////////////////////////////// -// KeyboardHTMLSource - -KeyboardUI::KeyboardHTMLSource::KeyboardHTMLSource() - : DataSource(chrome::kChromeUIKeyboardHost, MessageLoop::current()) { -} - -void KeyboardUI::KeyboardHTMLSource::StartDataRequest(const std::string& path, - bool is_incognito, - int request_id) { - NOTREACHED() << "We should never get here since the extension should have" - << "been triggered"; - SendResponse(request_id, NULL); -} - -std::string KeyboardUI::KeyboardHTMLSource::GetMimeType( - const std::string&) const { - NOTREACHED() << "We should never get here since the extension should have" - << "been triggered"; - return "text/html"; -} diff --git a/chrome/browser/ui/webui/keyboard_ui.h b/chrome/browser/ui/webui/keyboard_ui.h deleted file mode 100644 index 3562e54..0000000 --- a/chrome/browser/ui/webui/keyboard_ui.h +++ /dev/null @@ -1,40 +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 CHROME_BROWSER_UI_WEBUI_KEYBOARD_UI_H_ -#define CHROME_BROWSER_UI_WEBUI_KEYBOARD_UI_H_ -#pragma once - -#include <string> - -#include "chrome/browser/ui/webui/chrome_url_data_manager.h" -#include "content/public/browser/web_ui_controller.h" - -// The WebContents used for the keyboard page. -class KeyboardUI : public content::WebUIController { - public: - explicit KeyboardUI(content::WebUI* web_ui); - virtual ~KeyboardUI(); - - class KeyboardHTMLSource : public ChromeURLDataManager::DataSource { - public: - KeyboardHTMLSource(); - - // Overrides from DataSource - virtual void StartDataRequest(const std::string& path, - bool is_incognito, - int request_id) OVERRIDE; - virtual std::string GetMimeType(const std::string&) const OVERRIDE; - - private: - virtual ~KeyboardHTMLSource() {} - - DISALLOW_COPY_AND_ASSIGN(KeyboardHTMLSource); - }; - - private: - DISALLOW_COPY_AND_ASSIGN(KeyboardUI); -}; - -#endif // CHROME_BROWSER_UI_WEBUI_KEYBOARD_UI_H_ diff --git a/chrome/browser/ui/webui/options2/chromeos/cros_language_options_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/cros_language_options_handler2.cc index e8479cc..821b4df 100644 --- a/chrome/browser/ui/webui/options2/chromeos/cros_language_options_handler2.cc +++ b/chrome/browser/ui/webui/options2/chromeos/cros_language_options_handler2.cc @@ -66,9 +66,6 @@ void CrosLanguageOptionsHandler::GetLocalizedValues( localized_strings->SetString("restart_button", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON)); - localized_strings->SetString("virtual_keyboard_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_BUTTON)); input_method::InputMethodManager* manager = input_method::InputMethodManager::GetInstance(); diff --git a/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.cc b/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.cc deleted file mode 100644 index d5bc27f..0000000 --- a/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.cc +++ /dev/null @@ -1,234 +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 "chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h" - -#include <map> -#include <set> -#include <string> - -#include "base/bind.h" -#include "base/bind_helpers.h" -#include "base/string_number_conversions.h" -#include "base/utf_string_conversions.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/virtual_keyboard_selector.h" -#include "chrome/browser/chromeos/preferences.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/prefs/scoped_user_pref_update.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/common/chrome_notification_types.h" -#include "chrome/common/pref_names.h" -#include "content/public/browser/notification_details.h" -#include "content/public/browser/notification_source.h" -#include "content/public/browser/web_ui.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace ime = ::chromeos::input_method; - -namespace chromeos { -namespace options2 { - -VirtualKeyboardManagerHandler::VirtualKeyboardManagerHandler() { -} - -VirtualKeyboardManagerHandler::~VirtualKeyboardManagerHandler() { -} - -void VirtualKeyboardManagerHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - static const OptionsStringResource resources[] = { - { "virtualKeyboardLayoutColumnTitle", - IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_LAYOUT_COLUMN_TITLE }, - { "virtualKeyboardKeyboardColumnTitle", - IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_KEYBOARD_COLUMN_TITLE }, - { "defaultVirtualKeyboard", - IDS_OPTIONS_SETTINGS_LANGUAGES_DEFAULT_VIRTUAL_KEYBOARD }, - }; - RegisterStrings(localized_strings, resources, arraysize(resources)); - - RegisterTitle(localized_strings, "virtualKeyboardPage", - IDS_OPTIONS_SETTINGS_LANGUAGES_VIRTUAL_KEYBOARD_SETTINGS_TITLE); - - // Do not call GetVirtualKeyboardList() here since |web_ui()| is not ready - // yet. -} - -void VirtualKeyboardManagerHandler::RegisterMessages() { - // Register handler functions for chrome.send(). - web_ui()->RegisterMessageCallback("updateVirtualKeyboardList", - base::Bind(&VirtualKeyboardManagerHandler::UpdateVirtualKeyboardList, - base::Unretained(this))); - web_ui()->RegisterMessageCallback("setVirtualKeyboardPreference", - base::Bind(&VirtualKeyboardManagerHandler::SetVirtualKeyboardPreference, - base::Unretained(this))); - web_ui()->RegisterMessageCallback("clearVirtualKeyboardPreference", - base::Bind(&VirtualKeyboardManagerHandler::ClearVirtualKeyboardPreference, - base::Unretained(this))); -} - -ListValue* VirtualKeyboardManagerHandler::GetVirtualKeyboardList() { - ime::InputMethodManager* input_method = - ime::InputMethodManager::GetInstance(); - - // Get a multi map from layout name (e.g. "us(dvorak)"), to virtual keyboard - // extension. - const LayoutToKeyboard& layout_to_keyboard = - input_method->GetLayoutNameToKeyboardMapping(); - const UrlToKeyboard& url_to_keyboard = - input_method->GetUrlToKeyboardMapping(); - - // Get the current pref values. - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - DCHECK(prefs); - const DictionaryValue* virtual_keyboard_pref = - prefs->GetDictionary(prefs::kLanguagePreferredVirtualKeyboard); - - return CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, virtual_keyboard_pref); -} - -void VirtualKeyboardManagerHandler::UpdateVirtualKeyboardList( - const ListValue* args) { - scoped_ptr<Value> virtual_keyboards(GetVirtualKeyboardList()); - DCHECK(virtual_keyboards.get()); - web_ui()->CallJavascriptFunction( - "VirtualKeyboardManager.updateVirtualKeyboardList", *virtual_keyboards); -} - -void VirtualKeyboardManagerHandler::SetVirtualKeyboardPreference( - const ListValue* args) { - std::string layout, url; - if (!args || !args->GetString(0, &layout) || !args->GetString(1, &url)) { - LOG(ERROR) << "SetVirtualKeyboardPreference: Invalid argument"; - return; - } - - // Validate args. - ime::InputMethodManager* input_method = - ime::InputMethodManager::GetInstance(); - if (!ValidateUrl(input_method->GetUrlToKeyboardMapping(), layout, url)) { - LOG(ERROR) << "SetVirtualKeyboardPreference: Invalid args: " - << "layout=" << layout << ", url=" << url; - return; - } - - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - DCHECK(prefs); - { - DictionaryPrefUpdate updater( - prefs, prefs::kLanguagePreferredVirtualKeyboard); - DictionaryValue* pref_value = updater.Get(); - pref_value->SetWithoutPathExpansion(layout, new StringValue(url)); - } - Preferences::UpdateVirturalKeyboardPreference(prefs); -} - -void VirtualKeyboardManagerHandler::ClearVirtualKeyboardPreference( - const ListValue* args) { - std::string layout; - if (!args || !args->GetString(0, &layout)) { - LOG(ERROR) << "ClearVirtualKeyboardPreference: Invalid argument"; - return; - } - - // Validate |layout|. - ime::InputMethodManager* input_method = - ime::InputMethodManager::GetInstance(); - if (!input_method->GetLayoutNameToKeyboardMapping().count(layout)) { - LOG(ERROR) << "ClearVirtualKeyboardPreference: Invalid layout: " << layout; - return; - } - - PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); - DCHECK(prefs); - { - DictionaryPrefUpdate updater( - prefs, prefs::kLanguagePreferredVirtualKeyboard); - DictionaryValue* pref_value = updater.Get(); - pref_value->RemoveWithoutPathExpansion(layout, NULL); - } - Preferences::UpdateVirturalKeyboardPreference(prefs); -} - -// static -bool VirtualKeyboardManagerHandler::ValidateUrl( - const UrlToKeyboard& url_to_keyboard, - const std::string& layout, - const std::string& url) { - UrlToKeyboard::const_iterator iter = url_to_keyboard.find(GURL(url)); - if (iter == url_to_keyboard.end() || - !iter->second->supported_layouts().count(layout)) { - return false; - } - return true; -} - -// static -ListValue* VirtualKeyboardManagerHandler::CreateVirtualKeyboardList( - const LayoutToKeyboard& layout_to_keyboard, - const UrlToKeyboard& url_to_keyboard, - const DictionaryValue* virtual_keyboard_pref) { - ListValue* layout_list = new ListValue; - - // |dictionary| points to an element in the |layout_list|. One dictionary - // element is created for one layout. - DictionaryValue* dictionary = NULL; - - LayoutToKeyboard::const_iterator i; - for (i = layout_to_keyboard.begin(); i != layout_to_keyboard.end(); ++i) { - const std::string& layout_id = i->first; - - std::string string_value; - // Check the "layout" value in the current dictionary. - if (dictionary) { - dictionary->GetString("layout", &string_value); - } - - if (string_value != layout_id) { - // New layout is found. Add the layout to |layout_list|. - dictionary = new DictionaryValue; - layout_list->Append(dictionary); - - // Set layout id as well as its human readable form. - ime::InputMethodManager* manager = ime::InputMethodManager::GetInstance(); - const ime::InputMethodDescriptor* desc = - manager->GetInputMethodUtil()->GetInputMethodDescriptorFromXkbId( - layout_id); - const std::string layout_name = desc ? - manager->GetInputMethodUtil()->GetInputMethodDisplayNameFromId( - desc->id()) : layout_id; - dictionary->SetString("layout", layout_id); - dictionary->SetString("layoutName", layout_name); - - // Check if the layout is in user pref. - if (virtual_keyboard_pref && - virtual_keyboard_pref->GetString(layout_id, &string_value) && - ValidateUrl(url_to_keyboard, layout_id, string_value)) { - dictionary->SetString("preferredKeyboard", string_value); - } - dictionary->Set("supportedKeyboards", new ListValue); - } - - ListValue* supported_keyboards = NULL; - dictionary->GetList("supportedKeyboards", &supported_keyboards); - DCHECK(supported_keyboards); - - DictionaryValue* virtual_keyboard = new DictionaryValue; - virtual_keyboard->SetString("name", i->second->name()); - virtual_keyboard->SetBoolean("isSystem", i->second->is_system()); - virtual_keyboard->SetString("url", i->second->url().spec()); - supported_keyboards->Append(virtual_keyboard); - } - - return layout_list; -} - -} // namespace options2 -} // namespace chromeos diff --git a/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h b/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h deleted file mode 100644 index 8f53d16..0000000 --- a/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h +++ /dev/null @@ -1,80 +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. - -#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_VIRTUAL_KEYBOARD_MANAGER_HANDLER2_H_ -#define CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_VIRTUAL_KEYBOARD_MANAGER_HANDLER2_H_ -#pragma once - -#include <map> -#include <set> -#include <string> - -#include "chrome/browser/ui/webui/options2/options_ui2.h" -#include "googleurl/src/gurl.h" - -namespace base { -class DictionaryValue; -class ListValue; -} // namespace base - -namespace chromeos { - -namespace input_method { -class VirtualKeyboard; -} // namespace input_method; - -namespace options2 { - -// A class which provides information to virtual_keyboard.js. -class VirtualKeyboardManagerHandler : public ::options2::OptionsPageUIHandler { - public: - VirtualKeyboardManagerHandler(); - virtual ~VirtualKeyboardManagerHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues( - base::DictionaryValue* localized_strings) OVERRIDE; - virtual void RegisterMessages() OVERRIDE; - - protected: - typedef std::multimap< - std::string, const input_method::VirtualKeyboard*> LayoutToKeyboard; - typedef std::map<GURL, const input_method::VirtualKeyboard*> UrlToKeyboard; - - // Returns true if |layout_to_keyboard| contains |layout| as a key, and the - // value for |layout| contains |url|. This function is protected for - // testability. - static bool ValidateUrl(const UrlToKeyboard& url_to_keyboard, - const std::string& layout, - const std::string& url); - - // Builds a list from |layout_to_keyboard| and |virtual_keyboard_user_pref|. - // See virtual_keyboard_list.js for an example of the format the list should - // take. This function is protected for testability. - static base::ListValue* CreateVirtualKeyboardList( - const LayoutToKeyboard& layout_to_keyboard, - const UrlToKeyboard& url_to_keyboard, - const base::DictionaryValue* virtual_keyboard_user_pref); - - private: - // Reads user pref and create a list using CreateVirtualKeyboardList(). - base::ListValue* GetVirtualKeyboardList(); - - // Handles chrome.send("updateVirtualKeyboardList") JS call. - // TODO(yusukes): This function should also be called when user pref is - // updated by chrome://settings page in other tab. - void UpdateVirtualKeyboardList(const base::ListValue* args); - - // Handles chrome.send("setVirtualKeyboardPreference") JS call. - void SetVirtualKeyboardPreference(const base::ListValue* args); - // Handles chrome.send("clearVirtualKeyboardPreference") JS call. - void ClearVirtualKeyboardPreference(const base::ListValue* args); - - DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardManagerHandler); -}; - -} // namespace options2 -} // namespace chromeos - -#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS2_CHROMEOS_VIRTUAL_KEYBOARD_MANAGER_HANDLER2_H_ diff --git a/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2_unittest.cc b/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2_unittest.cc deleted file mode 100644 index 8d41ffb..0000000 --- a/chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2_unittest.cc +++ /dev/null @@ -1,552 +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 "chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h" - -#include <map> -#include <set> -#include <string> - -#include "base/logging.h" -#include "base/values.h" -#include "chrome/browser/chromeos/input_method/virtual_keyboard_selector.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - -typedef std::multimap< - std::string, const chromeos::input_method::VirtualKeyboard*> LayoutToKeyboard; -typedef std::map< - GURL, const chromeos::input_method::VirtualKeyboard*> UrlToKeyboard; - -template <size_t L> -std::set<std::string> CreateLayoutSet(const char* (&layouts)[L]) { - return std::set<std::string>(layouts, layouts + L); -} - -} // namespace - -namespace chromeos { -namespace options2 { - -class Testee : public VirtualKeyboardManagerHandler { - public: - // Change access rights. - using VirtualKeyboardManagerHandler::ValidateUrl; - using VirtualKeyboardManagerHandler::CreateVirtualKeyboardList; -}; - -TEST(VirtualKeyboardManagerHandler, TestValidateUrl) { - static const char* layouts1[] = { "a", "b" }; - static const char* layouts2[] = { "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts1), true); - input_method::VirtualKeyboard virtual_keyboard_2( - GURL("http://url2/"), "name 2", CreateLayoutSet(layouts2), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_2.url(), - virtual_keyboard_2.name(), - virtual_keyboard_2.supported_layouts(), - virtual_keyboard_2.is_system())); - - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(2U, url_to_keyboard.size()); - - EXPECT_TRUE(Testee::ValidateUrl(url_to_keyboard, "a", "http://url1/")); - EXPECT_TRUE(Testee::ValidateUrl(url_to_keyboard, "b", "http://url1/")); - EXPECT_TRUE(Testee::ValidateUrl(url_to_keyboard, "b", "http://url2/")); - - EXPECT_FALSE(Testee::ValidateUrl(url_to_keyboard, "a", "http://url3/")); - EXPECT_FALSE(Testee::ValidateUrl(url_to_keyboard, "b", "http://url3/")); - EXPECT_FALSE(Testee::ValidateUrl(url_to_keyboard, "c", "http://url1/")); - EXPECT_FALSE(Testee::ValidateUrl(url_to_keyboard, "c", "http://url2/")); -} - -TEST(VirtualKeyboardManagerHandler, TestSingleKeyboard) { - static const char* layouts[] = { "a", "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(arraysize(layouts), layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(1U, url_to_keyboard.size()); - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, NULL)); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(arraysize(layouts), keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); -} - -TEST(VirtualKeyboardManagerHandler, TestSingleKeyboardWithPref) { - static const char* layouts[] = { "a", "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(arraysize(layouts), layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(1U, url_to_keyboard.size()); - - // create pref object. - scoped_ptr<DictionaryValue> pref(new DictionaryValue); - pref->SetString("b", "http://url1/"); - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, pref.get())); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(arraysize(layouts), keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_TRUE(dictionary_value->GetString("preferredKeyboard", &string_value)); - EXPECT_EQ("http://url1/", string_value); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); -} - -TEST(VirtualKeyboardManagerHandler, TestSingleKeyboardWithTwoPrefs) { - static const char* layouts[] = { "a", "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(arraysize(layouts), layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(1U, url_to_keyboard.size()); - - // create pref object. - scoped_ptr<DictionaryValue> pref(new DictionaryValue); - pref->SetString("a", "http://url1/"); - pref->SetString("b", "http://url1/"); - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, pref.get())); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(arraysize(layouts), keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_TRUE(dictionary_value->GetString("preferredKeyboard", &string_value)); - EXPECT_EQ("http://url1/", string_value); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_TRUE(dictionary_value->GetString("preferredKeyboard", &string_value)); - EXPECT_EQ("http://url1/", string_value); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); -} - -TEST(VirtualKeyboardManagerHandler, TestSingleKeyboardWithBadPref1) { - static const char* layouts[] = { "a", "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(arraysize(layouts), layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(1U, url_to_keyboard.size()); - - // create pref object. - scoped_ptr<DictionaryValue> pref(new DictionaryValue); - pref->SetString("unknownlayout", "http://url1/"); - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, pref.get())); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(arraysize(layouts), keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); -} - -TEST(VirtualKeyboardManagerHandler, TestSingleKeyboardWithBadPref2) { - static const char* layouts[] = { "a", "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(arraysize(layouts), layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(1U, url_to_keyboard.size()); - - // create pref object. - scoped_ptr<DictionaryValue> pref(new DictionaryValue); - pref->SetString("a", "http://unknownurl/"); - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, pref.get())); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(arraysize(layouts), keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); -} - -TEST(VirtualKeyboardManagerHandler, TestSingleKeyboardWithBadPref3) { - static const char* layout1[] = { "a" }; - static const char* layout2[] = { "b" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layout1), true); - input_method::VirtualKeyboard virtual_keyboard_2( - GURL("http://url2/"), "name 2", CreateLayoutSet(layout2), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_2.url(), - virtual_keyboard_2.name(), - virtual_keyboard_2.supported_layouts(), - virtual_keyboard_2.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(2U, layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(2U, url_to_keyboard.size()); - - // create pref object. - scoped_ptr<DictionaryValue> pref(new DictionaryValue); - pref->SetString("a", "http://url2/"); // url2 does not support "a". - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, pref.get())); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(2U, keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url2/", string_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 2", string_value); -} - -TEST(VirtualKeyboardManagerHandler, TestMultipleKeyboards) { - static const char* layouts1[] = { "a", "b" }; - static const char* layouts2[] = { "c" }; - static const char* layouts3[] = { "b", "d" }; - input_method::VirtualKeyboard virtual_keyboard_1( - GURL("http://url1/"), "name 1", CreateLayoutSet(layouts1), true); - input_method::VirtualKeyboard virtual_keyboard_2( - GURL("http://url2/"), "name 2", CreateLayoutSet(layouts2), false); - input_method::VirtualKeyboard virtual_keyboard_3( - GURL("http://url3/"), "name 3", CreateLayoutSet(layouts3), true); - - input_method::VirtualKeyboardSelector selector; - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_1.url(), - virtual_keyboard_1.name(), - virtual_keyboard_1.supported_layouts(), - virtual_keyboard_1.is_system())); - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_2.url(), - virtual_keyboard_2.name(), - virtual_keyboard_2.supported_layouts(), - virtual_keyboard_2.is_system())); - ASSERT_TRUE(selector.AddVirtualKeyboard( - virtual_keyboard_3.url(), - virtual_keyboard_3.name(), - virtual_keyboard_3.supported_layouts(), - virtual_keyboard_3.is_system())); - - const LayoutToKeyboard& layout_to_keyboard = selector.layout_to_keyboard(); - ASSERT_EQ(arraysize(layouts1) + arraysize(layouts2) + arraysize(layouts3), - layout_to_keyboard.size()); - const UrlToKeyboard& url_to_keyboard = selector.url_to_keyboard(); - ASSERT_EQ(3U, url_to_keyboard.size()); - - scoped_ptr<ListValue> keyboards(Testee::CreateVirtualKeyboardList( - layout_to_keyboard, url_to_keyboard, NULL)); - ASSERT_TRUE(keyboards.get()); - ASSERT_EQ(4U /* a, b, c, and d */, keyboards->GetSize()); - - DictionaryValue* dictionary_value; - std::string string_value; - ListValue* list_value; - bool boolean_value = false; - - // Check the first element (for the layout "a"). - ASSERT_TRUE(keyboards->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("a", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetBoolean("isSystem", &boolean_value)); - EXPECT_TRUE(boolean_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - - // Check the second element (for the layout "b"). - ASSERT_TRUE(keyboards->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("b", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(2U, list_value->GetSize()); // keyboard1 and 3. - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url1/", string_value); - EXPECT_TRUE(dictionary_value->GetBoolean("isSystem", &boolean_value)); - EXPECT_TRUE(boolean_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 1", string_value); - ASSERT_TRUE(list_value->GetDictionary(1, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url3/", string_value); - EXPECT_TRUE(dictionary_value->GetBoolean("isSystem", &boolean_value)); - EXPECT_TRUE(boolean_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 3", string_value); - - // 3rd. - ASSERT_TRUE(keyboards->GetDictionary(2, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("c", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url2/", string_value); - EXPECT_TRUE(dictionary_value->GetBoolean("isSystem", &boolean_value)); - EXPECT_FALSE(boolean_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 2", string_value); - - // 4th. - ASSERT_TRUE(keyboards->GetDictionary(3, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("layout", &string_value)); - EXPECT_EQ("d", string_value); - EXPECT_TRUE(dictionary_value->GetString("layoutName", &string_value)); - EXPECT_FALSE(dictionary_value->GetString("preferredKeyboard", &string_value)); - ASSERT_TRUE(dictionary_value->GetList("supportedKeyboards", &list_value)); - ASSERT_EQ(1U, list_value->GetSize()); - ASSERT_TRUE(list_value->GetDictionary(0, &dictionary_value)); - EXPECT_TRUE(dictionary_value->GetString("url", &string_value)); - EXPECT_EQ("http://url3/", string_value); - EXPECT_TRUE(dictionary_value->GetBoolean("isSystem", &boolean_value)); - EXPECT_TRUE(boolean_value); - EXPECT_TRUE(dictionary_value->GetString("name", &string_value)); - EXPECT_EQ("name 3", string_value); -} - -} // namespace options2 -} // namespace chromeos diff --git a/chrome/browser/ui/webui/options2/options_ui2.cc b/chrome/browser/ui/webui/options2/options_ui2.cc index 33b13b7..d7f0a9f 100644 --- a/chrome/browser/ui/webui/options2/options_ui2.cc +++ b/chrome/browser/ui/webui/options2/options_ui2.cc @@ -77,9 +77,6 @@ #include "chrome/browser/ui/webui/options2/chromeos/stats_options_handler2.h" #include "chrome/browser/ui/webui/options2/chromeos/user_image_source2.h" #include "chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.h" -#if defined(USE_VIRTUAL_KEYBOARD) -#include "chrome/browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h" -#endif #endif #if defined(OS_CHROMEOS) && defined(USE_ASH) @@ -271,12 +268,6 @@ OptionsUI::OptionsUI(content::WebUI* web_ui) new chromeos::options2::PointerHandler(); AddOptionsPageUIHandler(localized_strings, pointer_handler); -#if defined(USE_VIRTUAL_KEYBOARD) - AddOptionsPageUIHandler( - localized_strings, - new chromeos::options2::VirtualKeyboardManagerHandler()); -#endif - AddOptionsPageUIHandler(localized_strings, new chromeos::options2::ProxyHandler()); AddOptionsPageUIHandler( diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 79d86bd..8ba6fde 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -597,8 +597,6 @@ 'browser/chromeos/input_method/input_method_whitelist.h', 'browser/chromeos/input_method/mock_ibus_controller.cc', 'browser/chromeos/input_method/mock_ibus_controller.h', - 'browser/chromeos/input_method/virtual_keyboard_selector.cc', - 'browser/chromeos/input_method/virtual_keyboard_selector.h', 'browser/chromeos/input_method/xkeyboard.cc', 'browser/chromeos/input_method/xkeyboard.h', 'browser/chromeos/input_method/xkeyboard_data.h', @@ -3618,8 +3616,6 @@ 'browser/ui/views/web_intent_picker_views.cc', 'browser/ui/views/wrench_menu.cc', 'browser/ui/views/wrench_menu.h', - 'browser/ui/virtual_keyboard/virtual_keyboard_manager.cc', - 'browser/ui/virtual_keyboard/virtual_keyboard_manager.h', 'browser/ui/web_applications/web_app_ui.cc', 'browser/ui/web_applications/web_app_ui.h', 'browser/ui/website_settings_ui.cc', @@ -3741,8 +3737,6 @@ 'browser/ui/webui/history_ui.h', 'browser/ui/webui/inspect_ui.cc', 'browser/ui/webui/inspect_ui.h', - 'browser/ui/webui/keyboard_ui.cc', - 'browser/ui/webui/keyboard_ui.h', 'browser/ui/webui/media/media_internals_handler.cc', 'browser/ui/webui/media/media_internals_handler.h', 'browser/ui/webui/media/media_internals_proxy.cc', @@ -3838,8 +3832,6 @@ 'browser/ui/webui/options2/chromeos/system_settings_provider2.h', 'browser/ui/webui/options2/chromeos/user_image_source2.cc', 'browser/ui/webui/options2/chromeos/user_image_source2.h', - 'browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.cc', - 'browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.h', 'browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.cc', 'browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source2.h', 'browser/ui/webui/options2/clear_browser_data_handler2.cc', @@ -4405,14 +4397,6 @@ '../ui/gl/gl.gyp:gl', ], }], - ['use_virtual_keyboard==0', { - 'sources/': [ - ['exclude', '^browser/chromeos/input_method/virtual_keyboard_selector.*'], - ['exclude', '^browser/ui/virtual_keyboard/*'], - ['exclude', '^browser/ui/webui/keyboard_ui.*'], - ['exclude', '^browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2.*'], - ], - }], ['os_posix == 1 and OS != "mac" and OS != "android"', { 'link_settings': { 'libraries': [ diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 550704f..319ffb7 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -522,8 +522,6 @@ 'browser/extensions/extension_input_ime_api.h', 'browser/extensions/extension_input_method_api.cc', 'browser/extensions/extension_input_method_api.h', - 'browser/extensions/extension_input_ui_api.cc', - 'browser/extensions/extension_input_ui_api.h', 'browser/extensions/extension_managed_mode_api.cc', 'browser/extensions/extension_managed_mode_api.h', 'browser/extensions/extension_management_api.cc', @@ -579,11 +577,6 @@ ['include', '^browser/extensions/api/web_request/web_request_time_tracker.cc'], ], }], - ['use_virtual_keyboard==0', { - 'sources/': [ - ['exclude', '^browser/extensions/extension_input_ui_api.*'], - ], - }], ['OS=="linux" and use_aura==1', { 'dependencies': [ '../build/linux/system.gyp:dbus', @@ -644,14 +637,6 @@ ['exclude', '^browser/extensions/key_identifier_conversion_views.h'], ], }], - # Exclude extension_input_ui_api that depends on chromeos again - # (Required because of the '^browser/extensions/' include above) - ['chromeos == 0 or use_virtual_keyboard == 0', { - 'sources/': [ - ['exclude', '^browser/extensions/extension_input_ui_api.cc'], - ['exclude', '^browser/extensions/extension_input_ui_api.h'], - ], - }], ['chromeos==1',{ 'sources/': [ ['exclude', '^browser/extensions/extension_tts_api_linux.cc'], diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 6b1eea0..b7db1bc 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1093,7 +1093,6 @@ 'browser/chromeos/input_method/input_method_property_unittest.cc', 'browser/chromeos/input_method/input_method_util_unittest.cc', 'browser/chromeos/input_method/input_method_whitelist_unittest.cc', - 'browser/chromeos/input_method/virtual_keyboard_selector_unittest.cc', 'browser/chromeos/input_method/xkeyboard_unittest.cc', 'browser/chromeos/kiosk_mode/kiosk_mode_idle_logout_unittest.cc', 'browser/chromeos/kiosk_mode/kiosk_mode_screensaver_unittest.cc', @@ -1773,7 +1772,6 @@ 'browser/ui/webui/chrome_web_ui_data_source_unittest.cc', 'browser/ui/webui/fileicon_source_unittest.cc', 'browser/ui/webui/ntp/suggestions_combiner_unittest.cc', - 'browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2_unittest.cc', 'browser/ui/webui/options2/language_options_handler2_unittest.cc', 'browser/ui/webui/policy_ui_unittest.cc', 'browser/ui/webui/print_preview/print_preview_handler_unittest.cc', @@ -2074,12 +2072,6 @@ ['exclude', '^browser/automation/'], ], }], - ['use_virtual_keyboard!=1', { - 'sources/': [ - ['exclude', '^browser/chromeos/input_method/virtual_keyboard_selector_unittest.cc'], - ['exclude', '^browser/ui/webui/options2/chromeos/virtual_keyboard_manager_handler2_unittest.cc'], - ], - }], ['enable_session_service!=1', { 'sources!': [ 'browser/sessions/session_service_unittest.cc', @@ -2711,7 +2703,6 @@ 'browser/extensions/extension_input_apitest.cc', 'browser/extensions/extension_input_ime_apitest_chromeos.cc', 'browser/extensions/extension_input_method_apitest_chromeos.cc', - 'browser/extensions/extension_input_ui_apitest.cc', 'browser/extensions/extension_install_ui_browsertest.cc', 'browser/extensions/extension_javascript_url_apitest.cc', 'browser/extensions/extension_keybinding_apitest.cc', @@ -3060,21 +3051,11 @@ 'browser/ui/panels/panel_browser_view_browsertest.cc', ], }], - ['use_virtual_keyboard==1', { - 'sources': [ - 'browser/ui/virtual_keyboard/virtual_keyboard_manager_browsertest.cc', - ], - }], ['file_manager_extension==0', { 'sources!': [ 'browser/ui/views/select_file_dialog_extension_browsertest.cc', ], }], - ['chromeos==0 or use_virtual_keyboard==0', { - 'sources!': [ - 'browser/extensions/extension_input_ui_apitest.cc', - ], - }], ['configuration_policy==0', { 'sources/': [ ['exclude', '^browser/policy/'], diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h index edb7d9e..f0b7a4c 100644 --- a/chrome/common/chrome_notification_types.h +++ b/chrome/common/chrome_notification_types.h @@ -1017,25 +1017,6 @@ enum NotificationType { // Sent when a new web store promo has been loaded. NOTIFICATION_WEB_STORE_PROMO_LOADED, -#if defined(USE_VIRTUAL_KEYBOARD) - // Sent when the keyboard visibility has changed. Used for testing purposes - // only. Source is the keyboard manager, and Details is a boolean indicating - // whether the keyboard is visibile or not. - NOTIFICATION_KEYBOARD_VISIBILITY_CHANGED, - - // Sent when an API for hiding the keyboard is invoked from JavaScript code. - NOTIFICATION_HIDE_KEYBOARD_INVOKED, - - // Sent when an API for set height of the keyboard is invoked from - // JavaScript code. - NOTIFICATION_SET_KEYBOARD_HEIGHT_INVOKED, - - // Sent after the keyboard has been animated up or down. Source is the - // keyboard Widget, and Details is bounds of the keyboard in screen - // coordinates. - NOTIFICATION_KEYBOARD_VISIBLE_BOUNDS_CHANGED, -#endif - // Protocol Handler Registry ----------------------------------------------- // Sent when a ProtocolHandlerRegistry is changed. The source is the profile. NOTIFICATION_PROTOCOL_HANDLER_REGISTRY_CHANGED, diff --git a/chrome/common/extensions/api/experimental_input_ui.json b/chrome/common/extensions/api/experimental_input_ui.json deleted file mode 100644 index 303d947..0000000 --- a/chrome/common/extensions/api/experimental_input_ui.json +++ /dev/null @@ -1,146 +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. - -[ - { - "namespace": "experimental.input.ui", - "nodoc": true, - "platforms": ["chromeos touch"], - "types": [], - "functions": [ - { - "name": "register", - "type": "function", - "description": "Registers the extension, so the extension can receive input method related events.", - "parameters": [ - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - }, - { - "name": "candidateClicked", - "type": "function", - "description": "Notifies input method engine that a candidate was clicked.", - "parameters": [ - { "type": "integer", - "name": "index" - }, - { "type": "integer", - "name": "button" - }, - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - }, - { - "name": "cursorUp", - "type": "function", - "description": "Notifies input method engine cursor up button was clicked.", - "parameters": [ - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - }, - { - "name": "cursorDown", - "type": "function", - "description": "Notifies input method engine cursor down button was clicked.", - "parameters": [ - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - }, - { - "name": "pageUp", - "type": "function", - "description": "Notifies input method engine page up button was clicked.", - "parameters": [ - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - }, - { - "name": "pageDown", - "type": "function", - "description": "Notifies input method engine page down button was clicked.", - "parameters": [ - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - } - ], - "events": [ - { - "name": "onSetCursorLocation", - "type": "function", - "description": "Fired when input cursor location is changed.", - "parameters": [ - { "type": "integer", - "name": "x" - }, - { "type": "integer", - "name": "y" - }, - { "type": "integer", - "name": "width" - }, - { "type": "integer", - "name": "height" - } - ] - }, - { - "name": "onUpdateAuxiliaryText", - "type": "function", - "description": "Fired when auxiliary text is changed.", - "parameters": [ - { "type": "string", - "name": "text", - "description": "Auxiliary text." - } - ] - }, - { - "name": "onUpdateLookupTable", - "type": "function", - "description": "Fired when lookup table is updated.", - "parameters": [ - { "type": "object", - "name": "lookupTable", - "properties": { - "visible": { "type": "boolean" }, - "candidates": { "type": "array", "items": { "type": "string" } } - }, - "description": "Lookup table" - } - ] - } - - ] - } -] diff --git a/chrome/common/extensions/api/experimental_input_virtual_keyboard.json b/chrome/common/extensions/api/experimental_input_virtual_keyboard.json index 6845d8f..2aea6ca 100644 --- a/chrome/common/extensions/api/experimental_input_virtual_keyboard.json +++ b/chrome/common/extensions/api/experimental_input_virtual_keyboard.json @@ -54,85 +54,6 @@ "parameters": [] } ] - }, - { - "name": "hideKeyboard", - "type": "function", - "description": "Hides the keyboard UI.", - "parameters": [ - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed.", - "parameters": [] - } - ] - }, - { - "name": "setKeyboardHeight", - "type": "function", - "description": "Sets the height of the keyboard UI.", - "parameters": [ - { "type": "integer", - "name": "height", - "minimum": 0, - "optional": false, - "description": "The height of the keyboard UI." - }, - { "type": "function", - "name": "callback", - "optional": true, - "description": "This function is called when the event processing is completed but the resizeing may be not finished.", - "parameters": [] - } - ] - }, - { - "name": "sendHandwritingStroke", - "type": "function", - "description": "Sends a handwriting event to Chrome.", - "parameters": [ - { - "name": "stroke", - "type": "array", - "items": { - "type": "object", - "properties": { - "x": {"type": "number", "minimum": 0, "maximum": 1}, - "y": {"type": "number", "minimum": 0, "maximum": 1} - } - } - } - ] - }, - { - "name": "cancelHandwritingStrokes", - "type": "function", - "description": "Clears last N handwriting strokes.", - "parameters": [ - { - "name": "strokeCount", - "optional": true, - "description": "The number of strokes to be removed. Pass 0 to remove all strokes. If omitted, removes all.", - "type": "integer", - "minimum": 0 - } - ] - } - ], - "events": [ - { - "name": "onTextInputTypeChanged", - "type": "function", - "description": "This event is sent to the virtual keyboard when the text input type is changed.", - "parameters": [ - { - "type": "string", - "name": "type", - "enum": ["none", "text", "password", "search", "email", "number", "tel", "url"], - "description": "Type of the current focused input field." - } - ] } ] } diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index b713a27..3b16613 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -365,8 +365,6 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_EXPERIMENTAL_IDENTITY)); RegisterSchema("experimental.infobars", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS)); - RegisterSchema("experimental.input.ui", ReadFromResource( - IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_UI)); RegisterSchema("experimental.input.virtualKeyboard", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD)); RegisterSchema("experimental.keybinding", ReadFromResource( diff --git a/chrome/common/extensions/docs/js/api_page_generator.js b/chrome/common/extensions/docs/js/api_page_generator.js index b785b30..43008c3 100644 --- a/chrome/common/extensions/docs/js/api_page_generator.js +++ b/chrome/common/extensions/docs/js/api_page_generator.js @@ -41,7 +41,6 @@ var MODULE_SCHEMAS = [ '../api/experimental_font_settings.json', '../api/experimental_identity.json', '../api/experimental_infobars.json', - '../api/experimental_input_ui.json', '../api/experimental_input_virtual_keyboard.json', '../api/experimental_keybinding.json', '../api/experimental_media_galleries.json', diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index 539e238..824d85f 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -1947,14 +1947,6 @@ bool Extension::LoadInputComponents( if (module_value->GetString(keys::kType, &type_str)) { if (type_str == "ime") { type = INPUT_COMPONENT_TYPE_IME; - } else if (type_str == "virtual_keyboard") { - if (!api_permissions.count(ExtensionAPIPermission::kExperimental)) { - // Virtual Keyboards require the experimental flag. - *error = ExtensionErrorUtils::FormatErrorMessageUTF16( - errors::kInvalidInputComponentType, base::IntToString(i)); - return false; - } - type = INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD; } else { *error = ExtensionErrorUtils::FormatErrorMessageUTF16( errors::kInvalidInputComponentType, base::IntToString(i)); @@ -2306,9 +2298,6 @@ bool Extension::LoadChromeURLOverrides(string16* error) { std::string val; // Restrict override pages to a list of supported URLs. if ((page != chrome::kChromeUINewTabHost && -#if defined(USE_VIRTUAL_KEYBOARD) - page != chrome::kChromeUIKeyboardHost && -#endif #if defined(OS_CHROMEOS) page != chrome::kChromeUIActivationMessageHost && #endif diff --git a/chrome/common/extensions/extension.h b/chrome/common/extensions/extension.h index 2e68ab1..6624b15 100644 --- a/chrome/common/extensions/extension.h +++ b/chrome/common/extensions/extension.h @@ -140,7 +140,6 @@ class Extension : public base::RefCountedThreadSafe<Extension> { enum InputComponentType { INPUT_COMPONENT_TYPE_NONE = -1, INPUT_COMPONENT_TYPE_IME, - INPUT_COMPONENT_TYPE_VIRTUAL_KEYBOARD, INPUT_COMPONENT_TYPE_COUNT }; diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd index cf6ed5f..e1379e0 100644 --- a/chrome/common/extensions_api_resources.grd +++ b/chrome/common/extensions_api_resources.grd @@ -30,7 +30,6 @@ <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_FONTSSETTINGS" file="extensions\api\experimental_font_settings.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_IDENTITY" file="extensions\api\experimental_identity.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS" file="extensions\api\experimental_infobars.json" type="BINDATA" /> - <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_UI" file="extensions\api\experimental_input_ui.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD" file="extensions\api\experimental_input_virtual_keyboard.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_KEYBINDING" file="extensions\api\experimental_keybinding.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_MEDIAGALLERIES" file="extensions\api\experimental_media_galleries.json" type="BINDATA" /> diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index f56d35f..f6a270b5 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -645,11 +645,6 @@ const char kLanguageXkbAutoRepeatInterval[] = // "_r2" suffixes are added to the three prefs above when we change the // preferences not user-configurable, not to sync them with cloud. -// A dictionary pref which determines a preferred virtual keyboard per layout. -// e.g. { "us(dvorak)": "http://asdfg..yuiop/" } -const char kLanguagePreferredVirtualKeyboard[] = - "settings.language.preferred_virtual_keyboard"; - // A boolean pref which determines whether spoken feedback is enabled. const char kSpokenFeedbackEnabled[] = "settings.accessibility"; // A boolean pref which determines whether high conrast is enabled. @@ -657,6 +652,7 @@ const char kHighContrastEnabled[] = "settings.a11y.high_contrast"; // A boolean pref which determines whether screen magnifier is enabled. const char kScreenMagnifierEnabled[] = "settings.a11y.screen_magnifier"; // A boolean pref which determines whether virtual keyboard is enabled. +// TODO(hashimoto): Remove this pref. const char kVirtualKeyboardEnabled[] = "settings.a11y.virtual_keyboard"; // A boolean pref which turns on Advanced Filesystem diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 12ad69d..7b0e6a1 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -242,7 +242,6 @@ extern const char kLanguageXkbRemapAltKeyTo[]; extern const char kLanguageXkbAutoRepeatEnabled[]; extern const char kLanguageXkbAutoRepeatDelay[]; extern const char kLanguageXkbAutoRepeatInterval[]; -extern const char kLanguagePreferredVirtualKeyboard[]; extern const char kSpokenFeedbackEnabled[]; extern const char kHighContrastEnabled[]; extern const char kScreenMagnifierEnabled[]; diff --git a/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/manifest.json b/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/manifest.json deleted file mode 100644 index 5221ff2..0000000 --- a/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "chrome.experimental.input.ui", - "version": "0.1", - "manifest_version": 2, - "description": "end-to-end browser test for chrome.experimental.input.ui API", - "background": { - "page": "test.html" - }, - "permissions": ["experimental"] -} diff --git a/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/test.html b/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/test.html deleted file mode 100644 index 3efb342..0000000 --- a/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/test.html +++ /dev/null @@ -1,6 +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. ---> -<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/test.js b/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/test.js deleted file mode 100644 index 58b3e07..0000000 --- a/chrome/test/data/extensions/api_test/input_ui/chromeos_virtual_keyboard/test.js +++ /dev/null @@ -1,16 +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. - -// experimental.input.ui API test for Chrome -// browser_tests --gtest_filter=ExtensionApiTest.InputUI - -chrome.test.runTests([ - function inputUIExist() { - if (chrome.experimental.input.ui) { - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - } -]); diff --git a/chrome/test/data/extensions/api_test/input_ui/other/manifest.json b/chrome/test/data/extensions/api_test/input_ui/other/manifest.json deleted file mode 100644 index 5221ff2..0000000 --- a/chrome/test/data/extensions/api_test/input_ui/other/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "chrome.experimental.input.ui", - "version": "0.1", - "manifest_version": 2, - "description": "end-to-end browser test for chrome.experimental.input.ui API", - "background": { - "page": "test.html" - }, - "permissions": ["experimental"] -} diff --git a/chrome/test/data/extensions/api_test/input_ui/other/test.html b/chrome/test/data/extensions/api_test/input_ui/other/test.html deleted file mode 100644 index 3efb342..0000000 --- a/chrome/test/data/extensions/api_test/input_ui/other/test.html +++ /dev/null @@ -1,6 +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. ---> -<script src="test.js"></script> diff --git a/chrome/test/data/extensions/api_test/input_ui/other/test.js b/chrome/test/data/extensions/api_test/input_ui/other/test.js deleted file mode 100644 index 239d635..0000000 --- a/chrome/test/data/extensions/api_test/input_ui/other/test.js +++ /dev/null @@ -1,16 +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. - -// experimental.input.ui API test for Chrome -// browser_tests --gtest_filter=ExtensionApiTest.InputUI - -chrome.test.runTests([ - function inputUINotExist() { - if (!chrome.experimental.input.ui) { - chrome.test.succeed(); - } else { - chrome.test.fail(); - } - } -]); diff --git a/content/browser/renderer_host/render_process_host_browsertest.cc b/content/browser/renderer_host/render_process_host_browsertest.cc index 127db54..9b8f209 100644 --- a/content/browser/renderer_host/render_process_host_browsertest.cc +++ b/content/browser/renderer_host/render_process_host_browsertest.cc @@ -69,10 +69,6 @@ class RenderProcessHostTest : public InProcessBrowserTest { content::RenderProcessHost* rph2 = NULL; content::RenderProcessHost* rph3 = NULL; -#if defined(USE_VIRTUAL_KEYBOARD) - ++host_count; // For the virtual keyboard. -#endif - // Change the first tab to be the new tab page (TYPE_WEBUI). GURL newtab(chrome::kTestNewTabURL); ui_test_utils::NavigateToURL(browser(), newtab); @@ -130,11 +126,7 @@ class RenderProcessHostTest : public InProcessBrowserTest { if (browser()->tab_count() == tab_count) ui_test_utils::WaitForNewTab(browser()); tab_count++; -#if !defined(USE_VIRTUAL_KEYBOARD) - // The virtual keyboard already creates an extension process. So this - // should not increase the process count. host_count++; -#endif EXPECT_EQ(tab_count, browser()->tab_count()); tab1 = browser()->GetWebContentsAt(tab_count - 1); rph3 = tab1->GetRenderProcessHost(); @@ -164,10 +156,6 @@ IN_PROC_BROWSER_TEST_F(RenderProcessHostTest, ProcessPerTab) { int tab_count = 1; int host_count = 1; -#if defined(USE_VIRTUAL_KEYBOARD) - ++host_count; // For the virtual keyboard. -#endif - // Change the first tab to be the new tab page (TYPE_WEBUI). GURL newtab(chrome::kTestNewTabURL); ui_test_utils::NavigateToURL(browser(), newtab); diff --git a/ui/base/ime/input_method_base.cc b/ui/base/ime/input_method_base.cc index ae2d41a4..b6fa482 100644 --- a/ui/base/ime/input_method_base.cc +++ b/ui/base/ime/input_method_base.cc @@ -53,7 +53,6 @@ TextInputClient* InputMethodBase::GetTextInputClient() const { void InputMethodBase::OnTextInputTypeChanged(const TextInputClient* client) { if (!IsTextInputClientFocused(client)) return; - // TODO(yusukes): Support TextInputTypeTracker for USE_VIRTUAL_KEYBOARD. } TextInputType InputMethodBase::GetTextInputType() const { |