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..828f3a71ca170bf1625ecce57800eb7d9a86e8eb 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()) |
aboxhall
2014/04/28 19:50:38
Why reset when Enable() is called, rather than Dis
David Tseng
2014/04/29 01:35:03
In case Enable() gets called by multiple clients.
|
+ current_tree_serializer_->Reset(); |
+} |
+ |
+void AutomationManagerViews::Disable() { |
+ enabled_ = false; |
+} |
+ |
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* obj = |
aboxhall
2014/04/28 19:50:38
Could we call this aura_obj or similar?
David Tseng
2014/04/29 01:35:03
Done.
|
+ views::AXAuraObjCache::GetInstance()->GetOrCreate(view); |
+ current_tree_serializer_->SerializeChanges(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), |
+ 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() {} |