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" |
11 #include "ash/session/session_state_delegate.h" | 11 #include "ash/session/session_state_delegate.h" |
12 #include "ash/shelf/shelf_layout_manager.h" | |
12 #include "ash/shell.h" | 13 #include "ash/shell.h" |
13 #include "ash/sticky_keys/sticky_keys_controller.h" | 14 #include "ash/sticky_keys/sticky_keys_controller.h" |
14 #include "ash/system/tray/system_tray_notifier.h" | 15 #include "ash/system/tray/system_tray_notifier.h" |
15 #include "base/callback.h" | 16 #include "base/callback.h" |
16 #include "base/callback_helpers.h" | 17 #include "base/callback_helpers.h" |
17 #include "base/command_line.h" | 18 #include "base/command_line.h" |
18 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
19 #include "base/memory/singleton.h" | 20 #include "base/memory/singleton.h" |
20 #include "base/metrics/histogram.h" | 21 #include "base/metrics/histogram.h" |
21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 | 264 |
264 void UnloadChromeVoxExtension(Profile* profile) { | 265 void UnloadChromeVoxExtension(Profile* profile) { |
265 base::FilePath path = GetChromeVoxPath(); | 266 base::FilePath path = GetChromeVoxPath(); |
266 ExtensionService* extension_service = | 267 ExtensionService* extension_service = |
267 extensions::ExtensionSystem::Get(profile)->extension_service(); | 268 extensions::ExtensionSystem::Get(profile)->extension_service(); |
268 extension_service->component_loader()->Remove(path); | 269 extension_service->component_loader()->Remove(path); |
269 } | 270 } |
270 | 271 |
271 } // namespace | 272 } // namespace |
272 | 273 |
274 class ChromeVoxPanelWidgetObserver : public views::WidgetObserver { | |
275 public: | |
276 ChromeVoxPanelWidgetObserver(views::Widget* widget, | |
277 AccessibilityManager* manager) | |
278 : widget_(widget), manager_(manager) { | |
279 widget_->AddObserver(this); | |
280 } | |
281 | |
282 void OnWidgetClosing(views::Widget* widget) override { | |
283 CHECK_EQ(widget_, widget); | |
284 widget_->RemoveObserver(this); | |
oshima
2015/11/10 19:47:51
nit: you can just use the widget passed instead?
dmazzoni
2015/11/10 21:55:51
Done.
| |
285 manager_->OnChromeVoxPanelClosing(); | |
286 } | |
287 | |
288 private: | |
289 views::Widget* widget_; | |
290 AccessibilityManager* manager_; | |
291 | |
292 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWidgetObserver); | |
293 }; | |
294 | |
273 /////////////////////////////////////////////////////////////////////////////// | 295 /////////////////////////////////////////////////////////////////////////////// |
274 // AccessibilityStatusEventDetails | 296 // AccessibilityStatusEventDetails |
275 | 297 |
276 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( | 298 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( |
277 AccessibilityNotificationType notification_type, | 299 AccessibilityNotificationType notification_type, |
278 bool enabled, | 300 bool enabled, |
279 ui::AccessibilityNotificationVisibility notify) | 301 ui::AccessibilityNotificationVisibility notify) |
280 : notification_type(notification_type), | 302 : notification_type(notification_type), |
281 enabled(enabled), | 303 enabled(enabled), |
282 magnifier_type(ui::kDefaultMagnifierType), | 304 magnifier_type(ui::kDefaultMagnifierType), |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
370 high_contrast_enabled_(false), | 392 high_contrast_enabled_(false), |
371 autoclick_enabled_(false), | 393 autoclick_enabled_(false), |
372 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 394 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
373 virtual_keyboard_enabled_(false), | 395 virtual_keyboard_enabled_(false), |
374 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), | 396 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), |
375 should_speak_chrome_vox_announcements_on_user_screen_(true), | 397 should_speak_chrome_vox_announcements_on_user_screen_(true), |
376 system_sounds_enabled_(false), | 398 system_sounds_enabled_(false), |
377 braille_display_connected_(false), | 399 braille_display_connected_(false), |
378 scoped_braille_observer_(this), | 400 scoped_braille_observer_(this), |
379 braille_ime_current_(false), | 401 braille_ime_current_(false), |
402 chromevox_panel_(nullptr), | |
380 weak_ptr_factory_(this) { | 403 weak_ptr_factory_(this) { |
381 notification_registrar_.Add(this, | 404 notification_registrar_.Add(this, |
382 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, | 405 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, |
383 content::NotificationService::AllSources()); | 406 content::NotificationService::AllSources()); |
384 notification_registrar_.Add(this, | 407 notification_registrar_.Add(this, |
385 chrome::NOTIFICATION_SESSION_STARTED, | 408 chrome::NOTIFICATION_SESSION_STARTED, |
386 content::NotificationService::AllSources()); | 409 content::NotificationService::AllSources()); |
387 notification_registrar_.Add(this, | 410 notification_registrar_.Add(this, |
388 chrome::NOTIFICATION_PROFILE_DESTROYED, | 411 chrome::NOTIFICATION_PROFILE_DESTROYED, |
389 content::NotificationService::AllSources()); | 412 content::NotificationService::AllSources()); |
(...skipping 21 matching lines...) Expand all Loading... | |
411 bundle.GetRawDataResource(IDR_SOUND_ENTER_SCREEN_WAV)); | 434 bundle.GetRawDataResource(IDR_SOUND_ENTER_SCREEN_WAV)); |
412 } | 435 } |
413 | 436 |
414 AccessibilityManager::~AccessibilityManager() { | 437 AccessibilityManager::~AccessibilityManager() { |
415 CHECK(this == g_accessibility_manager); | 438 CHECK(this == g_accessibility_manager); |
416 AccessibilityStatusEventDetails details( | 439 AccessibilityStatusEventDetails details( |
417 ACCESSIBILITY_MANAGER_SHUTDOWN, | 440 ACCESSIBILITY_MANAGER_SHUTDOWN, |
418 false, | 441 false, |
419 ui::A11Y_NOTIFICATION_NONE); | 442 ui::A11Y_NOTIFICATION_NONE); |
420 NotifyAccessibilityStatusChanged(details); | 443 NotifyAccessibilityStatusChanged(details); |
421 input_method::InputMethodManager::Get()->RemoveObserver(this); | 444 input_method::InputMethodManager::Get()->RemoveObserver(this); |
oshima
2015/11/10 19:47:51
DCHECK(!chromevox_panel_)?
dmazzoni
2015/11/10 21:55:50
Done.
| |
422 } | 445 } |
423 | 446 |
424 bool AccessibilityManager::ShouldShowAccessibilityMenu() { | 447 bool AccessibilityManager::ShouldShowAccessibilityMenu() { |
425 // If any of the loaded profiles has an accessibility feature turned on - or | 448 // If any of the loaded profiles has an accessibility feature turned on - or |
426 // enforced to always show the menu - we return true to show the menu. | 449 // enforced to always show the menu - we return true to show the menu. |
427 std::vector<Profile*> profiles = | 450 std::vector<Profile*> profiles = |
428 g_browser_process->profile_manager()->GetLoadedProfiles(); | 451 g_browser_process->profile_manager()->GetLoadedProfiles(); |
429 for (std::vector<Profile*>::iterator it = profiles.begin(); | 452 for (std::vector<Profile*>::iterator it = profiles.begin(); |
430 it != profiles.end(); | 453 it != profiles.end(); |
431 ++it) { | 454 ++it) { |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 chrome_vox_loaded_on_lock_screen_ = true; | 652 chrome_vox_loaded_on_lock_screen_ = true; |
630 LoadChromeVoxExtension( | 653 LoadChromeVoxExtension( |
631 profile, | 654 profile, |
632 lock_web_ui->GetWebContents()->GetRenderViewHost(), | 655 lock_web_ui->GetWebContents()->GetRenderViewHost(), |
633 done_cb); | 656 done_cb); |
634 } | 657 } |
635 } | 658 } |
636 } | 659 } |
637 | 660 |
638 void AccessibilityManager::UnloadChromeVox() { | 661 void AccessibilityManager::UnloadChromeVox() { |
662 if (chromevox_panel_) { | |
663 chromevox_panel_->Close(); | |
664 chromevox_panel_ = nullptr; | |
665 } | |
666 | |
639 if (chrome_vox_loaded_on_lock_screen_) | 667 if (chrome_vox_loaded_on_lock_screen_) |
640 UnloadChromeVoxFromLockScreen(); | 668 UnloadChromeVoxFromLockScreen(); |
641 | 669 |
642 if (chrome_vox_loaded_on_user_screen_) { | 670 if (chrome_vox_loaded_on_user_screen_) { |
643 UnloadChromeVoxExtension(profile_); | 671 UnloadChromeVoxExtension(profile_); |
644 chrome_vox_loaded_on_user_screen_ = false; | 672 chrome_vox_loaded_on_user_screen_ = false; |
645 } | 673 } |
646 | 674 |
647 PostUnloadChromeVox(profile_); | 675 PostUnloadChromeVox(profile_); |
648 } | 676 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1131 extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX, | 1159 extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX, |
1132 extensions::api::accessibility_private::OnIntroduceChromeVox:: | 1160 extensions::api::accessibility_private::OnIntroduceChromeVox:: |
1133 kEventName, | 1161 kEventName, |
1134 event_args.Pass())); | 1162 event_args.Pass())); |
1135 event_router->DispatchEventWithLazyListener( | 1163 event_router->DispatchEventWithLazyListener( |
1136 extension_misc::kChromeVoxExtensionId, event.Pass()); | 1164 extension_misc::kChromeVoxExtensionId, event.Pass()); |
1137 } | 1165 } |
1138 | 1166 |
1139 should_speak_chrome_vox_announcements_on_user_screen_ = | 1167 should_speak_chrome_vox_announcements_on_user_screen_ = |
1140 chrome_vox_loaded_on_lock_screen_; | 1168 chrome_vox_loaded_on_lock_screen_; |
1169 | |
1170 chromevox_panel_ = new ChromeVoxPanel(profile_); | |
1171 chromevox_panel_widget_observer_.reset( | |
1172 new ChromeVoxPanelWidgetObserver(chromevox_panel_->GetWidget(), this)); | |
1141 } | 1173 } |
1142 | 1174 |
1143 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { | 1175 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { |
1144 // Do any teardown work needed immediately after ChromeVox actually unloads. | 1176 // Do any teardown work needed immediately after ChromeVox actually unloads. |
1145 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); | 1177 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); |
1146 // Clear the accessibility focus ring. | 1178 // Clear the accessibility focus ring. |
1147 AccessibilityFocusRingController::GetInstance()->SetFocusRing( | 1179 AccessibilityFocusRingController::GetInstance()->SetFocusRing( |
1148 std::vector<gfx::Rect>()); | 1180 std::vector<gfx::Rect>()); |
1149 } | 1181 } |
1150 | 1182 |
1183 void AccessibilityManager::OnChromeVoxPanelClosing() { | |
1184 aura::Window* root_window = chromevox_panel_->GetRootWindow(); | |
1185 chromevox_panel_widget_observer_.reset(nullptr); | |
1186 chromevox_panel_ = nullptr; | |
1187 ash::ShelfLayoutManager::ForShelf(root_window)->SetChromeVoxPanelHeight(0); | |
1188 } | |
1189 | |
1151 } // namespace chromeos | 1190 } // namespace chromeos |
OLD | NEW |