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/system/tiles/tiles_default_view.h" | 5 #include "ash/system/tiles/tiles_default_view.h" |
6 | 6 |
7 #include "ash/metrics/user_metrics_action.h" | 7 #include "ash/metrics/user_metrics_action.h" |
8 #include "ash/resources/vector_icons/vector_icons.h" | 8 #include "ash/resources/vector_icons/vector_icons.h" |
9 #include "ash/session/session_controller.h" | 9 #include "ash/session/session_controller.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 base::i18n::GetConfiguredLocale() == kHebrewLocale) { | 79 base::i18n::GetConfiguredLocale() == kHebrewLocale) { |
80 // The asset for the help button is a question mark '?'. Normally this asset | 80 // The asset for the help button is a question mark '?'. Normally this asset |
81 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the | 81 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the |
82 // flipping must be disabled. (crbug.com/475237) | 82 // flipping must be disabled. (crbug.com/475237) |
83 help_button_->EnableCanvasFlippingForRTLUI(false); | 83 help_button_->EnableCanvasFlippingForRTLUI(false); |
84 } | 84 } |
85 help_button_->SetEnabled(can_show_web_ui); | 85 help_button_->SetEnabled(can_show_web_ui); |
86 AddChildView(help_button_); | 86 AddChildView(help_button_); |
87 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | 87 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
88 | 88 |
89 night_light_button_ = new NightLightToggleButton(this); | 89 if (NightLightController::IsFeatureEnabled()) { |
90 night_light_button_->SetEnabled(can_show_web_ui); | 90 night_light_button_ = new NightLightToggleButton(this); |
91 AddChildView(night_light_button_); | 91 night_light_button_->SetEnabled(can_show_web_ui); |
92 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | 92 AddChildView(night_light_button_); |
| 93 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| 94 } |
93 | 95 |
94 lock_button_ = | 96 lock_button_ = |
95 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, | 97 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, |
96 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); | 98 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); |
97 lock_button_->SetEnabled(can_show_web_ui && | 99 lock_button_->SetEnabled(can_show_web_ui && |
98 Shell::Get()->session_controller()->CanLockScreen()); | 100 Shell::Get()->session_controller()->CanLockScreen()); |
99 | 101 |
100 AddChildView(lock_button_); | 102 AddChildView(lock_button_); |
101 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | 103 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
102 | 104 |
(...skipping 10 matching lines...) Expand all Loading... |
113 | 115 |
114 void TilesDefaultView::ButtonPressed(views::Button* sender, | 116 void TilesDefaultView::ButtonPressed(views::Button* sender, |
115 const ui::Event& event) { | 117 const ui::Event& event) { |
116 DCHECK(sender); | 118 DCHECK(sender); |
117 if (sender == settings_button_) { | 119 if (sender == settings_button_) { |
118 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS); | 120 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS); |
119 Shell::Get()->system_tray_controller()->ShowSettings(); | 121 Shell::Get()->system_tray_controller()->ShowSettings(); |
120 } else if (sender == help_button_) { | 122 } else if (sender == help_button_) { |
121 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP); | 123 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP); |
122 Shell::Get()->system_tray_controller()->ShowHelp(); | 124 Shell::Get()->system_tray_controller()->ShowHelp(); |
123 } else if (sender == night_light_button_) { | 125 } else if (NightLightController::IsFeatureEnabled() && |
| 126 sender == night_light_button_) { |
124 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT); | 127 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT); |
125 Shell::Get()->night_light_controller()->Toggle(); | 128 Shell::Get()->night_light_controller()->Toggle(); |
126 night_light_button_->Update(); | 129 night_light_button_->Update(); |
127 } else if (sender == lock_button_) { | 130 } else if (sender == lock_button_) { |
128 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); | 131 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); |
129 chromeos::DBusThreadManager::Get() | 132 chromeos::DBusThreadManager::Get() |
130 ->GetSessionManagerClient() | 133 ->GetSessionManagerClient() |
131 ->RequestLockScreen(); | 134 ->RequestLockScreen(); |
132 } else if (sender == power_button_) { | 135 } else if (sender == power_button_) { |
133 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); | 136 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); |
134 Shell::Get()->lock_state_controller()->RequestShutdown(); | 137 Shell::Get()->lock_state_controller()->RequestShutdown(); |
135 } | 138 } |
136 } | 139 } |
137 | 140 |
138 views::View* TilesDefaultView::GetHelpButtonView() const { | 141 views::View* TilesDefaultView::GetHelpButtonView() const { |
139 return help_button_; | 142 return help_button_; |
140 } | 143 } |
141 | 144 |
142 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() | 145 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() |
143 const { | 146 const { |
144 return power_button_; | 147 return power_button_; |
145 } | 148 } |
146 | 149 |
147 } // namespace ash | 150 } // namespace ash |
OLD | NEW |