From dd0bf461376beee097367a82c78ab70abc41744e Mon Sep 17 00:00:00 2001 From: "michaelpg@chromium.org" Date: Mon, 28 Apr 2014 05:47:00 +0000 Subject: Date and Time dialog for when the clock isn't synced. If the time has not been set automatically via network syncing, the system clock can be changed. This dialog allows the user to change the date, time and time zone when possible. The motivation is to unbrick devices with the wrong time that need to be rolled out into time-sensitive networks. Documentation of the changes to Chrome OS and Ash for this CL is here: https://docs.google.com/a/google.com/drawings/d/1T3demthtROnXf1iE31p5aIPcQzK9SmjfE9EjnJbZ4zs System Time Manual Update UI design doc: https://docs.google.com/a/google.com/document/d/1djzhBrtbx-52Gctp3Fd5MIosARbTwQh_lMmd_qUnqgo Screenshot with timezone: https://drive.google.com/a/google.com/file/d/0B6HSBrih6pNUd3p2SFBoVktjVzQ Screenshot from settings page, no timezone: https://drive.google.com/a/google.com/file/d/0B6HSBrih6pNUXzk0TjNiT0tKMTQ BUG=232066 TEST=SetTimeWebUITest, DateTimeOptionsWebUITest R=stevenjb@chromium.org,nkostylev@chromium.org,dbeam@chromium.org,derat@chromium.org,asvitkine@chromium.org TBR=sky@chromium.org # TBR for adding resources to chrome/browser/chrome_resources.grd Please review: stevenjb@chromium.org - ash/system - chromeos/dbus derat@chromium.org: - chrome/browser/chromeos - chrome/browser/ui/ash - chromeos/dbus (optional) nkostylev@chromium.org: - chrome/app - chrome/browser/chromeos - chrome/browser/resources/chromeos - chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc - chrome/browser/ui/webui/chromeos - chrome/browser/ui/webui/options/chromeos - chrome/browser/browser_resources.grd - chrome/chrome_*.gypi - chrome/common dbeam@chromium.org: - chrome/browser/resources/options - chrome/browser/ui/webui/options/*.cc sky@chromium.org: - chrome/browser/browser_resources.grd Review URL: https://codereview.chromium.org/247663003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266431 0039d316-1c4b-4281-b951-d872f2087c98 --- ash/system/chromeos/system_clock_observer.cc | 9 ++++++++- ash/system/chromeos/system_clock_observer.h | 5 +++++ ash/system/date/clock_observer.h | 1 + ash/system/date/date_default_view.cc | 2 +- ash/system/date/date_view.cc | 22 ++++++++++++---------- ash/system/date/date_view.h | 8 ++++---- ash/system/date/tray_date.cc | 19 ++++++++++++++++++- ash/system/date/tray_date.h | 13 +++++++++++-- ash/system/tray/default_system_tray_delegate.cc | 3 +++ ash/system/tray/default_system_tray_delegate.h | 1 + ash/system/tray/system_tray_delegate.h | 3 +++ ash/system/tray/system_tray_notifier.cc | 6 ++++++ ash/system/tray/system_tray_notifier.h | 1 + 13 files changed, 74 insertions(+), 19 deletions(-) (limited to 'ash') diff --git a/ash/system/chromeos/system_clock_observer.cc b/ash/system/chromeos/system_clock_observer.cc index d154d5e..5ed6330 100644 --- a/ash/system/chromeos/system_clock_observer.cc +++ b/ash/system/chromeos/system_clock_observer.cc @@ -14,6 +14,8 @@ SystemClockObserver::SystemClockObserver() { chromeos::DBusThreadManager::Get()->GetSystemClockClient() ->AddObserver(this); chromeos::system::TimezoneSettings::GetInstance()->AddObserver(this); + can_set_time_ = + chromeos::DBusThreadManager::Get()->GetSystemClockClient()->CanSetTime(); } SystemClockObserver::~SystemClockObserver() { @@ -23,8 +25,13 @@ SystemClockObserver::~SystemClockObserver() { } void SystemClockObserver::SystemClockUpdated() { + Shell::GetInstance()->system_tray_notifier()->NotifySystemClockTimeUpdated(); +} + +void SystemClockObserver::SystemClockCanSetTimeChanged(bool can_set_time) { + can_set_time_ = can_set_time; Shell::GetInstance()->system_tray_notifier() - ->NotifySystemClockTimeUpdated(); + ->NotifySystemClockCanSetTimeChanged(can_set_time_); } void SystemClockObserver::TimezoneChanged(const icu::TimeZone& timezone) { diff --git a/ash/system/chromeos/system_clock_observer.h b/ash/system/chromeos/system_clock_observer.h index dcc11ee..5d4c4d6 100644 --- a/ash/system/chromeos/system_clock_observer.h +++ b/ash/system/chromeos/system_clock_observer.h @@ -19,11 +19,16 @@ class SystemClockObserver // chromeos::SystemClockClient::Observer virtual void SystemClockUpdated() OVERRIDE; + virtual void SystemClockCanSetTimeChanged(bool can_set_time) OVERRIDE; // chromeos::system::TimezoneSettings::Observer virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE; + bool can_set_time() { return can_set_time_; } + private: + bool can_set_time_; + DISALLOW_COPY_AND_ASSIGN(SystemClockObserver); }; diff --git a/ash/system/date/clock_observer.h b/ash/system/date/clock_observer.h index b3d9ece..a62e2be 100644 --- a/ash/system/date/clock_observer.h +++ b/ash/system/date/clock_observer.h @@ -15,6 +15,7 @@ class ASH_EXPORT ClockObserver { virtual void OnDateFormatChanged() = 0; virtual void OnSystemClockTimeUpdated() = 0; + virtual void OnSystemClockCanSetTimeChanged(bool can_set_time) = 0; // Force a refresh (e.g. after the system is resumed). virtual void Refresh() = 0; diff --git a/ash/system/date/date_default_view.cc b/ash/system/date/date_default_view.cc index e72e048..389485f 100644 --- a/ash/system/date/date_default_view.cc +++ b/ash/system/date/date_default_view.cc @@ -46,7 +46,7 @@ DateDefaultView::DateDefaultView(ash::user::LoginStatus login) login == ash::user::LOGGED_IN_NONE) return; - date_view_->SetActionable(true); + date_view_->SetAction(TrayDate::SHOW_DATE_SETTINGS); help_ = new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_HELP, diff --git a/ash/system/date/date_view.cc b/ash/system/date/date_view.cc index 26f910d..6bdd83e 100644 --- a/ash/system/date/date_view.cc +++ b/ash/system/date/date_view.cc @@ -128,7 +128,7 @@ void BaseDateTimeView::OnLocaleChanged() { DateView::DateView() : hour_type_(ash::Shell::GetInstance()->system_tray_delegate()-> GetHourClockType()), - actionable_(false) { + action_(TrayDate::NONE) { SetLayoutManager( new views::BoxLayout( views::BoxLayout::kVertical, 0, 0, 0)); @@ -136,15 +136,15 @@ DateView::DateView() date_label_->SetEnabledColor(kHeaderTextColorNormal); UpdateTextInternal(base::Time::Now()); AddChildView(date_label_); - SetFocusable(actionable_); + SetFocusable(false); } DateView::~DateView() { } -void DateView::SetActionable(bool actionable) { - actionable_ = actionable; - SetFocusable(actionable_); +void DateView::SetAction(TrayDate::DateAction action) { + action_ = action; + SetFocusable(action_ != TrayDate::NONE); } void DateView::UpdateTimeFormat() { @@ -169,22 +169,24 @@ void DateView::UpdateTextInternal(const base::Time& now) { } bool DateView::PerformAction(const ui::Event& event) { - if (!actionable_) + if (action_ == TrayDate::NONE) return false; - - ash::Shell::GetInstance()->system_tray_delegate()->ShowDateSettings(); + if (action_ == TrayDate::SHOW_DATE_SETTINGS) + ash::Shell::GetInstance()->system_tray_delegate()->ShowDateSettings(); + else if (action_ == TrayDate::SET_SYSTEM_TIME) + ash::Shell::GetInstance()->system_tray_delegate()->ShowSetTimeDialog(); return true; } void DateView::OnMouseEntered(const ui::MouseEvent& event) { - if (!actionable_) + if (action_ == TrayDate::NONE) return; date_label_->SetEnabledColor(kHeaderTextColorHover); SchedulePaint(); } void DateView::OnMouseExited(const ui::MouseEvent& event) { - if (!actionable_) + if (action_ == TrayDate::NONE) return; date_label_->SetEnabledColor(kHeaderTextColorNormal); SchedulePaint(); diff --git a/ash/system/date/date_view.h b/ash/system/date/date_view.h index 7d03a9a..1f4377a 100644 --- a/ash/system/date/date_view.h +++ b/ash/system/date/date_view.h @@ -55,10 +55,10 @@ class ASH_EXPORT DateView : public BaseDateTimeView { DateView(); virtual ~DateView(); - // Sets whether the view is actionable. An actionable date view gives visual + // Sets the action the view should take. An actionable date view gives visual // feedback on hover, can be focused by keyboard, and clicking/pressing space - // or enter on the view shows date-related settings. - void SetActionable(bool actionable); + // or enter on the view executes the action. + void SetAction(TrayDate::DateAction action); // Updates the format of the displayed time. void UpdateTimeFormat(); @@ -81,7 +81,7 @@ class ASH_EXPORT DateView : public BaseDateTimeView { // Time format (12/24hr) used for accessibility string. base::HourClockType hour_type_; - bool actionable_; + TrayDate::DateAction action_; DISALLOW_COPY_AND_ASSIGN(DateView); }; diff --git a/ash/system/date/tray_date.cc b/ash/system/date/tray_date.cc index 156d355..8a574fe 100644 --- a/ash/system/date/tray_date.cc +++ b/ash/system/date/tray_date.cc @@ -20,7 +20,8 @@ namespace ash { TrayDate::TrayDate(SystemTray* system_tray) : SystemTrayItem(system_tray), time_tray_(NULL), - default_view_(NULL) { + default_view_(NULL), + login_status_(user::LOGGED_IN_NONE) { #if defined(OS_CHROMEOS) system_clock_observer_.reset(new SystemClockObserver()); #endif @@ -63,6 +64,13 @@ views::View* TrayDate::CreateTrayView(user::LoginStatus status) { views::View* TrayDate::CreateDefaultView(user::LoginStatus status) { default_view_ = new DateDefaultView(status); + +#if defined(OS_CHROMEOS) + // Save the login status we created the view with. + login_status_ = status; + + OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time()); +#endif return default_view_; } @@ -107,6 +115,15 @@ void TrayDate::OnSystemClockTimeUpdated() { default_view_->GetDateView()->UpdateTimeFormat(); } +void TrayDate::OnSystemClockCanSetTimeChanged(bool can_set_time) { + // Outside of a logged-in session, the date button should launch the set time + // dialog if the time can be set. + if (default_view_ && login_status_ == user::LOGGED_IN_NONE) { + default_view_->GetDateView()->SetAction( + can_set_time ? TrayDate::SET_SYSTEM_TIME : TrayDate::NONE); + } +} + void TrayDate::Refresh() { if (time_tray_) time_tray_->UpdateText(); diff --git a/ash/system/date/tray_date.h b/ash/system/date/tray_date.h index 90c02e2..c84e86e 100644 --- a/ash/system/date/tray_date.h +++ b/ash/system/date/tray_date.h @@ -27,9 +27,16 @@ class TimeView; class ASH_EXPORT TrayDate : public SystemTrayItem, public ClockObserver { public: enum ClockLayout { - HORIZONTAL_CLOCK, - VERTICAL_CLOCK, + HORIZONTAL_CLOCK, + VERTICAL_CLOCK, }; + + enum DateAction { + NONE, + SET_SYSTEM_TIME, + SHOW_DATE_SETTINGS, + }; + explicit TrayDate(SystemTray* system_tray); virtual ~TrayDate(); @@ -55,12 +62,14 @@ class ASH_EXPORT TrayDate : public SystemTrayItem, public ClockObserver { // Overridden from ClockObserver. virtual void OnDateFormatChanged() OVERRIDE; virtual void OnSystemClockTimeUpdated() OVERRIDE; + virtual void OnSystemClockCanSetTimeChanged(bool can_set_time) OVERRIDE; virtual void Refresh() OVERRIDE; void SetupLabelForTimeTray(views::Label* label); tray::TimeView* time_tray_; DateDefaultView* default_view_; + user::LoginStatus login_status_; #if defined(OS_CHROMEOS) scoped_ptr system_clock_observer_; diff --git a/ash/system/tray/default_system_tray_delegate.cc b/ash/system/tray/default_system_tray_delegate.cc index 2c20da7..5b254c1 100644 --- a/ash/system/tray/default_system_tray_delegate.cc +++ b/ash/system/tray/default_system_tray_delegate.cc @@ -104,6 +104,9 @@ bool DefaultSystemTrayDelegate::ShouldShowSettings() { void DefaultSystemTrayDelegate::ShowDateSettings() { } +void DefaultSystemTrayDelegate::ShowSetTimeDialog() { +} + void DefaultSystemTrayDelegate::ShowNetworkSettings( const std::string& service_path) { } diff --git a/ash/system/tray/default_system_tray_delegate.h b/ash/system/tray/default_system_tray_delegate.h index 0f0a63f..004d143 100644 --- a/ash/system/tray/default_system_tray_delegate.h +++ b/ash/system/tray/default_system_tray_delegate.h @@ -34,6 +34,7 @@ class ASH_EXPORT DefaultSystemTrayDelegate : public SystemTrayDelegate { virtual void ShowSettings() OVERRIDE; virtual bool ShouldShowSettings() OVERRIDE; virtual void ShowDateSettings() OVERRIDE; + virtual void ShowSetTimeDialog() OVERRIDE; virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE; virtual void ShowBluetoothSettings() OVERRIDE; virtual void ShowDisplaySettings() OVERRIDE; diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index 7e22f22..3e399eb 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -165,6 +165,9 @@ class ASH_EXPORT SystemTrayDelegate { // Shows the settings related to date, timezone etc. virtual void ShowDateSettings() = 0; + // Shows the dialog to set system time, date, and timezone. + virtual void ShowSetTimeDialog() = 0; + // Shows the settings related to network. If |service_path| is not empty, // show the settings for that network. virtual void ShowNetworkSettings(const std::string& service_path) = 0; diff --git a/ash/system/tray/system_tray_notifier.cc b/ash/system/tray/system_tray_notifier.cc index 3adafe1..ed858c3 100644 --- a/ash/system/tray/system_tray_notifier.cc +++ b/ash/system/tray/system_tray_notifier.cc @@ -260,6 +260,12 @@ void SystemTrayNotifier::NotifySystemClockTimeUpdated() { OnSystemClockTimeUpdated()); } +void SystemTrayNotifier::NotifySystemClockCanSetTimeChanged(bool can_set_time) { + FOR_EACH_OBSERVER(ClockObserver, + clock_observers_, + OnSystemClockCanSetTimeChanged(can_set_time)); +} + void SystemTrayNotifier::NotifyDriveJobUpdated( const DriveOperationStatus& status) { FOR_EACH_OBSERVER(DriveObserver, diff --git a/ash/system/tray/system_tray_notifier.h b/ash/system/tray/system_tray_notifier.h index 219b1a1..29cd9d2 100644 --- a/ash/system/tray/system_tray_notifier.h +++ b/ash/system/tray/system_tray_notifier.h @@ -115,6 +115,7 @@ class ASH_EXPORT SystemTrayNotifier { void NotifyRefreshClock(); void NotifyDateFormatChanged(); void NotifySystemClockTimeUpdated(); + void NotifySystemClockCanSetTimeChanged(bool can_set_time); void NotifyDriveJobUpdated(const DriveOperationStatus& status); void NotifyRefreshIME(); void NotifyLocaleChanged(LocaleObserver::Delegate* delegate, -- cgit v1.1