OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/common/system/date/tray_system_info.h" | 5 #include "ash/common/system/date/tray_system_info.h" |
6 | 6 |
7 #include "ash/common/shelf/wm_shelf_util.h" | 7 #include "ash/common/shelf/wm_shelf_util.h" |
| 8 #include "ash/common/system/chromeos/system_clock_observer.h" |
8 #include "ash/common/system/date/date_view.h" | 9 #include "ash/common/system/date/date_view.h" |
9 #include "ash/common/system/date/system_info_default_view.h" | 10 #include "ash/common/system/date/system_info_default_view.h" |
10 #include "ash/common/system/tray/system_tray.h" | 11 #include "ash/common/system/tray/system_tray.h" |
11 #include "ash/common/system/tray/system_tray_notifier.h" | 12 #include "ash/common/system/tray/system_tray_notifier.h" |
12 #include "ash/common/system/tray/tray_item_view.h" | 13 #include "ash/common/system/tray/tray_item_view.h" |
13 #include "ash/common/wm_shell.h" | 14 #include "ash/common/wm_shell.h" |
14 | 15 |
15 #if defined(OS_CHROMEOS) | |
16 #include "ash/common/system/chromeos/system_clock_observer.h" | |
17 #endif | |
18 | |
19 namespace ash { | 16 namespace ash { |
20 | 17 |
21 TraySystemInfo::TraySystemInfo(SystemTray* system_tray) | 18 TraySystemInfo::TraySystemInfo(SystemTray* system_tray) |
22 : SystemTrayItem(system_tray, UMA_DATE), | 19 : SystemTrayItem(system_tray, UMA_DATE), |
23 tray_view_(nullptr), | 20 tray_view_(nullptr), |
24 default_view_(nullptr), | 21 default_view_(nullptr), |
25 login_status_(LoginStatus::NOT_LOGGED_IN) { | 22 login_status_(LoginStatus::NOT_LOGGED_IN), |
26 #if defined(OS_CHROMEOS) | 23 system_clock_observer_(new SystemClockObserver()) { |
27 system_clock_observer_.reset(new SystemClockObserver()); | |
28 #endif | |
29 WmShell::Get()->system_tray_notifier()->AddClockObserver(this); | 24 WmShell::Get()->system_tray_notifier()->AddClockObserver(this); |
30 } | 25 } |
31 | 26 |
32 TraySystemInfo::~TraySystemInfo() { | 27 TraySystemInfo::~TraySystemInfo() { |
33 WmShell::Get()->system_tray_notifier()->RemoveClockObserver(this); | 28 WmShell::Get()->system_tray_notifier()->RemoveClockObserver(this); |
34 } | 29 } |
35 | 30 |
36 const tray::TimeView* TraySystemInfo::GetTimeTrayForTesting() const { | 31 const tray::TimeView* TraySystemInfo::GetTimeTrayForTesting() const { |
37 return tray_view_; | 32 return tray_view_; |
38 } | 33 } |
(...skipping 14 matching lines...) Expand all Loading... |
53 : tray::TimeView::ClockLayout::VERTICAL_CLOCK; | 48 : tray::TimeView::ClockLayout::VERTICAL_CLOCK; |
54 tray_view_ = new tray::TimeView(clock_layout); | 49 tray_view_ = new tray::TimeView(clock_layout); |
55 views::View* view = new TrayItemView(this); | 50 views::View* view = new TrayItemView(this); |
56 view->AddChildView(tray_view_); | 51 view->AddChildView(tray_view_); |
57 return view; | 52 return view; |
58 } | 53 } |
59 | 54 |
60 views::View* TraySystemInfo::CreateDefaultView(LoginStatus status) { | 55 views::View* TraySystemInfo::CreateDefaultView(LoginStatus status) { |
61 default_view_ = new SystemInfoDefaultView(this, status); | 56 default_view_ = new SystemInfoDefaultView(this, status); |
62 | 57 |
63 #if defined(OS_CHROMEOS) | |
64 // Save the login status we created the view with. | 58 // Save the login status we created the view with. |
65 login_status_ = status; | 59 login_status_ = status; |
66 | 60 |
67 OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time()); | 61 OnSystemClockCanSetTimeChanged(system_clock_observer_->can_set_time()); |
68 #endif | |
69 return default_view_; | 62 return default_view_; |
70 } | 63 } |
71 | 64 |
72 void TraySystemInfo::DestroyTrayView() { | 65 void TraySystemInfo::DestroyTrayView() { |
73 tray_view_ = nullptr; | 66 tray_view_ = nullptr; |
74 } | 67 } |
75 | 68 |
76 void TraySystemInfo::DestroyDefaultView() { | 69 void TraySystemInfo::DestroyDefaultView() { |
77 default_view_ = nullptr; | 70 default_view_ = nullptr; |
78 } | 71 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 } | 104 } |
112 | 105 |
113 void TraySystemInfo::UpdateTimeFormat() { | 106 void TraySystemInfo::UpdateTimeFormat() { |
114 if (tray_view_) | 107 if (tray_view_) |
115 tray_view_->UpdateTimeFormat(); | 108 tray_view_->UpdateTimeFormat(); |
116 if (default_view_) | 109 if (default_view_) |
117 default_view_->GetDateView()->UpdateTimeFormat(); | 110 default_view_->GetDateView()->UpdateTimeFormat(); |
118 } | 111 } |
119 | 112 |
120 } // namespace ash | 113 } // namespace ash |
OLD | NEW |