Commit 73bcb673 authored by John Palmer's avatar John Palmer Committed by Commit Bot

Add chromeVox messages for assistive autocorrect

Bug: 1111135
Change-Id: I0ecb9491026851d01331a95d20b29fc1e5caf0b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521552
Commit-Queue: John Palmer <jopalmer@chromium.org>
Reviewed-by: default avatarDarren Shen <shend@chromium.org>
Reviewed-by: default avatarMy Nguyen <myy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825722}
parent 1d9d4f26
...@@ -5839,6 +5839,15 @@ You can manage this account’s settings by installing the Family Link app on yo ...@@ -5839,6 +5839,15 @@ You can manage this account’s settings by installing the Family Link app on yo
<message name="IDS_SUGGESTION_INSERTED" desc="String announced by screenreader when a suggestion is inserted."> <message name="IDS_SUGGESTION_INSERTED" desc="String announced by screenreader when a suggestion is inserted.">
Suggestion inserted Suggestion inserted
</message> </message>
<message name="IDS_SUGGESTION_AUTOCORRECT_UNDONE" desc="String announced by screenreader when an autocorrected word is reverted. Example, user types 'hllo', system autocorrects to 'hello' but then that autocorrection is manually undone by the user.">
correction undone
</message>
<message name="IDS_SUGGESTION_AUTOCORRECT_UNDO_BUTTON" desc="String announced by screenreader when a button to undo an autocorrect is highlighted. Example, user types 'hllo', system autocorrects to 'hello', user then prepares to revert the autocorrect.">
Undo autocorrect button. Revert to <ph name="TYPED_WORD">$1<ex>hllo</ex></ph>. Press enter to activate, escape to dismiss.
</message>
<message name="IDS_SUGGESTION_AUTOCORRECT_UNDO_WINDOW_SHOWN" desc="String announced by screenreader when a button to undo an autocorrect is shown. Example, user types 'hllo', system autocorrects to 'hello', user then prepares to revert the autocorrect.">
Autocorrect undo dialog is shown for <ph name="TYPED_WORD">$1<ex>hllo</ex></ph> corrected to <ph name="CORRECTED_WORD">$2<ex>hello</ex></ph>. Press up arrow to access, escape to ignore.
</message>
<!-- Strings for Custom Tab UI --> <!-- Strings for Custom Tab UI -->
<message name="IDS_CUSTOM_TABS_ACTION_MENU_ACCESSIBLE_NAME" desc="Accessible name for the overflow menu of the Chrome Custom Tab toolbar."> <message name="IDS_CUSTOM_TABS_ACTION_MENU_ACCESSIBLE_NAME" desc="Accessible name for the overflow menu of the Chrome Custom Tab toolbar.">
......
82ea2c6dd7ddba8fa57359482cdad1304999a830
\ No newline at end of file
82ea2c6dd7ddba8fa57359482cdad1304999a830
\ No newline at end of file
82ea2c6dd7ddba8fa57359482cdad1304999a830
\ No newline at end of file
...@@ -4,10 +4,13 @@ ...@@ -4,10 +4,13 @@
#include "chrome/browser/chromeos/input_method/autocorrect_manager.h" #include "chrome/browser/chromeos/input_method/autocorrect_manager.h"
#include "base/strings/strcat.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/chromeos/input_method/assistive_window_properties.h" #include "chrome/browser/chromeos/input_method/assistive_window_properties.h"
#include "chrome/grit/generated_resources.h"
#include "ui/base/ime/chromeos/ime_bridge.h" #include "ui/base/ime/chromeos/ime_bridge.h"
#include "ui/base/ime/chromeos/ime_input_context_handler_interface.h" #include "ui/base/ime/chromeos/ime_input_context_handler_interface.h"
#include "ui/base/l10n/l10n_util.h"
namespace chromeos { namespace chromeos {
...@@ -22,6 +25,7 @@ void AutocorrectManager::MarkAutocorrectRange(const std::string& corrected_word, ...@@ -22,6 +25,7 @@ void AutocorrectManager::MarkAutocorrectRange(const std::string& corrected_word,
// TODO(crbug/1111135): call setAutocorrectTime() (for metrics) // TODO(crbug/1111135): call setAutocorrectTime() (for metrics)
// TODO(crbug/1111135): record metric (coverage) // TODO(crbug/1111135): record metric (coverage)
last_typed_word_ = typed_word; last_typed_word_ = typed_word;
last_corrected_word_ = corrected_word;
key_presses_until_underline_hide_ = kKeysUntilAutocorrectWindowHides; key_presses_until_underline_hide_ = kKeysUntilAutocorrectWindowHides;
ClearUnderline(); ClearUnderline();
...@@ -41,6 +45,9 @@ bool AutocorrectManager::OnKeyEvent( ...@@ -41,6 +45,9 @@ bool AutocorrectManager::OnKeyEvent(
auto button = ui::ime::AssistiveWindowButton(); auto button = ui::ime::AssistiveWindowButton();
button.id = ui::ime::ButtonId::kUndo; button.id = ui::ime::ButtonId::kUndo;
button.window_type = ui::ime::AssistiveWindowType::kUndoWindow; button.window_type = ui::ime::AssistiveWindowType::kUndoWindow;
button.announce_string =
l10n_util::GetStringFUTF8(IDS_SUGGESTION_AUTOCORRECT_UNDO_BUTTON,
base::UTF8ToUTF16(last_typed_word_));
engine_->SetButtonHighlighted(context_id_, button, true, &error); engine_->SetButtonHighlighted(context_id_, button, true, &error);
button_highlighted = true; button_highlighted = true;
return true; return true;
...@@ -64,6 +71,7 @@ void AutocorrectManager::ClearUnderline() { ...@@ -64,6 +71,7 @@ void AutocorrectManager::ClearUnderline() {
/*end=*/std::numeric_limits<uint32_t>::max()); /*end=*/std::numeric_limits<uint32_t>::max());
// TODO(b/171924347): expose engine->clearAutocorrectRange() and use it here. // TODO(b/171924347): expose engine->clearAutocorrectRange() and use it here.
} }
void AutocorrectManager::OnSurroundingTextChanged(const base::string16& text, void AutocorrectManager::OnSurroundingTextChanged(const base::string16& text,
const int cursor_pos, const int cursor_pos,
const int anchpr_pos) { const int anchpr_pos) {
...@@ -74,9 +82,12 @@ void AutocorrectManager::OnSurroundingTextChanged(const base::string16& text, ...@@ -74,9 +82,12 @@ void AutocorrectManager::OnSurroundingTextChanged(const base::string16& text,
chromeos::AssistiveWindowProperties properties; chromeos::AssistiveWindowProperties properties;
properties.type = ui::ime::AssistiveWindowType::kUndoWindow; properties.type = ui::ime::AssistiveWindowType::kUndoWindow;
properties.visible = true; properties.visible = true;
properties.announce_string =
l10n_util::GetStringFUTF8(IDS_SUGGESTION_AUTOCORRECT_UNDO_WINDOW_SHOWN,
base::UTF8ToUTF16(last_typed_word_),
base::UTF8ToUTF16(last_corrected_word_));
window_visible = true; window_visible = true;
button_highlighted = false; button_highlighted = false;
engine_->SetAssistiveWindowProperties(context_id_, properties, &error); engine_->SetAssistiveWindowProperties(context_id_, properties, &error);
key_presses_until_underline_hide_ = kKeysUntilAutocorrectWindowHides; key_presses_until_underline_hide_ = kKeysUntilAutocorrectWindowHides;
} else { } else {
...@@ -94,14 +105,16 @@ void AutocorrectManager::OnFocus(int context_id) { ...@@ -94,14 +105,16 @@ void AutocorrectManager::OnFocus(int context_id) {
} }
void AutocorrectManager::UndoAutocorrect() { void AutocorrectManager::UndoAutocorrect() {
// TODO(crbug/1111135): error handling, chromeVox and metrics // TODO(crbug/1111135): error handling and metrics
std::string error; std::string error;
chromeos::AssistiveWindowProperties properties; chromeos::AssistiveWindowProperties properties;
properties.type = ui::ime::AssistiveWindowType::kUndoWindow; properties.type = ui::ime::AssistiveWindowType::kUndoWindow;
properties.visible = false; properties.visible = false;
window_visible = false; window_visible = false;
button_highlighted = false; button_highlighted = false;
window_visible = false;
engine_->SetAssistiveWindowProperties(context_id_, properties, &error); engine_->SetAssistiveWindowProperties(context_id_, properties, &error);
const gfx::Range range = engine_->GetAutocorrectRange(); const gfx::Range range = engine_->GetAutocorrectRange();
const ui::SurroundingTextInfo surrounding_text = const ui::SurroundingTextInfo surrounding_text =
ui::IMEBridge::Get()->GetInputContextHandler()->GetSurroundingTextInfo(); ui::IMEBridge::Get()->GetInputContextHandler()->GetSurroundingTextInfo();
......
...@@ -7,12 +7,9 @@ ...@@ -7,12 +7,9 @@
#include <string> #include <string>
#include "chrome/browser/chromeos/input_method/emoji_suggester.h" #include "chrome/browser/chromeos/input_method/assistive_window_controller.h"
#include "chrome/browser/chromeos/input_method/input_method_engine.h" #include "chrome/browser/chromeos/input_method/input_method_engine.h"
#include "chrome/browser/chromeos/input_method/input_method_engine_base.h" #include "chrome/browser/chromeos/input_method/input_method_engine_base.h"
#include "chrome/browser/chromeos/input_method/personal_info_suggester.h"
#include "chrome/browser/chromeos/input_method/suggester.h"
#include "chrome/browser/chromeos/input_method/suggestion_enums.h"
namespace chromeos { namespace chromeos {
...@@ -54,6 +51,7 @@ class AutocorrectManager { ...@@ -54,6 +51,7 @@ class AutocorrectManager {
int context_id_ = -1; int context_id_ = -1;
InputMethodEngine* const engine_; InputMethodEngine* const engine_;
std::string last_typed_word_; std::string last_typed_word_;
std::string last_corrected_word_;
bool window_visible = false; bool window_visible = false;
bool button_highlighted = false; bool button_highlighted = false;
}; };
......
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