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); | 239 // TODO: how to send initial values? |
240 | |
241 OnSystemClockChanged(g_browser_process->platform_part()->GetSystemClock()); | |
242 | 240 |
243 device::BluetoothAdapterFactory::GetAdapter( | 241 device::BluetoothAdapterFactory::GetAdapter( |
244 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, | 242 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, |
245 weak_ptr_factory_.GetWeakPtr())); | 243 weak_ptr_factory_.GetWeakPtr())); |
246 | 244 |
247 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | 245 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); |
248 | 246 |
249 if (CrasAudioHandler::IsInitialized()) | 247 if (CrasAudioHandler::IsInitialized()) |
250 CrasAudioHandler::Get()->AddAudioObserver(this); | 248 CrasAudioHandler::Get()->AddAudioObserver(this); |
251 | 249 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 // Unregister PrefChangeRegistrars. | 284 // Unregister PrefChangeRegistrars. |
287 local_state_registrar_.reset(); | 285 local_state_registrar_.reset(); |
288 user_pref_registrar_.reset(); | 286 user_pref_registrar_.reset(); |
289 | 287 |
290 // Unregister content notifications before destroying any components. | 288 // Unregister content notifications before destroying any components. |
291 registrar_.reset(); | 289 registrar_.reset(); |
292 | 290 |
293 // Unregister a11y status subscription. | 291 // Unregister a11y status subscription. |
294 accessibility_subscription_.reset(); | 292 accessibility_subscription_.reset(); |
295 | 293 |
296 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this); | |
297 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); | 294 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); |
298 input_method::InputMethodManager::Get()->RemoveObserver(this); | 295 input_method::InputMethodManager::Get()->RemoveObserver(this); |
299 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); | 296 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); |
300 if (bluetooth_adapter_) | 297 if (bluetooth_adapter_) |
301 bluetooth_adapter_->RemoveObserver(this); | 298 bluetooth_adapter_->RemoveObserver(this); |
302 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( | 299 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( |
303 this); | 300 this); |
304 | 301 |
305 if (CrasAudioHandler::IsInitialized()) | 302 if (CrasAudioHandler::IsInitialized()) |
306 CrasAudioHandler::Get()->RemoveAudioObserver(this); | 303 CrasAudioHandler::Get()->RemoveAudioObserver(this); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 393 |
397 bool SystemTrayDelegateChromeOS::IsUserChild() const { | 394 bool SystemTrayDelegateChromeOS::IsUserChild() const { |
398 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); | 395 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); |
399 } | 396 } |
400 | 397 |
401 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( | 398 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( |
402 ash::UpdateInfo* info) const { | 399 ash::UpdateInfo* info) const { |
403 GetUpdateInfo(UpgradeDetector::GetInstance(), info); | 400 GetUpdateInfo(UpgradeDetector::GetInstance(), info); |
404 } | 401 } |
405 | 402 |
406 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const { | |
407 return clock_type_; | |
408 } | |
409 | |
410 void SystemTrayDelegateChromeOS::ShowSettings() { | 403 void SystemTrayDelegateChromeOS::ShowSettings() { |
411 SystemTrayCommon::ShowSettings(); | 404 SystemTrayCommon::ShowSettings(); |
412 } | 405 } |
413 | 406 |
414 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { | 407 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { |
415 ash::WmShell* wm_shell = ash::WmShell::Get(); | 408 ash::WmShell* wm_shell = ash::WmShell::Get(); |
416 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && | 409 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && |
417 !wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 410 !wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
418 } | 411 } |
419 | 412 |
420 void SystemTrayDelegateChromeOS::ShowDateSettings() { | |
421 SystemTrayCommon::ShowDateSettings(); | |
422 } | |
423 | |
424 void SystemTrayDelegateChromeOS::ShowSetTimeDialog() { | 413 void SystemTrayDelegateChromeOS::ShowSetTimeDialog() { |
425 // TODO(mash): Refactor out GetNativeWindow and move to SystemTrayCommon. | 414 // TODO(mash): Refactor out GetNativeWindow and move to SystemTrayCommon. |
426 SetTimeDialog::ShowDialog(GetNativeWindow()); | 415 SetTimeDialog::ShowDialog(GetNativeWindow()); |
427 } | 416 } |
428 | 417 |
429 void SystemTrayDelegateChromeOS::ShowNetworkSettingsForGuid( | 418 void SystemTrayDelegateChromeOS::ShowNetworkSettingsForGuid( |
430 const std::string& guid) { | 419 const std::string& guid) { |
431 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayCommon. | 420 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayCommon. |
432 ash::WmShell* wm_shell = ash::WmShell::Get(); | 421 ash::WmShell* wm_shell = ash::WmShell::Get(); |
433 if (LoginState::Get()->IsUserLoggedIn() && | 422 if (LoginState::Get()->IsUserLoggedIn() && |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
920 user_profile_ = NULL; | 909 user_profile_ = NULL; |
921 return true; | 910 return true; |
922 } | 911 } |
923 | 912 |
924 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { | 913 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const { |
925 return g_browser_process->platform_part() | 914 return g_browser_process->platform_part() |
926 ->GetSystemClock() | 915 ->GetSystemClock() |
927 ->ShouldUse24HourClock(); | 916 ->ShouldUse24HourClock(); |
928 } | 917 } |
929 | 918 |
930 void SystemTrayDelegateChromeOS::OnSystemClockChanged( | |
931 system::SystemClock* system_clock) { | |
932 const bool use_24_hour_clock = system_clock->ShouldUse24HourClock(); | |
933 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock; | |
934 GetSystemTrayNotifier()->NotifyDateFormatChanged(); | |
935 } | |
936 | |
937 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { | 919 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { |
938 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( | 920 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( |
939 user_pref_registrar_->prefs()->GetBoolean( | 921 user_pref_registrar_->prefs()->GetBoolean( |
940 prefs::kShowLogoutButtonInTray)); | 922 prefs::kShowLogoutButtonInTray)); |
941 } | 923 } |
942 | 924 |
943 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { | 925 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { |
944 const int duration_ms = | 926 const int duration_ms = |
945 user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs); | 927 user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs); |
946 GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged( | 928 GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged( |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " | 1281 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " |
1300 << "ENABLE_SUPERVISED_USERS undefined."; | 1282 << "ENABLE_SUPERVISED_USERS undefined."; |
1301 return base::string16(); | 1283 return base::string16(); |
1302 } | 1284 } |
1303 | 1285 |
1304 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1286 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1305 return new SystemTrayDelegateChromeOS(); | 1287 return new SystemTrayDelegateChromeOS(); |
1306 } | 1288 } |
1307 | 1289 |
1308 } // namespace chromeos | 1290 } // namespace chromeos |
OLD | NEW |