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

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

Issue 2891933004: Remove raw base::DictionaryValue::Set in //content (Closed)
Patch Set: Rebase Created 3 years, 6 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
OLDNEW
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 <memory> 7 #include <memory>
8 #include <utility>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/json/json_writer.h" 13 #include "base/json/json_writer.h"
13 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "content/browser/accessibility/accessibility_tree_formatter.h" 17 #include "content/browser/accessibility/accessibility_tree_formatter.h"
17 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h" 18 #include "content/browser/accessibility/accessibility_tree_formatter_blink.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 if (static_cast<RenderViewHostImpl*>(rvh)->GetDelegate()->IsNeverVisible()) 136 if (static_cast<RenderViewHostImpl*>(rvh)->GetDelegate()->IsNeverVisible())
136 continue; 137 continue;
137 BrowserContext* context = rvh->GetProcess()->GetBrowserContext(); 138 BrowserContext* context = rvh->GetProcess()->GetBrowserContext();
138 if (context != current_context) 139 if (context != current_context)
139 continue; 140 continue;
140 141
141 rvh_list->Append(BuildTargetDescriptor(rvh)); 142 rvh_list->Append(BuildTargetDescriptor(rvh));
142 } 143 }
143 144
144 base::DictionaryValue data; 145 base::DictionaryValue data;
145 data.Set("list", rvh_list.release()); 146 data.Set("list", std::move(rvh_list));
146 AccessibilityMode mode = 147 AccessibilityMode mode =
147 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode(); 148 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode();
148 bool disabled = base::CommandLine::ForCurrentProcess()->HasSwitch( 149 bool disabled = base::CommandLine::ForCurrentProcess()->HasSwitch(
149 switches::kDisableRendererAccessibility); 150 switches::kDisableRendererAccessibility);
150 bool native = mode.has_mode(AccessibilityMode::kNativeAPIs); 151 bool native = mode.has_mode(AccessibilityMode::kNativeAPIs);
151 bool web = mode.has_mode(AccessibilityMode::kWebContents); 152 bool web = mode.has_mode(AccessibilityMode::kWebContents);
152 bool text = mode.has_mode(AccessibilityMode::kInlineTextBoxes); 153 bool text = mode.has_mode(AccessibilityMode::kInlineTextBoxes);
153 bool screenreader = mode.has_mode(AccessibilityMode::kScreenReader); 154 bool screenreader = mode.has_mode(AccessibilityMode::kScreenReader);
154 bool html = mode.has_mode(AccessibilityMode::kHTML); 155 bool html = mode.has_mode(AccessibilityMode::kHTML);
155 156
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 CHECK(args->GetString(0, &process_id_str)); 316 CHECK(args->GetString(0, &process_id_str));
316 CHECK(args->GetString(1, &route_id_str)); 317 CHECK(args->GetString(1, &route_id_str));
317 CHECK(base::StringToInt(process_id_str, &process_id)); 318 CHECK(base::StringToInt(process_id_str, &process_id));
318 CHECK(base::StringToInt(route_id_str, &route_id)); 319 CHECK(base::StringToInt(route_id_str, &route_id));
319 320
320 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); 321 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id);
321 if (!rvh) { 322 if (!rvh) {
322 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue()); 323 std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue());
323 result->SetInteger(kProcessIdField, process_id); 324 result->SetInteger(kProcessIdField, process_id);
324 result->SetInteger(kRouteIdField, route_id); 325 result->SetInteger(kRouteIdField, route_id);
325 result->Set("error", new base::Value("Renderer no longer exists.")); 326 result->SetString("error", "Renderer no longer exists.");
326 web_ui()->CallJavascriptFunctionUnsafe("accessibility.showTree", 327 web_ui()->CallJavascriptFunctionUnsafe("accessibility.showTree",
327 *(result.get())); 328 *(result.get()));
328 return; 329 return;
329 } 330 }
330 331
331 std::unique_ptr<base::DictionaryValue> result(BuildTargetDescriptor(rvh)); 332 std::unique_ptr<base::DictionaryValue> result(BuildTargetDescriptor(rvh));
332 auto* web_contents = 333 auto* web_contents =
333 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(rvh)); 334 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(rvh));
334 // No matter the state of the current web_contents, we want to force the mode 335 // No matter the state of the current web_contents, we want to force the mode
335 // because we are about to show the accessibility tree 336 // because we are about to show the accessibility tree
336 web_contents->SetAccessibilityMode(AccessibilityMode( 337 web_contents->SetAccessibilityMode(AccessibilityMode(
337 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents)); 338 AccessibilityMode::kNativeAPIs | AccessibilityMode::kWebContents));
338 339
339 std::unique_ptr<AccessibilityTreeFormatter> formatter; 340 std::unique_ptr<AccessibilityTreeFormatter> formatter;
340 if (g_show_internal_accessibility_tree) 341 if (g_show_internal_accessibility_tree)
341 formatter.reset(new AccessibilityTreeFormatterBlink()); 342 formatter.reset(new AccessibilityTreeFormatterBlink());
342 else 343 else
343 formatter.reset(AccessibilityTreeFormatter::Create()); 344 formatter.reset(AccessibilityTreeFormatter::Create());
344 base::string16 accessibility_contents_utf16; 345 base::string16 accessibility_contents_utf16;
345 std::vector<AccessibilityTreeFormatter::Filter> filters; 346 std::vector<AccessibilityTreeFormatter::Filter> filters;
346 filters.push_back(AccessibilityTreeFormatter::Filter( 347 filters.push_back(AccessibilityTreeFormatter::Filter(
347 base::ASCIIToUTF16("*"), 348 base::ASCIIToUTF16("*"),
348 AccessibilityTreeFormatter::Filter::ALLOW)); 349 AccessibilityTreeFormatter::Filter::ALLOW));
349 formatter->SetFilters(filters); 350 formatter->SetFilters(filters);
350 auto* ax_mgr = web_contents->GetOrCreateRootBrowserAccessibilityManager(); 351 auto* ax_mgr = web_contents->GetOrCreateRootBrowserAccessibilityManager();
351 DCHECK(ax_mgr); 352 DCHECK(ax_mgr);
352 formatter->FormatAccessibilityTree(ax_mgr->GetRoot(), 353 formatter->FormatAccessibilityTree(ax_mgr->GetRoot(),
353 &accessibility_contents_utf16); 354 &accessibility_contents_utf16);
354 result->Set("tree", 355 result->SetString("tree", base::UTF16ToUTF8(accessibility_contents_utf16));
355 new base::Value(base::UTF16ToUTF8(accessibility_contents_utf16)));
356 web_ui()->CallJavascriptFunctionUnsafe("accessibility.showTree", 356 web_ui()->CallJavascriptFunctionUnsafe("accessibility.showTree",
357 *(result.get())); 357 *(result.get()));
358 } 358 }
359 359
360 } // namespace content 360 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698