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/ash/accessibility/ax_tree_source_ash.h" | 5 #include "chrome/browser/ui/ash/accessibility/ax_tree_source_ash.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
| 9 #include "chrome/browser/accessibility/ax_tree_id_registry.h" |
| 10 #include "chrome/browser/ui/ash/accessibility/automation_manager_ash.h" |
| 11 #include "content/public/browser/render_frame_host.h" |
| 12 #include "content/public/browser/render_process_host.h" |
| 13 #include "content/public/browser/web_contents.h" |
9 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 14 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" | 15 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" |
| 16 #include "ui/views/accessibility/ax_view_obj_wrapper.h" |
| 17 #include "ui/views/controls/webview/webview.h" |
11 | 18 |
12 using views::AXAuraObjCache; | 19 using views::AXAuraObjCache; |
13 using views::AXAuraObjWrapper; | 20 using views::AXAuraObjWrapper; |
14 | 21 |
15 AXTreeSourceAsh::AXTreeSourceAsh() { | 22 AXTreeSourceAsh::AXTreeSourceAsh() { |
16 root_.reset( | 23 root_.reset( |
17 new AXRootObjWrapper(AXAuraObjCache::GetInstance()->GetNextID())); | 24 new AXRootObjWrapper(AXAuraObjCache::GetInstance()->GetNextID())); |
18 } | 25 } |
19 | 26 |
20 AXTreeSourceAsh::~AXTreeSourceAsh() { | 27 AXTreeSourceAsh::~AXTreeSourceAsh() { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 return node1->GetID() == node2->GetID() && node1->GetID() != -1; | 90 return node1->GetID() == node2->GetID() && node1->GetID() != -1; |
84 } | 91 } |
85 | 92 |
86 AXAuraObjWrapper* AXTreeSourceAsh::GetNull() const { | 93 AXAuraObjWrapper* AXTreeSourceAsh::GetNull() const { |
87 return NULL; | 94 return NULL; |
88 } | 95 } |
89 | 96 |
90 void AXTreeSourceAsh::SerializeNode( | 97 void AXTreeSourceAsh::SerializeNode( |
91 AXAuraObjWrapper* node, ui::AXNodeData* out_data) const { | 98 AXAuraObjWrapper* node, ui::AXNodeData* out_data) const { |
92 node->Serialize(out_data); | 99 node->Serialize(out_data); |
| 100 |
| 101 if (out_data->role == ui::AX_ROLE_WEB_VIEW) { |
| 102 views::View* view = static_cast<views::AXViewObjWrapper*>(node)->view(); |
| 103 content::WebContents* contents = |
| 104 static_cast<views::WebView*>(view)->GetWebContents(); |
| 105 content::RenderFrameHost* rfh = contents->GetMainFrame(); |
| 106 if (rfh) { |
| 107 int process_id = rfh->GetProcess()->GetID(); |
| 108 int routing_id = rfh->GetRoutingID(); |
| 109 int ax_tree_id = AXTreeIDRegistry::GetInstance()->GetOrCreateAXTreeID( |
| 110 process_id, routing_id); |
| 111 out_data->AddIntAttribute(ui::AX_ATTR_CHILD_TREE_ID, ax_tree_id); |
| 112 } |
| 113 } |
93 } | 114 } |
94 | 115 |
95 std::string AXTreeSourceAsh::ToString( | 116 std::string AXTreeSourceAsh::ToString( |
96 AXAuraObjWrapper* root, std::string prefix) { | 117 AXAuraObjWrapper* root, std::string prefix) { |
97 ui::AXNodeData data; | 118 ui::AXNodeData data; |
98 root->Serialize(&data); | 119 root->Serialize(&data); |
99 std::string output = prefix + data.ToString() + '\n'; | 120 std::string output = prefix + data.ToString() + '\n'; |
100 | 121 |
101 std::vector<AXAuraObjWrapper*> children; | 122 std::vector<AXAuraObjWrapper*> children; |
102 root->GetChildren(&children); | 123 root->GetChildren(&children); |
103 | 124 |
104 prefix += prefix[0]; | 125 prefix += prefix[0]; |
105 for (size_t i = 0; i < children.size(); ++i) | 126 for (size_t i = 0; i < children.size(); ++i) |
106 output += ToString(children[i], prefix); | 127 output += ToString(children[i], prefix); |
107 | 128 |
108 return output; | 129 return output; |
109 } | 130 } |
OLD | NEW |