Commit f258c7a7 authored by James Cook's avatar James Cook Committed by Commit Bot

Mash cleanup: Remove accessibility AXHost service, part 2

This removes the implementation of the mojom::AXHost interface and the
interface itself.

TBR=rmrossi@chromium.org

Bug: 958187
Change-Id: I68f9eec4e7004a623579f90bf22bdc7e7e9473f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1592847Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarDavid Tseng <dtseng@chromium.org>
Auto-Submit: James Cook <jamescook@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656386}
parent d6996900
...@@ -466,7 +466,6 @@ source_set("chrome_content_browser_overlay_manifest") { ...@@ -466,7 +466,6 @@ source_set("chrome_content_browser_overlay_manifest") {
"//chromeos/services/multidevice_setup/public/mojom", "//chromeos/services/multidevice_setup/public/mojom",
"//chromeos/services/network_config/public/mojom", "//chromeos/services/network_config/public/mojom",
"//media/capture/video/chromeos/mojo:cros_camera", "//media/capture/video/chromeos/mojo:cros_camera",
"//ui/accessibility/mojom",
] ]
if (enable_cros_assistant) { if (enable_cros_assistant) {
...@@ -626,7 +625,6 @@ source_set("chrome_packaged_service_manifests") { ...@@ -626,7 +625,6 @@ source_set("chrome_packaged_service_manifests") {
"//chromeos/services/network_config/public/cpp:manifest", "//chromeos/services/network_config/public/cpp:manifest",
"//chromeos/services/secure_channel/public/cpp:manifest", "//chromeos/services/secure_channel/public/cpp:manifest",
"//services/ws/public/mojom/input_devices", "//services/ws/public/mojom/input_devices",
"//ui/accessibility:ax_host_manifest",
] ]
} }
......
...@@ -60,7 +60,6 @@ ...@@ -60,7 +60,6 @@
#include "media/capture/video/chromeos/mojo/cros_image_capture.mojom.h" #include "media/capture/video/chromeos/mojo/cros_image_capture.mojom.h"
#include "services/ws/common/switches.h" #include "services/ws/common/switches.h"
#include "services/ws/public/mojom/constants.mojom.h" #include "services/ws/public/mojom/constants.mojom.h"
#include "ui/accessibility/mojom/ax_host.mojom.h" // nogncheck
#if BUILDFLAG(ENABLE_CROS_ASSISTANT) #if BUILDFLAG(ENABLE_CROS_ASSISTANT)
#include "chromeos/services/assistant/public/cpp/manifest.h" // nogncheck #include "chromeos/services/assistant/public/cpp/manifest.h" // nogncheck
#endif #endif
...@@ -119,11 +118,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() { ...@@ -119,11 +118,6 @@ const service_manager::Manifest& GetChromeContentBrowserOverlayManifest() {
.ExposeCapability("gpu", .ExposeCapability("gpu",
service_manager::Manifest::InterfaceList< service_manager::Manifest::InterfaceList<
metrics::mojom::CallStackProfileCollector>()) metrics::mojom::CallStackProfileCollector>())
#if defined(OS_CHROMEOS)
.ExposeCapability(
"app",
service_manager::Manifest::InterfaceList<ax::mojom::AXHost>())
#endif
.ExposeCapability("profiling_client", .ExposeCapability("profiling_client",
service_manager::Manifest::InterfaceList< service_manager::Manifest::InterfaceList<
heap_profiling::mojom::ProfilingClient>()) heap_profiling::mojom::ProfilingClient>())
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "chromeos/services/network_config/public/cpp/manifest.h" #include "chromeos/services/network_config/public/cpp/manifest.h"
#include "chromeos/services/secure_channel/public/cpp/manifest.h" #include "chromeos/services/secure_channel/public/cpp/manifest.h"
#include "services/ws/public/mojom/input_devices/input_device_controller.mojom.h" #include "services/ws/public/mojom/input_devices/input_device_controller.mojom.h"
#include "ui/accessibility/ax_host_manifest.h" // nogncheck
#endif #endif
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
...@@ -174,7 +173,6 @@ GetChromePackagedServiceManifests() { ...@@ -174,7 +173,6 @@ GetChromePackagedServiceManifests() {
chromeos::ime::GetManifest(), chromeos::ime::GetManifest(),
chromeos::network_config::GetManifest(), chromeos::network_config::GetManifest(),
chromeos::secure_channel::GetManifest(), chromeos::secure_channel::GetManifest(),
ui::GetAXHostManifest(),
#endif #endif
}}; }};
return *manifests; return *manifests;
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h" #include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/browser/chromeos/accessibility/ax_host_service.h"
#include "chrome/browser/chromeos/prefs/pref_connector_service.h" #include "chrome/browser/chromeos/prefs/pref_connector_service.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "content/public/common/service_manager_connection.h" #include "content/public/common/service_manager_connection.h"
...@@ -69,8 +68,6 @@ std::unique_ptr<service_manager::Service> HandleServiceRequest( ...@@ -69,8 +68,6 @@ std::unique_ptr<service_manager::Service> HandleServiceRequest(
} }
if (service_name == ash::mojom::kPrefConnectorServiceName) if (service_name == ash::mojom::kPrefConnectorServiceName)
return std::make_unique<AshPrefConnector>(std::move(request)); return std::make_unique<AshPrefConnector>(std::move(request));
if (service_name == ax::mojom::kAXHostServiceName)
return std::make_unique<AXHostService>(std::move(request));
return nullptr; return nullptr;
} }
......
...@@ -306,10 +306,6 @@ source_set("chromeos") { ...@@ -306,10 +306,6 @@ source_set("chromeos") {
"accessibility/accessibility_manager.h", "accessibility/accessibility_manager.h",
"accessibility/accessibility_panel.cc", "accessibility/accessibility_panel.cc",
"accessibility/accessibility_panel.h", "accessibility/accessibility_panel.h",
"accessibility/ax_host_service.cc",
"accessibility/ax_host_service.h",
"accessibility/ax_remote_host_delegate.cc",
"accessibility/ax_remote_host_delegate.h",
"accessibility/chromevox_panel.cc", "accessibility/chromevox_panel.cc",
"accessibility/chromevox_panel.h", "accessibility/chromevox_panel.h",
"accessibility/dictation_chromeos.cc", "accessibility/dictation_chromeos.cc",
...@@ -2232,7 +2228,6 @@ source_set("unit_tests") { ...@@ -2232,7 +2228,6 @@ source_set("unit_tests") {
"../policy/default_geolocation_policy_handler_unittest.cc", "../policy/default_geolocation_policy_handler_unittest.cc",
"../resources/chromeos/zip_archiver/test/char_coding_test.cc", "../resources/chromeos/zip_archiver/test/char_coding_test.cc",
"../ui/browser_finder_chromeos_unittest.cc", "../ui/browser_finder_chromeos_unittest.cc",
"accessibility/ax_host_service_unittest.cc",
"accessibility/switch_access_panel_unittest.cc", "accessibility/switch_access_panel_unittest.cc",
"account_manager/account_migration_runner_unittest.cc", "account_manager/account_migration_runner_unittest.cc",
"android_sms/android_sms_app_manager_impl_unittest.cc", "android_sms/android_sms_app_manager_impl_unittest.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/accessibility/ax_host_service.h"
#include <utility>
#include "base/bind.h"
#include "base/stl_util.h"
#include "chrome/browser/chromeos/accessibility/ax_remote_host_delegate.h"
#include "ui/accessibility/ax_tree_id.h"
AXHostService* AXHostService::instance_ = nullptr;
bool AXHostService::automation_enabled_ = false;
AXHostService::AXHostService(service_manager::mojom::ServiceRequest request)
: service_binding_(this, std::move(request)) {
DCHECK(!instance_);
instance_ = this;
registry_.AddInterface<ax::mojom::AXHost>(
base::BindRepeating(&AXHostService::AddBinding, base::Unretained(this)));
}
AXHostService::~AXHostService() {
DCHECK_EQ(instance_, this);
instance_ = nullptr;
}
// static
void AXHostService::SetAutomationEnabled(bool enabled) {
automation_enabled_ = enabled;
if (instance_)
instance_->NotifyAutomationEnabled();
}
void AXHostService::OnBindInterface(
const service_manager::BindSourceInfo& remote_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
registry_.BindInterface(interface_name, std::move(interface_pipe));
}
void AXHostService::RegisterRemoteHost(
ax::mojom::AXRemoteHostPtr remote_host_ptr,
RegisterRemoteHostCallback cb) {
// Create the AXRemoteHostDelegate first so a tree ID will be assigned.
auto remote_host_delegate =
std::make_unique<AXRemoteHostDelegate>(this, std::move(remote_host_ptr));
ui::AXTreeID tree_id = remote_host_delegate->ax_tree_id();
DCHECK_NE(ui::AXTreeIDUnknown(), tree_id);
DCHECK(!base::ContainsKey(remote_host_delegate_map_, tree_id));
remote_host_delegate_map_[tree_id] = std::move(remote_host_delegate);
// Inform the remote process of the tree ID.
std::move(cb).Run(tree_id, automation_enabled_);
}
void AXHostService::HandleAccessibilityEvent(
const ui::AXTreeID& tree_id,
const std::vector<ui::AXTreeUpdate>& updates,
const ui::AXEvent& event) {
auto it = remote_host_delegate_map_.find(tree_id);
if (it == remote_host_delegate_map_.end())
return;
AXRemoteHostDelegate* delegate = it->second.get();
delegate->HandleAccessibilityEvent(tree_id, updates, event);
}
void AXHostService::OnRemoteHostDisconnected(const ui::AXTreeID& tree_id) {
// AXRemoteHostDelegate notified the extension that the tree was destroyed.
// Delete the AXRemoteHostDelegate.
remote_host_delegate_map_.erase(tree_id);
}
void AXHostService::FlushForTesting() {
for (const auto& pair : remote_host_delegate_map_) {
AXRemoteHostDelegate* delegate = pair.second.get();
delegate->FlushForTesting();
}
}
void AXHostService::AddBinding(ax::mojom::AXHostRequest request) {
bindings_.AddBinding(this, std::move(request));
}
void AXHostService::NotifyAutomationEnabled() {
for (const auto& pair : remote_host_delegate_map_) {
AXRemoteHostDelegate* delegate = pair.second.get();
delegate->OnAutomationEnabled(automation_enabled_);
}
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_AX_HOST_SERVICE_H_
#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_AX_HOST_SERVICE_H_
#include <map>
#include <memory>
#include "mojo/public/cpp/bindings/binding_set.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service.h"
#include "services/service_manager/public/cpp/service_binding.h"
#include "services/service_manager/public/mojom/service.mojom.h"
#include "ui/accessibility/mojom/ax_host.mojom.h"
class AXRemoteHostDelegate;
// Manages a set of remote processes that use aura and views. Renderers such as
// web content, PDF, etc. use a different path. Created when the first client
// connects over mojo.
class AXHostService : public service_manager::Service,
public ax::mojom::AXHost {
public:
explicit AXHostService(service_manager::mojom::ServiceRequest request);
~AXHostService() override;
// Requests AX node trees from remote clients and starts listening for remote
// AX events. Static because the mojo service_manager creates and owns the
// service object, but automation may be enabled before a client connects and
// the service starts.
static void SetAutomationEnabled(bool enabled);
// service_manager::Service:
void OnBindInterface(const service_manager::BindSourceInfo& source_info,
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) override;
// ax::mojom::AXHost:
void RegisterRemoteHost(ax::mojom::AXRemoteHostPtr remote_host_ptr,
RegisterRemoteHostCallback cb) override;
void HandleAccessibilityEvent(const ui::AXTreeID& tree_id,
const std::vector<ui::AXTreeUpdate>& updates,
const ui::AXEvent& event) override;
// Cleans up after a remote host disconnects.
void OnRemoteHostDisconnected(const ui::AXTreeID& tree_id);
void FlushForTesting();
private:
void AddBinding(ax::mojom::AXHostRequest request);
// Notifies all remote trees of automation enabled state.
void NotifyAutomationEnabled();
static AXHostService* instance_;
static bool automation_enabled_;
service_manager::ServiceBinding service_binding_;
service_manager::BinderRegistry registry_;
mojo::BindingSet<ax::mojom::AXHost> bindings_;
// Map from a child tree id to the remote host responsible for that tree.
std::map<ui::AXTreeID, std::unique_ptr<AXRemoteHostDelegate>>
remote_host_delegate_map_;
DISALLOW_COPY_AND_ASSIGN(AXHostService);
};
#endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_AX_HOST_SERVICE_H_
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/accessibility/ax_host_service.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/test/scoped_task_environment.h"
#include "chrome/browser/chromeos/accessibility/ax_remote_host_delegate.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_tree_id_registry.h"
#include "ui/accessibility/mojom/ax_host.mojom.h"
namespace {
class TestAXRemoteHost : ax::mojom::AXRemoteHost {
public:
TestAXRemoteHost() : binding_(this) {}
~TestAXRemoteHost() override = default;
ax::mojom::AXRemoteHostPtr CreateInterfacePtr() {
ax::mojom::AXRemoteHostPtr ptr;
binding_.Bind(mojo::MakeRequest(&ptr));
return ptr;
}
// Simulates the real AXRemoteHost.
void RegisterRemoteHostCallback(const ui::AXTreeID& tree_id, bool enabled) {
tree_id_ = tree_id;
OnAutomationEnabled(enabled);
}
// ax::mojom::AXRemoteHost:
void OnAutomationEnabled(bool enabled) override {
++automation_enabled_count_;
last_automation_enabled_ = enabled;
}
void PerformAction(const ui::AXActionData& action) override {
++perform_action_count_;
last_action_ = action;
}
mojo::Binding<ax::mojom::AXRemoteHost> binding_;
ui::AXTreeID tree_id_;
int automation_enabled_count_ = 0;
bool last_automation_enabled_ = false;
int perform_action_count_ = 0;
ui::AXActionData last_action_;
private:
DISALLOW_COPY_AND_ASSIGN(TestAXRemoteHost);
};
class AXHostServiceTest : public testing::Test {
public:
AXHostServiceTest() = default;
~AXHostServiceTest() override = default;
void RegisterRemoteHost(AXHostService* service, TestAXRemoteHost* remote) {
service->RegisterRemoteHost(
remote->CreateInterfacePtr(),
base::BindOnce(&TestAXRemoteHost::RegisterRemoteHostCallback,
base::Unretained(remote)));
service->FlushForTesting();
}
private:
base::test::ScopedTaskEnvironment scoped_task_enviroment_;
DISALLOW_COPY_AND_ASSIGN(AXHostServiceTest);
};
TEST_F(AXHostServiceTest, AddClientThenEnable) {
AXHostService service(nullptr);
TestAXRemoteHost remote;
RegisterRemoteHost(&service, &remote);
// Remote received initial state.
EXPECT_EQ(1, remote.automation_enabled_count_);
EXPECT_FALSE(remote.last_automation_enabled_);
// AXHostService assigned a tree id.
ui::AXTreeID tree_id = remote.tree_id_;
EXPECT_NE(ui::AXTreeIDUnknown(), tree_id);
AXHostService::SetAutomationEnabled(true);
service.FlushForTesting();
// Remote received updated state.
EXPECT_EQ(2, remote.automation_enabled_count_);
EXPECT_TRUE(remote.last_automation_enabled_);
}
TEST_F(AXHostServiceTest, EnableThenAddClient) {
AXHostService service(nullptr);
AXHostService::SetAutomationEnabled(true);
TestAXRemoteHost remote;
RegisterRemoteHost(&service, &remote);
// Remote received initial state.
EXPECT_EQ(1, remote.automation_enabled_count_);
EXPECT_TRUE(remote.last_automation_enabled_);
// AXHostService assigned a tree id.
EXPECT_NE(ui::AXTreeIDUnknown(), remote.tree_id_);
}
TEST_F(AXHostServiceTest, PerformAction) {
AXHostService service(nullptr);
AXHostService::SetAutomationEnabled(true);
TestAXRemoteHost remote;
RegisterRemoteHost(&service, &remote);
// AXActionHandler was created.
ui::AXTreeID tree_id = remote.tree_id_;
ui::AXActionHandler* action_handler =
ui::AXTreeIDRegistry::GetInstance()->GetActionHandler(tree_id);
ASSERT_TRUE(action_handler);
// Trigger an action.
ui::AXActionData action;
action.action = ax::mojom::Action::kScrollUp;
action_handler->PerformAction(action);
service.FlushForTesting();
// Remote interface received the action.
EXPECT_EQ(1, remote.perform_action_count_);
EXPECT_EQ(ax::mojom::Action::kScrollUp, remote.last_action_.action);
}
TEST_F(AXHostServiceTest, MultipleRemoteHosts) {
AXHostService service(nullptr);
AXHostService::SetAutomationEnabled(true);
// Connect 2 remote hosts.
TestAXRemoteHost remote1;
RegisterRemoteHost(&service, &remote1);
TestAXRemoteHost remote2;
RegisterRemoteHost(&service, &remote2);
// Different tree ids were assigned.
EXPECT_NE(ui::AXTreeIDUnknown(), remote1.tree_id_);
EXPECT_NE(ui::AXTreeIDUnknown(), remote2.tree_id_);
EXPECT_NE(remote1.tree_id_, remote2.tree_id_);
// Trigger an action on the first remote.
ui::AXActionData action;
action.action = ax::mojom::Action::kScrollUp;
ui::AXActionHandler* action_handler =
ui::AXTreeIDRegistry::GetInstance()->GetActionHandler(remote1.tree_id_);
action_handler->PerformAction(action);
service.FlushForTesting();
// Remote 1 received the action.
EXPECT_EQ(1, remote1.perform_action_count_);
EXPECT_EQ(ax::mojom::Action::kScrollUp, remote1.last_action_.action);
// Remote 2 did not receive the action.
EXPECT_EQ(0, remote2.perform_action_count_);
}
TEST_F(AXHostServiceTest, RemoteHostDisconnect) {
AXHostService service(nullptr);
AXHostService::SetAutomationEnabled(true);
// Connect 2 remote hosts.
TestAXRemoteHost remote1;
RegisterRemoteHost(&service, &remote1);
TestAXRemoteHost remote2;
RegisterRemoteHost(&service, &remote2);
// Tree IDs exist for both.
auto* tree_id_registry = ui::AXTreeIDRegistry::GetInstance();
EXPECT_TRUE(tree_id_registry->GetActionHandler(remote1.tree_id_));
EXPECT_TRUE(tree_id_registry->GetActionHandler(remote2.tree_id_));
// Simulate remote 1 disconnecting.
service.OnRemoteHostDisconnected(remote1.tree_id_);
// Tree ID for remote 1 is gone.
EXPECT_FALSE(tree_id_registry->GetActionHandler(remote1.tree_id_));
EXPECT_TRUE(tree_id_registry->GetActionHandler(remote2.tree_id_));
}
} // namespace
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/accessibility/ax_remote_host_delegate.h"
#include "base/bind.h"
#include "chrome/browser/chromeos/accessibility/ax_host_service.h"
#include "chrome/common/extensions/chrome_extension_messages.h"
#include "extensions/browser/api/automation_internal/automation_event_router.h"
#include "ui/accessibility/ax_event.h"
#include "ui/accessibility/ax_tree_update.h"
#include "ui/aura/env.h"
AXRemoteHostDelegate::AXRemoteHostDelegate(AXHostService* host_service,
ax::mojom::AXRemoteHostPtr ptr)
: host_service_(host_service), remote_host_ptr_(std::move(ptr)) {
DCHECK(host_service_);
DCHECK(remote_host_ptr_);
// AX tree ID is automatically assigned.
DCHECK_NE(ax_tree_id(), ui::AXTreeIDUnknown());
// Handle both clean and unclean shutdown of the remote app.
remote_host_ptr_.set_connection_error_handler(base::BindOnce(
&AXRemoteHostDelegate::OnRemoteHostDisconnected, base::Unretained(this)));
}
AXRemoteHostDelegate::~AXRemoteHostDelegate() = default;
void AXRemoteHostDelegate::OnAutomationEnabled(bool enabled) {
remote_host_ptr_->OnAutomationEnabled(enabled);
}
void AXRemoteHostDelegate::HandleAccessibilityEvent(
const ui::AXTreeID& tree_id,
const std::vector<ui::AXTreeUpdate>& updates,
const ui::AXEvent& event) {
CHECK_EQ(tree_id, ax_tree_id());
ExtensionMsg_AccessibilityEventBundleParams event_bundle;
event_bundle.tree_id = tree_id;
for (const ui::AXTreeUpdate& update : updates)
event_bundle.updates.push_back(update);
event_bundle.events.push_back(event);
event_bundle.mouse_location = aura::Env::GetInstance()->last_mouse_location();
// Forward the tree updates and the event to the accessibility extension.
extensions::AutomationEventRouter::GetInstance()->DispatchAccessibilityEvents(
event_bundle);
}
void AXRemoteHostDelegate::PerformAction(const ui::AXActionData& data) {
// Send to remote host.
remote_host_ptr_->PerformAction(data);
}
void AXRemoteHostDelegate::FlushForTesting() {
remote_host_ptr_.FlushForTesting();
}
void AXRemoteHostDelegate::OnRemoteHostDisconnected() {
extensions::AutomationEventRouter::GetInstance()->DispatchTreeDestroyedEvent(
ax_tree_id(), nullptr /* browser_context */);
host_service_->OnRemoteHostDisconnected(ax_tree_id());
// This object is now deleted.
}
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_AX_REMOTE_HOST_DELEGATE_H_
#define CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_AX_REMOTE_HOST_DELEGATE_H_
#include <vector>
#include "mojo/public/cpp/bindings/interface_ptr.h"
#include "ui/accessibility/ax_action_handler.h"
#include "ui/accessibility/ax_tree_update.h"
#include "ui/accessibility/mojom/ax_host.mojom.h"
namespace ui {
struct AXEvent;
class AXTreeID;
} // namespace ui
class AXHostService;
// Forwards accessibility events from a remote process that uses aura and views
// (e.g. the Chrome OS keyboard shortcut_viewer) to accessibility extensions.
// Renderers, PDF, etc. use a different path. Created when the app connects over
// mojo. Implements AXActionHandler to route actions over mojo to the remote
// process.
// TODO(jamescook): Rename to AXRemoteActionHandler.
class AXRemoteHostDelegate : public ui::AXActionHandler {
public:
// |host_service| owns this object. |remote_host_ptr| is the mojo interface
// for the remote app.
AXRemoteHostDelegate(AXHostService* host_service,
ax::mojom::AXRemoteHostPtr remote_host_ptr);
~AXRemoteHostDelegate() override;
// Requests AX node trees from remote clients and starts listening for remote
// AX events. Static because the mojo service_manager creates and owns the
// service object, but automation may be enabled before a client connects and
// the service starts.
void OnAutomationEnabled(bool enabled);
// Handles an accessibility event from a remote host.
void HandleAccessibilityEvent(const ui::AXTreeID& tree_id,
const std::vector<ui::AXTreeUpdate>& updates,
const ui::AXEvent& event);
// ui::AXActionHandler:
void PerformAction(const ui::AXActionData& data) override;
void FlushForTesting();
private:
// Cleans up the extension's AX tree when the remote app disconnects.
void OnRemoteHostDisconnected();
// The owning AXHostService.
AXHostService* host_service_;
// Connection to the remote host.
mojo::InterfacePtr<ax::mojom::AXRemoteHost> remote_host_ptr_;
DISALLOW_COPY_AND_ASSIGN(AXRemoteHostDelegate);
};
#endif // CHROME_BROWSER_CHROMEOS_ACCESSIBILITY_AX_REMOTE_HOST_DELEGATE_H_
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/wm/window_util.h" #include "ash/wm/window_util.h"
#include "chrome/browser/chromeos/accessibility/ax_host_service.h"
#include "ui/base/ui_base_features.h" #include "ui/base/ui_base_features.h"
#endif #endif
...@@ -71,18 +70,12 @@ void AutomationManagerAura::Enable() { ...@@ -71,18 +70,12 @@ void AutomationManagerAura::Enable() {
SendEvent(focus, ax::mojom::Event::kChildrenChanged); SendEvent(focus, ax::mojom::Event::kChildrenChanged);
} }
} }
// Gain access to out-of-process native windows.
AXHostService::SetAutomationEnabled(true);
#endif #endif
} }
void AutomationManagerAura::Disable() { void AutomationManagerAura::Disable() {
enabled_ = false; enabled_ = false;
Reset(true); Reset(true);
#if defined(OS_CHROMEOS)
AXHostService::SetAutomationEnabled(false);
#endif
} }
void AutomationManagerAura::OnViewEvent(views::View* view, void AutomationManagerAura::OnViewEvent(views::View* view,
......
...@@ -61,10 +61,6 @@ void AutomationManagerAura::Enable() { ...@@ -61,10 +61,6 @@ void AutomationManagerAura::Enable() {
void AutomationManagerAura::Disable() { void AutomationManagerAura::Disable() {
enabled_ = false; enabled_ = false;
Reset(true); Reset(true);
#if defined(OS_CHROMEOS)
AXHostService::SetAutomationEnabled(false);
#endif
} }
void AutomationManagerAura::OnViewEvent(views::View* view, void AutomationManagerAura::OnViewEvent(views::View* view,
......
...@@ -325,16 +325,3 @@ fuzzer_test("ax_table_fuzzer") { ...@@ -325,16 +325,3 @@ fuzzer_test("ax_table_fuzzer") {
seed_corpus = "fuzz_corpus" seed_corpus = "fuzz_corpus"
} }
source_set("ax_host_manifest") {
sources = [
"ax_host_manifest.cc",
"ax_host_manifest.h",
]
deps = [
"//base",
"//services/service_manager/public/cpp",
"//ui/accessibility/mojom",
]
}
...@@ -9,10 +9,5 @@ katie@chromium.org ...@@ -9,10 +9,5 @@ katie@chromium.org
per-file *.mojom=set noparent per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file ax_host_manifest.cc=set noparent
per-file ax_host_manifest.cc=file://ipc/SECURITY_OWNERS
per-file ax_host_manifest.h=set noparent
per-file ax_host_manifest.h=file://ipc/SECURITY_OWNERS
# TEAM: chromium-accessibility@chromium.org # TEAM: chromium-accessibility@chromium.org
# COMPONENT: Internals>Accessibility # COMPONENT: Internals>Accessibility
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/accessibility/ax_host_manifest.h"
#include "base/no_destructor.h"
#include "services/service_manager/public/cpp/manifest_builder.h"
#include "ui/accessibility/mojom/ax_host.mojom.h"
namespace ui {
const service_manager::Manifest& GetAXHostManifest() {
static base::NoDestructor<service_manager::Manifest> manifest{
service_manager::ManifestBuilder()
.WithServiceName(ax::mojom::kAXHostServiceName)
.WithDisplayName("Accessibility Host Service")
.WithOptions(service_manager::ManifestOptionsBuilder().Build())
.ExposeCapability(
"app",
service_manager::Manifest::InterfaceList<ax::mojom::AXHost>())
.Build()};
return *manifest;
}
} // namespace ui
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_ACCESSIBILITY_AX_HOST_MANIFEST_H_
#define UI_ACCESSIBILITY_AX_HOST_MANIFEST_H_
#include "services/service_manager/public/cpp/manifest.h"
namespace ui {
const service_manager::Manifest& GetAXHostManifest();
} // namespace ui
#endif // UI_ACCESSIBILITY_AX_HOST_MANIFEST_H_
...@@ -9,7 +9,6 @@ mojom("mojom") { ...@@ -9,7 +9,6 @@ mojom("mojom") {
"ax_action_data.mojom", "ax_action_data.mojom",
"ax_assistant_structure.mojom", "ax_assistant_structure.mojom",
"ax_event.mojom", "ax_event.mojom",
"ax_host.mojom",
"ax_node_data.mojom", "ax_node_data.mojom",
"ax_relative_bounds.mojom", "ax_relative_bounds.mojom",
"ax_tree_data.mojom", "ax_tree_data.mojom",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module ax.mojom;
import "ui/accessibility/ax_enums.mojom";
import "ui/accessibility/mojom/ax_action_data.mojom";
import "ui/accessibility/mojom/ax_event.mojom";
import "ui/accessibility/mojom/ax_tree_id.mojom";
import "ui/accessibility/mojom/ax_tree_update.mojom";
const string kAXHostServiceName = "ax_host_service";
// Accessibility host service for remote processes that use views UI. Not used
// for web content, PDF, or ARC++.
// * Receives accessibility node trees and events (e.g. focus changes) from the
// remote process. Forwards the events to accessibility extensions in the
// browser.
// * Sends requests for actions (e.g. click a button) to the remote process.
interface AXHost {
// Registers a host in a remote process. |tree_id| is the ID to use as the
// root of the AX node tree. If |automation_enabled| is true then the remote
// process must send its initial AX node tree immediately (because a feature
// like ChromeVox is enabled).
RegisterRemoteHost(AXRemoteHost remote) =>
(ax.mojom.AXTreeID tree_id, bool automation_enabled);
// Handles an accessibility |event| (e.g. focus change) for |tree_id| in the
// remote process. Includes |updates| to child nodes.
HandleAccessibilityEvent(
ax.mojom.AXTreeID tree_id, array<AXTreeUpdate> updates, AXEvent event);
};
// Remote hosts run outside the browser process, for example in a mojo app like
// shortcut_viewer.
interface AXRemoteHost {
// Remotes must send the initial accessibility tree when automation is
// enabled.
OnAutomationEnabled(bool enabled);
// Performs an accessibility action inside the remote app.
PerformAction(AXActionData data);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment