| OLD | NEW |
| 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/pattern.h" |
| 9 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 11 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/browser/accessibility/browser_accessibility_manager.h" | 14 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 15 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 15 #include "content/browser/web_contents/web_contents_impl.h" | 16 #include "content/browser/web_contents/web_contents_impl.h" |
| 16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 } | 147 } |
| 147 | 148 |
| 148 // static | 149 // static |
| 149 bool AccessibilityTreeFormatter::MatchesFilters( | 150 bool AccessibilityTreeFormatter::MatchesFilters( |
| 150 const std::vector<Filter>& filters, | 151 const std::vector<Filter>& filters, |
| 151 const base::string16& text, | 152 const base::string16& text, |
| 152 bool default_result) { | 153 bool default_result) { |
| 153 std::vector<Filter>::const_iterator iter = filters.begin(); | 154 std::vector<Filter>::const_iterator iter = filters.begin(); |
| 154 bool allow = default_result; | 155 bool allow = default_result; |
| 155 for (iter = filters.begin(); iter != filters.end(); ++iter) { | 156 for (iter = filters.begin(); iter != filters.end(); ++iter) { |
| 156 if (MatchPattern(text, iter->match_str)) { | 157 if (base::MatchPattern(text, iter->match_str)) { |
| 157 if (iter->type == Filter::ALLOW_EMPTY) | 158 if (iter->type == Filter::ALLOW_EMPTY) |
| 158 allow = true; | 159 allow = true; |
| 159 else if (iter->type == Filter::ALLOW) | 160 else if (iter->type == Filter::ALLOW) |
| 160 allow = (!MatchPattern(text, base::UTF8ToUTF16("*=''"))); | 161 allow = (!base::MatchPattern(text, base::UTF8ToUTF16("*=''"))); |
| 161 else | 162 else |
| 162 allow = false; | 163 allow = false; |
| 163 } | 164 } |
| 164 } | 165 } |
| 165 return allow; | 166 return allow; |
| 166 } | 167 } |
| 167 | 168 |
| 168 bool AccessibilityTreeFormatter::MatchesFilters( | 169 bool AccessibilityTreeFormatter::MatchesFilters( |
| 169 const base::string16& text, bool default_result) const { | 170 const base::string16& text, bool default_result) const { |
| 170 return MatchesFilters(filters_, text, default_result); | 171 return MatchesFilters(filters_, text, default_result); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 191 if (attr.empty()) | 192 if (attr.empty()) |
| 192 return; | 193 return; |
| 193 if (!MatchesFilters(attr, include_by_default)) | 194 if (!MatchesFilters(attr, include_by_default)) |
| 194 return; | 195 return; |
| 195 if (!line->empty()) | 196 if (!line->empty()) |
| 196 *line += base::ASCIIToUTF16(" "); | 197 *line += base::ASCIIToUTF16(" "); |
| 197 *line += attr; | 198 *line += attr; |
| 198 } | 199 } |
| 199 | 200 |
| 200 } // namespace content | 201 } // namespace content |
| OLD | NEW |