Chromium Code Reviews| 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/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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 if (profile) { | 280 if (profile) { |
| 281 int msg = 0; | 281 int msg = 0; |
| 282 switch (alert) { | 282 switch (alert) { |
| 283 case ash::A11Y_ALERT_CAPS_ON: | 283 case ash::A11Y_ALERT_CAPS_ON: |
| 284 msg = IDS_A11Y_ALERT_CAPS_ON; | 284 msg = IDS_A11Y_ALERT_CAPS_ON; |
| 285 break; | 285 break; |
| 286 case ash::A11Y_ALERT_CAPS_OFF: | 286 case ash::A11Y_ALERT_CAPS_OFF: |
| 287 msg = IDS_A11Y_ALERT_CAPS_OFF; | 287 msg = IDS_A11Y_ALERT_CAPS_OFF; |
| 288 break; | 288 break; |
| 289 case ash::A11Y_ALERT_SCREEN_ON: | 289 case ash::A11Y_ALERT_SCREEN_ON: |
| 290 // Enable automation manager when alert is screen-on, as it is | |
| 291 // previously disabled by alert screen-off. | |
| 292 SetAutomationManagerEnabled(profile, true); | |
| 290 msg = IDS_A11Y_ALERT_SCREEN_ON; | 293 msg = IDS_A11Y_ALERT_SCREEN_ON; |
| 291 break; | 294 break; |
| 292 case ash::A11Y_ALERT_SCREEN_OFF: | 295 case ash::A11Y_ALERT_SCREEN_OFF: |
| 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 // After handling the alert, if the alert is screen-off, we should | |
| 313 // disable automation manager to handle any following a11y events. | |
| 314 if (alert == ash::A11Y_ALERT_SCREEN_OFF) | |
| 315 SetAutomationManagerEnabled(profile, false); | |
| 309 } | 316 } |
| 310 } | 317 } |
| 311 } | 318 } |
| 312 | 319 |
| 313 ash::AccessibilityAlert GetLastAccessibilityAlert() override { | 320 ash::AccessibilityAlert GetLastAccessibilityAlert() override { |
| 314 return ash::A11Y_ALERT_NONE; | 321 return ash::A11Y_ALERT_NONE; |
| 315 } | 322 } |
| 316 | 323 |
| 317 bool ShouldToggleSpokenFeedbackViaTouch() override { | 324 bool ShouldToggleSpokenFeedbackViaTouch() override { |
| 318 DCHECK(AccessibilityManager::Get()); | 325 DCHECK(AccessibilityManager::Get()); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 332 | 339 |
| 333 base::TimeDelta PlayShutdownSound() const override { | 340 base::TimeDelta PlayShutdownSound() const override { |
| 334 return AccessibilityManager::Get()->PlayShutdownSound(); | 341 return AccessibilityManager::Get()->PlayShutdownSound(); |
| 335 } | 342 } |
| 336 | 343 |
| 337 void HandleAccessibilityGesture(ui::AXGesture gesture) override { | 344 void HandleAccessibilityGesture(ui::AXGesture gesture) override { |
| 338 AccessibilityManager::Get()->HandleAccessibilityGesture(gesture); | 345 AccessibilityManager::Get()->HandleAccessibilityGesture(gesture); |
| 339 } | 346 } |
| 340 | 347 |
| 341 private: | 348 private: |
| 349 void SetAutomationManagerEnabled(content::BrowserContext* context, | |
| 350 bool enabled) { | |
| 351 AutomationManagerAura* manager = AutomationManagerAura::GetInstance(); | |
| 352 DCHECK(context); | |
|
James Cook
2017/02/06 16:38:45
super nit: Do this as the first line of the functi
| |
| 353 if (enabled) | |
| 354 manager->Enable(context); | |
| 355 else | |
| 356 manager->Disable(); | |
| 357 } | |
| 358 | |
| 342 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); | 359 DISALLOW_COPY_AND_ASSIGN(AccessibilityDelegateImpl); |
| 343 }; | 360 }; |
| 344 | 361 |
| 345 } // namespace | 362 } // namespace |
| 346 | 363 |
| 347 ChromeShellDelegate::ChromeShellDelegate() | 364 ChromeShellDelegate::ChromeShellDelegate() |
| 348 : shelf_delegate_(NULL) { | 365 : shelf_delegate_(NULL) { |
| 349 PlatformInit(); | 366 PlatformInit(); |
| 350 } | 367 } |
| 351 | 368 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 NOTREACHED() << "Unexpected notification " << type; | 594 NOTREACHED() << "Unexpected notification " << type; |
| 578 } | 595 } |
| 579 } | 596 } |
| 580 | 597 |
| 581 void ChromeShellDelegate::PlatformInit() { | 598 void ChromeShellDelegate::PlatformInit() { |
| 582 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 599 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 583 content::NotificationService::AllSources()); | 600 content::NotificationService::AllSources()); |
| 584 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, | 601 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, |
| 585 content::NotificationService::AllSources()); | 602 content::NotificationService::AllSources()); |
| 586 } | 603 } |
| OLD | NEW |