Chromium Code Reviews| Index: chrome/browser/ui/views/accessibility/automation_manager_views.cc |
| diff --git a/chrome/browser/ui/views/accessibility/automation_manager_views.cc b/chrome/browser/ui/views/accessibility/automation_manager_views.cc |
| index 9b4812e0e579c909aa9bc6ce6adb89c5fa080efd..401c47a9402b593470bf0498c8d331b172e6c39d 100644 |
| --- a/chrome/browser/ui/views/accessibility/automation_manager_views.cc |
| +++ b/chrome/browser/ui/views/accessibility/automation_manager_views.cc |
| @@ -6,14 +6,14 @@ |
| #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,20 @@ 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; |
|
dmazzoni
2014/04/29 17:20:59
Do you also want to delete the serializer here to
|
| +} |
| + |
| void AutomationManagerViews::HandleEvent(Profile* profile, |
| views::View* view, |
| ui::AXEvent event_type) { |
| - if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| - switches::kEnableAutomationAPI)) { |
| + if (!enabled_) { |
| return; |
| } |
| @@ -44,25 +53,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 +79,6 @@ void AutomationManagerViews::HandleEvent(Profile* profile, |
| details, profile); |
| } |
| -AutomationManagerViews::AutomationManagerViews() {} |
| +AutomationManagerViews::AutomationManagerViews() : enabled_(false) {} |
| AutomationManagerViews:: ~AutomationManagerViews() {} |