Commit 9a822b4d authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

Add chrome.inputMethodPrivate.hideInputView()

This CL adds a method to explicitly close the virtual keyboard.
It will be used from Tast's Chrome ResetState function.

Tast side CL: https://crrev.com/c/2071552

TEST=tast run arc.ChromeVirtualKeyboard
BUG=None

Change-Id: Iffb9fb1f9b9e5059b38d3315f9d135d23624a479
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2071549
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarToni Baržić <tbarzic@chromium.org>
Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746227}
parent f0d5eb2c
...@@ -81,6 +81,8 @@ namespace { ...@@ -81,6 +81,8 @@ namespace {
const char kXkbPrefix[] = "xkb:"; const char kXkbPrefix[] = "xkb:";
const char kErrorFailToShowInputView[] = const char kErrorFailToShowInputView[] =
"Unable to show the input view window because the keyboard is not enabled."; "Unable to show the input view window because the keyboard is not enabled.";
const char kErrorFailToHideInputView[] =
"Unable to hide the input view window because the keyboard is not enabled.";
const char kErrorRouterNotAvailable[] = "The router is not available."; const char kErrorRouterNotAvailable[] = "The router is not available.";
const char kErrorInvalidInputMethod[] = "Input method not found."; const char kErrorInvalidInputMethod[] = "Input method not found.";
const char kErrorSpellCheckNotAvailable[] = const char kErrorSpellCheckNotAvailable[] =
...@@ -264,6 +266,17 @@ InputMethodPrivateShowInputViewFunction::Run() { ...@@ -264,6 +266,17 @@ InputMethodPrivateShowInputViewFunction::Run() {
return RespondNow(NoArguments()); return RespondNow(NoArguments());
} }
ExtensionFunction::ResponseAction
InputMethodPrivateHideInputViewFunction::Run() {
auto* keyboard_client = ChromeKeyboardControllerClient::Get();
if (!keyboard_client->is_keyboard_enabled()) {
return RespondNow(Error(kErrorFailToHideInputView));
}
keyboard_client->HideKeyboard(ash::HideReason::kUser);
return RespondNow(NoArguments());
}
ExtensionFunction::ResponseAction ExtensionFunction::ResponseAction
InputMethodPrivateOpenOptionsPageFunction::Run() { InputMethodPrivateOpenOptionsPageFunction::Run() {
std::unique_ptr<OpenOptionsPage::Params> params( std::unique_ptr<OpenOptionsPage::Params> params(
......
...@@ -171,6 +171,25 @@ class InputMethodPrivateShowInputViewFunction : public ExtensionFunction { ...@@ -171,6 +171,25 @@ class InputMethodPrivateShowInputViewFunction : public ExtensionFunction {
DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateShowInputViewFunction); DISALLOW_COPY_AND_ASSIGN(InputMethodPrivateShowInputViewFunction);
}; };
// Implements the inputMethodPrivate.hideInputView method.
class InputMethodPrivateHideInputViewFunction : public ExtensionFunction {
public:
InputMethodPrivateHideInputViewFunction() = default;
InputMethodPrivateHideInputViewFunction(
const InputMethodPrivateHideInputViewFunction&) = delete;
InputMethodPrivateHideInputViewFunction& operator=(
const InputMethodPrivateHideInputViewFunction&) = delete;
protected:
~InputMethodPrivateHideInputViewFunction() override {}
ResponseAction Run() override;
private:
DECLARE_EXTENSION_FUNCTION("inputMethodPrivate.hideInputView",
INPUTMETHODPRIVATE_HIDEINPUTVIEW)
};
// Implements the inputMethodPrivate.openOptionsPage method. // Implements the inputMethodPrivate.openOptionsPage method.
class InputMethodPrivateOpenOptionsPageFunction : public ExtensionFunction { class InputMethodPrivateOpenOptionsPageFunction : public ExtensionFunction {
public: public:
......
...@@ -332,6 +332,19 @@ ...@@ -332,6 +332,19 @@
"parameters": [] "parameters": []
} }
] ]
}, {
"name": "hideInputView",
"type": "function",
"description": "Shows the input view window. If the input view window is already hidden, this function will do nothing.",
"parameters": [
{
"type": "function",
"name": "callback",
"optional": true,
"description": "Called when the operation completes.",
"parameters": []
}
]
}, { }, {
"name": "openOptionsPage", "name": "openOptionsPage",
"type": "function", "type": "function",
......
...@@ -1512,6 +1512,7 @@ enum HistogramValue { ...@@ -1512,6 +1512,7 @@ enum HistogramValue {
WEBCAMPRIVATE_RESTORE_CAMERA_PRESET = 1449, WEBCAMPRIVATE_RESTORE_CAMERA_PRESET = 1449,
WEBCAMPRIVATE_SET_CAMERA_PRESET = 1450, WEBCAMPRIVATE_SET_CAMERA_PRESET = 1450,
PASSWORDSPRIVATE_GETCOMPROMISEDCREDENTIALSINFO = 1451, PASSWORDSPRIVATE_GETCOMPROMISEDCREDENTIALSINFO = 1451,
INPUTMETHODPRIVATE_HIDEINPUTVIEW = 1452,
// Last entry: Add new entries above, then run: // Last entry: Add new entries above, then run:
// python tools/metrics/histograms/update_extension_histograms.py // python tools/metrics/histograms/update_extension_histograms.py
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -197,6 +197,13 @@ chrome.inputMethodPrivate.notifyImeMenuItemActivated = function(engineID, name) ...@@ -197,6 +197,13 @@ chrome.inputMethodPrivate.notifyImeMenuItemActivated = function(engineID, name)
*/ */
chrome.inputMethodPrivate.showInputView = function(callback) {}; chrome.inputMethodPrivate.showInputView = function(callback) {};
/**
* Hides the input view window. If the input view window is already hidden, this
* function will do nothing.
* @param {function():void=} callback Called when the operation completes.
*/
chrome.inputMethodPrivate.hideInputView = function(callback) {};
/** /**
* Opens the options page for the input method extension. If the input method * Opens the options page for the input method extension. If the input method
* does not have options, this function will do nothing. * does not have options, this function will do nothing.
......
...@@ -22380,6 +22380,7 @@ to ensure that the crash string is shown properly on the user-facing crash UI. ...@@ -22380,6 +22380,7 @@ to ensure that the crash string is shown properly on the user-facing crash UI.
<int value="1449" label="WEBCAMPRIVATE_RESTORE_CAMERA_PRESET"/> <int value="1449" label="WEBCAMPRIVATE_RESTORE_CAMERA_PRESET"/>
<int value="1450" label="WEBCAMPRIVATE_SET_CAMERA_PRESET"/> <int value="1450" label="WEBCAMPRIVATE_SET_CAMERA_PRESET"/>
<int value="1451" label="PASSWORDSPRIVATE_GETCOMPROMISEDCREDENTIALSINFO"/> <int value="1451" label="PASSWORDSPRIVATE_GETCOMPROMISEDCREDENTIALSINFO"/>
<int value="1452" label="INPUTMETHODPRIVATE_HIDEINPUTVIEW"/>
</enum> </enum>
<enum name="ExtensionIconState"> <enum name="ExtensionIconState">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment