OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/android/jni_android.h" | 9 #include "base/android/jni_android.h" |
10 #include "base/android/jni_string.h" | 10 #include "base/android/jni_string.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 static_cast<int>(android_node->RangeCurrentValue())); | 115 static_cast<int>(android_node->RangeCurrentValue())); |
116 } | 116 } |
117 | 117 |
118 base::string16 AccessibilityTreeFormatter::ToString( | 118 base::string16 AccessibilityTreeFormatter::ToString( |
119 const base::DictionaryValue& dict, | 119 const base::DictionaryValue& dict, |
120 const base::string16& indent) { | 120 const base::string16& indent) { |
121 base::string16 line; | 121 base::string16 line; |
122 | 122 |
123 base::string16 class_value; | 123 base::string16 class_value; |
124 dict.GetString("class", &class_value); | 124 dict.GetString("class", &class_value); |
125 WriteAttribute(true, UTF16ToUTF8(class_value), &line); | 125 WriteAttribute(true, base::UTF16ToUTF8(class_value), &line); |
126 | 126 |
127 for (unsigned i = 0; i < arraysize(BOOL_ATTRIBUTES); i++) { | 127 for (unsigned i = 0; i < arraysize(BOOL_ATTRIBUTES); i++) { |
128 const char* attribute_name = BOOL_ATTRIBUTES[i]; | 128 const char* attribute_name = BOOL_ATTRIBUTES[i]; |
129 bool value; | 129 bool value; |
130 if (dict.GetBoolean(attribute_name, &value) && value) | 130 if (dict.GetBoolean(attribute_name, &value) && value) |
131 WriteAttribute(true, attribute_name, &line); | 131 WriteAttribute(true, attribute_name, &line); |
132 } | 132 } |
133 | 133 |
134 for (unsigned i = 0; i < arraysize(STRING_ATTRIBUTES); i++) { | 134 for (unsigned i = 0; i < arraysize(STRING_ATTRIBUTES); i++) { |
135 const char* attribute_name = STRING_ATTRIBUTES[i]; | 135 const char* attribute_name = STRING_ATTRIBUTES[i]; |
136 std::string value; | 136 std::string value; |
137 if (!dict.GetString(attribute_name, &value) || value.empty()) | 137 if (!dict.GetString(attribute_name, &value) || value.empty()) |
138 continue; | 138 continue; |
139 WriteAttribute(true, | 139 WriteAttribute(true, |
140 StringPrintf("%s='%s'", attribute_name, value.c_str()), | 140 StringPrintf("%s='%s'", attribute_name, value.c_str()), |
141 &line); | 141 &line); |
142 } | 142 } |
143 | 143 |
144 for (unsigned i = 0; i < arraysize(INT_ATTRIBUTES); i++) { | 144 for (unsigned i = 0; i < arraysize(INT_ATTRIBUTES); i++) { |
145 const char* attribute_name = INT_ATTRIBUTES[i]; | 145 const char* attribute_name = INT_ATTRIBUTES[i]; |
146 int value; | 146 int value; |
147 if (!dict.GetInteger(attribute_name, &value) || value == 0) | 147 if (!dict.GetInteger(attribute_name, &value) || value == 0) |
148 continue; | 148 continue; |
149 WriteAttribute(true, | 149 WriteAttribute(true, |
150 StringPrintf("%s=%d", attribute_name, value), | 150 StringPrintf("%s=%d", attribute_name, value), |
151 &line); | 151 &line); |
152 } | 152 } |
153 | 153 |
154 return indent + line + ASCIIToUTF16("\n"); | 154 return indent + line + base::ASCIIToUTF16("\n"); |
155 } | 155 } |
156 | 156 |
157 // static | 157 // static |
158 const base::FilePath::StringType | 158 const base::FilePath::StringType |
159 AccessibilityTreeFormatter::GetActualFileSuffix() { | 159 AccessibilityTreeFormatter::GetActualFileSuffix() { |
160 return FILE_PATH_LITERAL("-actual-android.txt"); | 160 return FILE_PATH_LITERAL("-actual-android.txt"); |
161 } | 161 } |
162 | 162 |
163 // static | 163 // static |
164 const base::FilePath::StringType | 164 const base::FilePath::StringType |
(...skipping 10 matching lines...) Expand all Loading... |
175 const std::string AccessibilityTreeFormatter::GetAllowString() { | 175 const std::string AccessibilityTreeFormatter::GetAllowString() { |
176 return "@ANDROID-ALLOW:"; | 176 return "@ANDROID-ALLOW:"; |
177 } | 177 } |
178 | 178 |
179 // static | 179 // static |
180 const std::string AccessibilityTreeFormatter::GetDenyString() { | 180 const std::string AccessibilityTreeFormatter::GetDenyString() { |
181 return "@ANDROID-DENY:"; | 181 return "@ANDROID-DENY:"; |
182 } | 182 } |
183 | 183 |
184 } // namespace content | 184 } // namespace content |
OLD | NEW |