Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: ash/system/date/tray_date.cc

Issue 2041233005: Moves ash::user::LoginStatus to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/system/date/tray_date.h ('k') | ash/system/ime/tray_ime_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ash/system/date/tray_date.h" 5 #include "ash/system/date/tray_date.h"
6 6
7 #include "ash/common/shelf/wm_shelf_util.h" 7 #include "ash/common/shelf/wm_shelf_util.h"
8 #include "ash/shelf/shelf_util.h" 8 #include "ash/shelf/shelf_util.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/date/date_default_view.h" 10 #include "ash/system/date/date_default_view.h"
11 #include "ash/system/date/date_view.h" 11 #include "ash/system/date/date_view.h"
12 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
13 #include "ash/system/tray/system_tray_notifier.h" 13 #include "ash/system/tray/system_tray_notifier.h"
14 #include "ash/system/tray/tray_item_view.h" 14 #include "ash/system/tray/tray_item_view.h"
15 15
16 #if defined(OS_CHROMEOS) 16 #if defined(OS_CHROMEOS)
17 #include "ash/system/chromeos/system_clock_observer.h" 17 #include "ash/system/chromeos/system_clock_observer.h"
18 #endif 18 #endif
19 19
20 namespace ash { 20 namespace ash {
21 21
22 TrayDate::TrayDate(SystemTray* system_tray) 22 TrayDate::TrayDate(SystemTray* system_tray)
23 : SystemTrayItem(system_tray), 23 : SystemTrayItem(system_tray),
24 time_tray_(NULL), 24 time_tray_(NULL),
25 default_view_(NULL), 25 default_view_(NULL),
26 login_status_(user::LOGGED_IN_NONE) { 26 login_status_(LoginStatus::NOT_LOGGED_IN) {
27 #if defined(OS_CHROMEOS) 27 #if defined(OS_CHROMEOS)
28 system_clock_observer_.reset(new SystemClockObserver()); 28 system_clock_observer_.reset(new SystemClockObserver());
29 #endif 29 #endif
30 Shell::GetInstance()->system_tray_notifier()->AddClockObserver(this); 30 Shell::GetInstance()->system_tray_notifier()->AddClockObserver(this);
31 } 31 }
32 32
33 TrayDate::~TrayDate() { 33 TrayDate::~TrayDate() {
34 Shell::GetInstance()->system_tray_notifier()->RemoveClockObserver(this); 34 Shell::GetInstance()->system_tray_notifier()->RemoveClockObserver(this);
35 } 35 }
36 36
37 views::View* TrayDate::GetHelpButtonView() const { 37 views::View* TrayDate::GetHelpButtonView() const {
38 if (!default_view_) 38 if (!default_view_)
39 return NULL; 39 return NULL;
40 return default_view_->GetHelpButtonView(); 40 return default_view_->GetHelpButtonView();
41 } 41 }
42 42
43 const tray::TimeView* TrayDate::GetTimeTrayForTesting() const { 43 const tray::TimeView* TrayDate::GetTimeTrayForTesting() const {
44 return time_tray_; 44 return time_tray_;
45 } 45 }
46 46
47 const DateDefaultView* TrayDate::GetDefaultViewForTesting() const { 47 const DateDefaultView* TrayDate::GetDefaultViewForTesting() const {
48 return default_view_; 48 return default_view_;
49 } 49 }
50 50
51 views::View* TrayDate::CreateDefaultViewForTesting(user::LoginStatus status) { 51 views::View* TrayDate::CreateDefaultViewForTesting(LoginStatus status) {
52 return CreateDefaultView(status); 52 return CreateDefaultView(status);
53 } 53 }
54 54
55 views::View* TrayDate::CreateTrayView(user::LoginStatus status) { 55 views::View* TrayDate::CreateTrayView(LoginStatus status) {
56 CHECK(time_tray_ == NULL); 56 CHECK(time_tray_ == NULL);
57 ClockLayout clock_layout = 57 ClockLayout clock_layout =
58 system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM 58 system_tray()->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM
59 ? HORIZONTAL_CLOCK 59 ? HORIZONTAL_CLOCK
60 : VERTICAL_CLOCK; 60 : VERTICAL_CLOCK;
61 time_tray_ = new tray::TimeView(clock_layout); 61 time_tray_ = new tray::TimeView(clock_layout);
62 views::View* view = new TrayItemView(this); 62 views::View* view = new TrayItemView(this);
63 view->AddChildView(time_tray_); 63 view->AddChildView(time_tray_);
64 return view; 64 return view;
65 } 65 }
66 66
67 views::View* TrayDate::CreateDefaultView(user::LoginStatus status) { 67 views::View* TrayDate::CreateDefaultView(LoginStatus status) {
68 default_view_ = new DateDefaultView(status); 68 default_view_ = new DateDefaultView(status);
69 69
70 #if defined(OS_CHROMEOS) 70 #if defined(OS_CHROMEOS)
71 // Save the login status we created the view with. 71 // Save the login status we created the view with.
72 login_status_ = status; 72 login_status_ = status;
73 73
74 OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time()); 74 OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time());
75 #endif 75 #endif
76 return default_view_; 76 return default_view_;
77 } 77 }
78 78
79 views::View* TrayDate::CreateDetailedView(user::LoginStatus status) { 79 views::View* TrayDate::CreateDetailedView(LoginStatus status) {
80 return NULL; 80 return NULL;
81 } 81 }
82 82
83 void TrayDate::DestroyTrayView() { 83 void TrayDate::DestroyTrayView() {
84 time_tray_ = NULL; 84 time_tray_ = NULL;
85 } 85 }
86 86
87 void TrayDate::DestroyDefaultView() { 87 void TrayDate::DestroyDefaultView() {
88 default_view_ = NULL; 88 default_view_ = NULL;
89 } 89 }
90 90
91 void TrayDate::DestroyDetailedView() { 91 void TrayDate::DestroyDetailedView() {
92 } 92 }
93 93
94 void TrayDate::UpdateAfterLoginStatusChange(user::LoginStatus status) { 94 void TrayDate::UpdateAfterLoginStatusChange(LoginStatus status) {}
95 }
96 95
97 void TrayDate::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 96 void TrayDate::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
98 if (time_tray_) { 97 if (time_tray_) {
99 ClockLayout clock_layout = 98 ClockLayout clock_layout =
100 IsHorizontalAlignment(alignment) ? HORIZONTAL_CLOCK : VERTICAL_CLOCK; 99 IsHorizontalAlignment(alignment) ? HORIZONTAL_CLOCK : VERTICAL_CLOCK;
101 time_tray_->UpdateClockLayout(clock_layout); 100 time_tray_->UpdateClockLayout(clock_layout);
102 } 101 }
103 } 102 }
104 103
105 void TrayDate::OnDateFormatChanged() { 104 void TrayDate::OnDateFormatChanged() {
106 if (time_tray_) 105 if (time_tray_)
107 time_tray_->UpdateTimeFormat(); 106 time_tray_->UpdateTimeFormat();
108 if (default_view_) 107 if (default_view_)
109 default_view_->GetDateView()->UpdateTimeFormat(); 108 default_view_->GetDateView()->UpdateTimeFormat();
110 } 109 }
111 110
112 void TrayDate::OnSystemClockTimeUpdated() { 111 void TrayDate::OnSystemClockTimeUpdated() {
113 if (time_tray_) 112 if (time_tray_)
114 time_tray_->UpdateTimeFormat(); 113 time_tray_->UpdateTimeFormat();
115 if (default_view_) 114 if (default_view_)
116 default_view_->GetDateView()->UpdateTimeFormat(); 115 default_view_->GetDateView()->UpdateTimeFormat();
117 } 116 }
118 117
119 void TrayDate::OnSystemClockCanSetTimeChanged(bool can_set_time) { 118 void TrayDate::OnSystemClockCanSetTimeChanged(bool can_set_time) {
120 // Outside of a logged-in session, the date button should launch the set time 119 // Outside of a logged-in session, the date button should launch the set time
121 // dialog if the time can be set. 120 // dialog if the time can be set.
122 if (default_view_ && login_status_ == user::LOGGED_IN_NONE) { 121 if (default_view_ && login_status_ == LoginStatus::NOT_LOGGED_IN) {
123 default_view_->GetDateView()->SetAction( 122 default_view_->GetDateView()->SetAction(
124 can_set_time ? TrayDate::SET_SYSTEM_TIME : TrayDate::NONE); 123 can_set_time ? TrayDate::SET_SYSTEM_TIME : TrayDate::NONE);
125 } 124 }
126 } 125 }
127 126
128 void TrayDate::Refresh() { 127 void TrayDate::Refresh() {
129 if (time_tray_) 128 if (time_tray_)
130 time_tray_->UpdateText(); 129 time_tray_->UpdateText();
131 } 130 }
132 131
133 } // namespace ash 132 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/date/tray_date.h ('k') | ash/system/ime/tray_ime_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698