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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
| 7 #include <utility> |
| 8 |
| 9 #include "base/memory/ptr_util.h" |
7 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
9 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/values.h" |
10 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" | 14 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" |
11 #include "content/browser/accessibility/browser_accessibility_manager.h" | 15 #include "content/browser/accessibility/browser_accessibility_manager.h" |
12 #include "ui/gfx/geometry/rect_conversions.h" | 16 #include "ui/gfx/geometry/rect_conversions.h" |
13 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
14 | 18 |
15 namespace content { | 19 namespace content { |
16 | 20 |
17 AccessibilityTreeFormatterBlink::AccessibilityTreeFormatterBlink() | 21 AccessibilityTreeFormatterBlink::AccessibilityTreeFormatterBlink() |
18 : AccessibilityTreeFormatter() { | 22 : AccessibilityTreeFormatter() { |
19 } | 23 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 dict->SetBoolean(ui::ToString(attr), node.GetBoolAttribute(attr)); | 117 dict->SetBoolean(ui::ToString(attr), node.GetBoolAttribute(attr)); |
114 } | 118 } |
115 | 119 |
116 for (int attr_index = ui::AX_INT_LIST_ATTRIBUTE_NONE; | 120 for (int attr_index = ui::AX_INT_LIST_ATTRIBUTE_NONE; |
117 attr_index <= ui::AX_INT_LIST_ATTRIBUTE_LAST; | 121 attr_index <= ui::AX_INT_LIST_ATTRIBUTE_LAST; |
118 ++attr_index) { | 122 ++attr_index) { |
119 auto attr = static_cast<ui::AXIntListAttribute>(attr_index); | 123 auto attr = static_cast<ui::AXIntListAttribute>(attr_index); |
120 if (node.HasIntListAttribute(attr)) { | 124 if (node.HasIntListAttribute(attr)) { |
121 std::vector<int32_t> values; | 125 std::vector<int32_t> values; |
122 node.GetIntListAttribute(attr, &values); | 126 node.GetIntListAttribute(attr, &values); |
123 base::ListValue* value_list = new base::ListValue; | 127 auto value_list = base::MakeUnique<base::ListValue>(); |
124 for (size_t i = 0; i < values.size(); ++i) { | 128 for (size_t i = 0; i < values.size(); ++i) { |
125 if (ui::IsNodeIdIntListAttribute(attr)) { | 129 if (ui::IsNodeIdIntListAttribute(attr)) { |
126 BrowserAccessibility* target = node.manager()->GetFromID(values[i]); | 130 BrowserAccessibility* target = node.manager()->GetFromID(values[i]); |
127 if (target) | 131 if (target) |
128 value_list->AppendString(ui::ToString(target->GetData().role)); | 132 value_list->AppendString(ui::ToString(target->GetData().role)); |
129 else | 133 else |
130 value_list->AppendString("null"); | 134 value_list->AppendString("null"); |
131 } else { | 135 } else { |
132 value_list->AppendInteger(values[i]); | 136 value_list->AppendInteger(values[i]); |
133 } | 137 } |
134 } | 138 } |
135 dict->Set(ui::ToString(attr), value_list); | 139 dict->Set(ui::ToString(attr), std::move(value_list)); |
136 } | 140 } |
137 } | 141 } |
138 | 142 |
139 std::vector<std::string> actions_strings; | 143 std::vector<std::string> actions_strings; |
140 for (int action_index = ui::AX_ACTION_NONE + 1; | 144 for (int action_index = ui::AX_ACTION_NONE + 1; |
141 action_index <= ui::AX_ACTION_LAST; ++action_index) { | 145 action_index <= ui::AX_ACTION_LAST; ++action_index) { |
142 auto action = static_cast<ui::AXAction>(action_index); | 146 auto action = static_cast<ui::AXAction>(action_index); |
143 if (node.HasAction(action)) | 147 if (node.HasAction(action)) |
144 actions_strings.push_back(ui::ToString(action)); | 148 actions_strings.push_back(ui::ToString(action)); |
145 } | 149 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 298 |
295 const std::string AccessibilityTreeFormatterBlink::GetAllowString() { | 299 const std::string AccessibilityTreeFormatterBlink::GetAllowString() { |
296 return "@BLINK-ALLOW:"; | 300 return "@BLINK-ALLOW:"; |
297 } | 301 } |
298 | 302 |
299 const std::string AccessibilityTreeFormatterBlink::GetDenyString() { | 303 const std::string AccessibilityTreeFormatterBlink::GetDenyString() { |
300 return "@BLINK-DENY:"; | 304 return "@BLINK-DENY:"; |
301 } | 305 } |
302 | 306 |
303 } // namespace content | 307 } // namespace content |
OLD | NEW |