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

Side by Side Diff: chrome/browser/ui/ash/chrome_shell_delegate.cc

Issue 2676563003: ChromeVox: Disable following a11y events after screen off alert is received (Closed)
Patch Set: SetAutomationManagerEnabled Created 3 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/ash/chrome_shell_delegate.h" 5 #include "chrome/browser/ui/ash/chrome_shell_delegate.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 double GetSavedScreenMagnifierScale() override { 270 double GetSavedScreenMagnifierScale() override {
271 if (chromeos::MagnificationManager::Get()) { 271 if (chromeos::MagnificationManager::Get()) {
272 return chromeos::MagnificationManager::Get() 272 return chromeos::MagnificationManager::Get()
273 ->GetSavedScreenMagnifierScale(); 273 ->GetSavedScreenMagnifierScale();
274 } 274 }
275 return std::numeric_limits<double>::min(); 275 return std::numeric_limits<double>::min();
276 } 276 }
277 277
278 void TriggerAccessibilityAlert(ash::AccessibilityAlert alert) override { 278 void TriggerAccessibilityAlert(ash::AccessibilityAlert alert) override {
279 Profile* profile = ProfileManager::GetActiveUserProfile(); 279 Profile* profile = ProfileManager::GetActiveUserProfile();
280 bool screen_off_alert = false;
280 if (profile) { 281 if (profile) {
281 int msg = 0; 282 int msg = 0;
282 switch (alert) { 283 switch (alert) {
283 case ash::A11Y_ALERT_CAPS_ON: 284 case ash::A11Y_ALERT_CAPS_ON:
284 msg = IDS_A11Y_ALERT_CAPS_ON; 285 msg = IDS_A11Y_ALERT_CAPS_ON;
285 break; 286 break;
286 case ash::A11Y_ALERT_CAPS_OFF: 287 case ash::A11Y_ALERT_CAPS_OFF:
287 msg = IDS_A11Y_ALERT_CAPS_OFF; 288 msg = IDS_A11Y_ALERT_CAPS_OFF;
288 break; 289 break;
289 case ash::A11Y_ALERT_SCREEN_ON: 290 case ash::A11Y_ALERT_SCREEN_ON:
291 SetAutomationManagerEnabled(profile, true);
290 msg = IDS_A11Y_ALERT_SCREEN_ON; 292 msg = IDS_A11Y_ALERT_SCREEN_ON;
291 break; 293 break;
292 case ash::A11Y_ALERT_SCREEN_OFF: 294 case ash::A11Y_ALERT_SCREEN_OFF:
295 screen_off_alert = true;
293 msg = IDS_A11Y_ALERT_SCREEN_OFF; 296 msg = IDS_A11Y_ALERT_SCREEN_OFF;
294 break; 297 break;
295 case ash::A11Y_ALERT_WINDOW_NEEDED: 298 case ash::A11Y_ALERT_WINDOW_NEEDED:
296 msg = IDS_A11Y_ALERT_WINDOW_NEEDED; 299 msg = IDS_A11Y_ALERT_WINDOW_NEEDED;
297 break; 300 break;
298 case ash::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED: 301 case ash::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED:
299 msg = IDS_A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED; 302 msg = IDS_A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED;
300 break; 303 break;
301 case ash::A11Y_ALERT_NONE: 304 case ash::A11Y_ALERT_NONE:
302 msg = 0; 305 msg = 0;
303 break; 306 break;
304 } 307 }
305 308
306 if (msg) { 309 if (msg) {
307 AutomationManagerAura::GetInstance()->HandleAlert( 310 AutomationManagerAura::GetInstance()->HandleAlert(
308 profile, l10n_util::GetStringUTF8(msg)); 311 profile, l10n_util::GetStringUTF8(msg));
312 if (screen_off_alert)
James Cook 2017/02/04 00:00:38 Can you just check alert == ash::A11Y_ALERT_SCREEN
Qiang(Joe) Xu 2017/02/06 03:13:57 Done.
313 SetAutomationManagerEnabled(profile, false);
309 } 314 }
310 } 315 }
311 } 316 }
312 317
313 ash::AccessibilityAlert GetLastAccessibilityAlert() override { 318 ash::AccessibilityAlert GetLastAccessibilityAlert() override {
314 return ash::A11Y_ALERT_NONE; 319 return ash::A11Y_ALERT_NONE;
315 } 320 }
316 321
317 bool ShouldToggleSpokenFeedbackViaTouch() override { 322 bool ShouldToggleSpokenFeedbackViaTouch() override {
318 DCHECK(AccessibilityManager::Get()); 323 DCHECK(AccessibilityManager::Get());
(...skipping 13 matching lines...) Expand all
332 337
333 base::TimeDelta PlayShutdownSound() const override { 338 base::TimeDelta PlayShutdownSound() const override {
334 return AccessibilityManager::Get()->PlayShutdownSound(); 339 return AccessibilityManager::Get()->PlayShutdownSound();
335 } 340 }
336 341
337 void HandleAccessibilityGesture(ui::AXGesture gesture) override { 342 void HandleAccessibilityGesture(ui::AXGesture gesture) override {
338 AccessibilityManager::Get()->HandleAccessibilityGesture(gesture); 343 AccessibilityManager::Get()->HandleAccessibilityGesture(gesture);
339 } 344 }
340 345
341 private: 346 private:
347 void SetAutomationManagerEnabled(content::BrowserContext* context,
348 bool enabled) {
349 AutomationManagerAura* manager = AutomationManagerAura::GetInstance();
James Cook 2017/02/04 00:00:38 optional: DCHECK(context); so the reader knows it
Qiang(Joe) Xu 2017/02/06 03:13:57 Done.
350 enabled ? manager->Enable(context) : manager->Disable();
James Cook 2017/02/04 00:00:38 Use if (enabled) not a trigraph.
Qiang(Joe) Xu 2017/02/06 03:13:57 Done.
351 }
352
342 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); 353 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl);
343 }; 354 };
344 355
345 } // namespace 356 } // namespace
346 357
347 ChromeShellDelegate::ChromeShellDelegate() 358 ChromeShellDelegate::ChromeShellDelegate()
348 : shelf_delegate_(NULL) { 359 : shelf_delegate_(NULL) {
349 PlatformInit(); 360 PlatformInit();
350 } 361 }
351 362
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 NOTREACHED() << "Unexpected notification " << type; 588 NOTREACHED() << "Unexpected notification " << type;
578 } 589 }
579 } 590 }
580 591
581 void ChromeShellDelegate::PlatformInit() { 592 void ChromeShellDelegate::PlatformInit() {
582 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 593 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
583 content::NotificationService::AllSources()); 594 content::NotificationService::AllSources());
584 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, 595 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED,
585 content::NotificationService::AllSources()); 596 content::NotificationService::AllSources());
586 } 597 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698