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 <utility> |
| 10 |
9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" |
10 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
12 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
13 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/values.h" |
14 #include "content/browser/accessibility/browser_accessibility_auralinux.h" | 18 #include "content/browser/accessibility/browser_accessibility_auralinux.h" |
15 | 19 |
16 namespace content { | 20 namespace content { |
17 | 21 |
18 class AccessibilityTreeFormatterAuraLinux : public AccessibilityTreeFormatter { | 22 class AccessibilityTreeFormatterAuraLinux : public AccessibilityTreeFormatter { |
19 public: | 23 public: |
20 explicit AccessibilityTreeFormatterAuraLinux(); | 24 explicit AccessibilityTreeFormatterAuraLinux(); |
21 ~AccessibilityTreeFormatterAuraLinux() override; | 25 ~AccessibilityTreeFormatterAuraLinux() override; |
22 | 26 |
23 private: | 27 private: |
(...skipping 29 matching lines...) Expand all Loading... |
53 if (role != ATK_ROLE_UNKNOWN) | 57 if (role != ATK_ROLE_UNKNOWN) |
54 dict->SetString("role", std::string(atk_role_get_name(role))); | 58 dict->SetString("role", std::string(atk_role_get_name(role))); |
55 const gchar* name = atk_object_get_name(atk_object); | 59 const gchar* name = atk_object_get_name(atk_object); |
56 if (name) | 60 if (name) |
57 dict->SetString("name", std::string(name)); | 61 dict->SetString("name", std::string(name)); |
58 const gchar* description = atk_object_get_description(atk_object); | 62 const gchar* description = atk_object_get_description(atk_object); |
59 if (description) | 63 if (description) |
60 dict->SetString("description", std::string(description)); | 64 dict->SetString("description", std::string(description)); |
61 | 65 |
62 AtkStateSet* state_set = atk_object_ref_state_set(atk_object); | 66 AtkStateSet* state_set = atk_object_ref_state_set(atk_object); |
63 base::ListValue* states = new base::ListValue; | 67 auto states = base::MakeUnique<base::ListValue>(); |
64 for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) { | 68 for (int i = ATK_STATE_INVALID; i < ATK_STATE_LAST_DEFINED; i++) { |
65 AtkStateType state_type = static_cast<AtkStateType>(i); | 69 AtkStateType state_type = static_cast<AtkStateType>(i); |
66 if (atk_state_set_contains_state(state_set, state_type)) | 70 if (atk_state_set_contains_state(state_set, state_type)) |
67 states->AppendString(atk_state_type_get_name(state_type)); | 71 states->AppendString(atk_state_type_get_name(state_type)); |
68 } | 72 } |
69 dict->Set("states", states); | 73 dict->Set("states", std::move(states)); |
70 } | 74 } |
71 | 75 |
72 base::string16 AccessibilityTreeFormatterAuraLinux::ToString( | 76 base::string16 AccessibilityTreeFormatterAuraLinux::ToString( |
73 const base::DictionaryValue& node) { | 77 const base::DictionaryValue& node) { |
74 base::string16 line; | 78 base::string16 line; |
75 std::string role_value; | 79 std::string role_value; |
76 node.GetString("role", &role_value); | 80 node.GetString("role", &role_value); |
77 if (!role_value.empty()) { | 81 if (!role_value.empty()) { |
78 WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line); | 82 WriteAttribute(true, base::StringPrintf("[%s]", role_value.c_str()), &line); |
79 } | 83 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 120 |
117 const std::string AccessibilityTreeFormatterAuraLinux::GetAllowString() { | 121 const std::string AccessibilityTreeFormatterAuraLinux::GetAllowString() { |
118 return "@AURALINUX-ALLOW:"; | 122 return "@AURALINUX-ALLOW:"; |
119 } | 123 } |
120 | 124 |
121 const std::string AccessibilityTreeFormatterAuraLinux::GetDenyString() { | 125 const std::string AccessibilityTreeFormatterAuraLinux::GetDenyString() { |
122 return "@AURALINUX-DENY:"; | 126 return "@AURALINUX-DENY:"; |
123 } | 127 } |
124 | 128 |
125 } | 129 } |
OLD | NEW |