| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> |
| 10 |
| 9 #include "base/logging.h" | 11 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | |
| 11 #include "base/strings/pattern.h" | 12 #include "base/strings/pattern.h" |
| 12 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 16 #include "content/browser/accessibility/browser_accessibility_manager.h" | 17 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 17 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 18 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 18 #include "content/browser/web_contents/web_contents_impl.h" | 19 #include "content/browser/web_contents/web_contents_impl.h" |
| 19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 namespace { | 23 namespace { |
| 23 const char kIndentSymbol = '+'; | 24 const char kIndentSymbol = '+'; |
| 24 const int kIndentSymbolCount = 2; | 25 const int kIndentSymbolCount = 2; |
| 25 const char* kSkipString = "@NO_DUMP"; | 26 const char* kSkipString = "@NO_DUMP"; |
| 26 const char* kSkipChildren = "@NO_CHILDREN_DUMP"; | 27 const char* kSkipChildren = "@NO_CHILDREN_DUMP"; |
| 27 const char* kChildrenDictAttr = "children"; | 28 const char* kChildrenDictAttr = "children"; |
| 28 } | 29 } |
| 29 | 30 |
| 30 AccessibilityTreeFormatter::AccessibilityTreeFormatter() | 31 AccessibilityTreeFormatter::AccessibilityTreeFormatter() |
| 31 : show_ids_(false) { | 32 : show_ids_(false) { |
| 32 } | 33 } |
| 33 | 34 |
| 34 AccessibilityTreeFormatter::~AccessibilityTreeFormatter() { | 35 AccessibilityTreeFormatter::~AccessibilityTreeFormatter() { |
| 35 } | 36 } |
| 36 | 37 |
| 37 scoped_ptr<base::DictionaryValue> | 38 std::unique_ptr<base::DictionaryValue> |
| 38 AccessibilityTreeFormatter::BuildAccessibilityTree( | 39 AccessibilityTreeFormatter::BuildAccessibilityTree(BrowserAccessibility* root) { |
| 39 BrowserAccessibility* root) { | |
| 40 CHECK(root); | 40 CHECK(root); |
| 41 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 41 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
| 42 RecursiveBuildAccessibilityTree(*root, dict.get()); | 42 RecursiveBuildAccessibilityTree(*root, dict.get()); |
| 43 return dict; | 43 return dict; |
| 44 } | 44 } |
| 45 | 45 |
| 46 void AccessibilityTreeFormatter::FormatAccessibilityTree( | 46 void AccessibilityTreeFormatter::FormatAccessibilityTree( |
| 47 BrowserAccessibility* root, base::string16* contents) { | 47 BrowserAccessibility* root, base::string16* contents) { |
| 48 scoped_ptr<base::DictionaryValue> dict = BuildAccessibilityTree(root); | 48 std::unique_ptr<base::DictionaryValue> dict = BuildAccessibilityTree(root); |
| 49 RecursiveFormatAccessibilityTree(*(dict.get()), contents); | 49 RecursiveFormatAccessibilityTree(*(dict.get()), contents); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree( | 52 void AccessibilityTreeFormatter::RecursiveBuildAccessibilityTree( |
| 53 const BrowserAccessibility& node, base::DictionaryValue* dict) { | 53 const BrowserAccessibility& node, base::DictionaryValue* dict) { |
| 54 AddProperties(node, dict); | 54 AddProperties(node, dict); |
| 55 | 55 |
| 56 base::ListValue* children = new base::ListValue; | 56 base::ListValue* children = new base::ListValue; |
| 57 dict->Set(kChildrenDictAttr, children); | 57 dict->Set(kChildrenDictAttr, children); |
| 58 | 58 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (attr.empty()) | 147 if (attr.empty()) |
| 148 return; | 148 return; |
| 149 if (!MatchesFilters(attr, include_by_default)) | 149 if (!MatchesFilters(attr, include_by_default)) |
| 150 return; | 150 return; |
| 151 if (!line->empty()) | 151 if (!line->empty()) |
| 152 *line += base::ASCIIToUTF16(" "); | 152 *line += base::ASCIIToUTF16(" "); |
| 153 *line += attr; | 153 *line += attr; |
| 154 } | 154 } |
| 155 | 155 |
| 156 } // namespace content | 156 } // namespace content |
| OLD | NEW |