OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 <atk/atk.h> | 7 #include <atk/atk.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 void AccessibilityTreeFormatterAuraLinux::AddProperties( | 44 void AccessibilityTreeFormatterAuraLinux::AddProperties( |
45 const BrowserAccessibility& node, | 45 const BrowserAccessibility& node, |
46 base::DictionaryValue* dict) { | 46 base::DictionaryValue* dict) { |
47 dict->SetInteger("id", node.GetId()); | 47 dict->SetInteger("id", node.GetId()); |
48 BrowserAccessibilityAuraLinux* acc_obj = | 48 BrowserAccessibilityAuraLinux* acc_obj = |
49 ToBrowserAccessibilityAuraLinux(const_cast<BrowserAccessibility*>(&node)); | 49 ToBrowserAccessibilityAuraLinux(const_cast<BrowserAccessibility*>(&node)); |
50 | 50 |
51 AtkObject* atk_object = acc_obj->GetAtkObject(); | 51 AtkObject* atk_object = acc_obj->GetAtkObject(); |
52 AtkRole role = acc_obj->atk_role(); | 52 AtkRole role = acc_obj->atk_role(); |
53 if (role != ATK_ROLE_UNKNOWN) | 53 if (role != ATK_ROLE_UNKNOWN) |
54 dict->SetString("role", atk_role_get_name(role)); | 54 dict->SetString("role", std::string(atk_role_get_name(role))); |
55 dict->SetString("name", atk_object_get_name(atk_object)); | 55 const gchar* name = atk_object_get_name(atk_object); |
56 dict->SetString("description", atk_object_get_description(atk_object)); | 56 if (name) |
| 57 dict->SetString("name", std::string(name)); |
| 58 const gchar* description = atk_object_get_description(atk_object); |
| 59 if (description) |
| 60 dict->SetString("description", std::string(description)); |
| 61 |
57 AtkStateSet* state_set = atk_object_ref_state_set(atk_object); | 62 AtkStateSet* state_set = atk_object_ref_state_set(atk_object); |
58 base::ListValue* states = new base::ListValue; | 63 base::ListValue* states = new base::ListValue; |
59 for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) { | 64 for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) { |
60 AtkStateType state_type = static_cast<AtkStateType>(i); | 65 AtkStateType state_type = static_cast<AtkStateType>(i); |
61 if (atk_state_set_contains_state(state_set, state_type)) | 66 if (atk_state_set_contains_state(state_set, state_type)) |
62 states->AppendString(atk_state_type_get_name(state_type)); | 67 states->AppendString(atk_state_type_get_name(state_type)); |
63 } | 68 } |
64 dict->Set("states", states); | 69 dict->Set("states", states); |
65 } | 70 } |
66 | 71 |
67 base::string16 AccessibilityTreeFormatterAuraLinux::ToString( | 72 base::string16 AccessibilityTreeFormatterAuraLinux::ToString( |
68 const base::DictionaryValue& node) { | 73 const base::DictionaryValue& node) { |
69 base::string16 line; | 74 base::string16 line; |
70 std::string role_value; | 75 std::string role_value; |
71 node.GetString("role", &role_value); | 76 node.GetString("role", &role_value); |
72 if (!role_value.empty()) { | 77 if (!role_value.empty()) { |
73 WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line); | 78 WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line); |
74 } | 79 } |
75 | 80 |
76 std::string name_value; | 81 std::string name_value; |
77 node.GetString("name", &name_value); | 82 if (node.GetString("name", &name_value)) |
78 WriteAttribute(true, base::StringPrintf("name='%s'", name_value.c_str()), | 83 WriteAttribute(true, base::StringPrintf("name='%s'", name_value.c_str()), |
79 &line); | 84 &line); |
80 | 85 |
81 std::string description_value; | 86 std::string description_value; |
82 node.GetString("description", &description_value); | 87 node.GetString("description", &description_value); |
83 WriteAttribute( | 88 WriteAttribute( |
84 false, base::StringPrintf("description='%s'", description_value.c_str()), | 89 false, base::StringPrintf("description='%s'", description_value.c_str()), |
85 &line); | 90 &line); |
86 | 91 |
87 const base::ListValue* states_value; | 92 const base::ListValue* states_value; |
88 node.GetList("states", &states_value); | 93 node.GetList("states", &states_value); |
89 for (base::ListValue::const_iterator it = states_value->begin(); | 94 for (base::ListValue::const_iterator it = states_value->begin(); |
(...skipping 21 matching lines...) Expand all Loading... |
111 | 116 |
112 const std::string AccessibilityTreeFormatterAuraLinux::GetAllowString() { | 117 const std::string AccessibilityTreeFormatterAuraLinux::GetAllowString() { |
113 return "@AURALINUX-ALLOW:"; | 118 return "@AURALINUX-ALLOW:"; |
114 } | 119 } |
115 | 120 |
116 const std::string AccessibilityTreeFormatterAuraLinux::GetDenyString() { | 121 const std::string AccessibilityTreeFormatterAuraLinux::GetDenyString() { |
117 return "@AURALINUX-DENY:"; | 122 return "@AURALINUX-DENY:"; |
118 } | 123 } |
119 | 124 |
120 } | 125 } |
OLD | NEW |