| Index: chrome/browser/ui/ash/accessibility/automation_manager_views.cc
|
| diff --git a/chrome/browser/ui/views/accessibility/automation_manager_views.cc b/chrome/browser/ui/ash/accessibility/automation_manager_views.cc
|
| similarity index 69%
|
| rename from chrome/browser/ui/views/accessibility/automation_manager_views.cc
|
| rename to chrome/browser/ui/ash/accessibility/automation_manager_views.cc
|
| index 9b4812e0e579c909aa9bc6ce6adb89c5fa080efd..92c808531042985aa2eb67d41059ccd2d29ec341 100644
|
| --- a/chrome/browser/ui/views/accessibility/automation_manager_views.cc
|
| +++ b/chrome/browser/ui/ash/accessibility/automation_manager_views.cc
|
| @@ -2,18 +2,18 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "chrome/browser/ui/views/accessibility/automation_manager_views.h"
|
| +#include "chrome/browser/ui/ash/accessibility/automation_manager_views.h"
|
|
|
| #include <vector>
|
|
|
| -#include "base/command_line.h"
|
| #include "base/memory/singleton.h"
|
| #include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/extensions/api/automation_internal/automation_util.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| -#include "chrome/common/chrome_switches.h"
|
| #include "content/public/browser/ax_event_notification_details.h"
|
| +#include "ui/views/accessibility/ax_aura_obj_cache.h"
|
| +#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
|
| #include "ui/views/view.h"
|
| #include "ui/views/widget/widget.h"
|
|
|
| @@ -22,11 +22,21 @@ AutomationManagerViews* AutomationManagerViews::GetInstance() {
|
| return Singleton<AutomationManagerViews>::get();
|
| }
|
|
|
| +void AutomationManagerViews::Enable() {
|
| + enabled_ = true;
|
| + if (current_tree_serializer_.get())
|
| + current_tree_serializer_->Reset();
|
| +}
|
| +
|
| +void AutomationManagerViews::Disable() {
|
| + enabled_ = false;
|
| + current_tree_serializer_->Reset();
|
| +}
|
| +
|
| void AutomationManagerViews::HandleEvent(Profile* profile,
|
| views::View* view,
|
| ui::AXEvent event_type) {
|
| - if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kEnableAutomationAPI)) {
|
| + if (!enabled_) {
|
| return;
|
| }
|
|
|
| @@ -44,25 +54,24 @@ void AutomationManagerViews::HandleEvent(Profile* profile,
|
| return;
|
| }
|
|
|
| - if (!current_tree_.get() ||
|
| - current_tree_->GetRoot()->GetWidget() != widget) {
|
| - current_tree_.reset(new views::AXTreeSourceViews(widget));
|
| + if (!current_tree_.get()) {
|
| + current_tree_.reset(new AXTreeSourceViews());
|
| current_tree_serializer_.reset(
|
| - new ui::AXTreeSerializer<views::View*>(current_tree_.get()));
|
| - // TODO(dtseng): Need to send a load complete and clear any previous desktop
|
| - // trees.
|
| + new ui::AXTreeSerializer<views::AXAuraObjWrapper*>(
|
| + current_tree_.get()));
|
| }
|
|
|
| ui::AXTreeUpdate out_update;
|
| - current_tree_serializer_->SerializeChanges(view, &out_update);
|
| + views::AXAuraObjWrapper* aura_obj =
|
| + views::AXAuraObjCache::GetInstance()->GetOrCreate(view);
|
| + current_tree_serializer_->SerializeChanges(aura_obj, &out_update);
|
|
|
| // Route this event to special process/routing ids recognized by the
|
| // Automation API as the desktop tree.
|
| -
|
| // TODO(dtseng): Would idealy define these special desktop constants in idl.
|
| content::AXEventNotificationDetails detail(out_update.nodes,
|
| event_type,
|
| - current_tree_->GetId(view),
|
| + aura_obj->GetID(),
|
| 0, /* process_id */
|
| 0 /* routing_id */);
|
| std::vector<content::AXEventNotificationDetails> details;
|
| @@ -71,6 +80,6 @@ void AutomationManagerViews::HandleEvent(Profile* profile,
|
| details, profile);
|
| }
|
|
|
| -AutomationManagerViews::AutomationManagerViews() {}
|
| +AutomationManagerViews::AutomationManagerViews() : enabled_(false) {}
|
|
|
| AutomationManagerViews:: ~AutomationManagerViews() {}
|
|
|