| 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/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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "content/browser/accessibility/browser_accessibility_manager.h" | 13 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 14 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
| 15 #include "content/browser/web_contents/web_contents_impl.h" |
| 15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.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 { |
| 19 namespace { | 20 namespace { |
| 20 const int kIndentSpaces = 4; | 21 const int kIndentSpaces = 4; |
| 21 const char* kSkipString = "@NO_DUMP"; | 22 const char* kSkipString = "@NO_DUMP"; |
| 22 const char* kChildrenDictAttr = "children"; | 23 const char* kChildrenDictAttr = "children"; |
| 23 } | 24 } |
| 24 | 25 |
| 25 AccessibilityTreeFormatter::AccessibilityTreeFormatter( | 26 AccessibilityTreeFormatter::AccessibilityTreeFormatter( |
| 26 BrowserAccessibility* root) | 27 BrowserAccessibility* root) |
| 27 : root_(root) { | 28 : root_(root) { |
| 28 Initialize(); | 29 Initialize(); |
| 29 } | 30 } |
| 30 | 31 |
| 31 // static | 32 // static |
| 32 AccessibilityTreeFormatter* AccessibilityTreeFormatter::Create( | 33 AccessibilityTreeFormatter* AccessibilityTreeFormatter::Create( |
| 33 RenderViewHost* rvh) { | 34 WebContents* web_contents) { |
| 34 RenderWidgetHostViewBase* host_view = static_cast<RenderWidgetHostViewBase*>( | |
| 35 WebContents::FromRenderViewHost(rvh)->GetRenderWidgetHostView()); | |
| 36 | |
| 37 BrowserAccessibilityManager* manager = | 35 BrowserAccessibilityManager* manager = |
| 38 host_view->GetBrowserAccessibilityManager(); | 36 static_cast<WebContentsImpl*>(web_contents)-> |
| 37 GetRootBrowserAccessibilityManager(); |
| 39 if (!manager) | 38 if (!manager) |
| 40 return NULL; | 39 return NULL; |
| 41 | 40 |
| 42 BrowserAccessibility* root = manager->GetRoot(); | 41 BrowserAccessibility* root = manager->GetRoot(); |
| 43 return new AccessibilityTreeFormatter(root); | 42 return new AccessibilityTreeFormatter(root); |
| 44 } | 43 } |
| 45 | 44 |
| 46 | 45 |
| 47 AccessibilityTreeFormatter::~AccessibilityTreeFormatter() { | 46 AccessibilityTreeFormatter::~AccessibilityTreeFormatter() { |
| 48 } | 47 } |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 if (attr.empty()) | 179 if (attr.empty()) |
| 181 return; | 180 return; |
| 182 if (!MatchesFilters(attr, include_by_default)) | 181 if (!MatchesFilters(attr, include_by_default)) |
| 183 return; | 182 return; |
| 184 if (!line->empty()) | 183 if (!line->empty()) |
| 185 *line += base::ASCIIToUTF16(" "); | 184 *line += base::ASCIIToUTF16(" "); |
| 186 *line += attr; | 185 *line += attr; |
| 187 } | 186 } |
| 188 | 187 |
| 189 } // namespace content | 188 } // namespace content |
| OLD | NEW |