Chromium Code Reviews| Index: chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| 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 834bb1e9c63b4a72bf17aeae2f70317a3a6ab22b..2857f122ad6b1f92d0379f89d3e9d4cfa1297f0a 100644 |
| --- a/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| +++ b/chrome/browser/chromeos/input_method/input_method_manager_impl.cc |
| @@ -12,7 +12,9 @@ |
| #include <sstream> |
| #include <utility> |
| +#include "ash/shell.h" |
| #include "base/bind.h" |
| +#include "base/feature_list.h" |
| #include "base/hash.h" |
| #include "base/location.h" |
| #include "base/metrics/histogram_macros.h" |
| @@ -30,6 +32,7 @@ |
| #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/browser/ui/ash/ash_util.h" |
| +#include "chrome/common/chrome_features.h" |
| #include "chrome/common/pref_names.h" |
| #include "components/prefs/pref_service.h" |
| #include "components/user_manager/user_manager.h" |
| @@ -1213,5 +1216,51 @@ void InputMethodManagerImpl::MaybeNotifyImeMenuActivationChanged() { |
| is_ime_menu_activated_); |
| } |
| +void InputMethodManagerImpl::ShowInputViewWithKeyset( |
| + const std::string& keyset) { |
| + std::string overriden_url = keyboard::GetOverrideContentUrl().spec(); |
|
James Cook
2016/09/12 17:05:56
nit: overriden -> overridden
Azure Wei
2016/09/14 06:53:28
Done.
|
| + |
| + auto i = overriden_url.find("#id"); |
|
James Cook
2016/09/12 17:05:57
Parsing URLs as strings is discouraged. Is there a
Azure Wei
2016/09/14 06:53:28
Updated with using ReplaceComponents(), it this be
James Cook
2016/09/14 21:14:27
Yes, thanks.
|
| + // If fails to find "#id", it means the current IME is not system IME, and we |
| + // don't support show e/v/h input for such IME extension. |
| + if (i == std::string::npos) { |
|
James Cook
2016/09/12 17:05:56
nit: no need for {} for single-line if
Azure Wei
2016/09/14 06:53:28
Done.
|
| + return; |
| + } |
| + |
| + // For system IME exension, the input view url is overriden as: |
| + // chrome-extension://${extension_id}/inputview.html#id=us.compact.qwerty |
| + // &language=en-US&passwordLayout=us.compact.qwerty&name=keyboard_us |
| + // We should replace the id=${keyset} part with desired keyset. |
| + auto j = overriden_url.find("&", i + 1); |
| + overriden_url.replace(i, j - i, "#id=" + keyset); |
| + |
| + keyboard::SetOverrideContentUrl(GURL(overriden_url)); |
| + |
| + keyboard::KeyboardController* keyboard_controller = |
| + keyboard::KeyboardController::GetInstance(); |
| + if (keyboard_controller) { |
| + keyboard_controller->ShowKeyboard(false); |
| + return; |
| + } |
| + |
| + if (keyboard::IsKeyboardEnabled()) |
| + return; |
| + |
| + // Forcibly enables the a11y onscreen keyboard if there is on keyboard enabled |
| + // for now. And re-disables it after showing once. |
| + keyboard::SetAccessibilityKeyboardEnabled(true); |
| + ash::Shell::GetInstance()->CreateKeyboard(); |
| + keyboard_controller = keyboard::KeyboardController::GetInstance(); |
| + if (!keyboard_controller) { |
| + keyboard::SetAccessibilityKeyboardEnabled(false); |
| + } |
| + keyboard_controller->ShowKeyboard(false); |
| + keyboard::SetAccessibilityKeyboardEnabled(false); |
|
James Cook
2016/09/12 17:05:57
Does it matter if the accessibilitykeyboard was en
Azure Wei
2016/09/14 06:53:28
Updated this logic.
|
| +} |
|
James Cook
2016/09/12 17:05:56
I don't know the virtual keyboard code very well,
Azure Wei
2016/09/14 06:53:28
Updated.
Also added tests:
InputMethodManagerImpl
|
| + |
| +bool InputMethodManagerImpl::IsEHVInputOnImeMenuEnabled() { |
| + return base::FeatureList::IsEnabled(features::kEHVInputOnImeMenu); |
|
James Cook
2016/09/12 17:05:56
FYI, I think the comment on kENVInputOnImeMenu in
Azure Wei
2016/09/14 06:53:28
Updated.
|
| +} |
| + |
| } // namespace input_method |
| } // namespace chromeos |