| 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 10 matching lines...) Expand all Loading... |
| 21 #include "ash/wm/lock_state_controller.h" | 21 #include "ash/wm/lock_state_controller.h" |
| 22 #include "chromeos/dbus/dbus_thread_manager.h" | 22 #include "chromeos/dbus/dbus_thread_manager.h" |
| 23 #include "chromeos/dbus/session_manager_client.h" | 23 #include "chromeos/dbus/session_manager_client.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 #include "ui/gfx/geometry/insets.h" | 25 #include "ui/gfx/geometry/insets.h" |
| 26 #include "ui/views/border.h" | 26 #include "ui/views/border.h" |
| 27 #include "ui/views/controls/button/custom_button.h" | 27 #include "ui/views/controls/button/custom_button.h" |
| 28 #include "ui/views/controls/separator.h" | 28 #include "ui/views/controls/separator.h" |
| 29 #include "ui/views/layout/box_layout.h" | 29 #include "ui/views/layout/box_layout.h" |
| 30 | 30 |
| 31 namespace ash { |
| 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| 33 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is | 35 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is |
| 34 // not mirrored in this locale. | 36 // not mirrored in this locale. |
| 35 const char kHebrewLocale[] = "he"; | 37 const char kHebrewLocale[] = "he"; |
| 36 | 38 |
| 39 const gfx::VectorIcon& GetNightLightButtonIcon() { |
| 40 return Shell::Get()->night_light_controller()->GetEnabled() |
| 41 ? kSystemMenuNightLightOnIcon |
| 42 : kSystemMenuNightLightOffIcon; |
| 43 } |
| 44 |
| 37 } // namespace | 45 } // namespace |
| 38 | 46 |
| 39 namespace ash { | |
| 40 | |
| 41 TilesDefaultView::TilesDefaultView(SystemTrayItem* owner) | 47 TilesDefaultView::TilesDefaultView(SystemTrayItem* owner) |
| 42 : owner_(owner), | 48 : owner_(owner), |
| 43 settings_button_(nullptr), | 49 settings_button_(nullptr), |
| 44 help_button_(nullptr), | 50 help_button_(nullptr), |
| 45 night_light_button_(nullptr), | 51 night_light_button_(nullptr), |
| 46 lock_button_(nullptr), | 52 lock_button_(nullptr), |
| 47 power_button_(nullptr) { | 53 power_button_(nullptr) { |
| 48 DCHECK(owner_); | 54 DCHECK(owner_); |
| 49 } | 55 } |
| 50 | 56 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 78 base::i18n::GetConfiguredLocale() == kHebrewLocale) { | 84 base::i18n::GetConfiguredLocale() == kHebrewLocale) { |
| 79 // The asset for the help button is a question mark '?'. Normally this asset | 85 // The asset for the help button is a question mark '?'. Normally this asset |
| 80 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the | 86 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the |
| 81 // flipping must be disabled. (crbug.com/475237) | 87 // flipping must be disabled. (crbug.com/475237) |
| 82 help_button_->EnableCanvasFlippingForRTLUI(false); | 88 help_button_->EnableCanvasFlippingForRTLUI(false); |
| 83 } | 89 } |
| 84 help_button_->SetEnabled(can_show_web_ui); | 90 help_button_->SetEnabled(can_show_web_ui); |
| 85 AddChildView(help_button_); | 91 AddChildView(help_button_); |
| 86 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | 92 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| 87 | 93 |
| 88 night_light_button_ = | 94 night_light_button_ = new SystemMenuButton( |
| 89 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, | 95 this, TrayPopupInkDropStyle::HOST_CENTERED, GetNightLightButtonIcon(), |
| 90 Shell::Get()->night_light_controller()->GetEnabled() | 96 IDS_ASH_STATUS_TRAY_NIGHT_LIGHT); |
| 91 ? kSystemMenuNightLightOnIcon | |
| 92 : kSystemMenuNightLightOffIcon, | |
| 93 IDS_ASH_STATUS_TRAY_NIGHT_LIGHT); | |
| 94 night_light_button_->SetEnabled(can_show_web_ui); | 97 night_light_button_->SetEnabled(can_show_web_ui); |
| 95 AddChildView(night_light_button_); | 98 AddChildView(night_light_button_); |
| 96 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | 99 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| 97 | 100 |
| 98 lock_button_ = | 101 lock_button_ = |
| 99 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, | 102 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, |
| 100 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); | 103 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); |
| 101 lock_button_->SetEnabled(can_show_web_ui && | 104 lock_button_->SetEnabled(can_show_web_ui && |
| 102 Shell::Get()->session_controller()->CanLockScreen()); | 105 Shell::Get()->session_controller()->CanLockScreen()); |
| 103 | 106 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 DCHECK(sender); | 123 DCHECK(sender); |
| 121 if (sender == settings_button_) { | 124 if (sender == settings_button_) { |
| 122 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS); | 125 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS); |
| 123 Shell::Get()->system_tray_controller()->ShowSettings(); | 126 Shell::Get()->system_tray_controller()->ShowSettings(); |
| 124 } else if (sender == help_button_) { | 127 } else if (sender == help_button_) { |
| 125 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP); | 128 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP); |
| 126 Shell::Get()->system_tray_controller()->ShowHelp(); | 129 Shell::Get()->system_tray_controller()->ShowHelp(); |
| 127 } else if (sender == night_light_button_) { | 130 } else if (sender == night_light_button_) { |
| 128 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT); | 131 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_NIGHT_LIGHT); |
| 129 Shell::Get()->night_light_controller()->Toggle(); | 132 Shell::Get()->night_light_controller()->Toggle(); |
| 133 night_light_button_->SetVectorIcon(GetNightLightButtonIcon()); |
| 130 } else if (sender == lock_button_) { | 134 } else if (sender == lock_button_) { |
| 131 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); | 135 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); |
| 132 chromeos::DBusThreadManager::Get() | 136 chromeos::DBusThreadManager::Get() |
| 133 ->GetSessionManagerClient() | 137 ->GetSessionManagerClient() |
| 134 ->RequestLockScreen(); | 138 ->RequestLockScreen(); |
| 135 } else if (sender == power_button_) { | 139 } else if (sender == power_button_) { |
| 136 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); | 140 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); |
| 137 Shell::Get()->lock_state_controller()->RequestShutdown(); | 141 Shell::Get()->lock_state_controller()->RequestShutdown(); |
| 138 } | 142 } |
| 139 | |
| 140 owner_->system_tray()->CloseSystemBubble(); | |
| 141 } | 143 } |
| 142 | 144 |
| 143 views::View* TilesDefaultView::GetHelpButtonView() const { | 145 views::View* TilesDefaultView::GetHelpButtonView() const { |
| 144 return help_button_; | 146 return help_button_; |
| 145 } | 147 } |
| 146 | 148 |
| 147 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() | 149 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() |
| 148 const { | 150 const { |
| 149 return power_button_; | 151 return power_button_; |
| 150 } | 152 } |
| 151 | 153 |
| 152 } // namespace ash | 154 } // namespace ash |
| OLD | NEW |