chromium/chrome/browser/ui/webui/accessibility/accessibility_ui.cc

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

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/40285824): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "chrome/browser/ui/webui/accessibility/accessibility_ui.h"

#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>

#include "base/command_line.h"
#include "base/containers/fixed_flat_map.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/json/json_writer.h"
#include "base/notreached.h"
#include "base/strings/escape.h"
#include "base/strings/pattern.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/accessibility_resources.h"
#include "chrome/grit/accessibility_resources_map.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/ax_inspect_factory.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/render_process_host.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 "content/public/browser/web_contents_delegate.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/ax_updates_and_events.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
#include "ui/accessibility/platform/inspect/ax_tree_formatter.h"
#include "ui/base/webui/web_ui_util.h"
#include "ui/views/accessibility/view_accessibility.h"

#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "ui/views/accessibility/widget_ax_tree_id_map.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#endif

static const char kTargetsDataFile[] =;

static const char kAccessibilityModeField[] =;
static const char kBrowsersField[] =;
static const char kEnabledField[] =;
static const char kErrorField[] =;
static const char kEventLogsField[] =;
static const char kFaviconUrlField[] =;
static const char kFlagNameField[] =;
static const char kStringNameField[] =;
static const char kModeIdField[] =;
static const char kNameField[] =;
static const char kPagesField[] =;
static const char kPidField[] =;
static const char kProcessIdField[] =;
static const char kRequestTypeField[] =;
static const char kRoutingIdField[] =;
static const char kSessionIdField[] =;
static const char kShouldRequestTreeField[] =;
static const char kSupportedApiTypesField[] =;
static const char kStartField[] =;
static const char kTreeField[] =;
static const char kTypeField[] =;
static const char kUrlField[] =;
static const char kValueField[] =;
static const char kWidgetsField[] =;
static const char kApiTypeField[] =;

#if defined(USE_AURA) && !BUILDFLAG(IS_CHROMEOS_ASH)
static const char kWidgetIdField[] =;
static const char kWidget[] =;
#endif

// Global flags
static const char kBrowser[] =;
static const char kCopyTree[] =;
static const char kHTML[] =;
static const char kLocked[] =;
static const char kNative[] =;
static const char kPage[] =;
static const char kPDFPrinting[] =;
static const char kScreenReader[] =;
static const char kShowOrRefreshTree[] =;
static const char kText[] =;
static const char kViewsAccessibility[] =;
static const char kWeb[] =;

// Possible global flag values
static const char kDisabled[] =;
static const char kOff[] =;
static const char kOn[] =;

AXPropertyFilter;

namespace {

base::Value::Dict BuildTargetDescriptor(
    const GURL& url,
    const std::string& name,
    const GURL& favicon_url,
    int process_id,
    int routing_id,
    ui::AXMode accessibility_mode,
    base::ProcessHandle handle = base::kNullProcessHandle) {}

base::Value::Dict BuildTargetDescriptor(content::RenderViewHost* rvh) {}

#if !BUILDFLAG(IS_ANDROID)
base::Value::Dict BuildTargetDescriptor(Browser* browser) {}
#endif  // !BUILDFLAG(IS_ANDROID)

#if defined(USE_AURA) && !BUILDFLAG(IS_CHROMEOS_ASH)
base::Value::Dict BuildTargetDescriptor(views::Widget* widget) {}
#endif  // defined(USE_AURA) && !BUILDFLAG(IS_CHROMEOS_ASH)

bool ShouldHandleAccessibilityRequestCallback(const std::string& path) {}

void HandleAccessibilityRequestCallback(
    content::BrowserContext* current_context,
    const std::string& path,
    content::WebUIDataSource::GotDataCallback callback) {}

std::string RecursiveDumpAXPlatformNodeAsString(
    ui::AXPlatformNode* node,
    int indent,
    const std::vector<AXPropertyFilter>& property_filters) {}

// Add property filters to the property_filters vector for the given property
// filter type. The attributes are passed in as a string with each attribute
// separated by a space.
void AddPropertyFilters(std::vector<AXPropertyFilter>& property_filters,
                        const std::string& attributes,
                        AXPropertyFilter::Type type) {}

bool IsValidJSValue(const std::string* str) {}

const std::string& CheckJSValue(const std::string* str) {}

}  // namespace

AccessibilityUIConfig::AccessibilityUIConfig()
    :{}

AccessibilityUIConfig::~AccessibilityUIConfig() = default;

AccessibilityUI::AccessibilityUI(content::WebUI* web_ui)
    :{}

AccessibilityUI::~AccessibilityUI() = default;

AccessibilityUIObserver::AccessibilityUIObserver(
    content::WebContents* web_contents,
    std::vector<std::string>* event_logs)
    :{}

AccessibilityUIObserver::~AccessibilityUIObserver() = default;

void AccessibilityUIObserver::AccessibilityEventReceived(
    const ui::AXUpdatesAndEvents& details) {}

AccessibilityUIMessageHandler::PageAccessibilityMode::PageAccessibilityMode(
    base::WeakPtr<content::WebContents> web_contents,
    std::unique_ptr<content::ScopedAccessibilityMode> accessibility_mode)
    :{}

AccessibilityUIMessageHandler::PageAccessibilityMode::PageAccessibilityMode(
    PageAccessibilityMode&& other) noexcept = default;

AccessibilityUIMessageHandler::PageAccessibilityMode::~PageAccessibilityMode() =
    default;

AccessibilityUIMessageHandler::AccessibilityUIMessageHandler()
    :{}

AccessibilityUIMessageHandler::~AccessibilityUIMessageHandler() {}

void AccessibilityUIMessageHandler::RegisterMessages() {}

void AccessibilityUIMessageHandler::SetAccessibilityModeForWebContents(
    content::WebContents* web_contents,
    ui::AXMode mode) {}

void AccessibilityUIMessageHandler::ToggleAccessibilityForWebContents(
    const base::Value::List& args) {}

void AccessibilityUIMessageHandler::SetGlobalFlag(
    const base::Value::List& args) {}

void AccessibilityUIMessageHandler::SetGlobalString(
    const base::Value::List& args) {}

void AccessibilityUIMessageHandler::GetRequestTypeAndFilters(
    const base::Value::Dict& data,
    std::string& request_type,
    std::string& allow,
    std::string& allow_empty,
    std::string& deny) {}

void AccessibilityUIMessageHandler::RequestWebContentsTree(
    const base::Value::List& args) {}

void AccessibilityUIMessageHandler::RequestNativeUITree(
    const base::Value::List& args) {}

void AccessibilityUIMessageHandler::RequestWidgetsTree(
    const base::Value::List& args) {}

void AccessibilityUIMessageHandler::Callback(const std::string& str) {}

void AccessibilityUIMessageHandler::StopRecording(
    content::WebContents* web_contents) {}

ui::AXApiType::Type AccessibilityUIMessageHandler::GetRecordingApiType() {}

void AccessibilityUIMessageHandler::RequestAccessibilityEvents(
    const base::Value::List& args) {}

// static
void AccessibilityUIMessageHandler::RegisterProfilePrefs(
    user_prefs::PrefRegistrySyncable* registry) {}