| 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/tiles/tiles_default_view.h" | 5 #include "ash/common/system/tiles/tiles_default_view.h" |
| 6 | 6 |
| 7 #include "ash/common/metrics/user_metrics_action.h" | 7 #include "ash/common/metrics/user_metrics_action.h" |
| 8 #include "ash/common/session/session_controller.h" | 8 #include "ash/common/session/session_controller.h" |
| 9 #include "ash/common/shutdown_controller.h" | 9 #include "ash/common/shutdown_controller.h" |
| 10 #include "ash/common/system/tray/system_menu_button.h" | 10 #include "ash/common/system/tray/system_menu_button.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 SetLayoutManager(box_layout); | 59 SetLayoutManager(box_layout); |
| 60 | 60 |
| 61 // Show the buttons in this row as disabled if the user is at the login | 61 // Show the buttons in this row as disabled if the user is at the login |
| 62 // screen, lock screen, or in a secondary account flow. The exception is | 62 // screen, lock screen, or in a secondary account flow. The exception is |
| 63 // |power_button_| which is always shown as enabled. | 63 // |power_button_| which is always shown as enabled. |
| 64 const bool disable_buttons = !TrayPopupUtils::CanOpenWebUISettings(login_); | 64 const bool disable_buttons = !TrayPopupUtils::CanOpenWebUISettings(login_); |
| 65 | 65 |
| 66 settings_button_ = new SystemMenuButton( | 66 settings_button_ = new SystemMenuButton( |
| 67 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuSettingsIcon, | 67 this, TrayPopupInkDropStyle::HOST_CENTERED, kSystemMenuSettingsIcon, |
| 68 IDS_ASH_STATUS_TRAY_SETTINGS); | 68 IDS_ASH_STATUS_TRAY_SETTINGS); |
| 69 if (disable_buttons || !shell->system_tray_delegate()->ShouldShowSettings()) | 69 if (disable_buttons || |
| 70 !Shell::Get()->system_tray_delegate()->ShouldShowSettings()) |
| 70 settings_button_->SetEnabled(false); | 71 settings_button_->SetEnabled(false); |
| 71 AddChildView(settings_button_); | 72 AddChildView(settings_button_); |
| 72 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); | 73 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); |
| 73 | 74 |
| 74 help_button_ = | 75 help_button_ = |
| 75 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, | 76 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, |
| 76 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); | 77 kSystemMenuHelpIcon, IDS_ASH_STATUS_TRAY_HELP); |
| 77 if (base::i18n::IsRTL() && | 78 if (base::i18n::IsRTL() && |
| 78 base::i18n::GetConfiguredLocale() == kHebrewLocale) { | 79 base::i18n::GetConfiguredLocale() == kHebrewLocale) { |
| 79 // 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 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 105 power_button_->SetTooltipText(l10n_util::GetStringUTF16( | 106 power_button_->SetTooltipText(l10n_util::GetStringUTF16( |
| 106 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); | 107 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void TilesDefaultView::ButtonPressed(views::Button* sender, | 110 void TilesDefaultView::ButtonPressed(views::Button* sender, |
| 110 const ui::Event& event) { | 111 const ui::Event& event) { |
| 111 DCHECK(sender); | 112 DCHECK(sender); |
| 112 WmShell* shell = WmShell::Get(); | 113 WmShell* shell = WmShell::Get(); |
| 113 if (sender == settings_button_) { | 114 if (sender == settings_button_) { |
| 114 shell->RecordUserMetricsAction(UMA_TRAY_SETTINGS); | 115 shell->RecordUserMetricsAction(UMA_TRAY_SETTINGS); |
| 115 shell->system_tray_controller()->ShowSettings(); | 116 Shell::Get()->system_tray_controller()->ShowSettings(); |
| 116 } else if (sender == help_button_) { | 117 } else if (sender == help_button_) { |
| 117 shell->RecordUserMetricsAction(UMA_TRAY_HELP); | 118 shell->RecordUserMetricsAction(UMA_TRAY_HELP); |
| 118 shell->system_tray_controller()->ShowHelp(); | 119 Shell::Get()->system_tray_controller()->ShowHelp(); |
| 119 } else if (sender == lock_button_) { | 120 } else if (sender == lock_button_) { |
| 120 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); | 121 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); |
| 121 chromeos::DBusThreadManager::Get() | 122 chromeos::DBusThreadManager::Get() |
| 122 ->GetSessionManagerClient() | 123 ->GetSessionManagerClient() |
| 123 ->RequestLockScreen(); | 124 ->RequestLockScreen(); |
| 124 } else if (sender == power_button_) { | 125 } else if (sender == power_button_) { |
| 125 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); | 126 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); |
| 126 Shell::GetInstance()->lock_state_controller()->RequestShutdown(); | 127 Shell::GetInstance()->lock_state_controller()->RequestShutdown(); |
| 127 } | 128 } |
| 128 | 129 |
| 129 owner_->system_tray()->CloseSystemBubble(); | 130 owner_->system_tray()->CloseSystemBubble(); |
| 130 } | 131 } |
| 131 | 132 |
| 132 views::View* TilesDefaultView::GetHelpButtonView() const { | 133 views::View* TilesDefaultView::GetHelpButtonView() const { |
| 133 return help_button_; | 134 return help_button_; |
| 134 } | 135 } |
| 135 | 136 |
| 136 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() | 137 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() |
| 137 const { | 138 const { |
| 138 return power_button_; | 139 return power_button_; |
| 139 } | 140 } |
| 140 | 141 |
| 141 } // namespace ash | 142 } // namespace ash |
| OLD | NEW |