| 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 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <utility> | 11 #include <utility> |
| 12 | 12 |
| 13 #include "ash/aura/wm_window_aura.h" | 13 #include "ash/aura/wm_window_aura.h" |
| 14 #include "ash/autoclick/autoclick_controller.h" | 14 #include "ash/autoclick/autoclick_controller.h" |
| 15 #include "ash/autoclick/mus/public/interfaces/autoclick.mojom.h" |
| 15 #include "ash/common/session/session_state_delegate.h" | 16 #include "ash/common/session/session_state_delegate.h" |
| 16 #include "ash/common/shelf/shelf_layout_manager.h" | 17 #include "ash/common/shelf/shelf_layout_manager.h" |
| 17 #include "ash/common/shelf/wm_shelf.h" | 18 #include "ash/common/shelf/wm_shelf.h" |
| 18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
| 19 #include "ash/high_contrast/high_contrast_controller.h" | 20 #include "ash/high_contrast/high_contrast_controller.h" |
| 20 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| 21 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 22 #include "ash/sticky_keys/sticky_keys_controller.h" | 23 #include "ash/sticky_keys/sticky_keys_controller.h" |
| 23 #include "base/callback.h" | 24 #include "base/callback.h" |
| 24 #include "base/callback_helpers.h" | 25 #include "base/callback_helpers.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | 42 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" |
| 42 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 43 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 43 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" | 44 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" |
| 44 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" | 45 #include "chrome/browser/extensions/api/braille_display_private/stub_braille_con
troller.h" |
| 45 #include "chrome/browser/extensions/component_loader.h" | 46 #include "chrome/browser/extensions/component_loader.h" |
| 46 #include "chrome/browser/extensions/extension_service.h" | 47 #include "chrome/browser/extensions/extension_service.h" |
| 47 #include "chrome/browser/extensions/tab_helper.h" | 48 #include "chrome/browser/extensions/tab_helper.h" |
| 48 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 49 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 49 #include "chrome/browser/profiles/profile.h" | 50 #include "chrome/browser/profiles/profile.h" |
| 50 #include "chrome/browser/profiles/profile_manager.h" | 51 #include "chrome/browser/profiles/profile_manager.h" |
| 52 #include "chrome/browser/ui/ash/ash_util.h" |
| 51 #include "chrome/common/chrome_paths.h" | 53 #include "chrome/common/chrome_paths.h" |
| 52 #include "chrome/common/extensions/api/accessibility_private.h" | 54 #include "chrome/common/extensions/api/accessibility_private.h" |
| 53 #include "chrome/common/extensions/extension_constants.h" | 55 #include "chrome/common/extensions/extension_constants.h" |
| 54 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" | 56 #include "chrome/common/extensions/manifest_handlers/content_scripts_handler.h" |
| 55 #include "chrome/common/pref_names.h" | 57 #include "chrome/common/pref_names.h" |
| 56 #include "chrome/grit/browser_resources.h" | 58 #include "chrome/grit/browser_resources.h" |
| 57 #include "chromeos/audio/audio_a11y_controller.h" | 59 #include "chromeos/audio/audio_a11y_controller.h" |
| 58 #include "chromeos/audio/chromeos_sounds.h" | 60 #include "chromeos/audio/chromeos_sounds.h" |
| 59 #include "chromeos/login/login_state.h" | 61 #include "chromeos/login/login_state.h" |
| 60 #include "components/prefs/pref_member.h" | 62 #include "components/prefs/pref_member.h" |
| 61 #include "components/prefs/pref_service.h" | 63 #include "components/prefs/pref_service.h" |
| 62 #include "components/user_manager/user_manager.h" | 64 #include "components/user_manager/user_manager.h" |
| 63 #include "content/public/browser/browser_accessibility_state.h" | 65 #include "content/public/browser/browser_accessibility_state.h" |
| 64 #include "content/public/browser/browser_thread.h" | 66 #include "content/public/browser/browser_thread.h" |
| 65 #include "content/public/browser/notification_details.h" | 67 #include "content/public/browser/notification_details.h" |
| 66 #include "content/public/browser/notification_service.h" | 68 #include "content/public/browser/notification_service.h" |
| 67 #include "content/public/browser/notification_source.h" | 69 #include "content/public/browser/notification_source.h" |
| 68 #include "content/public/browser/render_process_host.h" | 70 #include "content/public/browser/render_process_host.h" |
| 69 #include "content/public/browser/render_view_host.h" | 71 #include "content/public/browser/render_view_host.h" |
| 70 #include "content/public/browser/web_contents.h" | 72 #include "content/public/browser/web_contents.h" |
| 71 #include "content/public/browser/web_ui.h" | 73 #include "content/public/browser/web_ui.h" |
| 72 #include "content/public/common/content_switches.h" | 74 #include "content/public/common/content_switches.h" |
| 75 #include "content/public/common/mojo_shell_connection.h" |
| 73 #include "extensions/browser/event_router.h" | 76 #include "extensions/browser/event_router.h" |
| 74 #include "extensions/browser/extension_api_frame_id_map.h" | 77 #include "extensions/browser/extension_api_frame_id_map.h" |
| 75 #include "extensions/browser/extension_registry.h" | 78 #include "extensions/browser/extension_registry.h" |
| 76 #include "extensions/browser/extension_system.h" | 79 #include "extensions/browser/extension_system.h" |
| 77 #include "extensions/browser/file_reader.h" | 80 #include "extensions/browser/file_reader.h" |
| 78 #include "extensions/browser/script_executor.h" | 81 #include "extensions/browser/script_executor.h" |
| 79 #include "extensions/common/extension.h" | 82 #include "extensions/common/extension.h" |
| 80 #include "extensions/common/extension_messages.h" | 83 #include "extensions/common/extension_messages.h" |
| 81 #include "extensions/common/extension_resource.h" | 84 #include "extensions/common/extension_resource.h" |
| 82 #include "extensions/common/host_id.h" | 85 #include "extensions/common/host_id.h" |
| 86 #include "mash/public/interfaces/launchable.mojom.h" |
| 83 #include "media/audio/sounds/sounds_manager.h" | 87 #include "media/audio/sounds/sounds_manager.h" |
| 88 #include "services/shell/public/cpp/connector.h" |
| 84 #include "ui/base/ime/chromeos/input_method_manager.h" | 89 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 85 #include "ui/base/resource/resource_bundle.h" | 90 #include "ui/base/resource/resource_bundle.h" |
| 86 #include "ui/keyboard/keyboard_controller.h" | 91 #include "ui/keyboard/keyboard_controller.h" |
| 87 #include "ui/keyboard/keyboard_util.h" | 92 #include "ui/keyboard/keyboard_util.h" |
| 88 | 93 |
| 89 using content::BrowserThread; | 94 using content::BrowserThread; |
| 90 using content::RenderViewHost; | 95 using content::RenderViewHost; |
| 91 using extensions::api::braille_display_private::BrailleController; | 96 using extensions::api::braille_display_private::BrailleController; |
| 92 using extensions::api::braille_display_private::DisplayState; | 97 using extensions::api::braille_display_private::DisplayState; |
| 93 using extensions::api::braille_display_private::KeyEvent; | 98 using extensions::api::braille_display_private::KeyEvent; |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 if (!profile_) | 859 if (!profile_) |
| 855 return; | 860 return; |
| 856 | 861 |
| 857 bool enabled = | 862 bool enabled = |
| 858 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled); | 863 profile_->GetPrefs()->GetBoolean(prefs::kAccessibilityAutoclickEnabled); |
| 859 | 864 |
| 860 if (autoclick_enabled_ == enabled) | 865 if (autoclick_enabled_ == enabled) |
| 861 return; | 866 return; |
| 862 autoclick_enabled_ = enabled; | 867 autoclick_enabled_ = enabled; |
| 863 | 868 |
| 869 if (chrome::IsRunningInMash()) { |
| 870 shell::Connector* connector = |
| 871 content::MojoShellConnection::GetForProcess()->GetConnector(); |
| 872 mash::mojom::LaunchablePtr launchable; |
| 873 connector->ConnectToInterface("mojo:accessibility_autoclick", &launchable); |
| 874 launchable->Launch(mash::mojom::kWindow, mash::mojom::LaunchMode::DEFAULT); |
| 875 return; |
| 876 } |
| 877 |
| 864 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); | 878 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); |
| 865 } | 879 } |
| 866 | 880 |
| 867 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { | 881 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { |
| 868 if (!profile_) | 882 if (!profile_) |
| 869 return; | 883 return; |
| 870 | 884 |
| 871 PrefService* pref_service = profile_->GetPrefs(); | 885 PrefService* pref_service = profile_->GetPrefs(); |
| 872 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); | 886 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); |
| 873 pref_service->CommitPendingWrite(); | 887 pref_service->CommitPendingWrite(); |
| 874 } | 888 } |
| 875 | 889 |
| 876 int AccessibilityManager::GetAutoclickDelay() const { | 890 int AccessibilityManager::GetAutoclickDelay() const { |
| 877 return int{autoclick_delay_ms_.InMilliseconds()}; | 891 return static_cast<int>(autoclick_delay_ms_.InMilliseconds()); |
| 878 } | 892 } |
| 879 | 893 |
| 880 void AccessibilityManager::UpdateAutoclickDelayFromPref() { | 894 void AccessibilityManager::UpdateAutoclickDelayFromPref() { |
| 881 if (!profile_) | 895 if (!profile_) |
| 882 return; | 896 return; |
| 883 | 897 |
| 884 base::TimeDelta autoclick_delay_ms = base::TimeDelta::FromMilliseconds( | 898 base::TimeDelta autoclick_delay_ms = base::TimeDelta::FromMilliseconds( |
| 885 int64_t{profile_->GetPrefs()->GetInteger( | 899 int64_t{profile_->GetPrefs()->GetInteger( |
| 886 prefs::kAccessibilityAutoclickDelayMs)}); | 900 prefs::kAccessibilityAutoclickDelayMs)}); |
| 887 | 901 |
| 888 if (autoclick_delay_ms == autoclick_delay_ms_) | 902 if (autoclick_delay_ms == autoclick_delay_ms_) |
| 889 return; | 903 return; |
| 890 autoclick_delay_ms_ = autoclick_delay_ms; | 904 autoclick_delay_ms_ = autoclick_delay_ms; |
| 891 | 905 |
| 906 if (chrome::IsRunningInMash()) { |
| 907 shell::Connector* connector = |
| 908 content::MojoShellConnection::GetForProcess()->GetConnector(); |
| 909 ash::autoclick::mojom::AutoclickControllerPtr autoclick_controller; |
| 910 connector->ConnectToInterface("mojo:accessibility_autoclick", |
| 911 &autoclick_controller); |
| 912 autoclick_controller->SetAutoclickDelay( |
| 913 autoclick_delay_ms_.InMilliseconds()); |
| 914 return; |
| 915 } |
| 916 |
| 892 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( | 917 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( |
| 893 autoclick_delay_ms_); | 918 autoclick_delay_ms_); |
| 894 } | 919 } |
| 895 | 920 |
| 896 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { | 921 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { |
| 897 if (!profile_) | 922 if (!profile_) |
| 898 return; | 923 return; |
| 899 | 924 |
| 900 PrefService* pref_service = profile_->GetPrefs(); | 925 PrefService* pref_service = profile_->GetPrefs(); |
| 901 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, | 926 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 braille_ime_current_ = false; | 1201 braille_ime_current_ = false; |
| 1177 } | 1202 } |
| 1178 | 1203 |
| 1179 // Overridden from InputMethodManager::Observer. | 1204 // Overridden from InputMethodManager::Observer. |
| 1180 void AccessibilityManager::InputMethodChanged( | 1205 void AccessibilityManager::InputMethodChanged( |
| 1181 input_method::InputMethodManager* manager, | 1206 input_method::InputMethodManager* manager, |
| 1182 Profile* /* profile */, | 1207 Profile* /* profile */, |
| 1183 bool show_message) { | 1208 bool show_message) { |
| 1184 // Sticky keys is implemented only in ash. | 1209 // Sticky keys is implemented only in ash. |
| 1185 // TODO(dpolukhin): support Athena, crbug.com/408733. | 1210 // TODO(dpolukhin): support Athena, crbug.com/408733. |
| 1186 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( | 1211 if (!chrome::IsRunningInMash()) { |
| 1187 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), | 1212 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( |
| 1188 manager->IsAltGrUsedByCurrentInputMethod()); | 1213 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), |
| 1214 manager->IsAltGrUsedByCurrentInputMethod()); |
| 1215 } |
| 1189 const chromeos::input_method::InputMethodDescriptor descriptor = | 1216 const chromeos::input_method::InputMethodDescriptor descriptor = |
| 1190 manager->GetActiveIMEState()->GetCurrentInputMethod(); | 1217 manager->GetActiveIMEState()->GetCurrentInputMethod(); |
| 1191 braille_ime_current_ = | 1218 braille_ime_current_ = |
| 1192 (descriptor.id() == extension_misc::kBrailleImeEngineId); | 1219 (descriptor.id() == extension_misc::kBrailleImeEngineId); |
| 1193 } | 1220 } |
| 1194 | 1221 |
| 1195 void AccessibilityManager::SetProfile(Profile* profile) { | 1222 void AccessibilityManager::SetProfile(Profile* profile) { |
| 1196 pref_change_registrar_.reset(); | 1223 pref_change_registrar_.reset(); |
| 1197 local_state_pref_change_registrar_.reset(); | 1224 local_state_pref_change_registrar_.reset(); |
| 1198 | 1225 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 content::BrowserContext* context) { | 1589 content::BrowserContext* context) { |
| 1563 keyboard_listener_extension_id_ = id; | 1590 keyboard_listener_extension_id_ = id; |
| 1564 | 1591 |
| 1565 extensions::ExtensionRegistry* registry = | 1592 extensions::ExtensionRegistry* registry = |
| 1566 extensions::ExtensionRegistry::Get(context); | 1593 extensions::ExtensionRegistry::Get(context); |
| 1567 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) | 1594 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) |
| 1568 extension_registry_observer_.Add(registry); | 1595 extension_registry_observer_.Add(registry); |
| 1569 } | 1596 } |
| 1570 | 1597 |
| 1571 } // namespace chromeos | 1598 } // namespace chromeos |
| OLD | NEW |