Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(180)

Side by Side Diff: chrome/browser/chromeos/accessibility/accessibility_manager.cc

Issue 2617633004: Fix AccessibilityExtensionLoader's handling of locked screen (Closed)
Patch Set: Fix AccessibilityExtensionLoader's handling of locked screen Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "chromeos/audio/chromeos_sounds.h" 59 #include "chromeos/audio/chromeos_sounds.h"
60 #include "chromeos/login/login_state.h" 60 #include "chromeos/login/login_state.h"
61 #include "components/prefs/pref_member.h" 61 #include "components/prefs/pref_member.h"
62 #include "components/prefs/pref_service.h" 62 #include "components/prefs/pref_service.h"
63 #include "components/user_manager/user_manager.h" 63 #include "components/user_manager/user_manager.h"
64 #include "content/public/browser/browser_accessibility_state.h" 64 #include "content/public/browser/browser_accessibility_state.h"
65 #include "content/public/browser/browser_thread.h" 65 #include "content/public/browser/browser_thread.h"
66 #include "content/public/browser/notification_details.h" 66 #include "content/public/browser/notification_details.h"
67 #include "content/public/browser/notification_service.h" 67 #include "content/public/browser/notification_service.h"
68 #include "content/public/browser/notification_source.h" 68 #include "content/public/browser/notification_source.h"
69 #include "content/public/browser/render_view_host.h"
70 #include "content/public/browser/web_ui.h" 69 #include "content/public/browser/web_ui.h"
71 #include "content/public/common/content_switches.h" 70 #include "content/public/common/content_switches.h"
72 #include "content/public/common/service_manager_connection.h" 71 #include "content/public/common/service_manager_connection.h"
73 #include "extensions/browser/event_router.h" 72 #include "extensions/browser/event_router.h"
74 #include "extensions/browser/extension_registry.h" 73 #include "extensions/browser/extension_registry.h"
75 #include "extensions/browser/extension_system.h" 74 #include "extensions/browser/extension_system.h"
76 #include "extensions/common/extension.h" 75 #include "extensions/common/extension.h"
77 #include "extensions/common/extension_messages.h" 76 #include "extensions/common/extension_messages.h"
78 #include "extensions/common/extension_resource.h" 77 #include "extensions/common/extension_resource.h"
79 #include "extensions/common/host_id.h" 78 #include "extensions/common/host_id.h"
80 #include "mash/public/interfaces/launchable.mojom.h" 79 #include "mash/public/interfaces/launchable.mojom.h"
81 #include "media/audio/sounds/sounds_manager.h" 80 #include "media/audio/sounds/sounds_manager.h"
82 #include "media/base/media_switches.h" 81 #include "media/base/media_switches.h"
83 #include "services/service_manager/public/cpp/connector.h" 82 #include "services/service_manager/public/cpp/connector.h"
84 #include "ui/base/ime/chromeos/input_method_manager.h" 83 #include "ui/base/ime/chromeos/input_method_manager.h"
85 #include "ui/base/resource/resource_bundle.h" 84 #include "ui/base/resource/resource_bundle.h"
86 #include "ui/keyboard/keyboard_controller.h" 85 #include "ui/keyboard/keyboard_controller.h"
87 #include "ui/keyboard/keyboard_util.h" 86 #include "ui/keyboard/keyboard_util.h"
88 87
89 using content::BrowserThread; 88 using content::BrowserThread;
90 using content::RenderViewHost;
91 using extensions::api::braille_display_private::BrailleController; 89 using extensions::api::braille_display_private::BrailleController;
92 using extensions::api::braille_display_private::DisplayState; 90 using extensions::api::braille_display_private::DisplayState;
93 using extensions::api::braille_display_private::KeyEvent; 91 using extensions::api::braille_display_private::KeyEvent;
94 using extensions::api::braille_display_private::StubBrailleController; 92 using extensions::api::braille_display_private::StubBrailleController;
95 93
96 namespace chromeos { 94 namespace chromeos {
97 95
98 namespace { 96 namespace {
99 97
100 // When this flag is set, system sounds will not be played. 98 // When this flag is set, system sounds will not be played.
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 autoclick_enabled_(false), 252 autoclick_enabled_(false),
255 autoclick_delay_ms_(ash::AutoclickController::GetDefaultAutoclickDelay()), 253 autoclick_delay_ms_(ash::AutoclickController::GetDefaultAutoclickDelay()),
256 virtual_keyboard_enabled_(false), 254 virtual_keyboard_enabled_(false),
257 mono_audio_enabled_(false), 255 mono_audio_enabled_(false),
258 caret_highlight_enabled_(false), 256 caret_highlight_enabled_(false),
259 cursor_highlight_enabled_(false), 257 cursor_highlight_enabled_(false),
260 focus_highlight_enabled_(false), 258 focus_highlight_enabled_(false),
261 select_to_speak_enabled_(false), 259 select_to_speak_enabled_(false),
262 switch_access_enabled_(false), 260 switch_access_enabled_(false),
263 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE), 261 spoken_feedback_notification_(ash::A11Y_NOTIFICATION_NONE),
264 should_speak_chrome_vox_announcements_on_user_screen_(true),
265 system_sounds_enabled_(false), 262 system_sounds_enabled_(false),
266 braille_display_connected_(false), 263 braille_display_connected_(false),
267 scoped_braille_observer_(this), 264 scoped_braille_observer_(this),
268 braille_ime_current_(false), 265 braille_ime_current_(false),
269 chromevox_panel_(nullptr), 266 chromevox_panel_(nullptr),
270 extension_registry_observer_(this), 267 extension_registry_observer_(this),
271 weak_ptr_factory_(this) { 268 weak_ptr_factory_(this) {
272 notification_registrar_.Add(this, 269 notification_registrar_.Add(this,
273 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 270 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
274 content::NotificationService::AllSources()); 271 content::NotificationService::AllSources());
275 notification_registrar_.Add(this, 272 notification_registrar_.Add(this,
276 chrome::NOTIFICATION_SESSION_STARTED, 273 chrome::NOTIFICATION_SESSION_STARTED,
277 content::NotificationService::AllSources()); 274 content::NotificationService::AllSources());
278 notification_registrar_.Add(this, 275 notification_registrar_.Add(this,
279 chrome::NOTIFICATION_PROFILE_DESTROYED, 276 chrome::NOTIFICATION_PROFILE_DESTROYED,
280 content::NotificationService::AllSources()); 277 content::NotificationService::AllSources());
281 notification_registrar_.Add(this,
282 chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED,
283 content::NotificationService::AllSources());
284 278
285 input_method::InputMethodManager::Get()->AddObserver(this); 279 input_method::InputMethodManager::Get()->AddObserver(this);
286 280
287 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 281 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
288 media::SoundsManager* manager = media::SoundsManager::Get(); 282 media::SoundsManager* manager = media::SoundsManager::Get();
289 manager->Initialize(SOUND_SHUTDOWN, 283 manager->Initialize(SOUND_SHUTDOWN,
290 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV)); 284 bundle.GetRawDataResource(IDR_SOUND_SHUTDOWN_WAV));
291 manager->Initialize( 285 manager->Initialize(
292 SOUND_SPOKEN_FEEDBACK_ENABLED, 286 SOUND_SPOKEN_FEEDBACK_ENABLED,
293 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV)); 287 bundle.GetRawDataResource(IDR_SOUND_SPOKEN_FEEDBACK_ENABLED_WAV));
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 1151
1158 base::TimeDelta AccessibilityManager::PlayShutdownSound() { 1152 base::TimeDelta AccessibilityManager::PlayShutdownSound() {
1159 if (!system_sounds_enabled_) 1153 if (!system_sounds_enabled_)
1160 return base::TimeDelta(); 1154 return base::TimeDelta();
1161 system_sounds_enabled_ = false; 1155 system_sounds_enabled_ = false;
1162 if (!PlayEarcon(SOUND_SHUTDOWN, PlaySoundOption::SPOKEN_FEEDBACK_ENABLED)) 1156 if (!PlayEarcon(SOUND_SHUTDOWN, PlaySoundOption::SPOKEN_FEEDBACK_ENABLED))
1163 return base::TimeDelta(); 1157 return base::TimeDelta();
1164 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN); 1158 return media::SoundsManager::Get()->GetDuration(SOUND_SHUTDOWN);
1165 } 1159 }
1166 1160
1167 void AccessibilityManager::InjectChromeVox(RenderViewHost* render_view_host) {
1168 chromevox_loader_->LoadExtension(profile_, render_view_host, base::Closure());
1169 }
1170
1171 std::unique_ptr<AccessibilityStatusSubscription> 1161 std::unique_ptr<AccessibilityStatusSubscription>
1172 AccessibilityManager::RegisterCallback(const AccessibilityStatusCallback& cb) { 1162 AccessibilityManager::RegisterCallback(const AccessibilityStatusCallback& cb) {
1173 return callback_list_.Add(cb); 1163 return callback_list_.Add(cb);
1174 } 1164 }
1175 1165
1176 void AccessibilityManager::NotifyAccessibilityStatusChanged( 1166 void AccessibilityManager::NotifyAccessibilityStatusChanged(
1177 AccessibilityStatusEventDetails& details) { 1167 AccessibilityStatusEventDetails& details) {
1178 callback_list_.Notify(details); 1168 callback_list_.Notify(details);
1179 } 1169 }
1180 1170
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 // Update |profile_| when entering the login screen. 1229 // Update |profile_| when entering the login screen.
1240 Profile* profile = ProfileManager::GetActiveUserProfile(); 1230 Profile* profile = ProfileManager::GetActiveUserProfile();
1241 if (ProfileHelper::IsSigninProfile(profile)) 1231 if (ProfileHelper::IsSigninProfile(profile))
1242 SetProfile(profile); 1232 SetProfile(profile);
1243 break; 1233 break;
1244 } 1234 }
1245 case chrome::NOTIFICATION_SESSION_STARTED: 1235 case chrome::NOTIFICATION_SESSION_STARTED:
1246 // Update |profile_| when entering a session. 1236 // Update |profile_| when entering a session.
1247 SetProfile(ProfileManager::GetActiveUserProfile()); 1237 SetProfile(ProfileManager::GetActiveUserProfile());
1248 1238
1249 // Ensure ChromeVox makes announcements at the start of new sessions.
1250 should_speak_chrome_vox_announcements_on_user_screen_ = true;
1251
1252 // Add a session state observer to be able to monitor session changes. 1239 // Add a session state observer to be able to monitor session changes.
1253 if (!session_state_observer_.get() && ash::Shell::HasInstance()) 1240 if (!session_state_observer_.get() && ash::Shell::HasInstance())
1254 session_state_observer_.reset( 1241 session_state_observer_.reset(
1255 new ash::ScopedSessionStateObserver(this)); 1242 new ash::ScopedSessionStateObserver(this));
1256 break; 1243 break;
1257 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 1244 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
1258 // Update |profile_| when exiting a session or shutting down. 1245 // Update |profile_| when exiting a session or shutting down.
1259 Profile* profile = content::Source<Profile>(source).ptr(); 1246 Profile* profile = content::Source<Profile>(source).ptr();
1260 if (profile_ == profile) 1247 if (profile_ == profile)
1261 SetProfile(NULL); 1248 SetProfile(NULL);
1262 break; 1249 break;
1263 } 1250 }
1264 case chrome::NOTIFICATION_SCREEN_LOCK_STATE_CHANGED: {
1265 bool is_screen_locked = *content::Details<bool>(details).ptr();
1266 if (spoken_feedback_enabled_) {
1267 if (is_screen_locked)
1268 chromevox_loader_->LoadToLockScreen(base::Closure());
1269 // If spoken feedback was enabled, make sure it is also enabled on
1270 // the user screen.
1271 // The status tray gets verbalized by user screen ChromeVox, so we need
1272 // to load it on the user screen even if the screen is locked.
1273 chromevox_loader_->LoadToUserScreen(base::Closure());
1274 }
1275 break;
1276 }
1277 } 1251 }
1278 } 1252 }
1279 1253
1280 void AccessibilityManager::OnBrailleDisplayStateChanged( 1254 void AccessibilityManager::OnBrailleDisplayStateChanged(
1281 const DisplayState& display_state) { 1255 const DisplayState& display_state) {
1282 braille_display_connected_ = display_state.available; 1256 braille_display_connected_ = display_state.available;
1283 if (braille_display_connected_) { 1257 if (braille_display_connected_) {
1284 EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW); 1258 EnableSpokenFeedback(true, ash::A11Y_NOTIFICATION_SHOW);
1285 } 1259 }
1286 UpdateBrailleImeState(); 1260 UpdateBrailleImeState();
(...skipping 27 matching lines...) Expand all
1314 } 1288 }
1315 1289
1316 void AccessibilityManager::OnShutdown(extensions::ExtensionRegistry* registry) { 1290 void AccessibilityManager::OnShutdown(extensions::ExtensionRegistry* registry) {
1317 extension_registry_observer_.Remove(registry); 1291 extension_registry_observer_.Remove(registry);
1318 } 1292 }
1319 1293
1320 void AccessibilityManager::PostLoadChromeVox() { 1294 void AccessibilityManager::PostLoadChromeVox() {
1321 // Do any setup work needed immediately after ChromeVox actually loads. 1295 // Do any setup work needed immediately after ChromeVox actually loads.
1322 PlayEarcon(SOUND_SPOKEN_FEEDBACK_ENABLED, PlaySoundOption::ALWAYS); 1296 PlayEarcon(SOUND_SPOKEN_FEEDBACK_ENABLED, PlaySoundOption::ALWAYS);
1323 1297
1324 if (chromevox_loader_->loaded_on_lock_screen() || 1298 extensions::EventRouter* event_router =
1325 should_speak_chrome_vox_announcements_on_user_screen_) { 1299 extensions::EventRouter::Get(profile_);
1326 extensions::EventRouter* event_router = 1300 CHECK(event_router);
1327 extensions::EventRouter::Get(profile_);
1328 CHECK(event_router);
1329 1301
1330 std::unique_ptr<base::ListValue> event_args(new base::ListValue()); 1302 std::unique_ptr<base::ListValue> event_args(new base::ListValue());
1331 std::unique_ptr<extensions::Event> event(new extensions::Event( 1303 std::unique_ptr<extensions::Event> event(new extensions::Event(
1332 extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX, 1304 extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX,
1333 extensions::api::accessibility_private::OnIntroduceChromeVox:: 1305 extensions::api::accessibility_private::OnIntroduceChromeVox::kEventName,
1334 kEventName, 1306 std::move(event_args)));
1335 std::move(event_args))); 1307 event_router->DispatchEventWithLazyListener(
1336 event_router->DispatchEventWithLazyListener( 1308 extension_misc::kChromeVoxExtensionId, std::move(event));
1337 extension_misc::kChromeVoxExtensionId, std::move(event));
1338 }
1339
1340 should_speak_chrome_vox_announcements_on_user_screen_ =
1341 chromevox_loader_->loaded_on_lock_screen();
1342 1309
1343 if (!chromevox_panel_) { 1310 if (!chromevox_panel_) {
1344 chromevox_panel_ = new ChromeVoxPanel(profile_); 1311 chromevox_panel_ = new ChromeVoxPanel(profile_);
1345 chromevox_panel_widget_observer_.reset( 1312 chromevox_panel_widget_observer_.reset(
1346 new ChromeVoxPanelWidgetObserver(chromevox_panel_->GetWidget(), this)); 1313 new ChromeVoxPanelWidgetObserver(chromevox_panel_->GetWidget(), this));
1347 } 1314 }
1348 1315
1349 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 1316 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
1350 switches::kEnableDefaultMediaSession)) { 1317 switches::kEnableDefaultMediaSession)) {
1351 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1318 base::CommandLine::ForCurrentProcess()->AppendSwitch(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1402 content::BrowserContext* context) { 1369 content::BrowserContext* context) {
1403 keyboard_listener_extension_id_ = id; 1370 keyboard_listener_extension_id_ = id;
1404 1371
1405 extensions::ExtensionRegistry* registry = 1372 extensions::ExtensionRegistry* registry =
1406 extensions::ExtensionRegistry::Get(context); 1373 extensions::ExtensionRegistry::Get(context);
1407 if (!extension_registry_observer_.IsObserving(registry) && !id.empty()) 1374 if (!extension_registry_observer_.IsObserving(registry) && !id.empty())
1408 extension_registry_observer_.Add(registry); 1375 extension_registry_observer_.Add(registry);
1409 } 1376 }
1410 1377
1411 } // namespace chromeos 1378 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698