| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 dict->SetString("role", IAccessible2RoleToString(acc_obj->ia2_role())); | 69 dict->SetString("role", IAccessible2RoleToString(acc_obj->ia2_role())); |
| 70 | 70 |
| 71 CComBSTR msaa_variant; | 71 CComBSTR msaa_variant; |
| 72 HRESULT hresult = acc_obj->get_accName(variant_self, &msaa_variant); | 72 HRESULT hresult = acc_obj->get_accName(variant_self, &msaa_variant); |
| 73 if (hresult == S_OK) | 73 if (hresult == S_OK) |
| 74 dict->SetString("name", msaa_variant.m_str); | 74 dict->SetString("name", msaa_variant.m_str); |
| 75 hresult = acc_obj->get_accValue(variant_self, &msaa_variant); | 75 hresult = acc_obj->get_accValue(variant_self, &msaa_variant); |
| 76 if (hresult == S_OK) | 76 if (hresult == S_OK) |
| 77 dict->SetString("value", msaa_variant.m_str); | 77 dict->SetString("value", msaa_variant.m_str); |
| 78 | 78 |
| 79 std::vector<string16> state_strings; | 79 std::vector<base::string16> state_strings; |
| 80 int32 ia_state = acc_obj->ia_state(); | 80 int32 ia_state = acc_obj->ia_state(); |
| 81 | 81 |
| 82 // Avoid flakiness: these states depend on whether the window is focused | 82 // Avoid flakiness: these states depend on whether the window is focused |
| 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<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(UTF16ToUTF8(*it)); |
| 94 } | 94 } |
| 95 dict->Set("states", states); | 95 dict->Set("states", states); |
| 96 | 96 |
| 97 const std::vector<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<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(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) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (n_selections > 0) { | 192 if (n_selections > 0) { |
| 193 LONG start, end; | 193 LONG start, end; |
| 194 if (acc_obj->get_selection(0, &start, &end) == S_OK) { | 194 if (acc_obj->get_selection(0, &start, &end) == S_OK) { |
| 195 dict->SetInteger("selection_start", start); | 195 dict->SetInteger("selection_start", start); |
| 196 dict->SetInteger("selection_end", end); | 196 dict->SetInteger("selection_end", end); |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 string16 AccessibilityTreeFormatter::ToString(const base::DictionaryValue& dict, | 202 base::string16 AccessibilityTreeFormatter::ToString( |
| 203 const string16& indent) { | 203 const base::DictionaryValue& dict, |
| 204 string16 line; | 204 const base::string16& indent) { |
| 205 base::string16 line; |
| 205 | 206 |
| 206 string16 role_value; | 207 base::string16 role_value; |
| 207 dict.GetString("role", &role_value); | 208 dict.GetString("role", &role_value); |
| 208 WriteAttribute(true, UTF16ToUTF8(role_value), &line); | 209 WriteAttribute(true, UTF16ToUTF8(role_value), &line); |
| 209 | 210 |
| 210 string16 name_value; | 211 base::string16 name_value; |
| 211 dict.GetString("name", &name_value); | 212 dict.GetString("name", &name_value); |
| 212 WriteAttribute(true, base::StringPrintf(L"name='%ls'", name_value.c_str()), | 213 WriteAttribute(true, base::StringPrintf(L"name='%ls'", name_value.c_str()), |
| 213 &line); | 214 &line); |
| 214 | 215 |
| 215 for (int i = 0; i < arraysize(ALL_ATTRIBUTES); i++) { | 216 for (int i = 0; i < arraysize(ALL_ATTRIBUTES); i++) { |
| 216 const char* attribute_name = ALL_ATTRIBUTES[i]; | 217 const char* attribute_name = ALL_ATTRIBUTES[i]; |
| 217 const base::Value* value; | 218 const base::Value* value; |
| 218 if (!dict.Get(attribute_name, &value)) | 219 if (!dict.Get(attribute_name, &value)) |
| 219 continue; | 220 continue; |
| 220 | 221 |
| 221 switch (value->GetType()) { | 222 switch (value->GetType()) { |
| 222 case base::Value::TYPE_STRING: { | 223 case base::Value::TYPE_STRING: { |
| 223 string16 string_value; | 224 base::string16 string_value; |
| 224 value->GetAsString(&string_value); | 225 value->GetAsString(&string_value); |
| 225 WriteAttribute(false, | 226 WriteAttribute(false, |
| 226 StringPrintf(L"%ls='%ls'", | 227 StringPrintf(L"%ls='%ls'", |
| 227 UTF8ToUTF16(attribute_name).c_str(), | 228 UTF8ToUTF16(attribute_name).c_str(), |
| 228 string_value.c_str()), | 229 string_value.c_str()), |
| 229 &line); | 230 &line); |
| 230 break; | 231 break; |
| 231 } | 232 } |
| 232 case base::Value::TYPE_INTEGER: { | 233 case base::Value::TYPE_INTEGER: { |
| 233 int int_value; | 234 int int_value; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 250 break; | 251 break; |
| 251 } | 252 } |
| 252 case base::Value::TYPE_LIST: { | 253 case base::Value::TYPE_LIST: { |
| 253 // Currently all list values are string and are written without | 254 // Currently all list values are string and are written without |
| 254 // attribute names. | 255 // attribute names. |
| 255 const base::ListValue* list_value; | 256 const base::ListValue* list_value; |
| 256 value->GetAsList(&list_value); | 257 value->GetAsList(&list_value); |
| 257 for (base::ListValue::const_iterator it = list_value->begin(); | 258 for (base::ListValue::const_iterator it = list_value->begin(); |
| 258 it != list_value->end(); | 259 it != list_value->end(); |
| 259 ++it) { | 260 ++it) { |
| 260 string16 string_value; | 261 base::string16 string_value; |
| 261 if ((*it)->GetAsString(&string_value)) | 262 if ((*it)->GetAsString(&string_value)) |
| 262 WriteAttribute(false, string_value, &line); | 263 WriteAttribute(false, string_value, &line); |
| 263 } | 264 } |
| 264 break; | 265 break; |
| 265 } | 266 } |
| 266 case base::Value::TYPE_DICTIONARY: { | 267 case base::Value::TYPE_DICTIONARY: { |
| 267 // Currently all dictionary values are coordinates. | 268 // Currently all dictionary values are coordinates. |
| 268 // Revisit this if that changes. | 269 // Revisit this if that changes. |
| 269 const base::DictionaryValue* dict_value; | 270 const base::DictionaryValue* dict_value; |
| 270 value->GetAsDictionary(&dict_value); | 271 value->GetAsDictionary(&dict_value); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 const std::string AccessibilityTreeFormatter::GetAllowString() { | 311 const std::string AccessibilityTreeFormatter::GetAllowString() { |
| 311 return "@WIN-ALLOW:"; | 312 return "@WIN-ALLOW:"; |
| 312 } | 313 } |
| 313 | 314 |
| 314 // static | 315 // static |
| 315 const std::string AccessibilityTreeFormatter::GetDenyString() { | 316 const std::string AccessibilityTreeFormatter::GetDenyString() { |
| 316 return "@WIN-DENY:"; | 317 return "@WIN-DENY:"; |
| 317 } | 318 } |
| 318 | 319 |
| 319 } // namespace content | 320 } // namespace content |
| OLD | NEW |