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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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/common/system/date/tray_date.h ('k') | ash/common/system/date/tray_system_info.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/system/date/tray_date.h"
6
7 #include "ash/common/shelf/wm_shelf_util.h"
8 #include "ash/common/system/chromeos/system_clock_observer.h"
9 #include "ash/common/system/date/date_default_view.h"
10 #include "ash/common/system/date/date_view.h"
11 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/system/tray/system_tray_notifier.h"
13 #include "ash/common/system/tray/tray_item_view.h"
14 #include "ash/common/wm_shell.h"
15
16 namespace ash {
17
18 TrayDate::TrayDate(SystemTray* system_tray)
19 : SystemTrayItem(system_tray, UMA_DATE),
20 time_tray_(NULL),
21 default_view_(NULL),
22 login_status_(LoginStatus::NOT_LOGGED_IN),
23 system_clock_observer_(new SystemClockObserver()) {
24 WmShell::Get()->system_tray_notifier()->AddClockObserver(this);
25 }
26
27 TrayDate::~TrayDate() {
28 WmShell::Get()->system_tray_notifier()->RemoveClockObserver(this);
29 }
30
31 views::View* TrayDate::GetHelpButtonView() const {
32 if (!default_view_)
33 return NULL;
34 return default_view_->GetHelpButtonView();
35 }
36
37 const tray::TimeView* TrayDate::GetTimeTrayForTesting() const {
38 return time_tray_;
39 }
40
41 const DateDefaultView* TrayDate::GetDefaultViewForTesting() const {
42 return default_view_;
43 }
44
45 views::View* TrayDate::CreateDefaultViewForTesting(LoginStatus status) {
46 return CreateDefaultView(status);
47 }
48
49 views::View* TrayDate::CreateTrayView(LoginStatus status) {
50 CHECK(time_tray_ == NULL);
51 tray::TimeView::ClockLayout clock_layout =
52 IsHorizontalAlignment(system_tray()->shelf_alignment())
53 ? tray::TimeView::ClockLayout::HORIZONTAL_CLOCK
54 : tray::TimeView::ClockLayout::VERTICAL_CLOCK;
55 time_tray_ = new tray::TimeView(clock_layout);
56 views::View* view = new TrayItemView(this);
57 view->AddChildView(time_tray_);
58 return view;
59 }
60
61 views::View* TrayDate::CreateDefaultView(LoginStatus status) {
62 default_view_ = new DateDefaultView(this, status);
63
64 // Save the login status we created the view with.
65 login_status_ = status;
66
67 OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time());
68 return default_view_;
69 }
70
71 views::View* TrayDate::CreateDetailedView(LoginStatus status) {
72 return NULL;
73 }
74
75 void TrayDate::DestroyTrayView() {
76 time_tray_ = NULL;
77 }
78
79 void TrayDate::DestroyDefaultView() {
80 default_view_ = NULL;
81 }
82
83 void TrayDate::DestroyDetailedView() {}
84
85 void TrayDate::UpdateAfterLoginStatusChange(LoginStatus status) {}
86
87 void TrayDate::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
88 if (time_tray_) {
89 tray::TimeView::ClockLayout clock_layout =
90 IsHorizontalAlignment(alignment)
91 ? tray::TimeView::ClockLayout::HORIZONTAL_CLOCK
92 : tray::TimeView::ClockLayout::VERTICAL_CLOCK;
93 time_tray_->UpdateClockLayout(clock_layout);
94 }
95 }
96
97 void TrayDate::OnDateFormatChanged() {
98 if (time_tray_)
99 time_tray_->UpdateTimeFormat();
100 if (default_view_)
101 default_view_->GetDateView()->UpdateTimeFormat();
102 }
103
104 void TrayDate::OnSystemClockTimeUpdated() {
105 if (time_tray_)
106 time_tray_->UpdateTimeFormat();
107 if (default_view_)
108 default_view_->GetDateView()->UpdateTimeFormat();
109 }
110
111 void TrayDate::OnSystemClockCanSetTimeChanged(bool can_set_time) {
112 // Outside of a logged-in session, the date button should launch the set time
113 // dialog if the time can be set.
114 if (default_view_ && login_status_ == LoginStatus::NOT_LOGGED_IN) {
115 default_view_->GetDateView()->SetAction(
116 can_set_time ? tray::DateView::DateAction::SET_SYSTEM_TIME
117 : tray::DateView::DateAction::NONE);
118 }
119 }
120
121 void TrayDate::Refresh() {
122 if (time_tray_)
123 time_tray_->UpdateText();
124 }
125
126 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/date/tray_date.h ('k') | ash/common/system/date/tray_system_info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698