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

Side by Side Diff: ash/system/tiles/tiles_default_view.cc

Issue 2907503002: Use correct theme for the off icon of NightLight, fix tooltip and a11y (Closed)
Patch Set: Expose button for tests. Created 3 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
OLDNEW
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"
11 #include "ash/shell_port.h" 11 #include "ash/shell_port.h"
12 #include "ash/shutdown_controller.h" 12 #include "ash/shutdown_controller.h"
13 #include "ash/strings/grit/ash_strings.h" 13 #include "ash/strings/grit/ash_strings.h"
14 #include "ash/system/night_light/night_light_controller.h" 14 #include "ash/system/night_light/night_light_controller.h"
15 #include "ash/system/night_light/night_light_toggle_button.h"
15 #include "ash/system/tray/system_menu_button.h" 16 #include "ash/system/tray/system_menu_button.h"
16 #include "ash/system/tray/system_tray.h" 17 #include "ash/system/tray/system_tray.h"
17 #include "ash/system/tray/system_tray_controller.h" 18 #include "ash/system/tray/system_tray_controller.h"
18 #include "ash/system/tray/system_tray_item.h" 19 #include "ash/system/tray/system_tray_item.h"
19 #include "ash/system/tray/tray_constants.h" 20 #include "ash/system/tray/tray_constants.h"
20 #include "ash/system/tray/tray_popup_utils.h" 21 #include "ash/system/tray/tray_popup_utils.h"
21 #include "ash/wm/lock_state_controller.h" 22 #include "ash/wm/lock_state_controller.h"
22 #include "chromeos/dbus/dbus_thread_manager.h" 23 #include "chromeos/dbus/dbus_thread_manager.h"
23 #include "chromeos/dbus/session_manager_client.h" 24 #include "chromeos/dbus/session_manager_client.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/gfx/geometry/insets.h" 26 #include "ui/gfx/geometry/insets.h"
26 #include "ui/views/border.h" 27 #include "ui/views/border.h"
27 #include "ui/views/controls/button/custom_button.h" 28 #include "ui/views/controls/button/custom_button.h"
28 #include "ui/views/controls/separator.h" 29 #include "ui/views/controls/separator.h"
29 #include "ui/views/layout/box_layout.h" 30 #include "ui/views/layout/box_layout.h"
30 31
31 namespace ash { 32 namespace ash {
32 33
33 namespace { 34 namespace {
34 35
35 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is 36 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is
36 // not mirrored in this locale. 37 // not mirrored in this locale.
37 const char kHebrewLocale[] = "he"; 38 const char kHebrewLocale[] = "he";
38 39
39 const gfx::VectorIcon& GetNightLightButtonIcon() {
40 return Shell::Get()->night_light_controller()->GetEnabled()
41 ? kSystemMenuNightLightOnIcon
42 : kSystemMenuNightLightOffIcon;
43 }
44
45 } // namespace 40 } // namespace
46 41
47 TilesDefaultView::TilesDefaultView(SystemTrayItem* owner) 42 TilesDefaultView::TilesDefaultView(SystemTrayItem* owner)
48 : owner_(owner), 43 : owner_(owner),
49 settings_button_(nullptr), 44 settings_button_(nullptr),
50 help_button_(nullptr), 45 help_button_(nullptr),
51 night_light_button_(nullptr), 46 night_light_button_(nullptr),
52 lock_button_(nullptr), 47 lock_button_(nullptr),
53 power_button_(nullptr) { 48 power_button_(nullptr) {
54 DCHECK(owner_); 49 DCHECK(owner_);
(...skipping 29 matching lines...) Expand all
84 base::i18n::GetConfiguredLocale() == kHebrewLocale) { 79 base::i18n::GetConfiguredLocale() == kHebrewLocale) {
85 // 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
86 // 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
87 // flipping must be disabled. (crbug.com/475237) 82 // flipping must be disabled. (crbug.com/475237)
88 help_button_->EnableCanvasFlippingForRTLUI(false); 83 help_button_->EnableCanvasFlippingForRTLUI(false);
89 } 84 }
90 help_button_->SetEnabled(can_show_web_ui); 85 help_button_->SetEnabled(can_show_web_ui);
91 AddChildView(help_button_); 86 AddChildView(help_button_);
92 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); 87 AddChildView(TrayPopupUtils::CreateVerticalSeparator());
93 88
94 night_light_button_ = new SystemMenuButton( 89 night_light_button_ = new NightLightToggleButton(this);
95 this, TrayPopupInkDropStyle::HOST_CENTERED, GetNightLightButtonIcon(),
96 IDS_ASH_STATUS_TRAY_NIGHT_LIGHT);
97 night_light_button_->SetEnabled(can_show_web_ui); 90 night_light_button_->SetEnabled(can_show_web_ui);
98 AddChildView(night_light_button_); 91 AddChildView(night_light_button_);
99 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); 92 AddChildView(TrayPopupUtils::CreateVerticalSeparator());
100 93
101 lock_button_ = 94 lock_button_ =
102 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, 95 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED,
103 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); 96 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK);
104 lock_button_->SetEnabled(can_show_web_ui && 97 lock_button_->SetEnabled(can_show_web_ui &&
105 Shell::Get()->session_controller()->CanLockScreen()); 98 Shell::Get()->session_controller()->CanLockScreen());
106 99
(...skipping 16 matching lines...) Expand all
123 DCHECK(sender); 116 DCHECK(sender);
124 if (sender == settings_button_) { 117 if (sender == settings_button_) {
125 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS); 118 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS);
126 Shell::Get()->system_tray_controller()->ShowSettings(); 119 Shell::Get()->system_tray_controller()->ShowSettings();
127 } else if (sender == help_button_) { 120 } else if (sender == help_button_) {
128 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP); 121 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP);
129 Shell::Get()->system_tray_controller()->ShowHelp(); 122 Shell::Get()->system_tray_controller()->ShowHelp();
130 } else if (sender == night_light_button_) { 123 } else if (sender == night_light_button_) {
131 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT); 124 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT);
132 Shell::Get()->night_light_controller()->Toggle(); 125 Shell::Get()->night_light_controller()->Toggle();
133 night_light_button_->SetVectorIcon(GetNightLightButtonIcon()); 126 night_light_button_->Update();
134 } else if (sender == lock_button_) { 127 } else if (sender == lock_button_) {
135 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); 128 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN);
136 chromeos::DBusThreadManager::Get() 129 chromeos::DBusThreadManager::Get()
137 ->GetSessionManagerClient() 130 ->GetSessionManagerClient()
138 ->RequestLockScreen(); 131 ->RequestLockScreen();
139 } else if (sender == power_button_) { 132 } else if (sender == power_button_) {
140 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); 133 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN);
141 Shell::Get()->lock_state_controller()->RequestShutdown(); 134 Shell::Get()->lock_state_controller()->RequestShutdown();
142 } 135 }
143 } 136 }
144 137
145 views::View* TilesDefaultView::GetHelpButtonView() const { 138 views::View* TilesDefaultView::GetHelpButtonView() const {
146 return help_button_; 139 return help_button_;
147 } 140 }
148 141
149 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() 142 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest()
150 const { 143 const {
151 return power_button_; 144 return power_button_;
152 } 145 }
153 146
154 } // namespace ash 147 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698