| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/accessibility/accessibility_manager.h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 6 | 6 |
| 7 #include "ash/audio/sounds.h" | 7 #include "ash/audio/sounds.h" |
| 8 #include "ash/autoclick/autoclick_controller.h" | 8 #include "ash/autoclick/autoclick_controller.h" |
| 9 #include "ash/high_contrast/high_contrast_controller.h" | 9 #include "ash/high_contrast/high_contrast_controller.h" |
| 10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 pref_service->GetBoolean(prefs::kHighContrastEnabled) || | 352 pref_service->GetBoolean(prefs::kHighContrastEnabled) || |
| 353 pref_service->GetBoolean(prefs::kAutoclickEnabled) || | 353 pref_service->GetBoolean(prefs::kAutoclickEnabled) || |
| 354 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || | 354 pref_service->GetBoolean(prefs::kShouldAlwaysShowAccessibilityMenu) || |
| 355 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled) || | 355 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled) || |
| 356 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)) | 356 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)) |
| 357 return true; | 357 return true; |
| 358 } | 358 } |
| 359 return false; | 359 return false; |
| 360 } | 360 } |
| 361 | 361 |
| 362 bool AccessibilityManager::ShouldEnableCursorCompositing() { |
| 363 #if defined(OS_CHROMEOS) |
| 364 if (!profile_) |
| 365 return false; |
| 366 PrefService* pref_service = profile_->GetPrefs(); |
| 367 // Enable cursor compositing when one or more of the listed accessibility |
| 368 // features are turned on. |
| 369 if (pref_service->GetBoolean(prefs::kLargeCursorEnabled) || |
| 370 pref_service->GetBoolean(prefs::kHighContrastEnabled) || |
| 371 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)) |
| 372 return true; |
| 373 #endif |
| 374 return false; |
| 375 } |
| 376 |
| 362 void AccessibilityManager::EnableLargeCursor(bool enabled) { | 377 void AccessibilityManager::EnableLargeCursor(bool enabled) { |
| 363 if (!profile_) | 378 if (!profile_) |
| 364 return; | 379 return; |
| 365 | 380 |
| 366 PrefService* pref_service = profile_->GetPrefs(); | 381 PrefService* pref_service = profile_->GetPrefs(); |
| 367 pref_service->SetBoolean(prefs::kLargeCursorEnabled, enabled); | 382 pref_service->SetBoolean(prefs::kLargeCursorEnabled, enabled); |
| 368 pref_service->CommitPendingWrite(); | 383 pref_service->CommitPendingWrite(); |
| 369 } | 384 } |
| 370 | 385 |
| 371 void AccessibilityManager::UpdateLargeCursorFromPref() { | 386 void AccessibilityManager::UpdateLargeCursorFromPref() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 386 content::NotificationService::AllSources(), | 401 content::NotificationService::AllSources(), |
| 387 content::Details<AccessibilityStatusEventDetails>(&details)); | 402 content::Details<AccessibilityStatusEventDetails>(&details)); |
| 388 | 403 |
| 389 #if defined(USE_ASH) | 404 #if defined(USE_ASH) |
| 390 // Large cursor is implemented only in ash. | 405 // Large cursor is implemented only in ash. |
| 391 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( | 406 ash::Shell::GetInstance()->cursor_manager()->SetCursorSet( |
| 392 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); | 407 enabled ? ui::CURSOR_SET_LARGE : ui::CURSOR_SET_NORMAL); |
| 393 #endif | 408 #endif |
| 394 | 409 |
| 395 #if defined(OS_CHROMEOS) | 410 #if defined(OS_CHROMEOS) |
| 396 // Enable cursor compositing mode when using high contrast or large cursor. | |
| 397 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 411 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
| 398 large_cursor_enabled_ || high_contrast_enabled_); | 412 ShouldEnableCursorCompositing()); |
| 399 #endif | 413 #endif |
| 400 } | 414 } |
| 401 | 415 |
| 402 bool AccessibilityManager::IsIncognitoAllowed() { | 416 bool AccessibilityManager::IsIncognitoAllowed() { |
| 403 UserManager* user_manager = UserManager::Get(); | 417 UserManager* user_manager = UserManager::Get(); |
| 404 // Supervised users can't create incognito-mode windows. | 418 // Supervised users can't create incognito-mode windows. |
| 405 return !(user_manager->IsLoggedInAsLocallyManagedUser()); | 419 return !(user_manager->IsLoggedInAsLocallyManagedUser()); |
| 406 } | 420 } |
| 407 | 421 |
| 408 bool AccessibilityManager::IsLargeCursorEnabled() { | 422 bool AccessibilityManager::IsLargeCursorEnabled() { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 content::NotificationService::current()->Notify( | 606 content::NotificationService::current()->Notify( |
| 593 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, | 607 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
| 594 content::NotificationService::AllSources(), | 608 content::NotificationService::AllSources(), |
| 595 content::Details<AccessibilityStatusEventDetails>(&detail)); | 609 content::Details<AccessibilityStatusEventDetails>(&detail)); |
| 596 | 610 |
| 597 #if defined(USE_ASH) | 611 #if defined(USE_ASH) |
| 598 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); | 612 ash::Shell::GetInstance()->high_contrast_controller()->SetEnabled(enabled); |
| 599 #endif | 613 #endif |
| 600 | 614 |
| 601 #if defined(OS_CHROMEOS) | 615 #if defined(OS_CHROMEOS) |
| 602 // Enable cursor compositing mode when using high contrast or large cursor. | |
| 603 ash::Shell::GetInstance()->SetCursorCompositingEnabled( | 616 ash::Shell::GetInstance()->SetCursorCompositingEnabled( |
| 604 large_cursor_enabled_ || high_contrast_enabled_); | 617 ShouldEnableCursorCompositing()); |
| 605 #endif | 618 #endif |
| 606 } | 619 } |
| 607 | 620 |
| 608 void AccessibilityManager::LocalePrefChanged() { | 621 void AccessibilityManager::LocalePrefChanged() { |
| 609 if (!profile_) | 622 if (!profile_) |
| 610 return; | 623 return; |
| 611 | 624 |
| 612 if (!IsSpokenFeedbackEnabled()) | 625 if (!IsSpokenFeedbackEnabled()) |
| 613 return; | 626 return; |
| 614 | 627 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 | 962 |
| 950 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 963 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
| 951 // Do any teardown work needed immediately after ChromeVox actually unloads. | 964 // Do any teardown work needed immediately after ChromeVox actually unloads. |
| 952 if (system_sounds_enabled_) { | 965 if (system_sounds_enabled_) { |
| 953 ash::PlaySystemSound(SOUND_SPOKEN_FEEDBACK_DISABLED, | 966 ash::PlaySystemSound(SOUND_SPOKEN_FEEDBACK_DISABLED, |
| 954 false /* honor_spoken_feedback */); | 967 false /* honor_spoken_feedback */); |
| 955 } | 968 } |
| 956 } | 969 } |
| 957 | 970 |
| 958 } // namespace chromeos | 971 } // namespace chromeos |
| OLD | NEW |