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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } // namespace | 186 } // namespace |
187 | 187 |
188 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() | 188 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() |
189 : user_profile_(NULL), | 189 : user_profile_(NULL), |
190 clock_type_(base::GetHourClockType()), | 190 clock_type_(base::GetHourClockType()), |
191 search_key_mapped_to_(input_method::kSearchKey), | 191 search_key_mapped_to_(input_method::kSearchKey), |
192 screen_locked_(false), | 192 screen_locked_(false), |
193 have_session_start_time_(false), | 193 have_session_start_time_(false), |
194 have_session_length_limit_(false), | 194 have_session_length_limit_(false), |
195 should_run_bluetooth_discovery_(false), | 195 should_run_bluetooth_discovery_(false), |
| 196 session_started_(false), |
196 volume_control_delegate_(new VolumeController()), | 197 volume_control_delegate_(new VolumeController()), |
197 device_settings_observer_(CrosSettings::Get()->AddSettingsObserver( | 198 device_settings_observer_(CrosSettings::Get()->AddSettingsObserver( |
198 kSystemUse24HourClock, | 199 kSystemUse24HourClock, |
199 base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, | 200 base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, |
200 base::Unretained(this)))), | 201 base::Unretained(this)))), |
201 weak_ptr_factory_(this) { | 202 weak_ptr_factory_(this) { |
202 // Register notifications on construction so that events such as | 203 // Register notifications on construction so that events such as |
203 // PROFILE_CREATED do not get missed if they happen before Initialize(). | 204 // PROFILE_CREATED do not get missed if they happen before Initialize(). |
204 registrar_.reset(new content::NotificationRegistrar); | 205 registrar_.reset(new content::NotificationRegistrar); |
205 registrar_->Add(this, | 206 registrar_->Add(this, |
(...skipping 12 matching lines...) Expand all Loading... |
218 content::NotificationService::AllSources()); | 219 content::NotificationService::AllSources()); |
219 registrar_->Add(this, | 220 registrar_->Add(this, |
220 chrome::NOTIFICATION_PROFILE_DESTROYED, | 221 chrome::NOTIFICATION_PROFILE_DESTROYED, |
221 content::NotificationService::AllSources()); | 222 content::NotificationService::AllSources()); |
222 | 223 |
223 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); | 224 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); |
224 CHECK(accessibility_manager); | 225 CHECK(accessibility_manager); |
225 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 226 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
226 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, | 227 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, |
227 base::Unretained(this))); | 228 base::Unretained(this))); |
| 229 |
| 230 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
228 } | 231 } |
229 | 232 |
230 void SystemTrayDelegateChromeOS::Initialize() { | 233 void SystemTrayDelegateChromeOS::Initialize() { |
231 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 234 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
232 | 235 |
233 input_method::InputMethodManager::Get()->AddObserver(this); | 236 input_method::InputMethodManager::Get()->AddObserver(this); |
234 ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 237 ash::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
235 UpdateClockType(); | 238 UpdateClockType(); |
236 | 239 |
237 device::BluetoothAdapterFactory::GetAdapter( | 240 device::BluetoothAdapterFactory::GetAdapter( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 | 312 |
310 BrowserList::RemoveObserver(this); | 313 BrowserList::RemoveObserver(this); |
311 StopObservingAppWindowRegistry(); | 314 StopObservingAppWindowRegistry(); |
312 | 315 |
313 policy::BrowserPolicyConnectorChromeOS* connector = | 316 policy::BrowserPolicyConnectorChromeOS* connector = |
314 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 317 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
315 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | 318 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = |
316 connector->GetDeviceCloudPolicyManager(); | 319 connector->GetDeviceCloudPolicyManager(); |
317 if (policy_manager) | 320 if (policy_manager) |
318 policy_manager->core()->store()->RemoveObserver(this); | 321 policy_manager->core()->store()->RemoveObserver(this); |
| 322 |
| 323 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); |
319 } | 324 } |
320 | 325 |
321 // Overridden from ash::SystemTrayDelegate: | 326 // Overridden from ash::SystemTrayDelegate: |
322 bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() { | 327 bool SystemTrayDelegateChromeOS::GetTrayVisibilityOnStartup() { |
323 // In case of OOBE / sign in screen tray will be shown later. | 328 // In case of OOBE / sign in screen tray will be shown later. |
324 return LoginState::Get()->IsUserLoggedIn(); | 329 return LoginState::Get()->IsUserLoggedIn(); |
325 } | 330 } |
326 | 331 |
327 ash::user::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { | 332 ash::user::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { |
328 // All non-logged in ChromeOS specific LOGGED_IN states map to the same | 333 // All non-logged in ChromeOS specific LOGGED_IN states map to the same |
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); | 857 Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user); |
853 CHECK(user_profile); | 858 CHECK(user_profile); |
854 accounts_delegates_.set( | 859 accounts_delegates_.set( |
855 user_id, | 860 user_id, |
856 scoped_ptr<ash::tray::UserAccountsDelegate>( | 861 scoped_ptr<ash::tray::UserAccountsDelegate>( |
857 new UserAccountsDelegateChromeOS(user_profile))); | 862 new UserAccountsDelegateChromeOS(user_profile))); |
858 } | 863 } |
859 return accounts_delegates_.get(user_id); | 864 return accounts_delegates_.get(user_id); |
860 } | 865 } |
861 | 866 |
| 867 void SystemTrayDelegateChromeOS::UserAddedToSession( |
| 868 const user_manager::User* active_user) { |
| 869 } |
| 870 |
| 871 void SystemTrayDelegateChromeOS::UserChangedSupervisedStatus( |
| 872 user_manager::User* user) { |
| 873 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); |
| 874 DCHECK(user_profile); |
| 875 |
| 876 if (session_started_ && user_profile_ == user_profile) { |
| 877 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 878 GetUserLoginStatus()); |
| 879 } |
| 880 } |
| 881 |
862 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { | 882 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { |
863 return ash::Shell::GetInstance()->GetPrimarySystemTray(); | 883 return ash::Shell::GetInstance()->GetPrimarySystemTray(); |
864 } | 884 } |
865 | 885 |
866 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { | 886 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { |
867 return ash::Shell::GetInstance()->system_tray_notifier(); | 887 return ash::Shell::GetInstance()->system_tray_notifier(); |
868 } | 888 } |
869 | 889 |
870 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { | 890 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { |
871 // Stop observing the AppWindowRegistry of the current |user_profile_|. | 891 // Stop observing the AppWindowRegistry of the current |user_profile_|. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 } | 1131 } |
1112 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 1132 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
1113 if (UnsetProfile(content::Source<Profile>(source).ptr())) { | 1133 if (UnsetProfile(content::Source<Profile>(source).ptr())) { |
1114 registrar_->Remove(this, | 1134 registrar_->Remove(this, |
1115 chrome::NOTIFICATION_PROFILE_DESTROYED, | 1135 chrome::NOTIFICATION_PROFILE_DESTROYED, |
1116 content::NotificationService::AllSources()); | 1136 content::NotificationService::AllSources()); |
1117 } | 1137 } |
1118 break; | 1138 break; |
1119 } | 1139 } |
1120 case chrome::NOTIFICATION_SESSION_STARTED: { | 1140 case chrome::NOTIFICATION_SESSION_STARTED: { |
| 1141 session_started_ = true; |
1121 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 1142 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
1122 GetUserLoginStatus()); | 1143 GetUserLoginStatus()); |
1123 SetProfile(ProfileManager::GetActiveUserProfile()); | 1144 SetProfile(ProfileManager::GetActiveUserProfile()); |
1124 break; | 1145 break; |
1125 } | 1146 } |
1126 default: | 1147 default: |
1127 NOTREACHED(); | 1148 NOTREACHED(); |
1128 } | 1149 } |
1129 } | 1150 } |
1130 | 1151 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 accessibility_subscription_.reset(); | 1298 accessibility_subscription_.reset(); |
1278 else | 1299 else |
1279 OnAccessibilityModeChanged(details.notify); | 1300 OnAccessibilityModeChanged(details.notify); |
1280 } | 1301 } |
1281 | 1302 |
1282 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1303 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1283 return new SystemTrayDelegateChromeOS(); | 1304 return new SystemTrayDelegateChromeOS(); |
1284 } | 1305 } |
1285 | 1306 |
1286 } // namespace chromeos | 1307 } // namespace chromeos |
OLD | NEW |