| 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/string_number_conversions.h" | 8 #include "base/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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 scoped_ptr<base::ListValue> event_args) { | 164 scoped_ptr<base::ListValue> event_args) { |
| 165 if (enabled_ && profile && | 165 if (enabled_ && profile && |
| 166 extensions::ExtensionSystem::Get(profile)->event_router()) { | 166 extensions::ExtensionSystem::Get(profile)->event_router()) { |
| 167 scoped_ptr<extensions::Event> event(new extensions::Event( | 167 scoped_ptr<extensions::Event> event(new extensions::Event( |
| 168 event_name, event_args.Pass())); | 168 event_name, event_args.Pass())); |
| 169 extensions::ExtensionSystem::Get(profile)->event_router()-> | 169 extensions::ExtensionSystem::Get(profile)->event_router()-> |
| 170 BroadcastEvent(event.Pass()); | 170 BroadcastEvent(event.Pass()); |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 | 173 |
| 174 bool SetAccessibilityEnabledFunction::RunImpl() { | 174 bool AccessibilitySetAccessibilityEnabledFunction::RunImpl() { |
| 175 bool enabled; | 175 bool enabled; |
| 176 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); | 176 EXTENSION_FUNCTION_VALIDATE(args_->GetBoolean(0, &enabled)); |
| 177 ExtensionAccessibilityEventRouter::GetInstance() | 177 ExtensionAccessibilityEventRouter::GetInstance() |
| 178 ->SetAccessibilityEnabled(enabled); | 178 ->SetAccessibilityEnabled(enabled); |
| 179 return true; | 179 return true; |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool GetFocusedControlFunction::RunImpl() { | 182 bool AccessibilityGetFocusedControlFunction::RunImpl() { |
| 183 // Get the serialized dict from the last focused control and return it. | 183 // Get the serialized dict from the last focused control and return it. |
| 184 // However, if the dict is empty, that means we haven't seen any focus | 184 // However, if the dict is empty, that means we haven't seen any focus |
| 185 // events yet, so return null instead. | 185 // events yet, so return null instead. |
| 186 ExtensionAccessibilityEventRouter *accessibility_event_router = | 186 ExtensionAccessibilityEventRouter *accessibility_event_router = |
| 187 ExtensionAccessibilityEventRouter::GetInstance(); | 187 ExtensionAccessibilityEventRouter::GetInstance(); |
| 188 DictionaryValue *last_focused_control_dict = | 188 DictionaryValue *last_focused_control_dict = |
| 189 accessibility_event_router->last_focused_control_dict(); | 189 accessibility_event_router->last_focused_control_dict(); |
| 190 if (last_focused_control_dict->size()) { | 190 if (last_focused_control_dict->size()) { |
| 191 SetResult(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); | 191 SetResult(last_focused_control_dict->DeepCopyWithoutEmptyChildren()); |
| 192 } else { | 192 } else { |
| 193 SetResult(Value::CreateNullValue()); | 193 SetResult(Value::CreateNullValue()); |
| 194 } | 194 } |
| 195 return true; | 195 return true; |
| 196 } | 196 } |
| 197 | 197 |
| 198 bool GetAlertsForTabFunction::RunImpl() { | 198 bool AccessibilityGetAlertsForTabFunction::RunImpl() { |
| 199 int tab_id; | 199 int tab_id; |
| 200 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); | 200 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(0, &tab_id)); |
| 201 | 201 |
| 202 TabStripModel* tab_strip = NULL; | 202 TabStripModel* tab_strip = NULL; |
| 203 content::WebContents* contents = NULL; | 203 content::WebContents* contents = NULL; |
| 204 int tab_index = -1; | 204 int tab_index = -1; |
| 205 if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(), | 205 if (!ExtensionTabUtil::GetTabById(tab_id, profile(), include_incognito(), |
| 206 NULL, &tab_strip, &contents, &tab_index)) { | 206 NULL, &tab_strip, &contents, &tab_index)) { |
| 207 error_ = extensions::ErrorUtils::FormatErrorMessage( | 207 error_ = extensions::ErrorUtils::FormatErrorMessage( |
| 208 extensions::tabs_constants::kTabNotFoundError, | 208 extensions::tabs_constants::kTabNotFoundError, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 221 DictionaryValue* alert_value = new DictionaryValue; | 221 DictionaryValue* alert_value = new DictionaryValue; |
| 222 const string16 message_text = confirm_infobar_delegate->GetMessageText(); | 222 const string16 message_text = confirm_infobar_delegate->GetMessageText(); |
| 223 alert_value->SetString(keys::kMessageKey, message_text); | 223 alert_value->SetString(keys::kMessageKey, message_text); |
| 224 alerts_value->Append(alert_value); | 224 alerts_value->Append(alert_value); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 SetResult(alerts_value); | 228 SetResult(alerts_value); |
| 229 return true; | 229 return true; |
| 230 } | 230 } |
| OLD | NEW |