chromium/content/browser/accessibility/browser_accessibility_state_impl.cc

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

#include "content/browser/accessibility/browser_accessibility_state_impl.h"

#include <stddef.h>

#include <utility>

#include "base/check.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/debug/crash_logging.h"
#include "base/functional/bind.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/scoped_accessibility_mode.h"
#include "content/public/common/content_switches.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/accessibility_switches.h"
#include "ui/accessibility/ax_mode_histogram_logger.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/events/base_event_utils.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"

namespace content {

namespace {

BrowserAccessibilityStateImpl* g_instance =;

// Auto-disable accessibility if this many seconds elapse with user input
// events but no accessibility API usage.
constexpr int kAutoDisableAccessibilityTimeSecs =;

// Minimum number of user input events with no accessibility API usage
// before auto-disabling accessibility.
constexpr int kAutoDisableAccessibilityEventCount =;

// Updating Active/Inactive time on every accessibility api calls would not be
// good for perf. Instead, delay the update task.
constexpr int kOnAccessibilityUsageUpdateDelaySecs =;

// How long to wait after `OnScreenReaderStopped` was called before actually
// disabling accessibility support. The main use case is when a screen reader
// or other client is toggled off and on in rapid succession. We don't want to
// destroy the full accessibility tree only to immediately recreate it because
// doing so is bad for performance.
constexpr int kDisableAccessibilitySupportDelaySecs =;

// Used for validating the 'basic' bundle parameter for
// --force-renderer-accessibility.
const char kAXModeBundleBasic[] =;

// Used for validating the 'form-controls' bundle parameter for
// --force-renderer-accessibility.
const char kAXModeBundleFormControls[] =;

// Update the accessibility histogram 45 seconds after initialization.
static const int ACCESSIBILITY_HISTOGRAM_DELAY_SECS =;

// A holder of a ScopedModeCollection targeting a specific BrowserContext or
// WebContents. The collection is bound to the lifetime of the target.
class ModeCollectionForTarget : public base::SupportsUserData::Data {};

// static
const int ModeCollectionForTarget::kUserDataKey;

// Returns a subset of `mode` for delivery to a WebContents.
ui::AXMode FilterAccessibilityModeInvariants(ui::AXMode mode) {}


}  // namespace

// static
BrowserAccessibilityState* BrowserAccessibilityState::GetInstance() {}

// static
BrowserAccessibilityStateImpl* BrowserAccessibilityStateImpl::GetInstance() {}

// On Android, Mac, Lacros, and Windows there are platform-specific subclasses.
#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_WIN) && !BUILDFLAG(IS_MAC) && \
    !BUILDFLAG(IS_CHROMEOS_LACROS)
// static
std::unique_ptr<BrowserAccessibilityStateImpl>
BrowserAccessibilityStateImpl::Create() {}
#endif

BrowserAccessibilityStateImpl::BrowserAccessibilityStateImpl()
    :{}

void BrowserAccessibilityStateImpl::InitBackgroundTasks() {}

BrowserAccessibilityStateImpl::~BrowserAccessibilityStateImpl() {}

void BrowserAccessibilityStateImpl::OnScreenReaderDetected() {}

void BrowserAccessibilityStateImpl::OnScreenReaderStopped() {}

void BrowserAccessibilityStateImpl::EnableAccessibility() {}

void BrowserAccessibilityStateImpl::DisableAccessibility() {}

bool BrowserAccessibilityStateImpl::IsRendererAccessibilityEnabled() {}

void BrowserAccessibilityStateImpl::MaybeResetAccessibilityMode() {}

void BrowserAccessibilityStateImpl::ResetAccessibilityMode() {}

bool BrowserAccessibilityStateImpl::IsAccessibleBrowser() {}

void BrowserAccessibilityStateImpl::AddUIThreadHistogramCallback(
    base::OnceClosure callback) {}

void BrowserAccessibilityStateImpl::AddOtherThreadHistogramCallback(
    base::OnceClosure callback) {}

void BrowserAccessibilityStateImpl::UpdateHistogramsForTesting() {}

void BrowserAccessibilityStateImpl::SetPerformanceFilteringAllowed(
    bool allowed) {}

bool BrowserAccessibilityStateImpl::IsPerformanceFilteringAllowed() {}

void BrowserAccessibilityStateImpl::UpdateHistogramsOnUIThread() {}

void BrowserAccessibilityStateImpl::UpdateHistogramsOnOtherThread() {}

void BrowserAccessibilityStateImpl::OnOtherThreadDone() {}

void BrowserAccessibilityStateImpl::UpdateAccessibilityActivityTask() {}

ui::AXMode BrowserAccessibilityStateImpl::GetAccessibilityMode() {}

ui::AXMode BrowserAccessibilityStateImpl::GetAccessibilityModeForBrowserContext(
    BrowserContext* browser_context) {}

void BrowserAccessibilityStateImpl::OnUserInputEvent() {}

void BrowserAccessibilityStateImpl::UpdateUniqueUserHistograms() {}

void BrowserAccessibilityStateImpl::SetAXModeChangeAllowed(bool allowed) {}

bool BrowserAccessibilityStateImpl::IsAXModeChangeAllowed() const {}

void BrowserAccessibilityStateImpl::AddAccessibilityModeFlags(ui::AXMode mode) {}

void BrowserAccessibilityStateImpl::RemoveAccessibilityModeFlags(
    ui::AXMode mode) {}

base::CallbackListSubscription
BrowserAccessibilityStateImpl::RegisterFocusChangedCallback(
    FocusChangedCallback callback) {}

// Returns the effective mode for the process, taking all process-wide scopers
// into account.
ui::AXMode BrowserAccessibilityStateImpl::GetProcessMode() {}

// Replaces the scoper that backs the legacy process-wide mode with one applying
// `new_mode`.
void BrowserAccessibilityStateImpl::SetProcessMode(ui::AXMode new_mode) {}

void BrowserAccessibilityStateImpl::OnAccessibilityApiUsage() {}

void BrowserAccessibilityStateImpl::OnInputEvent(
    const blink::WebInputEvent& event) {}

std::unique_ptr<ScopedAccessibilityMode>
BrowserAccessibilityStateImpl::CreateScopedModeForProcess(ui::AXMode mode) {}

void BrowserAccessibilityStateImpl::OnModeChangedForProcess(
    ui::AXMode old_mode,
    ui::AXMode new_mode) {}

std::unique_ptr<ScopedAccessibilityMode>
BrowserAccessibilityStateImpl::CreateScopedModeForBrowserContext(
    BrowserContext* browser_context,
    ui::AXMode mode) {}

void BrowserAccessibilityStateImpl::OnModeChangedForBrowserContext(
    BrowserContext* browser_context,
    ui::AXMode old_mode,
    ui::AXMode new_mode) {}

std::unique_ptr<ScopedAccessibilityMode>
BrowserAccessibilityStateImpl::CreateScopedModeForWebContents(
    WebContents* web_contents,
    ui::AXMode mode) {}

void BrowserAccessibilityStateImpl::OnModeChangedForWebContents(
    WebContents* web_contents,
    ui::AXMode old_mode,
    ui::AXMode new_mode) {}

void BrowserAccessibilityStateImpl::CallInitBackgroundTasksForTesting(
    base::RepeatingClosure done_callback) {}

void BrowserAccessibilityStateImpl::OnFocusChangedInPage(
    const FocusedNodeDetails& details) {}

}  // namespace content