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

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

Issue 1274563004: Show ChromeVox caption panel when spoken feedback is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chromevox_panel_html
Patch Set: Don't let ChromeVox Classic run on panel Created 5 years, 1 month 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 "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
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);
285 manager_->OnChromeVoxPanelClosing();
286 }
287
288 void OnWidgetDestroying(views::Widget* widget) override {
289 CHECK_EQ(widget_, widget);
290 widget->RemoveObserver(this);
291 manager_->OnChromeVoxPanelDestroying();
292 }
293
294 private:
295 views::Widget* widget_;
296 AccessibilityManager* manager_;
297
298 DISALLOW_COPY_AND_ASSIGN(ChromeVoxPanelWidgetObserver);
299 };
300
273 /////////////////////////////////////////////////////////////////////////////// 301 ///////////////////////////////////////////////////////////////////////////////
274 // AccessibilityStatusEventDetails 302 // AccessibilityStatusEventDetails
275 303
276 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails( 304 AccessibilityStatusEventDetails::AccessibilityStatusEventDetails(
277 AccessibilityNotificationType notification_type, 305 AccessibilityNotificationType notification_type,
278 bool enabled, 306 bool enabled,
279 ui::AccessibilityNotificationVisibility notify) 307 ui::AccessibilityNotificationVisibility notify)
280 : notification_type(notification_type), 308 : notification_type(notification_type),
281 enabled(enabled), 309 enabled(enabled),
282 magnifier_type(ui::kDefaultMagnifierType), 310 magnifier_type(ui::kDefaultMagnifierType),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 high_contrast_enabled_(false), 398 high_contrast_enabled_(false),
371 autoclick_enabled_(false), 399 autoclick_enabled_(false),
372 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs), 400 autoclick_delay_ms_(ash::AutoclickController::kDefaultAutoclickDelayMs),
373 virtual_keyboard_enabled_(false), 401 virtual_keyboard_enabled_(false),
374 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE), 402 spoken_feedback_notification_(ui::A11Y_NOTIFICATION_NONE),
375 should_speak_chrome_vox_announcements_on_user_screen_(true), 403 should_speak_chrome_vox_announcements_on_user_screen_(true),
376 system_sounds_enabled_(false), 404 system_sounds_enabled_(false),
377 braille_display_connected_(false), 405 braille_display_connected_(false),
378 scoped_braille_observer_(this), 406 scoped_braille_observer_(this),
379 braille_ime_current_(false), 407 braille_ime_current_(false),
408 chromevox_panel_(nullptr),
380 weak_ptr_factory_(this) { 409 weak_ptr_factory_(this) {
381 notification_registrar_.Add(this, 410 notification_registrar_.Add(this,
382 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE, 411 chrome::NOTIFICATION_LOGIN_OR_LOCK_WEBUI_VISIBLE,
383 content::NotificationService::AllSources()); 412 content::NotificationService::AllSources());
384 notification_registrar_.Add(this, 413 notification_registrar_.Add(this,
385 chrome::NOTIFICATION_SESSION_STARTED, 414 chrome::NOTIFICATION_SESSION_STARTED,
386 content::NotificationService::AllSources()); 415 content::NotificationService::AllSources());
387 notification_registrar_.Add(this, 416 notification_registrar_.Add(this,
388 chrome::NOTIFICATION_PROFILE_DESTROYED, 417 chrome::NOTIFICATION_PROFILE_DESTROYED,
389 content::NotificationService::AllSources()); 418 content::NotificationService::AllSources());
(...skipping 22 matching lines...) Expand all
412 } 441 }
413 442
414 AccessibilityManager::~AccessibilityManager() { 443 AccessibilityManager::~AccessibilityManager() {
415 CHECK(this == g_accessibility_manager); 444 CHECK(this == g_accessibility_manager);
416 AccessibilityStatusEventDetails details( 445 AccessibilityStatusEventDetails details(
417 ACCESSIBILITY_MANAGER_SHUTDOWN, 446 ACCESSIBILITY_MANAGER_SHUTDOWN,
418 false, 447 false,
419 ui::A11Y_NOTIFICATION_NONE); 448 ui::A11Y_NOTIFICATION_NONE);
420 NotifyAccessibilityStatusChanged(details); 449 NotifyAccessibilityStatusChanged(details);
421 input_method::InputMethodManager::Get()->RemoveObserver(this); 450 input_method::InputMethodManager::Get()->RemoveObserver(this);
451
452 if (chromevox_panel_) {
453 chromevox_panel_->Close();
454 chromevox_panel_ = nullptr;
455 }
422 } 456 }
423 457
424 bool AccessibilityManager::ShouldShowAccessibilityMenu() { 458 bool AccessibilityManager::ShouldShowAccessibilityMenu() {
425 // If any of the loaded profiles has an accessibility feature turned on - or 459 // 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. 460 // enforced to always show the menu - we return true to show the menu.
427 std::vector<Profile*> profiles = 461 std::vector<Profile*> profiles =
428 g_browser_process->profile_manager()->GetLoadedProfiles(); 462 g_browser_process->profile_manager()->GetLoadedProfiles();
429 for (std::vector<Profile*>::iterator it = profiles.begin(); 463 for (std::vector<Profile*>::iterator it = profiles.begin();
430 it != profiles.end(); 464 it != profiles.end();
431 ++it) { 465 ++it) {
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 chrome_vox_loaded_on_lock_screen_ = true; 663 chrome_vox_loaded_on_lock_screen_ = true;
630 LoadChromeVoxExtension( 664 LoadChromeVoxExtension(
631 profile, 665 profile,
632 lock_web_ui->GetWebContents()->GetRenderViewHost(), 666 lock_web_ui->GetWebContents()->GetRenderViewHost(),
633 done_cb); 667 done_cb);
634 } 668 }
635 } 669 }
636 } 670 }
637 671
638 void AccessibilityManager::UnloadChromeVox() { 672 void AccessibilityManager::UnloadChromeVox() {
673 if (chromevox_panel_) {
674 chromevox_panel_->Close();
675 chromevox_panel_ = nullptr;
676 }
677
639 if (chrome_vox_loaded_on_lock_screen_) 678 if (chrome_vox_loaded_on_lock_screen_)
640 UnloadChromeVoxFromLockScreen(); 679 UnloadChromeVoxFromLockScreen();
641 680
642 if (chrome_vox_loaded_on_user_screen_) { 681 if (chrome_vox_loaded_on_user_screen_) {
643 UnloadChromeVoxExtension(profile_); 682 UnloadChromeVoxExtension(profile_);
644 chrome_vox_loaded_on_user_screen_ = false; 683 chrome_vox_loaded_on_user_screen_ = false;
645 } 684 }
646 685
647 PostUnloadChromeVox(profile_); 686 PostUnloadChromeVox(profile_);
648 } 687 }
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX, 1170 extensions::events::ACCESSIBILITY_PRIVATE_ON_INTRODUCE_CHROME_VOX,
1132 extensions::api::accessibility_private::OnIntroduceChromeVox:: 1171 extensions::api::accessibility_private::OnIntroduceChromeVox::
1133 kEventName, 1172 kEventName,
1134 event_args.Pass())); 1173 event_args.Pass()));
1135 event_router->DispatchEventWithLazyListener( 1174 event_router->DispatchEventWithLazyListener(
1136 extension_misc::kChromeVoxExtensionId, event.Pass()); 1175 extension_misc::kChromeVoxExtensionId, event.Pass());
1137 } 1176 }
1138 1177
1139 should_speak_chrome_vox_announcements_on_user_screen_ = 1178 should_speak_chrome_vox_announcements_on_user_screen_ =
1140 chrome_vox_loaded_on_lock_screen_; 1179 chrome_vox_loaded_on_lock_screen_;
1180
1181 if (!chromevox_panel_) {
1182 chromevox_panel_ = new ChromeVoxPanel(profile_);
1183 chromevox_panel_widget_observer_.reset(
1184 new ChromeVoxPanelWidgetObserver(chromevox_panel_->GetWidget(), this));
1185 }
1141 } 1186 }
1142 1187
1143 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) { 1188 void AccessibilityManager::PostUnloadChromeVox(Profile* profile) {
1144 // Do any teardown work needed immediately after ChromeVox actually unloads. 1189 // Do any teardown work needed immediately after ChromeVox actually unloads.
1145 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED); 1190 ash::PlaySystemSoundAlways(SOUND_SPOKEN_FEEDBACK_DISABLED);
1146 // Clear the accessibility focus ring. 1191 // Clear the accessibility focus ring.
1147 AccessibilityFocusRingController::GetInstance()->SetFocusRing( 1192 AccessibilityFocusRingController::GetInstance()->SetFocusRing(
1148 std::vector<gfx::Rect>()); 1193 std::vector<gfx::Rect>());
1149 } 1194 }
1150 1195
1196 void AccessibilityManager::OnChromeVoxPanelClosing() {
1197 aura::Window* root_window = chromevox_panel_->GetRootWindow();
1198 chromevox_panel_widget_observer_.reset(nullptr);
1199 chromevox_panel_ = nullptr;
1200 ash::ShelfLayoutManager::ForShelf(root_window)->SetChromeVoxPanelHeight(0);
1201 }
1202
1203 void AccessibilityManager::OnChromeVoxPanelDestroying() {
1204 chromevox_panel_widget_observer_.reset(nullptr);
1205 chromevox_panel_ = nullptr;
1206 }
1207
1151 } // namespace chromeos 1208 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility/accessibility_manager.h ('k') | chrome/browser/chromeos/accessibility/chromevox_panel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698