Commit 4b3d2c7d authored by Jing Wang's avatar Jing Wang Committed by Commit Bot

Emit the correct event when input method settings are updated.

OnSettingsChanged event is an old event which is not used anywhere, we
should use the new OnInputMethodOptionsChange event instead.

This is also required for using SetSettings api in Tast tests.

Test: tested with Chrome on Linux
Bug: 1118927
Change-Id: I8e6db60bd11c3ae09f29cf1b88251db00f339813
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362491
Commit-Queue: Jing Wang <jiwan@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Reviewed-by: default avatarKeith Lee <keithlee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802156}
parent 49b84815
......@@ -76,8 +76,8 @@ namespace SetAutocorrectRange =
extensions::api::input_method_private::SetAutocorrectRange;
namespace SetSelectionRange =
extensions::api::input_method_private::SetSelectionRange;
namespace OnSettingsChanged =
extensions::api::input_method_private::OnSettingsChanged;
namespace OnInputMethodOptionsChanged =
extensions::api::input_method_private::OnInputMethodOptionsChanged;
using chromeos::InputMethodEngineBase;
......@@ -392,11 +392,11 @@ ExtensionFunction::ResponseAction InputMethodPrivateSetSettingsFunction::Run() {
// The router will only send the event to extensions that are listening.
extensions::EventRouter* router =
extensions::EventRouter::Get(browser_context());
if (router->HasEventListener(OnSettingsChanged::kEventName)) {
if (router->HasEventListener(OnInputMethodOptionsChanged::kEventName)) {
auto event = std::make_unique<extensions::Event>(
extensions::events::INPUT_METHOD_PRIVATE_ON_SETTINGS_CHANGED,
OnSettingsChanged::kEventName,
OnSettingsChanged::Create(params->engine_id, params->settings),
extensions::events::INPUT_IME_ON_INPUT_METHOD_OPTIONS_CHANGED,
OnInputMethodOptionsChanged::kEventName,
OnInputMethodOptionsChanged::Create(params->engine_id),
browser_context());
router->BroadcastEvent(std::move(event));
}
......
......@@ -56,15 +56,15 @@ chrome.test.runTests([
// Test OnSettingsChanged event gets raised when settings are updated.
function eventRaisedWhenSettingToInitialValue() {
const settings = { 'enableDoubleSpacePeriod': true };
const listener = (ime, value) => {
const listener = (ime) => {
chrome.test.assertEq('ime', ime);
chrome.test.assertEq(settings, value);
chrome.test.succeed();
chrome.inputMethodPrivate.onSettingsChanged.removeListener(listener);
chrome.inputMethodPrivate.onInputMethodOptionsChanged
.removeListener(listener);
};
chrome.inputMethodPrivate.onSettingsChanged.addListener(listener);
chrome.inputMethodPrivate.onInputMethodOptionsChanged.addListener(listener);
chrome.inputMethodPrivate.setSettings('ime', settings);
}
]);
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