Commit f6ba2c4a authored by John Palmer's avatar John Palmer Committed by Commit Bot

Merge tts handlers

BUG=1148093

Change-Id: Ib23c8bbc8ac1ad5b8c70a940693f14ad22acf1f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2530961
Commit-Queue: John Palmer <jopalmer@chromium.org>
Reviewed-by: default avatarMy Nguyen <myy@chromium.org>
Reviewed-by: default avatarJing Wang <jiwan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829016}
parent 90586e02
...@@ -1476,6 +1476,8 @@ source_set("chromeos") { ...@@ -1476,6 +1476,8 @@ source_set("chromeos") {
"input_method/suggester.h", "input_method/suggester.h",
"input_method/suggestion_enums.h", "input_method/suggestion_enums.h",
"input_method/suggestion_handler_interface.h", "input_method/suggestion_handler_interface.h",
"input_method/tts_handler.cc",
"input_method/tts_handler.h",
"input_method/ui/assistive_delegate.h", "input_method/ui/assistive_delegate.h",
"input_method/ui/border_factory.cc", "input_method/ui/border_factory.cc",
"input_method/ui/border_factory.h", "input_method/ui/border_factory.h",
......
...@@ -53,7 +53,7 @@ specific_include_rules = { ...@@ -53,7 +53,7 @@ specific_include_rules = {
# TODO: This should not be an allowed dep; see # TODO: This should not be an allowed dep; see
# http://crbug.com/1148093 and # http://crbug.com/1148093 and
# http://b/173144152. # http://b/173144152.
"(assistive_window_controller|personal_info_suggester)\.h": [ "tts_handler\.h": [
"!content/public/browser/tts_controller.h", "!content/public/browser/tts_controller.h",
], ],
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "ash/public/cpp/ash_pref_names.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
...@@ -16,7 +15,6 @@ ...@@ -16,7 +15,6 @@
#include "chrome/browser/chromeos/input_method/ui/suggestion_details.h" #include "chrome/browser/chromeos/input_method/ui/suggestion_details.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/prefs/pref_service.h"
#include "ui/base/ime/chromeos/ime_bridge.h" #include "ui/base/ime/chromeos/ime_bridge.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
...@@ -45,39 +43,6 @@ constexpr base::TimeDelta kTtsShowDelay = ...@@ -45,39 +43,6 @@ constexpr base::TimeDelta kTtsShowDelay =
} // namespace } // namespace
TtsHandler::TtsHandler(Profile* profile) : profile_(profile) {}
TtsHandler::~TtsHandler() = default;
void TtsHandler::Announce(const std::string& text,
const base::TimeDelta delay) {
const bool chrome_vox_enabled = profile_->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilitySpokenFeedbackEnabled);
if (!chrome_vox_enabled)
return;
delay_timer_ = std::make_unique<base::OneShotTimer>();
delay_timer_->Start(
FROM_HERE, delay,
base::BindOnce(&TtsHandler::Speak, base::Unretained(this), text));
}
void TtsHandler::OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) {}
void TtsHandler::Speak(const std::string& text) {
std::unique_ptr<content::TtsUtterance> utterance =
content::TtsUtterance::Create(profile_);
utterance->SetText(text);
utterance->SetEventDelegate(this);
utterance->SetCanEnqueue(true);
auto* tts_controller = content::TtsController::GetInstance();
tts_controller->SpeakOrEnqueue(std::move(utterance));
}
AssistiveWindowController::AssistiveWindowController( AssistiveWindowController::AssistiveWindowController(
AssistiveWindowControllerDelegate* delegate, AssistiveWindowControllerDelegate* delegate,
Profile* profile, Profile* profile,
......
...@@ -9,10 +9,10 @@ ...@@ -9,10 +9,10 @@
#include "base/macros.h" #include "base/macros.h"
#include "chrome/browser/chromeos/input_method/assistive_window_properties.h" #include "chrome/browser/chromeos/input_method/assistive_window_properties.h"
#include "chrome/browser/chromeos/input_method/tts_handler.h"
#include "chrome/browser/chromeos/input_method/ui/assistive_delegate.h" #include "chrome/browser/chromeos/input_method/ui/assistive_delegate.h"
#include "chrome/browser/chromeos/input_method/ui/suggestion_window_view.h" #include "chrome/browser/chromeos/input_method/ui/suggestion_window_view.h"
#include "chrome/browser/chromeos/input_method/ui/undo_window.h" #include "chrome/browser/chromeos/input_method/ui/undo_window.h"
#include "content/public/browser/tts_controller.h"
#include "ui/base/ime/chromeos/ime_assistive_window_handler_interface.h" #include "ui/base/ime/chromeos/ime_assistive_window_handler_interface.h"
#include "ui/gfx/native_widget_types.h" #include "ui/gfx/native_widget_types.h"
...@@ -26,31 +26,6 @@ namespace chromeos { ...@@ -26,31 +26,6 @@ namespace chromeos {
namespace input_method { namespace input_method {
class TtsHandler : public content::UtteranceEventDelegate {
public:
explicit TtsHandler(Profile* profile);
~TtsHandler() override;
// Announce |text| after some |delay|. The delay is to avoid conflict with
// other ChromeVox announcements. This should be no-op if ChromeVox is not
// enabled.
void Announce(const std::string& text,
const base::TimeDelta delay = base::TimeDelta());
// UtteranceEventDelegate implementation.
void OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) override;
private:
virtual void Speak(const std::string& text);
Profile* const profile_;
std::unique_ptr<base::OneShotTimer> delay_timer_;
};
class AssistiveWindowControllerDelegate; class AssistiveWindowControllerDelegate;
// AssistiveWindowController controls different assistive windows. // AssistiveWindowController controls different assistive windows.
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include "chrome/browser/chromeos/extensions/input_method_api.h" #include "chrome/browser/chromeos/extensions/input_method_api.h"
#include "chrome/browser/extensions/api/input_ime/input_ime_api.h" #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
...@@ -23,7 +22,6 @@ ...@@ -23,7 +22,6 @@
#include "components/autofill/core/browser/data_model/autofill_profile.h" #include "components/autofill/core/browser/data_model/autofill_profile.h"
#include "components/autofill/core/browser/personal_data_manager.h" #include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/ui/label_formatter_utils.h" #include "components/autofill/core/browser/ui/label_formatter_utils.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h" #include "components/prefs/scoped_user_pref_update.h"
#include "components/strings/grit/components_strings.h" #include "components/strings/grit/components_strings.h"
#include "third_party/re2/src/re2/re2.h" #include "third_party/re2/src/re2/re2.h"
...@@ -96,39 +94,6 @@ void RecordTimeToDismiss(base::TimeDelta delta) { ...@@ -96,39 +94,6 @@ void RecordTimeToDismiss(base::TimeDelta delta) {
} // namespace } // namespace
TtsHandler::TtsHandler(Profile* profile) : profile_(profile) {}
TtsHandler::~TtsHandler() = default;
void TtsHandler::Announce(const std::string& text,
const base::TimeDelta delay) {
const bool chrome_vox_enabled = profile_->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilitySpokenFeedbackEnabled);
if (!chrome_vox_enabled)
return;
delay_timer_ = std::make_unique<base::OneShotTimer>();
delay_timer_->Start(
FROM_HERE, delay,
base::BindOnce(&TtsHandler::Speak, base::Unretained(this), text));
}
void TtsHandler::OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) {}
void TtsHandler::Speak(const std::string& text) {
std::unique_ptr<content::TtsUtterance> utterance =
content::TtsUtterance::Create(profile_);
utterance->SetText(text);
utterance->SetEventDelegate(this);
utterance->SetCanEnqueue(true);
auto* tts_controller = content::TtsController::GetInstance();
tts_controller->SpeakOrEnqueue(std::move(utterance));
}
AssistiveType ProposePersonalInfoAssistiveAction(const base::string16& text) { AssistiveType ProposePersonalInfoAssistiveAction(const base::string16& text) {
std::string lower_case_utf8_text = std::string lower_case_utf8_text =
base::ToLowerASCII(base::UTF16ToUTF8(text)); base::ToLowerASCII(base::UTF16ToUTF8(text));
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
#include "chrome/browser/chromeos/input_method/suggester.h" #include "chrome/browser/chromeos/input_method/suggester.h"
#include "chrome/browser/chromeos/input_method/suggestion_enums.h" #include "chrome/browser/chromeos/input_method/suggestion_enums.h"
#include "chrome/browser/chromeos/input_method/suggestion_handler_interface.h" #include "chrome/browser/chromeos/input_method/suggestion_handler_interface.h"
#include "chrome/browser/chromeos/input_method/tts_handler.h"
#include "chrome/browser/extensions/api/input_ime/input_ime_api.h" #include "chrome/browser/extensions/api/input_ime/input_ime_api.h"
#include "content/public/browser/tts_controller.h"
namespace autofill { namespace autofill {
class PersonalDataManager; class PersonalDataManager;
...@@ -33,31 +33,6 @@ const int kMaxShowSettingCount = 10; ...@@ -33,31 +33,6 @@ const int kMaxShowSettingCount = 10;
AssistiveType ProposePersonalInfoAssistiveAction(const base::string16& text); AssistiveType ProposePersonalInfoAssistiveAction(const base::string16& text);
class TtsHandler : public content::UtteranceEventDelegate {
public:
explicit TtsHandler(Profile* profile);
~TtsHandler() override;
// Announce |text| after some |delay|. The delay is to avoid conflict with
// other ChromeVox announcements. This should be no-op if ChromeVox is not
// enabled.
void Announce(const std::string& text,
const base::TimeDelta delay = base::TimeDelta());
// UtteranceEventDelegate implementation.
void OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) override;
private:
virtual void Speak(const std::string& text);
Profile* const profile_;
std::unique_ptr<base::OneShotTimer> delay_timer_;
};
// An agent to suggest personal information when the user types, and adopt or // An agent to suggest personal information when the user types, and adopt or
// dismiss the suggestion according to the user action. // dismiss the suggestion according to the user action.
class PersonalInfoSuggester : public Suggester { class PersonalInfoSuggester : public Suggester {
......
// Copyright 2020 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/tts_handler.h"
#include "ash/public/cpp/ash_pref_names.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "components/prefs/pref_service.h"
namespace chromeos {
TtsHandler::TtsHandler(Profile* profile) : profile_(profile) {}
TtsHandler::~TtsHandler() = default;
void TtsHandler::Announce(const std::string& text,
const base::TimeDelta delay) {
const bool chrome_vox_enabled = profile_->GetPrefs()->GetBoolean(
ash::prefs::kAccessibilitySpokenFeedbackEnabled);
if (!chrome_vox_enabled)
return;
delay_timer_ = std::make_unique<base::OneShotTimer>();
delay_timer_->Start(
FROM_HERE, delay,
base::BindOnce(&TtsHandler::Speak, base::Unretained(this), text));
}
void TtsHandler::OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) {}
void TtsHandler::Speak(const std::string& text) {
std::unique_ptr<content::TtsUtterance> utterance =
content::TtsUtterance::Create(profile_);
utterance->SetText(text);
utterance->SetEventDelegate(this);
utterance->SetCanEnqueue(true);
auto* tts_controller = content::TtsController::GetInstance();
tts_controller->SpeakOrEnqueue(std::move(utterance));
}
} // namespace chromeos
// Copyright 2020 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_TTS_HANDLER_H_
#define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TTS_HANDLER_H_
#include <string>
#include "base/timer/timer.h"
#include "content/public/browser/tts_controller.h"
class Profile;
namespace chromeos {
class TtsHandler : public content::UtteranceEventDelegate {
public:
explicit TtsHandler(Profile* profile);
~TtsHandler() override;
// Announce |text| after some |delay|. The delay is to avoid conflict with
// other ChromeVox announcements. This should be no-op if ChromeVox is not
// enabled.
void Announce(const std::string& text,
const base::TimeDelta delay = base::TimeDelta());
// UtteranceEventDelegate implementation.
void OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) override;
private:
virtual void Speak(const std::string& text);
Profile* const profile_;
std::unique_ptr<base::OneShotTimer> delay_timer_;
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_TTS_HANDLER_H_
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