chromium/chrome/browser/accessibility/pdf_ocr_controller.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 =;

// Returns all WebContents with PDF content associated with a given Profile.
// When a PDF is opened in GuestView PDF Viewer, the following structure is
// expected:
// -----------------------------------------
// WebContents A:
//  Primary main frame
//   WebContents B (inner PDF WebContents):
//    PDF extension frame
//     PDF content frame (renderer)
// -----------------------------------------
// On the other hand, OOPIF PDF Viewer doesn't create an inner WebContents.
// When a PDF is opened in OOPIF PDF Viewer, the following structure is
// expected:
// -----------------------------------------
// WebContents A:
//  Primary main frame
//   PDF extension frame
//    PDF content frame (renderer)
// -----------------------------------------
std::vector<content::WebContents*> GetAllPdfWebContents(Profile* profile) {}

// Returns true if a screen reader is present, if the screen reader AXMode is
// enabled on any PDF web contents, or (on Chrome OS only) if select-to-speak is
// enabled.
bool IsAccessibilityEnabled(Profile* profile) {}

void RecordAcceptLanguages(const std::string& accept_languages) {}

}  // namespace

namespace screen_ai {

PdfOcrController::PdfOcrController(Profile* profile)
    :{}

PdfOcrController::~PdfOcrController() = default;

// static
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  // BUIDLFLAG(IS_CHROMEOS_ASH)

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  // !BUILDFLAG(IS_CHROMEOS_ASH)

}  // namespace screen_ai