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" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 void UnloadChromeVoxExtension(Profile* profile) { | 264 void UnloadChromeVoxExtension(Profile* profile) { |
265 base::FilePath path = GetChromeVoxPath(); | 265 base::FilePath path = GetChromeVoxPath(); |
266 ExtensionService* extension_service = | 266 ExtensionService* extension_service = |
267 extensions::ExtensionSystem::Get(profile)->extension_service(); | 267 extensions::ExtensionSystem::Get(profile)->extension_service(); |
268 extension_service->component_loader()->Remove(path); | 268 extension_service->component_loader()->Remove(path); |
269 } | 269 } |
270 | 270 |
271 } // namespace | 271 } // namespace |
272 | 272 |
| 273 class ChromeVoxPanelWidgetObserver : public views::WidgetObserver { |
| 274 public: |
| 275 ChromeVoxPanelWidgetObserver(views::Widget* widget, |
| 276 AccessibilityManager* manager) |
| 277 : widget_(widget), manager_(manager) { |
| 278 widget_->AddObserver(this); |
| 279 } |
| 280 |
| 281 void OnWidgetClosing(views::Widget* widget) override { |
| 282 CHECK_EQ(widget_, widget); |
| 283 widget_->RemoveObserver(this); |
| 284 manager_->OnChromeVoxPanelClosing(); |
| 285 } |
| 286 |
| 287 private: |
| 288 views::Widget* widget_; |
| 289 AccessibilityManager* manager_; |
| 290 |
| 291 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWidgetObserver); |
| 292 }; |
| 293 |
273 /////////////////////////////////////////////////////////////////////////////// | 294 /////////////////////////////////////////////////////////////////////////////// |
274 // AccessibilityStatusEventDetails | 295 // AccessibilityStatusEventDetails |
275 | 296 |
276 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( | 297 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( |
277 AccessibilityNotificationType notification_type, | 298 AccessibilityNotificationType notification_type, |
278 bool enabled, | 299 bool enabled, |
279 ui::AccessibilityNotificationVisibility notify) | 300 ui::AccessibilityNotificationVisibility notify) |
280 : notification_type(notification_type), | 301 : notification_type(notification_type), |
281 enabled(enabled), | 302 enabled(enabled), |
282 magnifier_type(ui::kDefaultMagnifierType), | 303 magnifier_type(ui::kDefaultMagnifierType), |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 high_contrast_enabled_(false), | 391 high_contrast_enabled_(false), |
371 autoclick_enabled_(false), | 392 autoclick_enabled_(false), |
372 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), | 393 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), |
373 virtual_keyboard_enabled_(false), | 394 virtual_keyboard_enabled_(false), |
374 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), | 395 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), |
375 should_speak_chrome_vox_announcements_on_user_screen_(true), | 396 should_speak_chrome_vox_announcements_on_user_screen_(true), |
376 system_sounds_enabled_(false), | 397 system_sounds_enabled_(false), |
377 braille_display_connected_(false), | 398 braille_display_connected_(false), |
378 scoped_braille_observer_(this), | 399 scoped_braille_observer_(this), |
379 braille_ime_current_(false), | 400 braille_ime_current_(false), |
| 401 chromevox_panel_(nullptr), |
| 402 chromevox_panel_widget_observer_(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 239 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_ = |
| 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::ComputeWorkAreaInsets( |
| 1184 aura::Window* root_window, |
| 1185 gfx::Insets* out_insets) const { |
| 1186 if (chromevox_panel_ && chromevox_panel_->GetRootWindow() == root_window) |
| 1187 *out_insets = gfx::Insets(chromevox_panel_->GetHeight(), 0, 0, 0); |
| 1188 } |
| 1189 |
| 1190 void AccessibilityManager::OnChromeVoxPanelClosing() { |
| 1191 aura::Window* root_window = chromevox_panel_->GetRootWindow(); |
| 1192 delete chromevox_panel_widget_observer_; |
| 1193 chromevox_panel_widget_observer_ = nullptr; |
| 1194 chromevox_panel_ = nullptr; |
| 1195 ash::Shell::GetInstance()->UpdateDisplayWorkAreaInsets(root_window); |
| 1196 } |
| 1197 |
1151 } // namespace chromeos | 1198 } // namespace chromeos |
OLD | NEW |