Chromium Code Reviews| 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 |
| 864 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); | 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 | |
| 878 if (ash::Shell::HasInstance()) { | |
|
sky
2016/09/09 21:42:30
no {}
riajiang
2016/09/12 16:15:47
Done.
| |
| 879 ash::Shell::GetInstance()->autoclick_controller()->SetEnabled(enabled); | |
| 880 } | |
| 865 } | 881 } |
| 866 | 882 |
| 867 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { | 883 void AccessibilityManager::SetAutoclickDelay(int delay_ms) { |
| 868 if (!profile_) | 884 if (!profile_) |
| 869 return; | 885 return; |
| 870 | 886 |
| 871 PrefService* pref_service = profile_->GetPrefs(); | 887 PrefService* pref_service = profile_->GetPrefs(); |
| 872 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); | 888 pref_service->SetInteger(prefs::kAccessibilityAutoclickDelayMs, delay_ms); |
| 873 pref_service->CommitPendingWrite(); | 889 pref_service->CommitPendingWrite(); |
| 874 } | 890 } |
| 875 | 891 |
| 876 int AccessibilityManager::GetAutoclickDelay() const { | 892 int AccessibilityManager::GetAutoclickDelay() const { |
| 877 return int{autoclick_delay_ms_.InMilliseconds()}; | 893 return static_cast<int>(autoclick_delay_ms_.InMilliseconds()); |
| 878 } | 894 } |
| 879 | 895 |
| 880 void AccessibilityManager::UpdateAutoclickDelayFromPref() { | 896 void AccessibilityManager::UpdateAutoclickDelayFromPref() { |
| 881 if (!profile_) | 897 if (!profile_) |
| 882 return; | 898 return; |
| 883 | 899 |
| 884 base::TimeDelta autoclick_delay_ms = base::TimeDelta::FromMilliseconds( | 900 base::TimeDelta autoclick_delay_ms = base::TimeDelta::FromMilliseconds( |
| 885 int64_t{profile_->GetPrefs()->GetInteger( | 901 int64_t{profile_->GetPrefs()->GetInteger( |
| 886 prefs::kAccessibilityAutoclickDelayMs)}); | 902 prefs::kAccessibilityAutoclickDelayMs)}); |
| 887 | 903 |
| 888 if (autoclick_delay_ms == autoclick_delay_ms_) | 904 if (autoclick_delay_ms == autoclick_delay_ms_) |
| 889 return; | 905 return; |
| 890 autoclick_delay_ms_ = autoclick_delay_ms; | 906 autoclick_delay_ms_ = autoclick_delay_ms; |
| 891 | 907 |
| 892 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( | 908 if (chrome::IsRunningInMash()) { |
| 893 autoclick_delay_ms_); | 909 shell::Connector* connector = |
| 910 content::MojoShellConnection::GetForProcess()->GetConnector(); | |
| 911 ash::autoclick::mojom::AutoclickControllerPtr autoclick_controller; | |
| 912 connector->ConnectToInterface("mojo:accessibility_autoclick", | |
| 913 &autoclick_controller); | |
| 914 autoclick_controller->SetAutoclickDelay( | |
| 915 autoclick_delay_ms_.InMilliseconds()); | |
| 916 return; | |
| 917 } | |
| 918 | |
| 919 if (ash::Shell::HasInstance()) { | |
| 920 ash::Shell::GetInstance()->autoclick_controller()->SetAutoclickDelay( | |
| 921 autoclick_delay_ms_); | |
| 922 } | |
| 894 } | 923 } |
| 895 | 924 |
| 896 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { | 925 void AccessibilityManager::EnableVirtualKeyboard(bool enabled) { |
| 897 if (!profile_) | 926 if (!profile_) |
| 898 return; | 927 return; |
| 899 | 928 |
| 900 PrefService* pref_service = profile_->GetPrefs(); | 929 PrefService* pref_service = profile_->GetPrefs(); |
| 901 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, | 930 pref_service->SetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled, |
| 902 enabled); | 931 enabled); |
| 903 pref_service->CommitPendingWrite(); | 932 pref_service->CommitPendingWrite(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 braille_ime_current_ = false; | 1205 braille_ime_current_ = false; |
| 1177 } | 1206 } |
| 1178 | 1207 |
| 1179 // Overridden from InputMethodManager::Observer. | 1208 // Overridden from InputMethodManager::Observer. |
| 1180 void AccessibilityManager::InputMethodChanged( | 1209 void AccessibilityManager::InputMethodChanged( |
| 1181 input_method::InputMethodManager* manager, | 1210 input_method::InputMethodManager* manager, |
| 1182 Profile* /* profile */, | 1211 Profile* /* profile */, |
| 1183 bool show_message) { | 1212 bool show_message) { |
| 1184 // Sticky keys is implemented only in ash. | 1213 // Sticky keys is implemented only in ash. |
| 1185 // TODO(dpolukhin): support Athena, crbug.com/408733. | 1214 // TODO(dpolukhin): support Athena, crbug.com/408733. |
| 1186 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( | 1215 if (!chrome::IsRunningInMash()) { |
| 1187 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), | 1216 ash::Shell::GetInstance()->sticky_keys_controller()->SetModifiersEnabled( |
| 1188 manager->IsAltGrUsedByCurrentInputMethod()); | 1217 manager->IsISOLevel5ShiftUsedByCurrentInputMethod(), |
| 1218 manager->IsAltGrUsedByCurrentInputMethod()); | |
| 1219 } | |
| 1189 const chromeos::input_method::InputMethodDescriptor descriptor = | 1220 const chromeos::input_method::InputMethodDescriptor descriptor = |
| 1190 manager->GetActiveIMEState()->GetCurrentInputMethod(); | 1221 manager->GetActiveIMEState()->GetCurrentInputMethod(); |
| 1191 braille_ime_current_ = | 1222 braille_ime_current_ = |
| 1192 (descriptor.id() == extension_misc::kBrailleImeEngineId); | 1223 (descriptor.id() == extension_misc::kBrailleImeEngineId); |
| 1193 } | 1224 } |
| 1194 | 1225 |
| 1195 void AccessibilityManager::SetProfile(Profile* profile) { | 1226 void AccessibilityManager::SetProfile(Profile* profile) { |
| 1196 pref_change_registrar_.reset(); | 1227 pref_change_registrar_.reset(); |
| 1197 local_state_pref_change_registrar_.reset(); | 1228 local_state_pref_change_registrar_.reset(); |
| 1198 | 1229 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1562 content::BrowserContext* context) { | 1593 content::BrowserContext* context) { |
| 1563 keyboard_listener_extension_id_ = id; | 1594 keyboard_listener_extension_id_ = id; |
| 1564 | 1595 |
| 1565 extensions::ExtensionRegistry* registry = | 1596 extensions::ExtensionRegistry* registry = |
| 1566 extensions::ExtensionRegistry::Get(context); | 1597 extensions::ExtensionRegistry::Get(context); |
| 1567 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) | 1598 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) |
| 1568 extension_registry_observer_.Add(registry); | 1599 extension_registry_observer_.Add(registry); |
| 1569 } | 1600 } |
| 1570 | 1601 |
| 1571 } // namespace chromeos | 1602 } // namespace chromeos |
| OLD | NEW |