#include "chrome/browser/speech/extension_api/tts_extension_api.h"
#include <stddef.h>
#include <memory>
#include <string>
#include <utility>
#include "base/lazy_instance.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/speech/extension_api/tts_engine_extension_api.h"
#include "chrome/browser/speech/extension_api/tts_extension_api_constants.h"
#include "content/public/browser/tts_controller.h"
#include "content/public/browser/tts_platform.h"
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_function_registry.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/process_manager.h"
#include "third_party/blink/public/mojom/speech/speech_synthesis.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/speech/extension_api/tts_engine_extension_observer_chromeos.h"
#include "chrome/common/extensions/extension_constants.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/speech/tts_client_lacros.h"
#endif
constants;
#if BUILDFLAG(IS_CHROMEOS_ASH)
namespace {
enum class UMATextToSpeechSource {
kOther = 0,
kChromeVox = 1,
kSelectToSpeak = 2,
kMaxValue = kSelectToSpeak,
};
}
#endif
namespace events {
const char kOnEvent[] = …;
const char kOnVoicesChanged[] = …;
}
const char* TtsEventTypeToString(content::TtsEventType event_type) { … }
content::TtsEventType TtsEventTypeFromString(const std::string& str) { … }
namespace extensions {
class TtsExtensionEventHandler : public content::UtteranceEventDelegate { … };
TtsExtensionEventHandler::TtsExtensionEventHandler(
const std::string& src_extension_id)
: … { … }
void TtsExtensionEventHandler::OnTtsEvent(content::TtsUtterance* utterance,
content::TtsEventType event_type,
int char_index,
int length,
const std::string& error_message) { … }
ExtensionFunction::ResponseAction TtsSpeakFunction::Run() { … }
ExtensionFunction::ResponseAction TtsStopSpeakingFunction::Run() { … }
ExtensionFunction::ResponseAction TtsPauseFunction::Run() { … }
ExtensionFunction::ResponseAction TtsResumeFunction::Run() { … }
void TtsIsSpeakingFunction::OnIsSpeakingComplete(bool speaking) { … }
ExtensionFunction::ResponseAction TtsIsSpeakingFunction::Run() { … }
ExtensionFunction::ResponseAction TtsGetVoicesFunction::Run() { … }
TtsAPI::TtsAPI(content::BrowserContext* context) { … }
TtsAPI::~TtsAPI() { … }
static base::LazyInstance<
BrowserContextKeyedAPIFactory<TtsAPI>>::DestructorAtExit g_factory = …;
BrowserContextKeyedAPIFactory<TtsAPI>* TtsAPI::GetFactoryInstance() { … }
void TtsAPI::OnVoicesChanged() { … }
void TtsAPI::OnListenerAdded(const EventListenerInfo& details) { … }
void TtsAPI::OnListenerRemoved(const EventListenerInfo& details) { … }
void TtsAPI::StartOrStopListeningForVoicesChanged() { … }
}