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

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

Issue 247663003: Date and Time dialog for when the clock isn't synced. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, single quotes in browsertest js Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/date/tray_date.h ('k') | ash/system/tray/default_system_tray_delegate.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/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/date/date_default_view.h" 8 #include "ash/system/date/date_default_view.h"
9 #include "ash/system/date/date_view.h" 9 #include "ash/system/date/date_view.h"
10 #include "ash/system/tray/system_tray.h" 10 #include "ash/system/tray/system_tray.h"
11 #include "ash/system/tray/system_tray_notifier.h" 11 #include "ash/system/tray/system_tray_notifier.h"
12 #include "ash/system/tray/tray_item_view.h" 12 #include "ash/system/tray/tray_item_view.h"
13 13
14 #if defined(OS_CHROMEOS) 14 #if defined(OS_CHROMEOS)
15 #include "ash/system/chromeos/system_clock_observer.h" 15 #include "ash/system/chromeos/system_clock_observer.h"
16 #endif 16 #endif
17 17
18 namespace ash { 18 namespace ash {
19 19
20 TrayDate::TrayDate(SystemTray* system_tray) 20 TrayDate::TrayDate(SystemTray* system_tray)
21 : SystemTrayItem(system_tray), 21 : SystemTrayItem(system_tray),
22 time_tray_(NULL), 22 time_tray_(NULL),
23 default_view_(NULL) { 23 default_view_(NULL),
24 login_status_(user::LOGGED_IN_NONE) {
24 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
25 system_clock_observer_.reset(new SystemClockObserver()); 26 system_clock_observer_.reset(new SystemClockObserver());
26 #endif 27 #endif
27 Shell::GetInstance()->system_tray_notifier()->AddClockObserver(this); 28 Shell::GetInstance()->system_tray_notifier()->AddClockObserver(this);
28 } 29 }
29 30
30 TrayDate::~TrayDate() { 31 TrayDate::~TrayDate() {
31 Shell::GetInstance()->system_tray_notifier()->RemoveClockObserver(this); 32 Shell::GetInstance()->system_tray_notifier()->RemoveClockObserver(this);
32 } 33 }
33 34
(...skipping 22 matching lines...) Expand all
56 system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) ? 57 system_tray()->shelf_alignment() == SHELF_ALIGNMENT_TOP) ?
57 HORIZONTAL_CLOCK : VERTICAL_CLOCK; 58 HORIZONTAL_CLOCK : VERTICAL_CLOCK;
58 time_tray_ = new tray::TimeView(clock_layout); 59 time_tray_ = new tray::TimeView(clock_layout);
59 views::View* view = new TrayItemView(this); 60 views::View* view = new TrayItemView(this);
60 view->AddChildView(time_tray_); 61 view->AddChildView(time_tray_);
61 return view; 62 return view;
62 } 63 }
63 64
64 views::View* TrayDate::CreateDefaultView(user::LoginStatus status) { 65 views::View* TrayDate::CreateDefaultView(user::LoginStatus status) {
65 default_view_ = new DateDefaultView(status); 66 default_view_ = new DateDefaultView(status);
67
68 #if defined(OS_CHROMEOS)
69 // Save the login status we created the view with.
70 login_status_ = status;
71
72 OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time());
73 #endif
66 return default_view_; 74 return default_view_;
67 } 75 }
68 76
69 views::View* TrayDate::CreateDetailedView(user::LoginStatus status) { 77 views::View* TrayDate::CreateDetailedView(user::LoginStatus status) {
70 return NULL; 78 return NULL;
71 } 79 }
72 80
73 void TrayDate::DestroyTrayView() { 81 void TrayDate::DestroyTrayView() {
74 time_tray_ = NULL; 82 time_tray_ = NULL;
75 } 83 }
(...skipping 24 matching lines...) Expand all
100 default_view_->GetDateView()->UpdateTimeFormat(); 108 default_view_->GetDateView()->UpdateTimeFormat();
101 } 109 }
102 110
103 void TrayDate::OnSystemClockTimeUpdated() { 111 void TrayDate::OnSystemClockTimeUpdated() {
104 if (time_tray_) 112 if (time_tray_)
105 time_tray_->UpdateTimeFormat(); 113 time_tray_->UpdateTimeFormat();
106 if (default_view_) 114 if (default_view_)
107 default_view_->GetDateView()->UpdateTimeFormat(); 115 default_view_->GetDateView()->UpdateTimeFormat();
108 } 116 }
109 117
118 void TrayDate::OnSystemClockCanSetTimeChanged(bool can_set_time) {
119 // Outside of a logged-in session, the date button should launch the set time
120 // dialog if the time can be set.
121 if (default_view_ && login_status_ == user::LOGGED_IN_NONE) {
122 default_view_->GetDateView()->SetAction(
123 can_set_time ? TrayDate::SET_SYSTEM_TIME : TrayDate::NONE);
124 }
125 }
126
110 void TrayDate::Refresh() { 127 void TrayDate::Refresh() {
111 if (time_tray_) 128 if (time_tray_)
112 time_tray_->UpdateText(); 129 time_tray_->UpdateText();
113 } 130 }
114 131
115 } // namespace ash 132 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/date/tray_date.h ('k') | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698