OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef ASH_SYSTEM_DATE_DATE_VIEW_H_ | 5 #ifndef ASH_SYSTEM_DATE_DATE_VIEW_H_ |
6 #define ASH_SYSTEM_DATE_DATE_VIEW_H_ | 6 #define ASH_SYSTEM_DATE_DATE_VIEW_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "ash/system/tray/tray_views.h" | 9 #include "ash/system/tray/tray_views.h" |
10 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
11 #include "base/timer.h" | 11 #include "base/timer.h" |
12 #include "ui/views/view.h" | 12 #include "ui/views/view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 class Label; | 15 class Label; |
16 } | 16 } |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 namespace internal { | 19 namespace internal { |
20 namespace tray { | 20 namespace tray { |
21 | 21 |
22 // Abstract base class containing common updating and layout code for the | 22 // Abstract base class containing common updating and layout code for the |
23 // DateView popup and the TimeView tray icon. | 23 // DateView popup and the TimeView tray icon. |
24 class BaseDateTimeView : public ActionableView { | 24 class BaseDateTimeView : public ActionableView { |
25 public: | 25 public: |
26 virtual ~BaseDateTimeView(); | 26 virtual ~BaseDateTimeView(); |
27 | 27 |
28 // Updates the displayed text for the current time. | 28 // Updates the displayed text for the current time and calls SetTimer(). |
29 void UpdateText(); | 29 void UpdateText(); |
30 | 30 |
31 protected: | 31 protected: |
32 BaseDateTimeView(); | 32 BaseDateTimeView(); |
33 | 33 |
34 private: | 34 private: |
| 35 // Starts |timer_| to schedule the next update. |
| 36 void SetTimer(const base::Time& now); |
| 37 |
35 // Updates labels to display the current time. | 38 // Updates labels to display the current time. |
36 virtual void UpdateTextInternal(const base::Time& now) = 0; | 39 virtual void UpdateTextInternal(const base::Time& now) = 0; |
37 | 40 |
38 // Overridden from views::View. | 41 // Overridden from views::View. |
39 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; | 42 virtual void ChildPreferredSizeChanged(views::View* child) OVERRIDE; |
40 virtual void OnLocaleChanged() OVERRIDE; | 43 virtual void OnLocaleChanged() OVERRIDE; |
41 | 44 |
| 45 // Invokes UpdateText() when the displayed time should change. |
42 base::OneShotTimer<BaseDateTimeView> timer_; | 46 base::OneShotTimer<BaseDateTimeView> timer_; |
43 | 47 |
44 DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView); | 48 DISALLOW_COPY_AND_ASSIGN(BaseDateTimeView); |
45 }; | 49 }; |
46 | 50 |
47 // Popup view used to display the date and day of week. | 51 // Popup view used to display the date and day of week. |
48 class DateView : public BaseDateTimeView { | 52 class DateView : public BaseDateTimeView { |
49 public: | 53 public: |
50 DateView(); | 54 DateView(); |
51 virtual ~DateView(); | 55 virtual ~DateView(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 base::HourClockType hour_type_; | 97 base::HourClockType hour_type_; |
94 | 98 |
95 DISALLOW_COPY_AND_ASSIGN(TimeView); | 99 DISALLOW_COPY_AND_ASSIGN(TimeView); |
96 }; | 100 }; |
97 | 101 |
98 } // namespace tray | 102 } // namespace tray |
99 } // namespace internal | 103 } // namespace internal |
100 } // namespace ash | 104 } // namespace ash |
101 | 105 |
102 #endif // ASH_SYSTEM_DATE_DATE_VIEW_H_ | 106 #endif // ASH_SYSTEM_DATE_DATE_VIEW_H_ |
OLD | NEW |