OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 5 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/extensions/api/automation_internal/automation_util.h" | 11 #include "chrome/browser/extensions/api/automation_internal/automation_event_rou
ter.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/common/extensions/chrome_extension_messages.h" |
13 #include "content/public/browser/ax_event_notification_details.h" | 14 #include "content/public/browser/ax_event_notification_details.h" |
14 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
16 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 17 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
17 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 18 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
20 | 21 |
21 using content::BrowserContext; | 22 using content::BrowserContext; |
| 23 using extensions::AutomationEventRouter; |
22 | 24 |
23 // static | 25 // static |
24 AutomationManagerAura* AutomationManagerAura::GetInstance() { | 26 AutomationManagerAura* AutomationManagerAura::GetInstance() { |
25 return Singleton<AutomationManagerAura>::get(); | 27 return Singleton<AutomationManagerAura>::get(); |
26 } | 28 } |
27 | 29 |
28 void AutomationManagerAura::Enable(BrowserContext* context) { | 30 void AutomationManagerAura::Enable(BrowserContext* context) { |
29 enabled_ = true; | 31 enabled_ = true; |
30 if (!current_tree_.get()) | 32 if (!current_tree_.get()) |
31 current_tree_.reset(new AXTreeSourceAura()); | 33 current_tree_.reset(new AXTreeSourceAura()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } | 119 } |
118 | 120 |
119 void AutomationManagerAura::ResetSerializer() { | 121 void AutomationManagerAura::ResetSerializer() { |
120 current_tree_serializer_.reset( | 122 current_tree_serializer_.reset( |
121 new ui::AXTreeSerializer<views::AXAuraObjWrapper*>(current_tree_.get())); | 123 new ui::AXTreeSerializer<views::AXAuraObjWrapper*>(current_tree_.get())); |
122 } | 124 } |
123 | 125 |
124 void AutomationManagerAura::SendEvent(BrowserContext* context, | 126 void AutomationManagerAura::SendEvent(BrowserContext* context, |
125 views::AXAuraObjWrapper* aura_obj, | 127 views::AXAuraObjWrapper* aura_obj, |
126 ui::AXEvent event_type) { | 128 ui::AXEvent event_type) { |
127 ui::AXTreeUpdate update; | 129 ExtensionMsg_AccessibilityEventParams params; |
128 current_tree_serializer_->SerializeChanges(aura_obj, &update); | 130 current_tree_serializer_->SerializeChanges(aura_obj, ¶ms.update); |
129 | 131 params.tree_id = 0; |
130 // Route this event to special process/routing ids recognized by the | 132 params.id = aura_obj->GetID(); |
131 // Automation API as the desktop tree. | 133 params.event_type = event_type; |
132 // TODO(dtseng): Would idealy define these special desktop constants in idl. | 134 AutomationEventRouter* router = AutomationEventRouter::GetInstance(); |
133 content::AXEventNotificationDetails detail( | 135 router->DispatchAccessibilityEvent(params); |
134 update.node_id_to_clear, update.nodes, event_type, aura_obj->GetID(), | |
135 0, /* process_id */ | |
136 0 /* routing_id */); | |
137 std::vector<content::AXEventNotificationDetails> details; | |
138 details.push_back(detail); | |
139 extensions::automation_util::DispatchAccessibilityEventsToAutomation( | |
140 details, context, gfx::Vector2d()); | |
141 } | 136 } |
OLD | NEW |