Chromium Code Reviews| Index: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| diff --git a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| index c2b2b64a6e1a968650d71cd10c8975fb2bbd3080..19fbfdbb9fe0e3aa2918f076fd759a8c8c2781ca 100644 |
| --- a/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| +++ b/chrome/browser/ui/ash/system_tray_delegate_chromeos.cc |
| @@ -275,22 +275,12 @@ SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
| registrar_->Add(this, |
| chrome::NOTIFICATION_PROFILE_DESTROYED, |
| content::NotificationService::AllSources()); |
| - registrar_->Add( |
| - this, |
| - chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, |
| - content::NotificationService::AllSources()); |
| - registrar_->Add( |
| - this, |
| - chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, |
| - content::NotificationService::AllSources()); |
| - registrar_->Add( |
| - this, |
| - chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, |
| - content::NotificationService::AllSources()); |
| - registrar_->Add( |
| - this, |
| - chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, |
| - content::NotificationService::AllSources()); |
| + |
| + AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
| + CHECK(accessibility_manager); |
| + accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| + base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
| + base::Unretained(this))); |
|
sky
2014/02/21 17:10:32
Add a comment as to why Unretained is safe here.
kevers
2014/02/21 17:52:31
The destructor for the subscription removes itself
|
| } |
| void SystemTrayDelegateChromeOS::Initialize() { |
| @@ -359,6 +349,9 @@ SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { |
| // Unregister content notifications befure destroying any components. |
| registrar_.reset(); |
| + // Unregister a11y status subscription. |
| + accessibility_subscription_.reset(); |
| + |
| DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| input_method::InputMethodManager::Get()->RemoveObserver(this); |
| ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
| @@ -1162,15 +1155,6 @@ void SystemTrayDelegateChromeOS::Observe( |
| SetProfile(ProfileManager::GetActiveUserProfile()); |
| break; |
| } |
| - case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK: |
| - case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE: |
| - case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER: |
| - case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD: { |
| - AccessibilityStatusEventDetails* accessibility_status = |
| - content::Details<AccessibilityStatusEventDetails>(details).ptr(); |
| - OnAccessibilityModeChanged(accessibility_status->notify); |
| - break; |
| - } |
| default: |
| NOTREACHED(); |
| } |
| @@ -1331,6 +1315,14 @@ void SystemTrayDelegateChromeOS::UserAddedToSession( |
| GetSystemTrayNotifier()->NotifyUserAddedToSession(); |
| } |
| +void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( |
| + const AccessibilityStatusEventDetails& details) { |
| + if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) |
| + accessibility_subscription_.reset(); |
| + else |
| + OnAccessibilityModeChanged(details.notify); |
| +} |
| + |
| ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| return new SystemTrayDelegateChromeOS(); |
| } |