Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: chrome/browser/accessibility/accessibility_extension_api.cc

Issue 42743003: Adjust ChromeVox (spoken feedback) strings and make it possible for announcemen (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing a few style tidbits. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 11 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
12 #include "chrome/browser/extensions/event_router.h" 12 #include "chrome/browser/extensions/event_router.h"
13 #include "chrome/browser/extensions/extension_host.h"
14 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 15 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/extensions/extension_tab_util.h" 16 #include "chrome/browser/extensions/extension_tab_util.h"
17 #include "chrome/browser/extensions/lazy_background_task_queue.h"
15 #include "chrome/browser/infobars/confirm_infobar_delegate.h" 18 #include "chrome/browser/infobars/confirm_infobar_delegate.h"
16 #include "chrome/browser/infobars/infobar_delegate.h" 19 #include "chrome/browser/infobars/infobar_delegate.h"
17 #include "chrome/browser/infobars/infobar_service.h" 20 #include "chrome/browser/infobars/infobar_service.h"
18 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/common/extensions/api/experimental_accessibility.h" 22 #include "chrome/common/extensions/api/experimental_accessibility.h"
23 #include "chrome/common/extensions/background_info.h"
20 #include "content/public/browser/browser_accessibility_state.h" 24 #include "content/public/browser/browser_accessibility_state.h"
21 #include "extensions/common/error_utils.h" 25 #include "extensions/common/error_utils.h"
22 26
23 namespace keys = extension_accessibility_api_constants; 27 namespace keys = extension_accessibility_api_constants;
24 namespace experimental_accessibility = 28 namespace experimental_accessibility =
25 extensions::api::experimental_accessibility; 29 extensions::api::experimental_accessibility;
26 30
27 // Returns the AccessibilityControlInfo serialized into a JSON string, 31 // Returns the AccessibilityControlInfo serialized into a JSON string,
28 // consisting of an array of a single object of type AccessibilityObject, 32 // consisting of an array of a single object of type AccessibilityObject,
29 // as defined in the accessibility extension api's json schema. 33 // as defined in the accessibility extension api's json schema.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 } 161 }
158 162
159 void ExtensionAccessibilityEventRouter::OnMenuClosed( 163 void ExtensionAccessibilityEventRouter::OnMenuClosed(
160 const AccessibilityMenuInfo* info) { 164 const AccessibilityMenuInfo* info) {
161 scoped_ptr<ListValue> args(ControlInfoToEventArguments(info)); 165 scoped_ptr<ListValue> args(ControlInfoToEventArguments(info));
162 DispatchEvent(info->profile(), 166 DispatchEvent(info->profile(),
163 experimental_accessibility::OnMenuClosed::kEventName, 167 experimental_accessibility::OnMenuClosed::kEventName,
164 args.Pass()); 168 args.Pass());
165 } 169 }
166 170
171 void ExtensionAccessibilityEventRouter::
172 OnSpokenFeedbackEnabled(Profile* profile, bool make_announcements) {
173 scoped_ptr<base::ListValue> event_args(new base::ListValue());
174 event_args->Append(base::Value::CreateBooleanValue(make_announcements));
175 ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(profile,
176 experimental_accessibility::OnSpokenFeedbackEnabled::kEventName,
177 event_args.Pass(),
178 true,
179 NULL);
180 }
181
182 void ExtensionAccessibilityEventRouter::
183 OnSpokenFeedbackDisabled(Profile* profile) {
184 scoped_ptr<base::ListValue> event_args(new base::ListValue());
185 ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(profile,
186 experimental_accessibility::OnSpokenFeedbackDisabled::kEventName,
187 event_args.Pass(),
188 true,
189 NULL);
190 }
191
192 // Static.
193 void ExtensionAccessibilityEventRouter::DispatchEventToChromeVox(
194 Profile* profile,
195 const char* event_name,
196 scoped_ptr<base::ListValue> event_args,
197 bool first_call,
198 extensions::ExtensionHost* host) {
199 if (!first_call && !host)
200 return;
201
202 extensions::ExtensionSystem* system =
203 extensions::ExtensionSystem::Get(profile);
204 if (!system)
205 return;
206
207 const char* extension_id = extension_misc::kChromeVoxExtensionId;
208 // If this is a persistent background page, we want to wait for it to load
209 // (it might not be ready, since this is startup). But only enqueue once.
210 // If it fails to load the first time, don't bother trying again.
211 const extensions::Extension* extension =
212 system->extension_service()->extensions()->GetByID(extension_id);
213 if (extension &&
214 extensions::BackgroundInfo::HasPersistentBackgroundPage(extension) &&
215 first_call &&
216 system->lazy_background_task_queue()->
217 ShouldEnqueueTask(profile, extension)) {
218 system->lazy_background_task_queue()->AddPendingTask(
dmazzoni 2013/10/25 23:09:16 nit: maybe stick system->lazy_background_task_queu
219 profile, extension_id,
220 base::Bind(&DispatchEventToChromeVox,
221 profile, event_name, base::Passed(&event_args), false));
222 return;
223 }
224
225 scoped_ptr<extensions::Event> event(new extensions::Event(event_name,
226 event_args.Pass()));
227 system->event_router()->DispatchEventToExtension(
228 extension_id, event.Pass());
229 }
230
167 void ExtensionAccessibilityEventRouter::DispatchEvent( 231 void ExtensionAccessibilityEventRouter::DispatchEvent(
168 Profile* profile, 232 Profile* profile,
169 const char* event_name, 233 const char* event_name,
170 scoped_ptr<base::ListValue> event_args) { 234 scoped_ptr<base::ListValue> event_args) {
171 if (enabled_ && profile && 235 if (enabled_ && profile &&
172 extensions::ExtensionSystem::Get(profile)->event_router()) { 236 extensions::ExtensionSystem::Get(profile)->event_router()) {
173 scoped_ptr<extensions::Event> event(new extensions::Event( 237 scoped_ptr<extensions::Event> event(new extensions::Event(
174 event_name, event_args.Pass())); 238 event_name, event_args.Pass()));
175 extensions::ExtensionSystem::Get(profile)->event_router()-> 239 extensions::ExtensionSystem::Get(profile)->event_router()->
176 BroadcastEvent(event.Pass()); 240 BroadcastEvent(event.Pass());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 DictionaryValue* alert_value = new DictionaryValue; 304 DictionaryValue* alert_value = new DictionaryValue;
241 const string16 message_text = confirm_infobar_delegate->GetMessageText(); 305 const string16 message_text = confirm_infobar_delegate->GetMessageText();
242 alert_value->SetString(keys::kMessageKey, message_text); 306 alert_value->SetString(keys::kMessageKey, message_text);
243 alerts_value->Append(alert_value); 307 alerts_value->Append(alert_value);
244 } 308 }
245 } 309 }
246 310
247 SetResult(alerts_value); 311 SetResult(alerts_value);
248 return true; 312 return true;
249 } 313 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698