| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 new ShutdownPolicyHandler(CrosSettings::Get(), this)); | 229 new ShutdownPolicyHandler(CrosSettings::Get(), this)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 void SystemTrayDelegateChromeOS::Initialize() { | 232 void SystemTrayDelegateChromeOS::Initialize() { |
| 233 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); | 233 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); |
| 234 | 234 |
| 235 input_method::InputMethodManager::Get()->AddObserver(this); | 235 input_method::InputMethodManager::Get()->AddObserver(this); |
| 236 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); | 236 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); |
| 237 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); | 237 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); |
| 238 | 238 |
| 239 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); | |
| 240 | |
| 241 OnSystemClockChanged(g_browser_process->platform_part()->GetSystemClock()); | |
| 242 | |
| 243 device::BluetoothAdapterFactory::GetAdapter( | 239 device::BluetoothAdapterFactory::GetAdapter( |
| 244 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, | 240 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, |
| 245 weak_ptr_factory_.GetWeakPtr())); | 241 weak_ptr_factory_.GetWeakPtr())); |
| 246 | 242 |
| 247 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | 243 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); |
| 248 | 244 |
| 249 if (CrasAudioHandler::IsInitialized()) | 245 if (CrasAudioHandler::IsInitialized()) |
| 250 CrasAudioHandler::Get()->AddAudioObserver(this); | 246 CrasAudioHandler::Get()->AddAudioObserver(this); |
| 251 | 247 |
| 252 BrowserList::AddObserver(this); | 248 BrowserList::AddObserver(this); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // Unregister PrefChangeRegistrars. | 282 // Unregister PrefChangeRegistrars. |
| 287 local_state_registrar_.reset(); | 283 local_state_registrar_.reset(); |
| 288 user_pref_registrar_.reset(); | 284 user_pref_registrar_.reset(); |
| 289 | 285 |
| 290 // Unregister content notifications before destroying any components. | 286 // Unregister content notifications before destroying any components. |
| 291 registrar_.reset(); | 287 registrar_.reset(); |
| 292 | 288 |
| 293 // Unregister a11y status subscription. | 289 // Unregister a11y status subscription. |
| 294 accessibility_subscription_.reset(); | 290 accessibility_subscription_.reset(); |
| 295 | 291 |
| 296 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); | |
| 297 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 292 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
| 298 input_method::InputMethodManager::Get()->RemoveObserver(this); | 293 input_method::InputMethodManager::Get()->RemoveObserver(this); |
| 299 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); | 294 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
| 300 if (bluetooth_adapter_) | 295 if (bluetooth_adapter_) |
| 301 bluetooth_adapter_->RemoveObserver(this); | 296 bluetooth_adapter_->RemoveObserver(this); |
| 302 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( | 297 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( |
| 303 this); | 298 this); |
| 304 | 299 |
| 305 if (CrasAudioHandler::IsInitialized()) | 300 if (CrasAudioHandler::IsInitialized()) |
| 306 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 301 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 | 391 |
| 397 bool SystemTrayDelegateChromeOS::IsUserChild() const { | 392 bool SystemTrayDelegateChromeOS::IsUserChild() const { |
| 398 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); | 393 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); |
| 399 } | 394 } |
| 400 | 395 |
| 401 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( | 396 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( |
| 402 ash::UpdateInfo* info) const { | 397 ash::UpdateInfo* info) const { |
| 403 GetUpdateInfo(UpgradeDetector::GetInstance(), info); | 398 GetUpdateInfo(UpgradeDetector::GetInstance(), info); |
| 404 } | 399 } |
| 405 | 400 |
| 406 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { | |
| 407 return clock_type_; | |
| 408 } | |
| 409 | |
| 410 void SystemTrayDelegateChromeOS::ShowSettings() { | 401 void SystemTrayDelegateChromeOS::ShowSettings() { |
| 411 SystemTrayCommon::ShowSettings(); | 402 SystemTrayCommon::ShowSettings(); |
| 412 } | 403 } |
| 413 | 404 |
| 414 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { | 405 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { |
| 415 ash::WmShell* wm_shell = ash::WmShell::Get(); | 406 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 416 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && | 407 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && |
| 417 !wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 408 !wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 418 } | 409 } |
| 419 | 410 |
| 420 void SystemTrayDelegateChromeOS::ShowDateSettings() { | |
| 421 SystemTrayCommon::ShowDateSettings(); | |
| 422 } | |
| 423 | |
| 424 void SystemTrayDelegateChromeOS::ShowSetTimeDialog() { | 411 void SystemTrayDelegateChromeOS::ShowSetTimeDialog() { |
| 425 // TODO(mash): Refactor out GetNativeWindow and move to SystemTrayCommon. | 412 // TODO(mash): Refactor out GetNativeWindow and move to SystemTrayCommon. |
| 426 SetTimeDialog::ShowDialog(GetNativeWindow()); | 413 SetTimeDialog::ShowDialog(GetNativeWindow()); |
| 427 } | 414 } |
| 428 | 415 |
| 429 void SystemTrayDelegateChromeOS::ShowNetworkSettingsForGuid( | 416 void SystemTrayDelegateChromeOS::ShowNetworkSettingsForGuid( |
| 430 const std::string& guid) { | 417 const std::string& guid) { |
| 431 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayCommon. | 418 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayCommon. |
| 432 ash::WmShell* wm_shell = ash::WmShell::Get(); | 419 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 433 if (LoginState::Get()->IsUserLoggedIn() && | 420 if (LoginState::Get()->IsUserLoggedIn() && |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 user_profile_ = NULL; | 900 user_profile_ = NULL; |
| 914 return true; | 901 return true; |
| 915 } | 902 } |
| 916 | 903 |
| 917 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { | 904 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { |
| 918 return g_browser_process->platform_part() | 905 return g_browser_process->platform_part() |
| 919 ->GetSystemClock() | 906 ->GetSystemClock() |
| 920 ->ShouldUse24HourClock(); | 907 ->ShouldUse24HourClock(); |
| 921 } | 908 } |
| 922 | 909 |
| 923 void SystemTrayDelegateChromeOS::OnSystemClockChanged( | |
| 924 system::SystemClock* system_clock) { | |
| 925 const bool use_24_hour_clock = system_clock->ShouldUse24HourClock(); | |
| 926 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; | |
| 927 GetSystemTrayNotifier()->NotifyDateFormatChanged(); | |
| 928 } | |
| 929 | |
| 930 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { | 910 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { |
| 931 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( | 911 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( |
| 932 user_pref_registrar_->prefs()->GetBoolean( | 912 user_pref_registrar_->prefs()->GetBoolean( |
| 933 prefs::kShowLogoutButtonInTray)); | 913 prefs::kShowLogoutButtonInTray)); |
| 934 } | 914 } |
| 935 | 915 |
| 936 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { | 916 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { |
| 937 const int duration_ms = | 917 const int duration_ms = |
| 938 user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs); | 918 user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs); |
| 939 GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged( | 919 GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged( |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 1272 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
| 1293 << "ENABLE_SUPERVISED_USERS undefined."; | 1273 << "ENABLE_SUPERVISED_USERS undefined."; |
| 1294 return base::string16(); | 1274 return base::string16(); |
| 1295 } | 1275 } |
| 1296 | 1276 |
| 1297 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1277 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1298 return new SystemTrayDelegateChromeOS(); | 1278 return new SystemTrayDelegateChromeOS(); |
| 1299 } | 1279 } |
| 1300 | 1280 |
| 1301 } // namespace chromeos | 1281 } // namespace chromeos |
| OLD | NEW |