Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: content/browser/accessibility/accessibility_tree_formatter.cc

Issue 121033002: Update uses of UTF conversions in content/ to use the base:: namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/accessibility/accessibility_tree_formatter_android.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 base::DictionaryValue* child_dict = new base::DictionaryValue; 72 base::DictionaryValue* child_dict = new base::DictionaryValue;
73 children->Append(child_dict); 73 children->Append(child_dict);
74 RecursiveBuildAccessibilityTree(*child_node, child_dict); 74 RecursiveBuildAccessibilityTree(*child_node, child_dict);
75 } 75 }
76 } 76 }
77 77
78 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree( 78 void AccessibilityTreeFormatter::RecursiveFormatAccessibilityTree(
79 const base::DictionaryValue& dict, base::string16* contents, int depth) { 79 const base::DictionaryValue& dict, base::string16* contents, int depth) {
80 base::string16 line = 80 base::string16 line =
81 ToString(dict, base::string16(depth * kIndentSpaces, ' ')); 81 ToString(dict, base::string16(depth * kIndentSpaces, ' '));
82 if (line.find(ASCIIToUTF16(kSkipString)) != base::string16::npos) 82 if (line.find(base::ASCIIToUTF16(kSkipString)) != base::string16::npos)
83 return; 83 return;
84 84
85 *contents += line; 85 *contents += line;
86 const base::ListValue* children; 86 const base::ListValue* children;
87 dict.GetList(kChildrenDictAttr, &children); 87 dict.GetList(kChildrenDictAttr, &children);
88 const base::DictionaryValue* child_dict; 88 const base::DictionaryValue* child_dict;
89 for (size_t i = 0; i < children->GetSize(); i++) { 89 for (size_t i = 0; i < children->GetSize(); i++) {
90 children->GetDictionary(i, &child_dict); 90 children->GetDictionary(i, &child_dict);
91 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1); 91 RecursiveFormatAccessibilityTree(*child_dict, contents, depth + 1);
92 } 92 }
93 } 93 }
94 94
95 #if (!defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \ 95 #if (!defined(OS_WIN) && !defined(OS_MACOSX) && !defined(OS_ANDROID) && \
96 !defined(TOOLKIT_GTK)) 96 !defined(TOOLKIT_GTK))
97 void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node, 97 void AccessibilityTreeFormatter::AddProperties(const BrowserAccessibility& node,
98 base::DictionaryValue* dict) { 98 base::DictionaryValue* dict) {
99 dict->SetInteger("id", node.renderer_id()); 99 dict->SetInteger("id", node.renderer_id());
100 } 100 }
101 101
102 base::string16 AccessibilityTreeFormatter::ToString( 102 base::string16 AccessibilityTreeFormatter::ToString(
103 const base::DictionaryValue& node, 103 const base::DictionaryValue& node,
104 const base::string16& indent) { 104 const base::string16& indent) {
105 int id_value; 105 int id_value;
106 node.GetInteger("id", &id_value); 106 node.GetInteger("id", &id_value);
107 return indent + base::IntToString16(id_value) + 107 return indent + base::IntToString16(id_value) +
108 ASCIIToUTF16("\n"); 108 base::ASCIIToUTF16("\n");
109 } 109 }
110 110
111 void AccessibilityTreeFormatter::Initialize() {} 111 void AccessibilityTreeFormatter::Initialize() {}
112 112
113 // static 113 // static
114 const base::FilePath::StringType 114 const base::FilePath::StringType
115 AccessibilityTreeFormatter::GetActualFileSuffix() { 115 AccessibilityTreeFormatter::GetActualFileSuffix() {
116 return base::FilePath::StringType(); 116 return base::FilePath::StringType();
117 } 117 }
118 118
(...skipping 26 matching lines...) Expand all
145 145
146 bool AccessibilityTreeFormatter::MatchesFilters( 146 bool AccessibilityTreeFormatter::MatchesFilters(
147 const base::string16& text, bool default_result) const { 147 const base::string16& text, bool default_result) const {
148 std::vector<Filter>::const_iterator iter = filters_.begin(); 148 std::vector<Filter>::const_iterator iter = filters_.begin();
149 bool allow = default_result; 149 bool allow = default_result;
150 for (iter = filters_.begin(); iter != filters_.end(); ++iter) { 150 for (iter = filters_.begin(); iter != filters_.end(); ++iter) {
151 if (MatchPattern(text, iter->match_str)) { 151 if (MatchPattern(text, iter->match_str)) {
152 if (iter->type == Filter::ALLOW_EMPTY) 152 if (iter->type == Filter::ALLOW_EMPTY)
153 allow = true; 153 allow = true;
154 else if (iter->type == Filter::ALLOW) 154 else if (iter->type == Filter::ALLOW)
155 allow = (!MatchPattern(text, UTF8ToUTF16("*=''"))); 155 allow = (!MatchPattern(text, base::UTF8ToUTF16("*=''")));
156 else 156 else
157 allow = false; 157 allow = false;
158 } 158 }
159 } 159 }
160 return allow; 160 return allow;
161 } 161 }
162 162
163 base::string16 AccessibilityTreeFormatter::FormatCoordinates( 163 base::string16 AccessibilityTreeFormatter::FormatCoordinates(
164 const char* name, const char* x_name, const char* y_name, 164 const char* name, const char* x_name, const char* y_name,
165 const base::DictionaryValue& value) { 165 const base::DictionaryValue& value) {
166 int x, y; 166 int x, y;
167 value.GetInteger(x_name, &x); 167 value.GetInteger(x_name, &x);
168 value.GetInteger(y_name, &y); 168 value.GetInteger(y_name, &y);
169 std::string xy_str(base::StringPrintf("%s=(%d, %d)", name, x, y)); 169 std::string xy_str(base::StringPrintf("%s=(%d, %d)", name, x, y));
170 170
171 return UTF8ToUTF16(xy_str); 171 return base::UTF8ToUTF16(xy_str);
172 } 172 }
173 173
174 void AccessibilityTreeFormatter::WriteAttribute( 174 void AccessibilityTreeFormatter::WriteAttribute(
175 bool include_by_default, const std::string& attr, base::string16* line) { 175 bool include_by_default, const std::string& attr, base::string16* line) {
176 WriteAttribute(include_by_default, UTF8ToUTF16(attr), line); 176 WriteAttribute(include_by_default, base::UTF8ToUTF16(attr), line);
177 } 177 }
178 178
179 void AccessibilityTreeFormatter::WriteAttribute( 179 void AccessibilityTreeFormatter::WriteAttribute(
180 bool include_by_default, const base::string16& attr, base::string16* line) { 180 bool include_by_default, const base::string16& attr, base::string16* line) {
181 if (attr.empty()) 181 if (attr.empty())
182 return; 182 return;
183 if (!MatchesFilters(attr, include_by_default)) 183 if (!MatchesFilters(attr, include_by_default))
184 return; 184 return;
185 if (!line->empty()) 185 if (!line->empty())
186 *line += ASCIIToUTF16(" "); 186 *line += base::ASCIIToUTF16(" ");
187 *line += attr; 187 *line += attr;
188 } 188 }
189 189
190 } // namespace content 190 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/accessibility_tree_formatter_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698