diff options
Diffstat (limited to 'chrome/browser/chromeos/status/clock_menu_button.cc')
-rw-r--r-- | chrome/browser/chromeos/status/clock_menu_button.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc index 450d379..68c5a6c 100644 --- a/chrome/browser/chromeos/status/clock_menu_button.cc +++ b/chrome/browser/chromeos/status/clock_menu_button.cc @@ -14,6 +14,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/chromeos/status/status_area_host.h" #include "chrome/browser/profile.h" +#include "chrome/common/pref_names.h" #include "grit/generated_resources.h" #include "unicode/calendar.h" @@ -37,6 +38,10 @@ ClockMenuButton::ClockMenuButton(StatusAreaHost* host) SetText(l10n_util::GetStringF(IDS_STATUSBAR_CLOCK_SHORT_TIME_PM, zero, zero)); set_alignment(TextButton::ALIGN_RIGHT); UpdateTextAndSetNextTimer(); + // Init member prefs so we can update the clock if prefs change. + // This only works if we are within a browser and have a profile. + if (host->GetProfile()) + timezone_.Init(prefs::kTimeZone, host->GetProfile()->GetPrefs(), this); } void ClockMenuButton::UpdateTextAndSetNextTimer() { @@ -122,6 +127,21 @@ void ClockMenuButton::ActivatedAt(int index) { host_->OpenButtonOptions(this); } +/////////////////////////////////////////////////////////////////////////////// +// ClockMenuButton, NotificationObserver implementation: + +void ClockMenuButton::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + if (type == NotificationType::PREF_CHANGED) { + const std::wstring* pref_name = Details<std::wstring>(details).ptr(); + if (!pref_name || *pref_name == prefs::kTimeZone) { + UpdateText(); + } + } +} + + //////////////////////////////////////////////////////////////////////////////// // ClockMenuButton, views::ViewMenuDelegate implementation: |