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 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), | |
|
Daniel Erat
2014/10/07 16:19:19
do you need to check whether a session is already
merkulova
2014/10/08 09:47:11
I'm using this flag to prevent early UpdateAfterLo
| |
| 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::UserChangedSupervisedStatus( | |
| 868 user_manager::User* user) { | |
| 869 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); | |
| 870 DCHECK(user_profile); | |
| 871 | |
| 872 if (session_started_ && user_profile_ == user_profile) { | |
| 873 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | |
| 874 GetUserLoginStatus()); | |
| 875 } | |
| 876 } | |
| 877 | |
| 862 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { | 878 ash::SystemTray* SystemTrayDelegateChromeOS::GetPrimarySystemTray() { |
| 863 return ash::Shell::GetInstance()->GetPrimarySystemTray(); | 879 return ash::Shell::GetInstance()->GetPrimarySystemTray(); |
| 864 } | 880 } |
| 865 | 881 |
| 866 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { | 882 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { |
| 867 return ash::Shell::GetInstance()->system_tray_notifier(); | 883 return ash::Shell::GetInstance()->system_tray_notifier(); |
| 868 } | 884 } |
| 869 | 885 |
| 870 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { | 886 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { |
| 871 // Stop observing the AppWindowRegistry of the current |user_profile_|. | 887 // Stop observing the AppWindowRegistry of the current |user_profile_|. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 } | 1127 } |
| 1112 case chrome::NOTIFICATION_PROFILE_DESTROYED: { | 1128 case chrome::NOTIFICATION_PROFILE_DESTROYED: { |
| 1113 if (UnsetProfile(content::Source<Profile>(source).ptr())) { | 1129 if (UnsetProfile(content::Source<Profile>(source).ptr())) { |
| 1114 registrar_->Remove(this, | 1130 registrar_->Remove(this, |
| 1115 chrome::NOTIFICATION_PROFILE_DESTROYED, | 1131 chrome::NOTIFICATION_PROFILE_DESTROYED, |
| 1116 content::NotificationService::AllSources()); | 1132 content::NotificationService::AllSources()); |
| 1117 } | 1133 } |
| 1118 break; | 1134 break; |
| 1119 } | 1135 } |
| 1120 case chrome::NOTIFICATION_SESSION_STARTED: { | 1136 case chrome::NOTIFICATION_SESSION_STARTED: { |
| 1137 session_started_ = true; | |
| 1121 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( | 1138 ash::Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 1122 GetUserLoginStatus()); | 1139 GetUserLoginStatus()); |
| 1123 SetProfile(ProfileManager::GetActiveUserProfile()); | 1140 SetProfile(ProfileManager::GetActiveUserProfile()); |
| 1124 break; | 1141 break; |
| 1125 } | 1142 } |
| 1126 default: | 1143 default: |
| 1127 NOTREACHED(); | 1144 NOTREACHED(); |
| 1128 } | 1145 } |
| 1129 } | 1146 } |
| 1130 | 1147 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1277 accessibility_subscription_.reset(); | 1294 accessibility_subscription_.reset(); |
| 1278 else | 1295 else |
| 1279 OnAccessibilityModeChanged(details.notify); | 1296 OnAccessibilityModeChanged(details.notify); |
| 1280 } | 1297 } |
| 1281 | 1298 |
| 1282 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1299 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1283 return new SystemTrayDelegateChromeOS(); | 1300 return new SystemTrayDelegateChromeOS(); |
| 1284 } | 1301 } |
| 1285 | 1302 |
| 1286 } // namespace chromeos | 1303 } // namespace chromeos |
| OLD | NEW |