| 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" |
| 11 #include "ash/shell_port.h" |
| 11 #include "ash/shutdown_controller.h" | 12 #include "ash/shutdown_controller.h" |
| 12 #include "ash/strings/grit/ash_strings.h" | 13 #include "ash/strings/grit/ash_strings.h" |
| 13 #include "ash/system/tray/system_menu_button.h" | 14 #include "ash/system/tray/system_menu_button.h" |
| 14 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
| 15 #include "ash/system/tray/system_tray_controller.h" | 16 #include "ash/system/tray/system_tray_controller.h" |
| 16 #include "ash/system/tray/system_tray_delegate.h" | 17 #include "ash/system/tray/system_tray_delegate.h" |
| 17 #include "ash/system/tray/system_tray_item.h" | 18 #include "ash/system/tray/system_tray_item.h" |
| 18 #include "ash/system/tray/tray_constants.h" | 19 #include "ash/system/tray/tray_constants.h" |
| 19 #include "ash/system/tray/tray_popup_utils.h" | 20 #include "ash/system/tray/tray_popup_utils.h" |
| 20 #include "ash/wm/lock_state_controller.h" | 21 #include "ash/wm/lock_state_controller.h" |
| 21 #include "ash/wm_shell.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 { | 31 namespace { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // This object is recreated every time the menu opens. Don't bother updating | 102 // This object is recreated every time the menu opens. Don't bother updating |
| 103 // the tooltip if the shutdown policy changes while the menu is open. | 103 // the tooltip if the shutdown policy changes while the menu is open. |
| 104 bool reboot = Shell::Get()->shutdown_controller()->reboot_on_shutdown(); | 104 bool reboot = Shell::Get()->shutdown_controller()->reboot_on_shutdown(); |
| 105 power_button_->SetTooltipText(l10n_util::GetStringUTF16( | 105 power_button_->SetTooltipText(l10n_util::GetStringUTF16( |
| 106 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); | 106 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void TilesDefaultView::ButtonPressed(views::Button* sender, | 109 void TilesDefaultView::ButtonPressed(views::Button* sender, |
| 110 const ui::Event& event) { | 110 const ui::Event& event) { |
| 111 DCHECK(sender); | 111 DCHECK(sender); |
| 112 WmShell* shell = WmShell::Get(); | |
| 113 if (sender == settings_button_) { | 112 if (sender == settings_button_) { |
| 114 shell->RecordUserMetricsAction(UMA_TRAY_SETTINGS); | 113 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SETTINGS); |
| 115 Shell::Get()->system_tray_controller()->ShowSettings(); | 114 Shell::Get()->system_tray_controller()->ShowSettings(); |
| 116 } else if (sender == help_button_) { | 115 } else if (sender == help_button_) { |
| 117 shell->RecordUserMetricsAction(UMA_TRAY_HELP); | 116 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_HELP); |
| 118 Shell::Get()->system_tray_controller()->ShowHelp(); | 117 Shell::Get()->system_tray_controller()->ShowHelp(); |
| 119 } else if (sender == lock_button_) { | 118 } else if (sender == lock_button_) { |
| 120 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); | 119 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); |
| 121 chromeos::DBusThreadManager::Get() | 120 chromeos::DBusThreadManager::Get() |
| 122 ->GetSessionManagerClient() | 121 ->GetSessionManagerClient() |
| 123 ->RequestLockScreen(); | 122 ->RequestLockScreen(); |
| 124 } else if (sender == power_button_) { | 123 } else if (sender == power_button_) { |
| 125 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); | 124 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); |
| 126 Shell::Get()->lock_state_controller()->RequestShutdown(); | 125 Shell::Get()->lock_state_controller()->RequestShutdown(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 owner_->system_tray()->CloseSystemBubble(); | 128 owner_->system_tray()->CloseSystemBubble(); |
| 130 } | 129 } |
| 131 | 130 |
| 132 views::View* TilesDefaultView::GetHelpButtonView() const { | 131 views::View* TilesDefaultView::GetHelpButtonView() const { |
| 133 return help_button_; | 132 return help_button_; |
| 134 } | 133 } |
| 135 | 134 |
| 136 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() | 135 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() |
| 137 const { | 136 const { |
| 138 return power_button_; | 137 return power_button_; |
| 139 } | 138 } |
| 140 | 139 |
| 141 } // namespace ash | 140 } // namespace ash |
| OLD | NEW |