#include "chrome/browser/accessibility/pdf_ocr_controller.h"
#include <vector>
#include "base/check_is_test.h"
#include "base/check_op.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/metrics_hashes.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "chrome/browser/accessibility/accessibility_state_utils.h"
#include "chrome/browser/pdf/pdf_viewer_stream_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/screen_ai/screen_ai_install_state.h"
#include "chrome/browser/screen_ai/screen_ai_service_router.h"
#include "chrome/browser/screen_ai/screen_ai_service_router_factory.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/grit/generated_resources.h"
#include "components/language/core/browser/pref_names.h"
#include "components/language/core/common/language_util.h"
#include "components/pdf/common/pdf_util.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_iterator.h"
#include "content/public/browser/scoped_accessibility_mode.h"
#include "content/public/browser/web_contents.h"
#include "pdf/pdf_features.h"
#include "ui/accessibility/accessibility_features.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/accessibility/accessibility_manager.h"
#endif
namespace {
constexpr uint32_t kMaxInitializationRetry = …;
constexpr base::TimeDelta kRetryDelay = …;
std::vector<content::WebContents*> GetAllPdfWebContents(Profile* profile) { … }
bool IsAccessibilityEnabled(Profile* profile) { … }
void RecordAcceptLanguages(const std::string& accept_languages) { … }
}
namespace screen_ai {
PdfOcrController::PdfOcrController(Profile* profile)
: … { … }
PdfOcrController::~PdfOcrController() = default;
std::vector<content::WebContents*>
PdfOcrController::GetAllPdfWebContentsForTesting(Profile* profile) { … }
bool PdfOcrController::IsEnabled() const { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
void PdfOcrController::OnAccessibilityStatusEvent(
const ash::AccessibilityStatusEventDetails& details) {
if (details.notification_type ==
ash::AccessibilityNotificationType::kToggleSpokenFeedback ||
details.notification_type ==
ash::AccessibilityNotificationType::kToggleSelectToSpeak) {
OnActivationChanged();
}
}
#endif
void PdfOcrController::OnActivationChanged() { … }
void PdfOcrController::InitializeService() { … }
void PdfOcrController::OCRServiceInitializationCallback(bool successful) { … }
void PdfOcrController::Activate() { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void PdfOcrController::OnAXModeAdded(ui::AXMode mode) { … }
#endif
}