| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/accessibility/accessibility_extension_api.h" | 5 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" | 10 #include "chrome/browser/accessibility/accessibility_extension_api_constants.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 return; | 210 return; |
| 211 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile); | 211 extensions::EventRouter* event_router = extensions::EventRouter::Get(profile); |
| 212 if (!event_router) | 212 if (!event_router) |
| 213 return; | 213 return; |
| 214 | 214 |
| 215 scoped_ptr<extensions::Event> event(new extensions::Event( | 215 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 216 event_name, event_args.Pass())); | 216 event_name, event_args.Pass())); |
| 217 event_router->BroadcastEvent(event.Pass()); | 217 event_router->BroadcastEvent(event.Pass()); |
| 218 } | 218 } |
| 219 | 219 |
| 220 bool AccessibilityPrivateSetAccessibilityEnabledFunction::RunImpl() { | 220 bool AccessibilityPrivateSetAccessibilityEnabledFunction::RunSync() { |
| 221 bool enabled; | 221 bool enabled; |
| 222 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); | 222 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); |
| 223 ExtensionAccessibilityEventRouter::GetInstance() | 223 ExtensionAccessibilityEventRouter::GetInstance() |
| 224 ->SetAccessibilityEnabled(enabled); | 224 ->SetAccessibilityEnabled(enabled); |
| 225 return true; | 225 return true; |
| 226 } | 226 } |
| 227 | 227 |
| 228 bool AccessibilityPrivateSetNativeAccessibilityEnabledFunction::RunImpl() { | 228 bool AccessibilityPrivateSetNativeAccessibilityEnabledFunction::RunSync() { |
| 229 bool enabled; | 229 bool enabled; |
| 230 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); | 230 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); |
| 231 if (enabled) { | 231 if (enabled) { |
| 232 content::BrowserAccessibilityState::GetInstance()-> | 232 content::BrowserAccessibilityState::GetInstance()-> |
| 233 EnableAccessibility(); | 233 EnableAccessibility(); |
| 234 } else { | 234 } else { |
| 235 content::BrowserAccessibilityState::GetInstance()-> | 235 content::BrowserAccessibilityState::GetInstance()-> |
| 236 DisableAccessibility(); | 236 DisableAccessibility(); |
| 237 } | 237 } |
| 238 return true; | 238 return true; |
| 239 } | 239 } |
| 240 | 240 |
| 241 bool AccessibilityPrivateGetFocusedControlFunction::RunImpl() { | 241 bool AccessibilityPrivateGetFocusedControlFunction::RunSync() { |
| 242 // Get the serialized dict from the last focused control and return it. | 242 // Get the serialized dict from the last focused control and return it. |
| 243 // However, if the dict is empty, that means we haven't seen any focus | 243 // However, if the dict is empty, that means we haven't seen any focus |
| 244 // events yet, so return null instead. | 244 // events yet, so return null instead. |
| 245 ExtensionAccessibilityEventRouter *accessibility_event_router = | 245 ExtensionAccessibilityEventRouter *accessibility_event_router = |
| 246 ExtensionAccessibilityEventRouter::GetInstance(); | 246 ExtensionAccessibilityEventRouter::GetInstance(); |
| 247 base::DictionaryValue *last_focused_control_dict = | 247 base::DictionaryValue *last_focused_control_dict = |
| 248 accessibility_event_router->last_focused_control_dict(); | 248 accessibility_event_router->last_focused_control_dict(); |
| 249 if (last_focused_control_dict->size()) { | 249 if (last_focused_control_dict->size()) { |
| 250 SetResult(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 250 SetResult(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
| 251 } else { | 251 } else { |
| 252 SetResult(base::Value::CreateNullValue()); | 252 SetResult(base::Value::CreateNullValue()); |
| 253 } | 253 } |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool AccessibilityPrivateGetAlertsForTabFunction::RunImpl() { | 257 bool AccessibilityPrivateGetAlertsForTabFunction::RunSync() { |
| 258 int tab_id; | 258 int tab_id; |
| 259 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); | 259 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| 260 | 260 |
| 261 TabStripModel* tab_strip = NULL; | 261 TabStripModel* tab_strip = NULL; |
| 262 content::WebContents* contents = NULL; | 262 content::WebContents* contents = NULL; |
| 263 int tab_index = -1; | 263 int tab_index = -1; |
| 264 if (!extensions::ExtensionTabUtil::GetTabById(tab_id, | 264 if (!extensions::ExtensionTabUtil::GetTabById(tab_id, |
| 265 GetProfile(), | 265 GetProfile(), |
| 266 include_incognito(), | 266 include_incognito(), |
| 267 NULL, | 267 NULL, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 286 const base::string16 message_text = | 286 const base::string16 message_text = |
| 287 confirm_infobar_delegate->GetMessageText(); | 287 confirm_infobar_delegate->GetMessageText(); |
| 288 alert_value->SetString(keys::kMessageKey, message_text); | 288 alert_value->SetString(keys::kMessageKey, message_text); |
| 289 alerts_value->Append(alert_value); | 289 alerts_value->Append(alert_value); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 | 292 |
| 293 SetResult(alerts_value); | 293 SetResult(alerts_value); |
| 294 return true; | 294 return true; |
| 295 } | 295 } |
| OLD | NEW |