#include "components/live_caption/live_caption_controller.h"
#include <memory>
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "build/build_config.h"
#include "components/live_caption/caption_bubble_context.h"
#include "components/live_caption/caption_bubble_controller.h"
#include "components/live_caption/caption_util.h"
#include "components/live_caption/pref_names.h"
#include "components/live_caption/views/caption_bubble.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/soda/constants.h"
#include "components/soda/soda_installer.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "media/base/media_switches.h"
#include "ui/native_theme/native_theme.h"
namespace {
const char* const kCaptionStylePrefsToObserve[] = …;
}
namespace captions {
LiveCaptionController::LiveCaptionController(
PrefService* profile_prefs,
PrefService* global_prefs,
const std::string& application_locale,
content::BrowserContext* browser_context)
: … { … }
LiveCaptionController::~LiveCaptionController() { … }
void LiveCaptionController::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
void LiveCaptionController::OnLiveCaptionEnabledChanged() { … }
void LiveCaptionController::OnLiveCaptionLanguageChanged() { … }
bool LiveCaptionController::IsLiveCaptionEnabled() { … }
void LiveCaptionController::StartLiveCaption() { … }
void LiveCaptionController::StopLiveCaption() { … }
void LiveCaptionController::OnSodaInstalled(
speech::LanguageCode language_code) { … }
void LiveCaptionController::OnSodaInstallError(
speech::LanguageCode language_code,
speech::SodaInstaller::ErrorCode error_code) { … }
void LiveCaptionController::CreateUI() { … }
void LiveCaptionController::DestroyUI() { … }
bool LiveCaptionController::DispatchTranscription(
CaptionBubbleContext* caption_bubble_context,
const media::SpeechRecognitionResult& result) { … }
void LiveCaptionController::OnError(
CaptionBubbleContext* caption_bubble_context,
CaptionBubbleErrorType error_type,
OnErrorClickedCallback error_clicked_callback,
OnDoNotShowAgainClickedCallback error_silenced_callback) { … }
void LiveCaptionController::OnAudioStreamEnd(
CaptionBubbleContext* caption_bubble_context) { … }
void LiveCaptionController::OnLanguageIdentificationEvent(
CaptionBubbleContext* caption_bubble_context,
const media::mojom::LanguageIdentificationEventPtr& event) { … }
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
void LiveCaptionController::OnToggleFullscreen(
CaptionBubbleContext* caption_bubble_context) {
if (!enabled_) {
return;
}
DestroyUI();
CreateUI();
}
#endif
void LiveCaptionController::OnCaptionStyleUpdated() { … }
}