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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 continue; | 109 continue; |
110 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); | 110 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(widget); |
111 BrowserContext* context = rwhi->GetProcess()->GetBrowserContext(); | 111 BrowserContext* context = rwhi->GetProcess()->GetBrowserContext(); |
112 if (context != current_context) | 112 if (context != current_context) |
113 continue; | 113 continue; |
114 | 114 |
115 RenderViewHost* rvh = RenderViewHost::From(widget); | 115 RenderViewHost* rvh = RenderViewHost::From(widget); |
116 rvh_list->Append(BuildTargetDescriptor(rvh)); | 116 rvh_list->Append(BuildTargetDescriptor(rvh)); |
117 } | 117 } |
118 | 118 |
119 scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); | 119 base::DictionaryValue data; |
120 data->Set("list", rvh_list.release()); | 120 data.Set("list", rvh_list.release()); |
121 data->SetInteger( | 121 data.SetInteger( |
122 "global_a11y_mode", | 122 "global_a11y_mode", |
123 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()); | 123 BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode()); |
124 | 124 |
125 std::string json_string; | 125 std::string json_string; |
126 base::JSONWriter::Write(data.get(), &json_string); | 126 base::JSONWriter::Write(data, &json_string); |
127 | 127 |
128 callback.Run(base::RefCountedString::TakeString(&json_string)); | 128 callback.Run(base::RefCountedString::TakeString(&json_string)); |
129 return true; | 129 return true; |
130 } | 130 } |
131 | 131 |
132 } // namespace | 132 } // namespace |
133 | 133 |
134 AccessibilityUI::AccessibilityUI(WebUI* web_ui) : WebUIController(web_ui) { | 134 AccessibilityUI::AccessibilityUI(WebUI* web_ui) : WebUIController(web_ui) { |
135 // Set up the chrome://accessibility source. | 135 // Set up the chrome://accessibility source. |
136 WebUIDataSource* html_source = | 136 WebUIDataSource* html_source = |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 formatter->SetFilters(filters); | 233 formatter->SetFilters(filters); |
234 formatter->FormatAccessibilityTree(&accessibility_contents_utf16); | 234 formatter->FormatAccessibilityTree(&accessibility_contents_utf16); |
235 | 235 |
236 result->Set("tree", | 236 result->Set("tree", |
237 new base::StringValue( | 237 new base::StringValue( |
238 base::UTF16ToUTF8(accessibility_contents_utf16))); | 238 base::UTF16ToUTF8(accessibility_contents_utf16))); |
239 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); | 239 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); |
240 } | 240 } |
241 | 241 |
242 } // namespace content | 242 } // namespace content |
OLD | NEW |