| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "content/browser/accessibility/accessibility_tree_formatter.h" | 13 #include "content/browser/accessibility/accessibility_tree_formatter.h" |
| 14 #include "content/browser/accessibility/browser_accessibility_manager.h" | 14 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 15 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 15 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 16 #include "content/browser/renderer_host/render_widget_host_impl.h" | 16 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 17 #include "content/common/view_message_enums.h" | 17 #include "content/common/view_message_enums.h" |
| 18 #include "content/port/browser/render_widget_host_view_port.h" | 18 #include "content/port/browser/render_widget_host_view_port.h" |
| 19 #include "content/public/browser/browser_thread.h" | |
| 20 #include "content/public/browser/favicon_status.h" | 19 #include "content/public/browser/favicon_status.h" |
| 21 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 22 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
| 23 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 24 #include "content/public/browser/render_widget_host.h" | 23 #include "content/public/browser/render_widget_host.h" |
| 25 #include "content/public/browser/render_widget_host_iterator.h" | 24 #include "content/public/browser/render_widget_host_iterator.h" |
| 26 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_ui_data_source.h" | 26 #include "content/public/browser/web_ui_data_source.h" |
| 28 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 29 #include "grit/content_resources.h" | 28 #include "grit/content_resources.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 163 } |
| 165 | 164 |
| 166 AccessibilityUI::~AccessibilityUI() { | 165 AccessibilityUI::~AccessibilityUI() { |
| 167 } | 166 } |
| 168 | 167 |
| 169 void AccessibilityUI::ToggleAccessibility(const base::ListValue* args) { | 168 void AccessibilityUI::ToggleAccessibility(const base::ListValue* args) { |
| 170 std::string process_id_str; | 169 std::string process_id_str; |
| 171 std::string route_id_str; | 170 std::string route_id_str; |
| 172 int process_id; | 171 int process_id; |
| 173 int route_id; | 172 int route_id; |
| 174 CHECK(args->GetSize() == 2); | 173 CHECK_EQ(2U, args->GetSize()); |
| 175 CHECK(args->GetString(0, &process_id_str)); | 174 CHECK(args->GetString(0, &process_id_str)); |
| 176 CHECK(args->GetString(1, &route_id_str)); | 175 CHECK(args->GetString(1, &route_id_str)); |
| 177 CHECK(base::StringToInt(process_id_str, | 176 CHECK(base::StringToInt(process_id_str, &process_id)); |
| 178 &process_id)); | |
| 179 CHECK(base::StringToInt(route_id_str, &route_id)); | 177 CHECK(base::StringToInt(route_id_str, &route_id)); |
| 180 | 178 |
| 181 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); | 179 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); |
| 182 if (!rvh) | 180 if (!rvh) |
| 183 return; | 181 return; |
| 184 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rvh); | 182 RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rvh); |
| 185 if (!rwhi) | 183 if (!rwhi) |
| 186 return; | 184 return; |
| 187 AccessibilityMode mode = rwhi->accessibility_mode(); | 185 AccessibilityMode mode = rwhi->accessibility_mode(); |
| 188 if (mode == AccessibilityModeOff) | 186 if (mode == AccessibilityModeOff) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 199 state->EnableAccessibility(); | 197 state->EnableAccessibility(); |
| 200 else | 198 else |
| 201 state->DisableAccessibility(); | 199 state->DisableAccessibility(); |
| 202 } | 200 } |
| 203 | 201 |
| 204 void AccessibilityUI::RequestAccessibilityTree(const base::ListValue* args) { | 202 void AccessibilityUI::RequestAccessibilityTree(const base::ListValue* args) { |
| 205 std::string process_id_str; | 203 std::string process_id_str; |
| 206 std::string route_id_str; | 204 std::string route_id_str; |
| 207 int process_id; | 205 int process_id; |
| 208 int route_id; | 206 int route_id; |
| 209 CHECK(args->GetSize() == 2); | 207 CHECK_EQ(2U, args->GetSize()); |
| 210 CHECK(args->GetString(0, &process_id_str)); | 208 CHECK(args->GetString(0, &process_id_str)); |
| 211 CHECK(args->GetString(1, &route_id_str)); | 209 CHECK(args->GetString(1, &route_id_str)); |
| 212 CHECK(base::StringToInt(process_id_str, &process_id)); | 210 CHECK(base::StringToInt(process_id_str, &process_id)); |
| 213 CHECK(base::StringToInt(route_id_str, &route_id)); | 211 CHECK(base::StringToInt(route_id_str, &route_id)); |
| 214 | 212 |
| 215 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); | 213 RenderViewHost* rvh = RenderViewHost::FromID(process_id, route_id); |
| 216 if (!rvh) { | 214 if (!rvh) { |
| 217 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); | 215 scoped_ptr<base::DictionaryValue> result(new base::DictionaryValue()); |
| 218 result->SetInteger(kProcessIdField, process_id); | 216 result->SetInteger(kProcessIdField, process_id); |
| 219 result->SetInteger(kRouteIdField, route_id); | 217 result->SetInteger(kRouteIdField, route_id); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 249 formatter->SetFilters(filters); | 247 formatter->SetFilters(filters); |
| 250 formatter->FormatAccessibilityTree(&accessibility_contents_utf16); | 248 formatter->FormatAccessibilityTree(&accessibility_contents_utf16); |
| 251 | 249 |
| 252 result->Set("tree", | 250 result->Set("tree", |
| 253 new base::StringValue( | 251 new base::StringValue( |
| 254 base::UTF16ToUTF8(accessibility_contents_utf16))); | 252 base::UTF16ToUTF8(accessibility_contents_utf16))); |
| 255 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); | 253 web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); |
| 256 } | 254 } |
| 257 | 255 |
| 258 } // namespace content | 256 } // namespace content |
| OLD | NEW |