OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/accessibility/accessibility_tree_formatter.h" | 5 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
6 | 6 |
7 #include <oleacc.h> | 7 #include <oleacc.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // and the position of the mouse cursor. | 83 // and the position of the mouse cursor. |
84 ia_state &= ~STATE_SYSTEM_HOTTRACKED; | 84 ia_state &= ~STATE_SYSTEM_HOTTRACKED; |
85 ia_state &= ~STATE_SYSTEM_OFFSCREEN; | 85 ia_state &= ~STATE_SYSTEM_OFFSCREEN; |
86 | 86 |
87 IAccessibleStateToStringVector(ia_state, &state_strings); | 87 IAccessibleStateToStringVector(ia_state, &state_strings); |
88 IAccessible2StateToStringVector(acc_obj->ia2_state(), &state_strings); | 88 IAccessible2StateToStringVector(acc_obj->ia2_state(), &state_strings); |
89 base::ListValue* states = new base::ListValue; | 89 base::ListValue* states = new base::ListValue; |
90 for (std::vector<base::string16>::const_iterator it = state_strings.begin(); | 90 for (std::vector<base::string16>::const_iterator it = state_strings.begin(); |
91 it != state_strings.end(); | 91 it != state_strings.end(); |
92 ++it) { | 92 ++it) { |
93 states->AppendString(UTF16ToUTF8(*it)); | 93 states->AppendString(base::UTF16ToUTF8(*it)); |
94 } | 94 } |
95 dict->Set("states", states); | 95 dict->Set("states", states); |
96 | 96 |
97 const std::vector<base::string16>& ia2_attributes = acc_obj->ia2_attributes(); | 97 const std::vector<base::string16>& ia2_attributes = acc_obj->ia2_attributes(); |
98 base::ListValue* attributes = new base::ListValue; | 98 base::ListValue* attributes = new base::ListValue; |
99 for (std::vector<base::string16>::const_iterator it = ia2_attributes.begin(); | 99 for (std::vector<base::string16>::const_iterator it = ia2_attributes.begin(); |
100 it != ia2_attributes.end(); | 100 it != ia2_attributes.end(); |
101 ++it) { | 101 ++it) { |
102 attributes->AppendString(UTF16ToUTF8(*it)); | 102 attributes->AppendString(base::UTF16ToUTF8(*it)); |
103 } | 103 } |
104 dict->Set("attributes", attributes); | 104 dict->Set("attributes", attributes); |
105 | 105 |
106 dict->SetString("role_name", acc_obj->role_name()); | 106 dict->SetString("role_name", acc_obj->role_name()); |
107 | 107 |
108 VARIANT currentValue; | 108 VARIANT currentValue; |
109 if (acc_obj->get_currentValue(¤tValue) == S_OK) | 109 if (acc_obj->get_currentValue(¤tValue) == S_OK) |
110 dict->SetDouble("currentValue", V_R8(¤tValue)); | 110 dict->SetDouble("currentValue", V_R8(¤tValue)); |
111 | 111 |
112 VARIANT minimumValue; | 112 VARIANT minimumValue; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 base::string16 AccessibilityTreeFormatter::ToString( | 202 base::string16 AccessibilityTreeFormatter::ToString( |
203 const base::DictionaryValue& dict, | 203 const base::DictionaryValue& dict, |
204 const base::string16& indent) { | 204 const base::string16& indent) { |
205 base::string16 line; | 205 base::string16 line; |
206 | 206 |
207 base::string16 role_value; | 207 base::string16 role_value; |
208 dict.GetString("role", &role_value); | 208 dict.GetString("role", &role_value); |
209 WriteAttribute(true, UTF16ToUTF8(role_value), &line); | 209 WriteAttribute(true, base::UTF16ToUTF8(role_value), &line); |
210 | 210 |
211 base::string16 name_value; | 211 base::string16 name_value; |
212 dict.GetString("name", &name_value); | 212 dict.GetString("name", &name_value); |
213 WriteAttribute(true, base::StringPrintf(L"name='%ls'", name_value.c_str()), | 213 WriteAttribute(true, base::StringPrintf(L"name='%ls'", name_value.c_str()), |
214 &line); | 214 &line); |
215 | 215 |
216 for (int i = 0; i < arraysize(ALL_ATTRIBUTES); i++) { | 216 for (int i = 0; i < arraysize(ALL_ATTRIBUTES); i++) { |
217 const char* attribute_name = ALL_ATTRIBUTES[i]; | 217 const char* attribute_name = ALL_ATTRIBUTES[i]; |
218 const base::Value* value; | 218 const base::Value* value; |
219 if (!dict.Get(attribute_name, &value)) | 219 if (!dict.Get(attribute_name, &value)) |
220 continue; | 220 continue; |
221 | 221 |
222 switch (value->GetType()) { | 222 switch (value->GetType()) { |
223 case base::Value::TYPE_STRING: { | 223 case base::Value::TYPE_STRING: { |
224 base::string16 string_value; | 224 base::string16 string_value; |
225 value->GetAsString(&string_value); | 225 value->GetAsString(&string_value); |
226 WriteAttribute(false, | 226 WriteAttribute(false, |
227 StringPrintf(L"%ls='%ls'", | 227 StringPrintf(L"%ls='%ls'", |
228 UTF8ToUTF16(attribute_name).c_str(), | 228 base::UTF8ToUTF16(attribute_name).c_str(), |
229 string_value.c_str()), | 229 string_value.c_str()), |
230 &line); | 230 &line); |
231 break; | 231 break; |
232 } | 232 } |
233 case base::Value::TYPE_INTEGER: { | 233 case base::Value::TYPE_INTEGER: { |
234 int int_value; | 234 int int_value; |
235 value->GetAsInteger(&int_value); | 235 value->GetAsInteger(&int_value); |
236 WriteAttribute(false, | 236 WriteAttribute(false, |
237 base::StringPrintf(L"%ls=%d", | 237 base::StringPrintf(L"%ls=%d", |
238 UTF8ToUTF16(attribute_name).c_str(), | 238 base::UTF8ToUTF16( |
| 239 attribute_name).c_str(), |
239 int_value), | 240 int_value), |
240 &line); | 241 &line); |
241 break; | 242 break; |
242 } | 243 } |
243 case base::Value::TYPE_DOUBLE: { | 244 case base::Value::TYPE_DOUBLE: { |
244 double double_value; | 245 double double_value; |
245 value->GetAsDouble(&double_value); | 246 value->GetAsDouble(&double_value); |
246 WriteAttribute(false, | 247 WriteAttribute(false, |
247 base::StringPrintf(L"%ls=%.2f", | 248 base::StringPrintf(L"%ls=%.2f", |
248 UTF8ToUTF16(attribute_name).c_str(), | 249 base::UTF8ToUTF16( |
| 250 attribute_name).c_str(), |
249 double_value), | 251 double_value), |
250 &line); | 252 &line); |
251 break; | 253 break; |
252 } | 254 } |
253 case base::Value::TYPE_LIST: { | 255 case base::Value::TYPE_LIST: { |
254 // Currently all list values are string and are written without | 256 // Currently all list values are string and are written without |
255 // attribute names. | 257 // attribute names. |
256 const base::ListValue* list_value; | 258 const base::ListValue* list_value; |
257 value->GetAsList(&list_value); | 259 value->GetAsList(&list_value); |
258 for (base::ListValue::const_iterator it = list_value->begin(); | 260 for (base::ListValue::const_iterator it = list_value->begin(); |
(...skipping 21 matching lines...) Expand all Loading... |
280 &line); | 282 &line); |
281 } | 283 } |
282 break; | 284 break; |
283 } | 285 } |
284 default: | 286 default: |
285 NOTREACHED(); | 287 NOTREACHED(); |
286 break; | 288 break; |
287 } | 289 } |
288 } | 290 } |
289 | 291 |
290 return indent + line + ASCIIToUTF16("\n"); | 292 return indent + line + base::ASCIIToUTF16("\n"); |
291 } | 293 } |
292 | 294 |
293 // static | 295 // static |
294 const base::FilePath::StringType | 296 const base::FilePath::StringType |
295 AccessibilityTreeFormatter::GetActualFileSuffix() { | 297 AccessibilityTreeFormatter::GetActualFileSuffix() { |
296 return FILE_PATH_LITERAL("-actual-win.txt"); | 298 return FILE_PATH_LITERAL("-actual-win.txt"); |
297 } | 299 } |
298 | 300 |
299 // static | 301 // static |
300 const base::FilePath::StringType | 302 const base::FilePath::StringType |
(...skipping 10 matching lines...) Expand all Loading... |
311 const std::string AccessibilityTreeFormatter::GetAllowString() { | 313 const std::string AccessibilityTreeFormatter::GetAllowString() { |
312 return "@WIN-ALLOW:"; | 314 return "@WIN-ALLOW:"; |
313 } | 315 } |
314 | 316 |
315 // static | 317 // static |
316 const std::string AccessibilityTreeFormatter::GetDenyString() { | 318 const std::string AccessibilityTreeFormatter::GetDenyString() { |
317 return "@WIN-DENY:"; | 319 return "@WIN-DENY:"; |
318 } | 320 } |
319 | 321 |
320 } // namespace content | 322 } // namespace content |
OLD | NEW |