Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/ash/system_tray_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 registrar_->Add(this, | 268 registrar_->Add(this, |
| 269 chrome::NOTIFICATION_SESSION_STARTED, | 269 chrome::NOTIFICATION_SESSION_STARTED, |
| 270 content::NotificationService::AllSources()); | 270 content::NotificationService::AllSources()); |
| 271 } | 271 } |
| 272 registrar_->Add(this, | 272 registrar_->Add(this, |
| 273 chrome::NOTIFICATION_PROFILE_CREATED, | 273 chrome::NOTIFICATION_PROFILE_CREATED, |
| 274 content::NotificationService::AllSources()); | 274 content::NotificationService::AllSources()); |
| 275 registrar_->Add(this, | 275 registrar_->Add(this, |
| 276 chrome::NOTIFICATION_PROFILE_DESTROYED, | 276 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 277 content::NotificationService::AllSources()); | 277 content::NotificationService::AllSources()); |
| 278 registrar_->Add( | 278 |
| 279 this, | 279 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
| 280 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER, | 280 CHECK(accessibility_manager); |
| 281 content::NotificationService::AllSources()); | 281 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| 282 registrar_->Add( | 282 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
| 283 this, | 283 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
| |
| 284 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, | |
| 285 content::NotificationService::AllSources()); | |
| 286 registrar_->Add( | |
| 287 this, | |
| 288 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE, | |
| 289 content::NotificationService::AllSources()); | |
| 290 registrar_->Add( | |
| 291 this, | |
| 292 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD, | |
| 293 content::NotificationService::AllSources()); | |
| 294 } | 284 } |
| 295 | 285 |
| 296 void SystemTrayDelegateChromeOS::Initialize() { | 286 void SystemTrayDelegateChromeOS::Initialize() { |
| 297 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 287 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 298 | 288 |
| 299 input_method::InputMethodManager::Get()->AddObserver(this); | 289 input_method::InputMethodManager::Get()->AddObserver(this); |
| 300 ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 290 ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
| 301 UpdateClockType(); | 291 UpdateClockType(); |
| 302 | 292 |
| 303 if (SystemKeyEventListener::GetInstance()) | 293 if (SystemKeyEventListener::GetInstance()) |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 352 } | 342 } |
| 353 | 343 |
| 354 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { | 344 SystemTrayDelegateChromeOS::~SystemTrayDelegateChromeOS() { |
| 355 // Unregister PrefChangeRegistrars. | 345 // Unregister PrefChangeRegistrars. |
| 356 local_state_registrar_.reset(); | 346 local_state_registrar_.reset(); |
| 357 user_pref_registrar_.reset(); | 347 user_pref_registrar_.reset(); |
| 358 | 348 |
| 359 // Unregister content notifications befure destroying any components. | 349 // Unregister content notifications befure destroying any components. |
| 360 registrar_.reset(); | 350 registrar_.reset(); |
| 361 | 351 |
| 352 // Unregister a11y status subscription. | |
| 353 accessibility_subscription_.reset(); | |
| 354 | |
| 362 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 355 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 363 input_method::InputMethodManager::Get()->RemoveObserver(this); | 356 input_method::InputMethodManager::Get()->RemoveObserver(this); |
| 364 ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); | 357 ash::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
| 365 if (SystemKeyEventListener::GetInstance()) | 358 if (SystemKeyEventListener::GetInstance()) |
| 366 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); | 359 SystemKeyEventListener::GetInstance()->RemoveCapsLockObserver(this); |
| 367 bluetooth_adapter_->RemoveObserver(this); | 360 bluetooth_adapter_->RemoveObserver(this); |
| 368 ash::Shell::GetInstance() | 361 ash::Shell::GetInstance() |
| 369 ->session_state_delegate() | 362 ->session_state_delegate() |
| 370 ->RemoveSessionStateObserver(this); | 363 ->RemoveSessionStateObserver(this); |
| 371 LoginState::Get()->RemoveObserver(this); | 364 LoginState::Get()->RemoveObserver(this); |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1155 content::NotificationService::AllSources()); | 1148 content::NotificationService::AllSources()); |
| 1156 } | 1149 } |
| 1157 break; | 1150 break; |
| 1158 } | 1151 } |
| 1159 case chrome::NOTIFICATION_SESSION_STARTED: { | 1152 case chrome::NOTIFICATION_SESSION_STARTED: { |
| 1160 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 1153 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 1161 GetUserLoginStatus()); | 1154 GetUserLoginStatus()); |
| 1162 SetProfile(ProfileManager::GetActiveUserProfile()); | 1155 SetProfile(ProfileManager::GetActiveUserProfile()); |
| 1163 break; | 1156 break; |
| 1164 } | 1157 } |
| 1165 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK: | |
| 1166 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_HIGH_CONTRAST_MODE: | |
| 1167 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SCREEN_MAGNIFIER: | |
| 1168 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_VIRTUAL_KEYBOARD: { | |
| 1169 AccessibilityStatusEventDetails* accessibility_status = | |
| 1170 content::Details<AccessibilityStatusEventDetails>(details).ptr(); | |
| 1171 OnAccessibilityModeChanged(accessibility_status->notify); | |
| 1172 break; | |
| 1173 } | |
| 1174 default: | 1158 default: |
| 1175 NOTREACHED(); | 1159 NOTREACHED(); |
| 1176 } | 1160 } |
| 1177 } | 1161 } |
| 1178 | 1162 |
| 1179 void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() { | 1163 void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() { |
| 1180 search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger( | 1164 search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger( |
| 1181 prefs::kLanguageRemapSearchKeyTo); | 1165 prefs::kLanguageRemapSearchKeyTo); |
| 1182 } | 1166 } |
| 1183 | 1167 |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1324 void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) { | 1308 void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) { |
| 1325 UpdateEnterpriseDomain(); | 1309 UpdateEnterpriseDomain(); |
| 1326 } | 1310 } |
| 1327 | 1311 |
| 1328 // Overridden from ash::SessionStateObserver | 1312 // Overridden from ash::SessionStateObserver |
| 1329 void SystemTrayDelegateChromeOS::UserAddedToSession( | 1313 void SystemTrayDelegateChromeOS::UserAddedToSession( |
| 1330 const std::string& user_id) { | 1314 const std::string& user_id) { |
| 1331 GetSystemTrayNotifier()->NotifyUserAddedToSession(); | 1315 GetSystemTrayNotifier()->NotifyUserAddedToSession(); |
| 1332 } | 1316 } |
| 1333 | 1317 |
| 1318 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( | |
| 1319 const AccessibilityStatusEventDetails& details) { | |
| 1320 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) | |
| 1321 accessibility_subscription_.reset(); | |
| 1322 else | |
| 1323 OnAccessibilityModeChanged(details.notify); | |
| 1324 } | |
| 1325 | |
| 1334 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1326 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1335 return new SystemTrayDelegateChromeOS(); | 1327 return new SystemTrayDelegateChromeOS(); |
| 1336 } | 1328 } |
| 1337 | 1329 |
| 1338 } // namespace chromeos | 1330 } // namespace chromeos |
| OLD | NEW |