Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(713)

Side by Side Diff: chrome/browser/ui/ash/accessibility/ax_tree_source_ash.cc

Issue 667713006: Implement automatic load of composed/embedded automation trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/public/browser/render_frame_host.h"
10 #include "content/public/browser/render_process_host.h"
11 #include "content/public/browser/web_contents.h"
9 #include "ui/views/accessibility/ax_aura_obj_cache.h" 12 #include "ui/views/accessibility/ax_aura_obj_cache.h"
10 #include "ui/views/accessibility/ax_aura_obj_wrapper.h" 13 #include "ui/views/accessibility/ax_aura_obj_wrapper.h"
14 #include "ui/views/accessibility/ax_view_obj_wrapper.h"
15 #include "ui/views/controls/webview/webview.h"
11 16
12 using views::AXAuraObjCache; 17 using views::AXAuraObjCache;
13 using views::AXAuraObjWrapper; 18 using views::AXAuraObjWrapper;
14 19
15 AXTreeSourceAsh::AXTreeSourceAsh() { 20 AXTreeSourceAsh::AXTreeSourceAsh() {
16 root_.reset( 21 root_.reset(
17 new AXRootObjWrapper(AXAuraObjCache::GetInstance()->GetNextID())); 22 new AXRootObjWrapper(AXAuraObjCache::GetInstance()->GetNextID()));
18 } 23 }
19 24
20 AXTreeSourceAsh::~AXTreeSourceAsh() { 25 AXTreeSourceAsh::~AXTreeSourceAsh() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 return node1->GetID() == node2->GetID() && node1->GetID() != -1; 88 return node1->GetID() == node2->GetID() && node1->GetID() != -1;
84 } 89 }
85 90
86 AXAuraObjWrapper* AXTreeSourceAsh::GetNull() const { 91 AXAuraObjWrapper* AXTreeSourceAsh::GetNull() const {
87 return NULL; 92 return NULL;
88 } 93 }
89 94
90 void AXTreeSourceAsh::SerializeNode( 95 void AXTreeSourceAsh::SerializeNode(
91 AXAuraObjWrapper* node, ui::AXNodeData* out_data) const { 96 AXAuraObjWrapper* node, ui::AXNodeData* out_data) const {
92 node->Serialize(out_data); 97 node->Serialize(out_data);
98
99 if (out_data->role == ui::AX_ROLE_GROUP) {
100 views::View* view = static_cast<views::AXViewObjWrapper*>(node)->view();
101 if (view->GetClassName() == views::WebView::kViewClassName) {
102 out_data->role = ui::AX_ROLE_WEB_AREA;
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 out_data->AddIntAttribute(ui::AX_ATTR_FRAME_ID, process_id);
aboxhall 2014/10/29 19:29:11 I'm confused as to why these two attributes are so
110 out_data->AddIntAttribute(ui::AX_ATTR_CHILD_FRAME_ID, routing_id);
111 }
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698