| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 114       RenderViewHost* rvh = | 114       RenderViewHost* rvh = | 
| 115           RenderViewHost::From(const_cast<RenderWidgetHost*>(rwh)); | 115           RenderViewHost::From(const_cast<RenderWidgetHost*>(rwh)); | 
| 116 | 116 | 
| 117       rvh_list->Append(BuildTargetDescriptor(rvh)); | 117       rvh_list->Append(BuildTargetDescriptor(rvh)); | 
| 118     } | 118     } | 
| 119   } | 119   } | 
| 120 | 120 | 
| 121   scoped_ptr<DictionaryValue> data(new DictionaryValue()); | 121   scoped_ptr<DictionaryValue> data(new DictionaryValue()); | 
| 122   data->Set("list", rvh_list.release()); | 122   data->Set("list", rvh_list.release()); | 
| 123   scoped_ptr<FundamentalValue> a11y_mode(new FundamentalValue( | 123   scoped_ptr<FundamentalValue> a11y_mode(new FundamentalValue( | 
| 124       BrowserAccessibilityStateImpl::GetInstance()->GetAccessibilityMode())); | 124       BrowserAccessibilityStateImpl::GetInstance()->accessibility_mode())); | 
| 125   data->Set("global_a11y_mode", a11y_mode.release()); | 125   data->Set("global_a11y_mode", a11y_mode.release()); | 
| 126 | 126 | 
| 127   std::string json_string; | 127   std::string json_string; | 
| 128   base::JSONWriter::Write(data.get(), &json_string); | 128   base::JSONWriter::Write(data.get(), &json_string); | 
| 129 | 129 | 
| 130   callback.Run(base::RefCountedString::TakeString(&json_string)); | 130   callback.Run(base::RefCountedString::TakeString(&json_string)); | 
| 131 } | 131 } | 
| 132 | 132 | 
| 133 bool HandleRequestCallback( | 133 bool HandleRequestCallback( | 
| 134     const std::string& path, | 134     const std::string& path, | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 198   AccessibilityMode mode = rwhi->accessibility_mode(); | 198   AccessibilityMode mode = rwhi->accessibility_mode(); | 
| 199   if (mode == AccessibilityModeOff) | 199   if (mode == AccessibilityModeOff) | 
| 200     rwhi->SetAccessibilityMode(AccessibilityModeComplete); | 200     rwhi->SetAccessibilityMode(AccessibilityModeComplete); | 
| 201   else | 201   else | 
| 202     rwhi->SetAccessibilityMode(AccessibilityModeOff); | 202     rwhi->SetAccessibilityMode(AccessibilityModeOff); | 
| 203 } | 203 } | 
| 204 | 204 | 
| 205 void AccessibilityUI::ToggleGlobalAccessibility(const base::ListValue* args) { | 205 void AccessibilityUI::ToggleGlobalAccessibility(const base::ListValue* args) { | 
| 206   BrowserAccessibilityStateImpl* state = | 206   BrowserAccessibilityStateImpl* state = | 
| 207       BrowserAccessibilityStateImpl::GetInstance(); | 207       BrowserAccessibilityStateImpl::GetInstance(); | 
| 208   AccessibilityMode mode = state->GetAccessibilityMode(); | 208   AccessibilityMode mode = state->accessibility_mode(); | 
| 209   AccessibilityMode new_mode = (mode == AccessibilityModeOff | 209   AccessibilityMode new_mode = (mode == AccessibilityModeOff | 
| 210                                 ? AccessibilityModeComplete | 210                                 ? AccessibilityModeComplete | 
| 211                                 : AccessibilityModeOff); | 211                                 : AccessibilityModeOff); | 
| 212   state->SetAccessibilityMode(new_mode); | 212   state->SetAccessibilityMode(new_mode); | 
| 213   for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); |  | 
| 214        !it.IsAtEnd(); it.Advance()) { |  | 
| 215     RenderProcessHost* render_process_host = it.GetCurrentValue(); |  | 
| 216     DCHECK(render_process_host); |  | 
| 217 |  | 
| 218     // Ignore processes that don't have a connection, such as crashed tabs. |  | 
| 219     if (!render_process_host->HasConnection()) |  | 
| 220       continue; |  | 
| 221 |  | 
| 222     RenderProcessHost::RenderWidgetHostsIterator rwit( |  | 
| 223         render_process_host->GetRenderWidgetHostsIterator()); |  | 
| 224     for (; !rwit.IsAtEnd(); rwit.Advance()) { |  | 
| 225       RenderWidgetHost* rwh = const_cast<RenderWidgetHost*>( |  | 
| 226           rwit.GetCurrentValue()); |  | 
| 227       DCHECK(rwh); |  | 
| 228       if (!rwh || !rwh->IsRenderView()) |  | 
| 229         continue; |  | 
| 230       RenderWidgetHostImpl* rwhi = RenderWidgetHostImpl::From(rwh); |  | 
| 231       rwhi->SetAccessibilityMode(new_mode); |  | 
| 232     } |  | 
| 233   } |  | 
| 234 } | 213 } | 
| 235 | 214 | 
| 236 void AccessibilityUI::RequestAccessibilityTree(const base::ListValue* args) { | 215 void AccessibilityUI::RequestAccessibilityTree(const base::ListValue* args) { | 
| 237   std::string process_id_str; | 216   std::string process_id_str; | 
| 238   std::string route_id_str; | 217   std::string route_id_str; | 
| 239   int process_id; | 218   int process_id; | 
| 240   int route_id; | 219   int route_id; | 
| 241   CHECK(args->GetSize() == 2); | 220   CHECK(args->GetSize() == 2); | 
| 242   CHECK(args->GetString(0, &process_id_str)); | 221   CHECK(args->GetString(0, &process_id_str)); | 
| 243   CHECK(args->GetString(1, &route_id_str)); | 222   CHECK(args->GetString(1, &route_id_str)); | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 278       AccessibilityTreeFormatter::Filter::ALLOW)); | 257       AccessibilityTreeFormatter::Filter::ALLOW)); | 
| 279   formatter->SetFilters(filters); | 258   formatter->SetFilters(filters); | 
| 280   formatter->FormatAccessibilityTree(&accessibility_contents_utf16); | 259   formatter->FormatAccessibilityTree(&accessibility_contents_utf16); | 
| 281 | 260 | 
| 282   result->Set("tree", | 261   result->Set("tree", | 
| 283               new StringValue(UTF16ToUTF8(accessibility_contents_utf16))); | 262               new StringValue(UTF16ToUTF8(accessibility_contents_utf16))); | 
| 284   web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); | 263   web_ui()->CallJavascriptFunction("accessibility.showTree", *(result.get())); | 
| 285 } | 264 } | 
| 286 | 265 | 
| 287 }  // namespace content | 266 }  // namespace content | 
| OLD | NEW | 
|---|