| Index: chrome/browser/chromeos/status/clock_menu_button.cc
|
| diff --git a/chrome/browser/chromeos/status/clock_menu_button.cc b/chrome/browser/chromeos/status/clock_menu_button.cc
|
| index deb3036dcb139857f84ce312e9bc370b25a625ba..7c6b1958262b2c0b7367b911e5f5e00fdb60b2a2 100644
|
| --- a/chrome/browser/chromeos/status/clock_menu_button.cc
|
| +++ b/chrome/browser/chromeos/status/clock_menu_button.cc
|
| @@ -9,9 +9,10 @@
|
| #include "base/time.h"
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| -#include "chrome/browser/chromeos/status/status_area_host.h"
|
| +#include "chrome/browser/chromeos/status/status_area_view_chromeos.h"
|
| +#include "chrome/browser/chromeos/view_ids.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| -#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "content/public/browser/notification_details.h"
|
| @@ -40,15 +41,14 @@ namespace chromeos {
|
| // when the timer goes off.
|
| const int kTimerSlopSeconds = 1;
|
|
|
| -ClockMenuButton::ClockMenuButton(StatusAreaHost* host)
|
| - : StatusAreaButton(host, this),
|
| +ClockMenuButton::ClockMenuButton(StatusAreaButton::Delegate* delegate)
|
| + : StatusAreaButton(delegate, this),
|
| default_use_24hour_clock_(false) {
|
| - // Add as TimezoneSettings observer. We update the clock if timezone changes.
|
| - system::TimezoneSettings::GetInstance()->AddObserver(this);
|
| - CrosLibrary::Get()->GetPowerLibrary()->AddObserver(this);
|
| + set_id(VIEW_ID_STATUS_BUTTON_CLOCK);
|
| // Start monitoring the kUse24HourClock preference.
|
| - if (host->GetProfile()) { // This can be NULL in the login screen.
|
| - registrar_.Init(host->GetProfile()->GetPrefs());
|
| + Profile* profile = ProfileManager::GetDefaultProfile();
|
| + if (profile) { // This can be NULL in the login screen.
|
| + registrar_.Init(profile->GetPrefs());
|
| registrar_.Add(prefs::kUse24HourClock, this);
|
| }
|
|
|
| @@ -57,8 +57,6 @@ ClockMenuButton::ClockMenuButton(StatusAreaHost* host)
|
|
|
| ClockMenuButton::~ClockMenuButton() {
|
| timer_.Stop();
|
| - CrosLibrary::Get()->GetPowerLibrary()->RemoveObserver(this);
|
| - system::TimezoneSettings::GetInstance()->RemoveObserver(this);
|
| }
|
|
|
| void ClockMenuButton::UpdateTextAndSetNextTimer() {
|
| @@ -87,10 +85,13 @@ void ClockMenuButton::UpdateTextAndSetNextTimer() {
|
|
|
| void ClockMenuButton::UpdateText() {
|
| base::Time time(base::Time::Now());
|
| + bool use_24hour_clock = default_use_24hour_clock_;
|
| +#if defined(OS_CHROMEOS)
|
| // If the profie is present, check the use 24-hour clock preference.
|
| - const bool use_24hour_clock = host_->GetProfile() ?
|
| - host_->GetProfile()->GetPrefs()->GetBoolean(prefs::kUse24HourClock) :
|
| - default_use_24hour_clock_;
|
| + Profile* profile = ProfileManager::GetDefaultProfile();
|
| + if (profile)
|
| + use_24hour_clock = profile->GetPrefs()->GetBoolean(prefs::kUse24HourClock);
|
| +#endif
|
| SetText(base::TimeFormatTimeOfDayWithHourClockType(
|
| time,
|
| use_24hour_clock ? base::k24HourClock : base::k12HourClock,
|
| @@ -134,19 +135,8 @@ bool ClockMenuButton::IsCommandEnabled(int id) const {
|
|
|
| void ClockMenuButton::ExecuteCommand(int id) {
|
| DCHECK_EQ(CLOCK_OPEN_OPTIONS_ITEM, id);
|
| - host_->OpenButtonOptions(this);
|
| -}
|
| -
|
| -// ClockMenuButton, PowerLibrary::Observer implementation:
|
| -
|
| -void ClockMenuButton::SystemResumed() {
|
| - UpdateText();
|
| -}
|
| -
|
| -// ClockMenuButton, SystemLibrary::Observer implementation:
|
| -
|
| -void ClockMenuButton::TimezoneChanged(const icu::TimeZone& timezone) {
|
| - UpdateText();
|
| + delegate()->ExecuteStatusAreaCommand(
|
| + this, StatusAreaViewChromeos::SHOW_SYSTEM_OPTIONS);
|
| }
|
|
|
| int ClockMenuButton::horizontal_padding() {
|
| @@ -188,9 +178,9 @@ void ClockMenuButton::EnsureMenu() {
|
| // Text for this item will be set by GetLabel().
|
| menu->AppendDelegateMenuItem(CLOCK_DISPLAY_ITEM);
|
|
|
| - // If options dialog is unavailable, don't show a separator and configure
|
| - // menu item.
|
| - if (host_->ShouldOpenButtonOptions(this)) {
|
| + // If options UI is available, show a separator and configure menu item.
|
| + if (delegate()->ShouldExecuteStatusAreaCommand(
|
| + this, StatusAreaViewChromeos::SHOW_SYSTEM_OPTIONS)) {
|
| menu->AppendSeparator();
|
|
|
| const string16 clock_open_options_label =
|
|
|