| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 #include "base/memory/singleton.h" | 26 #include "base/memory/singleton.h" |
| 27 #include "base/metrics/histogram.h" | 27 #include "base/metrics/histogram.h" |
| 28 #include "base/path_service.h" | 28 #include "base/path_service.h" |
| 29 #include "base/strings/string_split.h" | 29 #include "base/strings/string_split.h" |
| 30 #include "base/strings/string_util.h" | 30 #include "base/strings/string_util.h" |
| 31 #include "base/time/time.h" | 31 #include "base/time/time.h" |
| 32 #include "base/values.h" | 32 #include "base/values.h" |
| 33 #include "chrome/browser/accessibility/accessibility_extension_api.h" | 33 #include "chrome/browser/accessibility/accessibility_extension_api.h" |
| 34 #include "chrome/browser/browser_process.h" | 34 #include "chrome/browser/browser_process.h" |
| 35 #include "chrome/browser/chrome_notification_types.h" | 35 #include "chrome/browser/chrome_notification_types.h" |
| 36 #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager.
h" |
| 36 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 37 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| 37 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | 38 #include "chrome/browser/chromeos/login/lock/screen_locker.h" |
| 38 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 39 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 39 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 40 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 40 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 41 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 41 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | 42 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
| 42 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" | 43 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" |
| 43 #include "chrome/browser/extensions/component_loader.h" | 44 #include "chrome/browser/extensions/component_loader.h" |
| 44 #include "chrome/browser/extensions/extension_service.h" | 45 #include "chrome/browser/extensions/extension_service.h" |
| 45 #include "chrome/browser/extensions/tab_helper.h" | 46 #include "chrome/browser/extensions/tab_helper.h" |
| (...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 if (!profile_) | 895 if (!profile_) |
| 895 return; | 896 return; |
| 896 | 897 |
| 897 const bool enabled = profile_->GetPrefs()->GetBoolean( | 898 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 898 prefs::kAccessibilityCaretHighlightEnabled); | 899 prefs::kAccessibilityCaretHighlightEnabled); |
| 899 | 900 |
| 900 if (caret_highlight_enabled_ == enabled) | 901 if (caret_highlight_enabled_ == enabled) |
| 901 return; | 902 return; |
| 902 caret_highlight_enabled_ = enabled; | 903 caret_highlight_enabled_ = enabled; |
| 903 | 904 |
| 904 // TODO(dmazzoni): implement feature here. | 905 UpdateAccessibilityHighlightingFromPrefs(); |
| 905 } | 906 } |
| 906 | 907 |
| 907 void AccessibilityManager::SetCursorHighlightEnabled(bool enabled) { | 908 void AccessibilityManager::SetCursorHighlightEnabled(bool enabled) { |
| 908 if (!profile_) | 909 if (!profile_) |
| 909 return; | 910 return; |
| 910 | 911 |
| 911 PrefService* pref_service = profile_->GetPrefs(); | 912 PrefService* pref_service = profile_->GetPrefs(); |
| 912 pref_service->SetBoolean(prefs::kAccessibilityCursorHighlightEnabled, | 913 pref_service->SetBoolean(prefs::kAccessibilityCursorHighlightEnabled, |
| 913 enabled); | 914 enabled); |
| 914 pref_service->CommitPendingWrite(); | 915 pref_service->CommitPendingWrite(); |
| 915 } | 916 } |
| 916 | 917 |
| 917 bool AccessibilityManager::IsCursorHighlightEnabled() const { | 918 bool AccessibilityManager::IsCursorHighlightEnabled() const { |
| 918 return cursor_highlight_enabled_; | 919 return cursor_highlight_enabled_; |
| 919 } | 920 } |
| 920 | 921 |
| 921 void AccessibilityManager::UpdateCursorHighlightFromPref() { | 922 void AccessibilityManager::UpdateCursorHighlightFromPref() { |
| 922 if (!profile_) | 923 if (!profile_) |
| 923 return; | 924 return; |
| 924 | 925 |
| 925 const bool enabled = profile_->GetPrefs()->GetBoolean( | 926 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 926 prefs::kAccessibilityCursorHighlightEnabled); | 927 prefs::kAccessibilityCursorHighlightEnabled); |
| 927 | 928 |
| 928 if (cursor_highlight_enabled_ == enabled) | 929 if (cursor_highlight_enabled_ == enabled) |
| 929 return; | 930 return; |
| 930 cursor_highlight_enabled_ = enabled; | 931 cursor_highlight_enabled_ = enabled; |
| 931 | 932 |
| 932 // TODO(dmazzoni): implement feature here. | 933 UpdateAccessibilityHighlightingFromPrefs(); |
| 933 } | 934 } |
| 934 | 935 |
| 935 void AccessibilityManager::SetFocusHighlightEnabled(bool enabled) { | 936 void AccessibilityManager::SetFocusHighlightEnabled(bool enabled) { |
| 936 if (!profile_) | 937 if (!profile_) |
| 937 return; | 938 return; |
| 938 | 939 |
| 939 PrefService* pref_service = profile_->GetPrefs(); | 940 PrefService* pref_service = profile_->GetPrefs(); |
| 940 pref_service->SetBoolean(prefs::kAccessibilityFocusHighlightEnabled, enabled); | 941 pref_service->SetBoolean(prefs::kAccessibilityFocusHighlightEnabled, enabled); |
| 941 pref_service->CommitPendingWrite(); | 942 pref_service->CommitPendingWrite(); |
| 942 } | 943 } |
| 943 | 944 |
| 944 bool AccessibilityManager::IsFocusHighlightEnabled() const { | 945 bool AccessibilityManager::IsFocusHighlightEnabled() const { |
| 945 return focus_highlight_enabled_; | 946 return focus_highlight_enabled_; |
| 946 } | 947 } |
| 947 | 948 |
| 948 void AccessibilityManager::UpdateFocusHighlightFromPref() { | 949 void AccessibilityManager::UpdateFocusHighlightFromPref() { |
| 949 if (!profile_) | 950 if (!profile_) |
| 950 return; | 951 return; |
| 951 | 952 |
| 952 const bool enabled = profile_->GetPrefs()->GetBoolean( | 953 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 953 prefs::kAccessibilityFocusHighlightEnabled); | 954 prefs::kAccessibilityFocusHighlightEnabled); |
| 954 | 955 |
| 955 if (focus_highlight_enabled_ == enabled) | 956 if (focus_highlight_enabled_ == enabled) |
| 956 return; | 957 return; |
| 957 focus_highlight_enabled_ = enabled; | 958 focus_highlight_enabled_ = enabled; |
| 958 | 959 |
| 959 // TODO(dmazzoni): implement feature here. | 960 UpdateAccessibilityHighlightingFromPrefs(); |
| 960 } | 961 } |
| 961 | 962 |
| 962 void AccessibilityManager::SetSelectToSpeakEnabled(bool enabled) { | 963 void AccessibilityManager::SetSelectToSpeakEnabled(bool enabled) { |
| 963 if (!profile_) | 964 if (!profile_) |
| 964 return; | 965 return; |
| 965 | 966 |
| 966 PrefService* pref_service = profile_->GetPrefs(); | 967 PrefService* pref_service = profile_->GetPrefs(); |
| 967 pref_service->SetBoolean(prefs::kAccessibilitySelectToSpeakEnabled, enabled); | 968 pref_service->SetBoolean(prefs::kAccessibilitySelectToSpeakEnabled, enabled); |
| 968 pref_service->CommitPendingWrite(); | 969 pref_service->CommitPendingWrite(); |
| 969 } | 970 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 const bool enabled = profile_->GetPrefs()->GetBoolean( | 1007 const bool enabled = profile_->GetPrefs()->GetBoolean( |
| 1007 prefs::kAccessibilitySwitchAccessEnabled); | 1008 prefs::kAccessibilitySwitchAccessEnabled); |
| 1008 | 1009 |
| 1009 if (switch_access_enabled_ == enabled) | 1010 if (switch_access_enabled_ == enabled) |
| 1010 return; | 1011 return; |
| 1011 switch_access_enabled_ = enabled; | 1012 switch_access_enabled_ = enabled; |
| 1012 | 1013 |
| 1013 // TODO(dmazzoni): implement feature here. | 1014 // TODO(dmazzoni): implement feature here. |
| 1014 } | 1015 } |
| 1015 | 1016 |
| 1017 void AccessibilityManager::UpdateAccessibilityHighlightingFromPrefs() { |
| 1018 if (!focus_highlight_enabled_ && !caret_highlight_enabled_ && |
| 1019 !cursor_highlight_enabled_) { |
| 1020 if (accessibility_highlight_manager_) |
| 1021 accessibility_highlight_manager_.reset(); |
| 1022 return; |
| 1023 } |
| 1024 |
| 1025 if (!accessibility_highlight_manager_) |
| 1026 accessibility_highlight_manager_.reset(new AccessibilityHighlightManager()); |
| 1027 |
| 1028 accessibility_highlight_manager_->HighlightFocus(focus_highlight_enabled_); |
| 1029 accessibility_highlight_manager_->HighlightCaret(caret_highlight_enabled_); |
| 1030 accessibility_highlight_manager_->HighlightCursor(cursor_highlight_enabled_); |
| 1031 } |
| 1032 |
| 1016 bool AccessibilityManager::IsBrailleDisplayConnected() const { | 1033 bool AccessibilityManager::IsBrailleDisplayConnected() const { |
| 1017 return braille_display_connected_; | 1034 return braille_display_connected_; |
| 1018 } | 1035 } |
| 1019 | 1036 |
| 1020 void AccessibilityManager::CheckBrailleState() { | 1037 void AccessibilityManager::CheckBrailleState() { |
| 1021 BrailleController* braille_controller = GetBrailleController(); | 1038 BrailleController* braille_controller = GetBrailleController(); |
| 1022 if (!scoped_braille_observer_.IsObserving(braille_controller)) | 1039 if (!scoped_braille_observer_.IsObserving(braille_controller)) |
| 1023 scoped_braille_observer_.Add(braille_controller); | 1040 scoped_braille_observer_.Add(braille_controller); |
| 1024 BrowserThread::PostTaskAndReplyWithResult( | 1041 BrowserThread::PostTaskAndReplyWithResult( |
| 1025 BrowserThread::IO, | 1042 BrowserThread::IO, |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1424 content::BrowserContext* context) { | 1441 content::BrowserContext* context) { |
| 1425 keyboard_listener_extension_id_ = id; | 1442 keyboard_listener_extension_id_ = id; |
| 1426 | 1443 |
| 1427 extensions::ExtensionRegistry* registry = | 1444 extensions::ExtensionRegistry* registry = |
| 1428 extensions::ExtensionRegistry::Get(context); | 1445 extensions::ExtensionRegistry::Get(context); |
| 1429 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) | 1446 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) |
| 1430 extension_registry_observer_.Add(registry); | 1447 extension_registry_observer_.Add(registry); |
| 1431 } | 1448 } |
| 1432 | 1449 |
| 1433 } // namespace chromeos | 1450 } // namespace chromeos |
| OLD | NEW |