OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_ui.h" | 5 #include "content/browser/accessibility/accessibility_ui.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 rvh->GetProcess()->GetID(), | 92 rvh->GetProcess()->GetID(), |
93 rvh->GetRoutingID(), | 93 rvh->GetRoutingID(), |
94 accessibility_mode); | 94 accessibility_mode); |
95 } | 95 } |
96 | 96 |
97 bool HandleRequestCallback(BrowserContext* current_context, | 97 bool HandleRequestCallback(BrowserContext* current_context, |
98 const std::string& path, | 98 const std::string& path, |
99 const WebUIDataSource::GotDataCallback& callback) { | 99 const WebUIDataSource::GotDataCallback& callback) { |
100 if (path != kDataFile) | 100 if (path != kDataFile) |
101 return false; | 101 return false; |
102 scoped_ptr<base::ListValue> rvh_list(new base::ListValue()); | 102 std::unique_ptr<base::ListValue> rvh_list(new base::ListValue()); |
103 | 103 |
104 scoped_ptr<RenderWidgetHostIterator> widgets( | 104 std::unique_ptr<RenderWidgetHostIterator> widgets( |
105 RenderWidgetHost::GetRenderWidgetHosts()); | 105 RenderWidgetHost::GetRenderWidgetHosts()); |
106 | 106 |
107 while (RenderWidgetHost* widget = widgets->GetNextHost()) { | 107 while (RenderWidgetHost* widget = widgets->GetNextHost()) { |
108 // Ignore processes that don't have a connection, such as crashed tabs. | 108 // Ignore processes that don't have a connection, such as crashed tabs. |
109 if (!widget->GetProcess()->HasConnection()) | 109 if (!widget->GetProcess()->HasConnection()) |
110 continue; | 110 continue; |
111 RenderViewHost* rvh = RenderViewHost::From(widget); | 111 RenderViewHost* rvh = RenderViewHost::From(widget); |
112 if (!rvh) | 112 if (!rvh) |
113 continue; | 113 continue; |
114 BrowserContext* context = rvh->GetProcess()->GetBrowserContext(); | 114 BrowserContext* context = rvh->GetProcess()->GetBrowserContext(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 int process_id; | 219 int process_id; |
220 int route_id; | 220 int route_id; |
221 CHECK_EQ(2U, args->GetSize()); | 221 CHECK_EQ(2U, args->GetSize()); |
222 CHECK(args->GetString(0, &process_id_str)); | 222 CHECK(args->GetString(0, &process_id_str)); |
223 CHECK(args->GetString(1, &route_id_str)); | 223 CHECK(args->GetString(1, &route_id_str)); |
224 CHECK(base::StringToInt(process_id_str, &process_id)); | 224 CHECK(base::StringToInt(process_id_str, &process_id)); |
225 CHECK(base::StringToInt(route_id_str, &route_id)); | 225 CHECK(base::StringToInt(route_id_str, &route_id)); |
226 | 226 |
227 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); | 227 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); |
228 if (!rvh) { | 228 if (!rvh) { |
229 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 229 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
230 result->SetInteger(kProcessIdField, process_id); | 230 result->SetInteger(kProcessIdField, process_id); |
231 result->SetInteger(kRouteIdField, route_id); | 231 result->SetInteger(kRouteIdField, route_id); |
232 result->Set("error", new base::StringValue("Renderer no longer exists.")); | 232 result->Set("error", new base::StringValue("Renderer no longer exists.")); |
233 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); | 233 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); |
234 return; | 234 return; |
235 } | 235 } |
236 | 236 |
237 scoped_ptr<base::DictionaryValue> result(BuildTargetDescriptor(rvh)); | 237 std::unique_ptr<base::DictionaryValue> result(BuildTargetDescriptor(rvh)); |
238 auto web_contents = static_cast<WebContentsImpl*>( | 238 auto web_contents = static_cast<WebContentsImpl*>( |
239 WebContents::FromRenderViewHost(rvh)); | 239 WebContents::FromRenderViewHost(rvh)); |
240 scoped_ptr<AccessibilityTreeFormatter> formatter; | 240 std::unique_ptr<AccessibilityTreeFormatter> formatter; |
241 if (g_show_internal_accessibility_tree) | 241 if (g_show_internal_accessibility_tree) |
242 formatter.reset(new AccessibilityTreeFormatterBlink()); | 242 formatter.reset(new AccessibilityTreeFormatterBlink()); |
243 else | 243 else |
244 formatter.reset(AccessibilityTreeFormatter::Create()); | 244 formatter.reset(AccessibilityTreeFormatter::Create()); |
245 base::string16 accessibility_contents_utf16; | 245 base::string16 accessibility_contents_utf16; |
246 std::vector<AccessibilityTreeFormatter::Filter> filters; | 246 std::vector<AccessibilityTreeFormatter::Filter> filters; |
247 filters.push_back(AccessibilityTreeFormatter::Filter( | 247 filters.push_back(AccessibilityTreeFormatter::Filter( |
248 base::ASCIIToUTF16("*"), | 248 base::ASCIIToUTF16("*"), |
249 AccessibilityTreeFormatter::Filter::ALLOW)); | 249 AccessibilityTreeFormatter::Filter::ALLOW)); |
250 formatter->SetFilters(filters); | 250 formatter->SetFilters(filters); |
251 formatter->FormatAccessibilityTree( | 251 formatter->FormatAccessibilityTree( |
252 web_contents->GetRootBrowserAccessibilityManager()->GetRoot(), | 252 web_contents->GetRootBrowserAccessibilityManager()->GetRoot(), |
253 &accessibility_contents_utf16); | 253 &accessibility_contents_utf16); |
254 result->Set("tree", | 254 result->Set("tree", |
255 new base::StringValue( | 255 new base::StringValue( |
256 base::UTF16ToUTF8(accessibility_contents_utf16))); | 256 base::UTF16ToUTF8(accessibility_contents_utf16))); |
257 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); | 257 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); |
258 } | 258 } |
259 | 259 |
260 } // namespace content | 260 } // namespace content |
OLD | NEW |