diff options
author | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-15 11:44:31 +0000 |
---|---|---|
committer | bartfab@chromium.org <bartfab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-15 11:44:31 +0000 |
commit | 1682765344cb63cc02eef46f65e902c5aa5c1c3f (patch) | |
tree | 05ba1f3561338a9984e2b75ae2ba5881bafd791d /ash | |
parent | e279d9ec38ba0dd798afbdc245aa58f3e1c8a55b (diff) | |
download | chromium_src-1682765344cb63cc02eef46f65e902c5aa5c1c3f.zip chromium_src-1682765344cb63cc02eef46f65e902c5aa5c1c3f.tar.gz chromium_src-1682765344cb63cc02eef46f65e902c5aa5c1c3f.tar.bz2 |
Add countdown when session time is limited
This CL adds a countdown to the ash tray when the session time is limited.
The UI can/will be improved further in the future. This is a first basic
functional implementation.
BUG=chromium-os:26957
TEST=Manual
TBR=sky@chromium.org
(for ash.gyp and ash_strings.grd changes)
Review URL: https://codereview.chromium.org/11568036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash.gyp | 3 | ||||
-rw-r--r-- | ash/ash_strings.grd | 3 | ||||
-rw-r--r-- | ash/system/session_length_limit/session_length_limit_observer.h | 27 | ||||
-rw-r--r-- | ash/system/session_length_limit/tray_session_length_limit.cc | 307 | ||||
-rw-r--r-- | ash/system/session_length_limit/tray_session_length_limit.h | 48 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 2 | ||||
-rw-r--r-- | ash/system/tray/system_tray_delegate.h | 9 | ||||
-rw-r--r-- | ash/system/tray/system_tray_notifier.cc | 24 | ||||
-rw-r--r-- | ash/system/tray/system_tray_notifier.h | 8 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.cc | 8 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.h | 2 |
11 files changed, 441 insertions, 0 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index e95d815..886a963 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -215,6 +215,9 @@ 'system/power/power_supply_status.h', 'system/power/tray_power.cc', 'system/power/tray_power.h', + 'system/session_length_limit/session_length_limit_observer.h', + 'system/session_length_limit/tray_session_length_limit.cc', + 'system/session_length_limit/tray_session_length_limit.h', 'system/settings/tray_settings.cc', 'system/settings/tray_settings.h', 'system/status_area_widget.cc', diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index a4a5132..518dead 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd @@ -509,6 +509,9 @@ Press Shift + Alt to switch. <message name="IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING" desc="Shows a connecting network in the network list."> <ph name="NETWORK">$1<ex>GoogleGuest</ex></ph>: Connecting... </message> + <message name="IDS_ASH_STATUS_TRAY_REMAINING_SESSION_TIME" desc="The time remaining until the end of the session. Shown if the session length is limited."> + <ph name="hours">$1<ex>01</ex></ph>:<ph name="minutes">$2<ex>35</ex></ph>:<ph name="seconds">$3<ex>12</ex></ph> + </message> <message name="IDS_ASH_STATUS_TRAY_PREVIOUS_MENU" desc="The accessible text for header entries for detailed versions of status tray items."> Previous menu diff --git a/ash/system/session_length_limit/session_length_limit_observer.h b/ash/system/session_length_limit/session_length_limit_observer.h new file mode 100644 index 0000000..52be2c4 --- /dev/null +++ b/ash/system/session_length_limit/session_length_limit_observer.h @@ -0,0 +1,27 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SYSTEM_SESSION_LENGTH_LIMIT_SESSION_LENGTH_LIMIT_OBSERVER_H_ +#define ASH_SYSTEM_SESSION_LENGTH_LIMIT_SESSION_LENGTH_LIMIT_OBSERVER_H_ + +#include "base/time.h" + +namespace ash { + +// Observer for the session length limit. +class SessionLengthLimitObserver { + public: + virtual ~SessionLengthLimitObserver() {} + + // Called when the session start time is updated. + virtual void OnSessionStartTimeChanged( + const base::Time& session_start_time) = 0; + + // Called when the session length limit is updated. + virtual void OnSessionLengthLimitChanged(const base::TimeDelta& limit) = 0; +}; + +} // namespace ash + +#endif // ASH_SYSTEM_SESSION_LENGTH_LIMIT_SESSION_LENGTH_LIMIT_OBSERVER_H_ diff --git a/ash/system/session_length_limit/tray_session_length_limit.cc b/ash/system/session_length_limit/tray_session_length_limit.cc new file mode 100644 index 0000000..3401d85 --- /dev/null +++ b/ash/system/session_length_limit/tray_session_length_limit.cc @@ -0,0 +1,307 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/system/session_length_limit/tray_session_length_limit.h" + +#include <cmath> + +#include "ash/shelf_types.h" +#include "ash/shell.h" +#include "ash/system/tray/system_tray.h" +#include "ash/system/tray/system_tray_delegate.h" +#include "ash/system/tray/system_tray_notifier.h" +#include "ash/system/tray/tray_constants.h" +#include "ash/system/tray/tray_views.h" +#include "base/string16.h" +#include "base/string_number_conversions.h" +#include "base/time.h" +#include "base/timer.h" +#include "base/utf_string_conversions.h" +#include "grit/ash_strings.h" +#include "third_party/skia/include/core/SkColor.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/gfx/font.h" +#include "ui/gfx/text_constants.h" +#include "ui/views/border.h" +#include "ui/views/controls/label.h" +#include "ui/views/layout/box_layout.h" +#include "ui/views/layout/grid_layout.h" +#include "ui/views/view.h" + +namespace ash { +namespace internal { + +namespace tray { + +namespace { + +// Warning threshold for the remaining sessiont time. +const int kRemainingTimeWarningThresholdInSeconds = 5 * 60; // 5 minutes. +// Color in which the remaining session time is normally shown. +const SkColor kRemainingTimeColor = SK_ColorWHITE; +// Color in which the remaining session time is shown when it falls below the +// warning threshold. +const SkColor kRemainingTimeWarningColor = SK_ColorRED; + +views::Label* CreateAndSetupLabel() { + views::Label* label = new views::Label; + label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + SetupLabelForTray(label); + gfx::Font font = label->font(); + label->SetFont(font.DeriveFont(0, font.GetStyle() & ~gfx::Font::BOLD)); + return label; +} + +string16 IntToTwoDigitString(int value) { + DCHECK_GE(value, 0); + DCHECK_LE(value, 99); + if (value < 10) + return ASCIIToUTF16("0") + base::IntToString16(value); + return base::IntToString16(value); +} + +} // namespace + +class RemainingSessionTimeTrayView : public views::View { + public: + RemainingSessionTimeTrayView(const base::Time& session_start_time, + const base::TimeDelta& limit, + ShelfAlignment shelf_alignment); + virtual ~RemainingSessionTimeTrayView(); + + void SetSessionStartTime(const base::Time& session_start_time); + void SetSessionLengthLimit(const base::TimeDelta& limit); + + void UpdateClockLayout(ShelfAlignment shelf_alignment); + + private: + void SetBorder(ShelfAlignment shelf_alignment); + + // Update the label text only. + void UpdateText(); + // Update the timer state, label text and visibility. + void UpdateState(); + + views::Label* horizontal_layout_label_; + views::Label* vertical_layout_label_hours_left_; + views::Label* vertical_layout_label_hours_right_; + views::Label* vertical_layout_label_minutes_left_; + views::Label* vertical_layout_label_minutes_right_; + views::Label* vertical_layout_label_seconds_left_; + views::Label* vertical_layout_label_seconds_right_; + + base::Time session_start_time_; + base::TimeDelta limit_; + base::RepeatingTimer<RemainingSessionTimeTrayView> timer_; + + DISALLOW_COPY_AND_ASSIGN(RemainingSessionTimeTrayView); +}; + +RemainingSessionTimeTrayView::RemainingSessionTimeTrayView( + const base::Time& session_start_time, + const base::TimeDelta& limit, + ShelfAlignment shelf_alignment) + : horizontal_layout_label_(NULL), + vertical_layout_label_hours_left_(NULL), + vertical_layout_label_hours_right_(NULL), + vertical_layout_label_minutes_left_(NULL), + vertical_layout_label_minutes_right_(NULL), + vertical_layout_label_seconds_left_(NULL), + vertical_layout_label_seconds_right_(NULL), + session_start_time_(session_start_time), + limit_(limit) { + UpdateClockLayout(shelf_alignment); + UpdateState(); +} + +RemainingSessionTimeTrayView::~RemainingSessionTimeTrayView() { +} + +void RemainingSessionTimeTrayView::SetSessionStartTime( + const base::Time& session_start_time) { + session_start_time_ = session_start_time; + UpdateState(); +} + +void RemainingSessionTimeTrayView::SetSessionLengthLimit( + const base::TimeDelta& limit) { + limit_ = limit; + UpdateState(); +} + +void RemainingSessionTimeTrayView::UpdateClockLayout( + ShelfAlignment shelf_alignment) { + SetBorder(shelf_alignment); + const bool horizontal_layout = shelf_alignment == SHELF_ALIGNMENT_BOTTOM; + if (horizontal_layout && !horizontal_layout_label_) { + // Remove labels used for vertical layout. + RemoveAllChildViews(true); + vertical_layout_label_hours_left_ = NULL; + vertical_layout_label_hours_right_ = NULL; + vertical_layout_label_minutes_left_ = NULL; + vertical_layout_label_minutes_right_ = NULL; + vertical_layout_label_seconds_left_ = NULL; + vertical_layout_label_seconds_right_ = NULL; + + // Create label used for horizontal layout. + horizontal_layout_label_ = CreateAndSetupLabel(); + + // Construct layout. + SetLayoutManager( + new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); + AddChildView(horizontal_layout_label_); + + } else if (!horizontal_layout && horizontal_layout_label_) { + // Remove label used for horizontal layout. + RemoveAllChildViews(true); + horizontal_layout_label_ = NULL; + + // Create labels used for vertical layout. + vertical_layout_label_hours_left_ = CreateAndSetupLabel(); + vertical_layout_label_hours_right_ = CreateAndSetupLabel(); + vertical_layout_label_minutes_left_ = CreateAndSetupLabel(); + vertical_layout_label_minutes_right_ = CreateAndSetupLabel(); + vertical_layout_label_seconds_left_ = CreateAndSetupLabel(); + vertical_layout_label_seconds_right_ = CreateAndSetupLabel(); + + // Construct layout. + views::GridLayout* layout = new views::GridLayout(this); + SetLayoutManager(layout); + views::ColumnSet* columns = layout->AddColumnSet(0); + columns->AddPaddingColumn(0, 6); + columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, + 0, views::GridLayout::USE_PREF, 0, 0); + columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, + 0, views::GridLayout::USE_PREF, 0, 0); + layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVeriticalAlignment); + layout->StartRow(0, 0); + layout->AddView(vertical_layout_label_hours_left_); + layout->AddView(vertical_layout_label_hours_right_); + layout->StartRow(0, 0); + layout->AddView(vertical_layout_label_minutes_left_); + layout->AddView(vertical_layout_label_minutes_right_); + layout->StartRow(0, 0); + layout->AddView(vertical_layout_label_seconds_left_); + layout->AddView(vertical_layout_label_seconds_right_); + layout->AddPaddingRow(0, kTrayLabelItemVerticalPaddingVeriticalAlignment); + } + UpdateText(); +} + +void RemainingSessionTimeTrayView::SetBorder(ShelfAlignment shelf_alignment) { + if (shelf_alignment == SHELF_ALIGNMENT_BOTTOM) { + set_border(views::Border::CreateEmptyBorder( + 0, kTrayLabelItemHorizontalPaddingBottomAlignment, + 0, kTrayLabelItemHorizontalPaddingBottomAlignment)); + } else { + set_border(NULL); + } +} + +void RemainingSessionTimeTrayView::UpdateText() { + if (!visible()) + return; + + // Calculate the remaining session time, clamping so that it never falls below + // zero or exceeds 99 hours. + int seconds = + round((limit_ - (base::Time::Now() - session_start_time_)).InSecondsF()); + seconds = std::min(std::max(seconds, 0), 99 * 60 * 60); + int minutes = seconds / 60; + seconds %= 60; + const int hours = minutes / 60; + minutes %= 60; + + const string16 hours_str = IntToTwoDigitString(hours); + const string16 minutes_str = IntToTwoDigitString(minutes); + const string16 seconds_str = IntToTwoDigitString(seconds); + const SkColor color = seconds < kRemainingTimeWarningThresholdInSeconds ? + kRemainingTimeWarningColor : kRemainingTimeColor; + + if (horizontal_layout_label_) { + horizontal_layout_label_->SetText(l10n_util::GetStringFUTF16( + IDS_ASH_STATUS_TRAY_REMAINING_SESSION_TIME, + hours_str, minutes_str, seconds_str)); + horizontal_layout_label_->SetEnabledColor(color); + } else if (vertical_layout_label_hours_left_) { + vertical_layout_label_hours_left_->SetText(hours_str.substr(0, 1)); + vertical_layout_label_hours_right_->SetText(hours_str.substr(1, 1)); + vertical_layout_label_minutes_left_->SetText(minutes_str.substr(0, 1)); + vertical_layout_label_minutes_right_->SetText(minutes_str.substr(1, 1)); + vertical_layout_label_seconds_left_->SetText(seconds_str.substr(0, 1)); + vertical_layout_label_seconds_right_->SetText(seconds_str.substr(1, 1)); + vertical_layout_label_hours_left_->SetEnabledColor(color); + vertical_layout_label_hours_right_->SetEnabledColor(color); + vertical_layout_label_minutes_left_->SetEnabledColor(color); + vertical_layout_label_minutes_right_->SetEnabledColor(color); + vertical_layout_label_seconds_left_->SetEnabledColor(color); + vertical_layout_label_seconds_right_->SetEnabledColor(color); + } + + Layout(); +} + +void RemainingSessionTimeTrayView::UpdateState() { + const bool show = session_start_time_ != base::Time() && + limit_ != base::TimeDelta(); + SetVisible(show); + UpdateText(); + if (show && !timer_.IsRunning()) { + // Set timer to update the text once per second. + timer_.Start(FROM_HERE, + base::TimeDelta::FromSeconds(1), + this, + &RemainingSessionTimeTrayView::UpdateText); + } else if (!show && timer_.IsRunning()) { + timer_.Stop(); + } +} + +} // namespace tray + +TraySessionLengthLimit::TraySessionLengthLimit(SystemTray* system_tray) + : SystemTrayItem(system_tray), + tray_view_(NULL) { + Shell::GetInstance()->system_tray_notifier()-> + AddSessionLengthLimitObserver(this); +} + +TraySessionLengthLimit::~TraySessionLengthLimit() { + Shell::GetInstance()->system_tray_notifier()-> + RemoveSessionLengthLimitObserver(this); +} + +views::View* TraySessionLengthLimit::CreateTrayView(user::LoginStatus status) { + CHECK(tray_view_ == NULL); + ash::SystemTrayDelegate* delegate = + ash::Shell::GetInstance()->system_tray_delegate(); + tray_view_ = new tray::RemainingSessionTimeTrayView( + delegate->GetSessionStartTime(), + delegate->GetSessionLengthLimit(), + system_tray()->shelf_alignment()); + return tray_view_; +} + +void TraySessionLengthLimit::DestroyTrayView() { + tray_view_ = NULL; +} + +void TraySessionLengthLimit::UpdateAfterShelfAlignmentChange( + ShelfAlignment alignment) { + if (tray_view_) + tray_view_->UpdateClockLayout(alignment); +} + +void TraySessionLengthLimit::OnSessionStartTimeChanged( + const base::Time& start_time) { + tray_view_->SetSessionStartTime(start_time); +} + +void TraySessionLengthLimit::OnSessionLengthLimitChanged( + const base::TimeDelta& limit) { + tray_view_->SetSessionLengthLimit(limit); +} + +} // namespace internal +} // namespace ash diff --git a/ash/system/session_length_limit/tray_session_length_limit.h b/ash/system/session_length_limit/tray_session_length_limit.h new file mode 100644 index 0000000..0ee3f07 --- /dev/null +++ b/ash/system/session_length_limit/tray_session_length_limit.h @@ -0,0 +1,48 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef ASH_SYSTEM_SESSION_LENGTH_LIMIT_TRAY_SESSION_LENGTH_LIMIT_H_ +#define ASH_SYSTEM_SESSION_LENGTH_LIMIT_TRAY_SESSION_LENGTH_LIMIT_H_ + +#include "ash/system/session_length_limit/session_length_limit_observer.h" +#include "ash/system/tray/system_tray_item.h" +#include "base/basictypes.h" +#include "base/compiler_specific.h" + +namespace ash { +namespace internal { + +namespace tray { +class RemainingSessionTimeTrayView; +} + +// Adds a countdown timer to the system tray if the session length is limited. +class TraySessionLengthLimit : public SystemTrayItem, + public SessionLengthLimitObserver { + public: + explicit TraySessionLengthLimit(SystemTray* system_tray); + virtual ~TraySessionLengthLimit(); + + // SystemTrayItem: + virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE; + virtual void DestroyTrayView() OVERRIDE; + virtual void UpdateAfterShelfAlignmentChange( + ShelfAlignment alignment) OVERRIDE; + + // SessionLengthLimitObserver: + virtual void OnSessionStartTimeChanged( + const base::Time& start_time) OVERRIDE; + virtual void OnSessionLengthLimitChanged( + const base::TimeDelta& limit) OVERRIDE; + + private: + tray::RemainingSessionTimeTrayView* tray_view_; + + DISALLOW_COPY_AND_ASSIGN(TraySessionLengthLimit); +}; + +} // namespace internal +} // namespace ash + +#endif // ASH_SYSTEM_SESSION_LENGTH_LIMIT_TRAY_SESSION_LENGTH_LIMIT_H_ diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index d225ce0..fcad87e 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -20,6 +20,7 @@ #include "ash/system/monitor/tray_monitor.h" #include "ash/system/power/power_supply_status.h" #include "ash/system/power/tray_power.h" +#include "ash/system/session_length_limit/tray_session_length_limit.h" #include "ash/system/settings/tray_settings.h" #include "ash/system/status_area_widget.h" #include "ash/system/tray/system_tray_delegate.h" @@ -128,6 +129,7 @@ void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) { } void SystemTray::CreateItems(SystemTrayDelegate* delegate) { + AddTrayItem(new internal::TraySessionLengthLimit(this)); AddTrayItem(new internal::TrayLogoutButton(this)); AddTrayItem(new internal::TrayUser(this)); AddTrayItem(new internal::TrayIME(this)); diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index 30f9369..d78ffdd 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -15,6 +15,7 @@ #include "base/i18n/time_formatting.h" #include "base/memory/scoped_ptr.h" #include "base/string16.h" +#include "base/time.h" #include "ui/gfx/image/image_skia.h" namespace ash { @@ -299,6 +300,14 @@ class SystemTrayDelegate { virtual void SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate> delegate) = 0; + // Returns the session start time, or a zero base::Time if no session start + // time is set. + virtual base::Time GetSessionStartTime() = 0; + + // Returns the session length limit, or a zero base::TimeDelta if no session + // length limit is set. + virtual base::TimeDelta GetSessionLengthLimit() = 0; + // Creates a dummy delegate for testing. static SystemTrayDelegate* CreateDummyDelegate(); }; diff --git a/ash/system/tray/system_tray_notifier.cc b/ash/system/tray/system_tray_notifier.cc index e865550..77af895 100644 --- a/ash/system/tray/system_tray_notifier.cc +++ b/ash/system/tray/system_tray_notifier.cc @@ -107,6 +107,16 @@ void SystemTrayNotifier::RemovePowerStatusObserver( power_status_observers_.RemoveObserver(observer); } +void SystemTrayNotifier::AddSessionLengthLimitObserver( + SessionLengthLimitObserver* observer) { + session_length_limit_observers_.AddObserver(observer); +} + +void SystemTrayNotifier::RemoveSessionLengthLimitObserver( + SessionLengthLimitObserver* observer) { + session_length_limit_observers_.RemoveObserver(observer); +} + void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) { update_observers_.AddObserver(observer); } @@ -243,6 +253,20 @@ void SystemTrayNotifier::NotifyPowerStatusChanged( OnPowerStatusChanged(power_status)); } +void SystemTrayNotifier::NotifySessionStartTimeChanged( + const base::Time& session_start_time) { + FOR_EACH_OBSERVER(SessionLengthLimitObserver, + session_length_limit_observers_, + OnSessionStartTimeChanged(session_start_time)); +} + +void SystemTrayNotifier::NotifySessionLengthLimitChanged( + const base::TimeDelta& limit) { + FOR_EACH_OBSERVER(SessionLengthLimitObserver, + session_length_limit_observers_, + OnSessionLengthLimitChanged(limit)); +} + void SystemTrayNotifier::NotifyUpdateRecommended( UpdateObserver::UpdateSeverity severity) { FOR_EACH_OBSERVER(UpdateObserver, diff --git a/ash/system/tray/system_tray_notifier.h b/ash/system/tray/system_tray_notifier.h index 895d929..6cc50f1 100644 --- a/ash/system/tray/system_tray_notifier.h +++ b/ash/system/tray/system_tray_notifier.h @@ -20,11 +20,13 @@ #include "ash/system/locale/locale_observer.h" #include "ash/system/logout_button/logout_button_observer.h" #include "ash/system/power/power_status_observer.h" +#include "ash/system/session_length_limit/session_length_limit_observer.h" #include "ash/system/tray_accessibility.h" #include "ash/system/tray_caps_lock.h" #include "ash/system/user/update_observer.h" #include "ash/system/user/user_observer.h" #include "base/observer_list.h" +#include "base/time.h" #if defined(OS_CHROMEOS) #include "ash/system/chromeos/network/network_observer.h" @@ -71,6 +73,9 @@ public: void AddPowerStatusObserver(PowerStatusObserver* observer); void RemovePowerStatusObserver(PowerStatusObserver* observer); + void AddSessionLengthLimitObserver(SessionLengthLimitObserver* observer); + void RemoveSessionLengthLimitObserver(SessionLengthLimitObserver* observer); + void AddUpdateObserver(UpdateObserver* observer); void RemoveUpdateObserver(UpdateObserver* observer); @@ -106,6 +111,8 @@ public: const std::string& from_locale, const std::string& to_locale); void NotifyPowerStatusChanged(const PowerSupplyStatus& power_status); + void NotifySessionStartTimeChanged(const base::Time& session_start_time); + void NotifySessionLengthLimitChanged(const base::TimeDelta& limit); void NotifyUpdateRecommended(UpdateObserver::UpdateSeverity severity); void NotifyUserUpdate(); #if defined(OS_CHROMEOS) @@ -134,6 +141,7 @@ public: ObserverList<LocaleObserver> locale_observers_; ObserverList<LogoutButtonObserver> logout_button_observers_; ObserverList<PowerStatusObserver> power_status_observers_; + ObserverList<SessionLengthLimitObserver> session_length_limit_observers_; ObserverList<UpdateObserver> update_observers_; ObserverList<UserObserver> user_observers_; #if defined(OS_CHROMEOS) diff --git a/ash/system/tray/test_system_tray_delegate.cc b/ash/system/tray/test_system_tray_delegate.cc index 8735734..ff09b1f 100644 --- a/ash/system/tray/test_system_tray_delegate.cc +++ b/ash/system/tray/test_system_tray_delegate.cc @@ -303,5 +303,13 @@ void TestSystemTrayDelegate::SetVolumeControlDelegate( volume_control_delegate_ = delegate.Pass(); } +base::Time TestSystemTrayDelegate::GetSessionStartTime() { + return base::Time(); +} + +base::TimeDelta TestSystemTrayDelegate::GetSessionLengthLimit() { + return base::TimeDelta(); +} + } // namespace test } // namespace ash diff --git a/ash/system/tray/test_system_tray_delegate.h b/ash/system/tray/test_system_tray_delegate.h index 9335a17..8c3c913 100644 --- a/ash/system/tray/test_system_tray_delegate.h +++ b/ash/system/tray/test_system_tray_delegate.h @@ -94,6 +94,8 @@ class TestSystemTrayDelegate : public SystemTrayDelegate { virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE; virtual void SetVolumeControlDelegate( scoped_ptr<VolumeControlDelegate> delegate) OVERRIDE; + virtual base::Time GetSessionStartTime() OVERRIDE; + virtual base::TimeDelta GetSessionLengthLimit() OVERRIDE; private: bool wifi_enabled_; |