| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/date/date_default_view.h" | 5 #include "ash/system/date/date_default_view.h" |
| 6 | 6 |
| 7 #include "ash/common/session/session_state_delegate.h" | 7 #include "ash/common/session/session_state_delegate.h" |
| 8 #include "ash/common/system/tray/special_popup_row.h" | 8 #include "ash/common/system/tray/special_popup_row.h" |
| 9 #include "ash/common/system/tray/system_tray_delegate.h" | 9 #include "ash/common/system/tray/system_tray_delegate.h" |
| 10 #include "ash/common/system/tray/tray_constants.h" | 10 #include "ash/common/system/tray/tray_constants.h" |
| 11 #include "ash/common/system/tray/tray_popup_header_button.h" | 11 #include "ash/common/system/tray/tray_popup_header_button.h" |
| 12 #include "ash/common/wm/wm_user_metrics_action.h" |
| 12 #include "ash/common/wm_shell.h" | 13 #include "ash/common/wm_shell.h" |
| 13 #include "ash/metrics/user_metrics_recorder.h" | |
| 14 #include "ash/shell.h" | |
| 15 #include "ash/system/date/date_view.h" | 14 #include "ash/system/date/date_view.h" |
| 16 #include "ash/wm/lock_state_controller.h" | |
| 17 #include "base/i18n/rtl.h" | 15 #include "base/i18n/rtl.h" |
| 18 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 19 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/views/border.h" | 19 #include "ui/views/border.h" |
| 22 #include "ui/views/controls/button/button.h" | 20 #include "ui/views/controls/button/button.h" |
| 23 #include "ui/views/layout/fill_layout.h" | 21 #include "ui/views/layout/fill_layout.h" |
| 24 #include "ui/views/view.h" | 22 #include "ui/views/view.h" |
| 25 | 23 |
| 26 namespace { | 24 namespace { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 43 weak_factory_(this) { | 41 weak_factory_(this) { |
| 44 SetLayoutManager(new views::FillLayout); | 42 SetLayoutManager(new views::FillLayout); |
| 45 | 43 |
| 46 date_view_ = new tray::DateView(); | 44 date_view_ = new tray::DateView(); |
| 47 date_view_->SetBorder(views::Border::CreateEmptyBorder( | 45 date_view_->SetBorder(views::Border::CreateEmptyBorder( |
| 48 kPaddingVertical, ash::kTrayPopupPaddingHorizontal, 0, 0)); | 46 kPaddingVertical, ash::kTrayPopupPaddingHorizontal, 0, 0)); |
| 49 SpecialPopupRow* view = new SpecialPopupRow(); | 47 SpecialPopupRow* view = new SpecialPopupRow(); |
| 50 view->SetContent(date_view_); | 48 view->SetContent(date_view_); |
| 51 AddChildView(view); | 49 AddChildView(view); |
| 52 | 50 |
| 53 bool userAddingRunning = ash::Shell::GetInstance() | 51 WmShell* shell = WmShell::Get(); |
| 54 ->session_state_delegate() | 52 const bool adding_user = |
| 55 ->IsInSecondaryLoginScreen(); | 53 shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 56 | 54 |
| 57 if (login == LoginStatus::LOCKED || login == LoginStatus::NOT_LOGGED_IN || | 55 if (login == LoginStatus::LOCKED || login == LoginStatus::NOT_LOGGED_IN || |
| 58 userAddingRunning) | 56 adding_user) |
| 59 return; | 57 return; |
| 60 | 58 |
| 61 date_view_->SetAction(TrayDate::SHOW_DATE_SETTINGS); | 59 date_view_->SetAction(TrayDate::SHOW_DATE_SETTINGS); |
| 62 | 60 |
| 63 help_button_ = new TrayPopupHeaderButton( | 61 help_button_ = new TrayPopupHeaderButton( |
| 64 this, IDR_AURA_UBER_TRAY_HELP, IDR_AURA_UBER_TRAY_HELP, | 62 this, IDR_AURA_UBER_TRAY_HELP, IDR_AURA_UBER_TRAY_HELP, |
| 65 IDR_AURA_UBER_TRAY_HELP_HOVER, IDR_AURA_UBER_TRAY_HELP_HOVER, | 63 IDR_AURA_UBER_TRAY_HELP_HOVER, IDR_AURA_UBER_TRAY_HELP_HOVER, |
| 66 IDS_ASH_STATUS_TRAY_HELP); | 64 IDS_ASH_STATUS_TRAY_HELP); |
| 67 if (base::i18n::IsRTL() && | 65 if (base::i18n::IsRTL() && |
| 68 base::i18n::GetConfiguredLocale() == kHebrewLocale) { | 66 base::i18n::GetConfiguredLocale() == kHebrewLocale) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 79 if (login != LoginStatus::LOCKED) { | 77 if (login != LoginStatus::LOCKED) { |
| 80 shutdown_button_ = new TrayPopupHeaderButton( | 78 shutdown_button_ = new TrayPopupHeaderButton( |
| 81 this, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN, | 79 this, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN, |
| 82 IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, | 80 IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, |
| 83 IDS_ASH_STATUS_TRAY_SHUTDOWN); | 81 IDS_ASH_STATUS_TRAY_SHUTDOWN); |
| 84 shutdown_button_->SetTooltipText( | 82 shutdown_button_->SetTooltipText( |
| 85 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); | 83 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
| 86 view->AddButton(shutdown_button_); | 84 view->AddButton(shutdown_button_); |
| 87 } | 85 } |
| 88 | 86 |
| 89 if (ash::Shell::GetInstance()->session_state_delegate()->CanLockScreen()) { | 87 if (shell->GetSessionStateDelegate()->CanLockScreen()) { |
| 90 lock_button_ = new TrayPopupHeaderButton( | 88 lock_button_ = new TrayPopupHeaderButton( |
| 91 this, IDR_AURA_UBER_TRAY_LOCKSCREEN, IDR_AURA_UBER_TRAY_LOCKSCREEN, | 89 this, IDR_AURA_UBER_TRAY_LOCKSCREEN, IDR_AURA_UBER_TRAY_LOCKSCREEN, |
| 92 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, | 90 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, |
| 93 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, IDS_ASH_STATUS_TRAY_LOCK); | 91 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, IDS_ASH_STATUS_TRAY_LOCK); |
| 94 lock_button_->SetTooltipText( | 92 lock_button_->SetTooltipText( |
| 95 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCK)); | 93 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCK)); |
| 96 view->AddButton(lock_button_); | 94 view->AddButton(lock_button_); |
| 97 } | 95 } |
| 98 SystemTrayDelegate* system_tray_delegate = | 96 SystemTrayDelegate* system_tray_delegate = shell->system_tray_delegate(); |
| 99 WmShell::Get()->system_tray_delegate(); | |
| 100 system_tray_delegate->AddShutdownPolicyObserver(this); | 97 system_tray_delegate->AddShutdownPolicyObserver(this); |
| 101 system_tray_delegate->ShouldRebootOnShutdown(base::Bind( | 98 system_tray_delegate->ShouldRebootOnShutdown(base::Bind( |
| 102 &DateDefaultView::OnShutdownPolicyChanged, weak_factory_.GetWeakPtr())); | 99 &DateDefaultView::OnShutdownPolicyChanged, weak_factory_.GetWeakPtr())); |
| 103 #endif // !defined(OS_WIN) | 100 #endif // !defined(OS_WIN) |
| 104 } | 101 } |
| 105 | 102 |
| 106 DateDefaultView::~DateDefaultView() { | 103 DateDefaultView::~DateDefaultView() { |
| 107 // We need the check as on shell destruction, the delegate is destroyed first. | 104 // We need the check as on shell destruction, the delegate is destroyed first. |
| 108 SystemTrayDelegate* system_tray_delegate = | 105 SystemTrayDelegate* system_tray_delegate = |
| 109 WmShell::Get()->system_tray_delegate(); | 106 WmShell::Get()->system_tray_delegate(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 122 tray::DateView* DateDefaultView::GetDateView() { | 119 tray::DateView* DateDefaultView::GetDateView() { |
| 123 return date_view_; | 120 return date_view_; |
| 124 } | 121 } |
| 125 | 122 |
| 126 const tray::DateView* DateDefaultView::GetDateView() const { | 123 const tray::DateView* DateDefaultView::GetDateView() const { |
| 127 return date_view_; | 124 return date_view_; |
| 128 } | 125 } |
| 129 | 126 |
| 130 void DateDefaultView::ButtonPressed(views::Button* sender, | 127 void DateDefaultView::ButtonPressed(views::Button* sender, |
| 131 const ui::Event& event) { | 128 const ui::Event& event) { |
| 132 Shell* shell = Shell::GetInstance(); | 129 WmShell* shell = WmShell::Get(); |
| 133 SystemTrayDelegate* tray_delegate = WmShell::Get()->system_tray_delegate(); | 130 SystemTrayDelegate* tray_delegate = shell->system_tray_delegate(); |
| 134 if (sender == help_button_) { | 131 if (sender == help_button_) { |
| 135 shell->metrics()->RecordUserMetricsAction(ash::UMA_TRAY_HELP); | 132 shell->RecordUserMetricsAction(wm::WmUserMetricsAction::TRAY_HELP); |
| 136 tray_delegate->ShowHelp(); | 133 tray_delegate->ShowHelp(); |
| 137 } else if (sender == shutdown_button_) { | 134 } else if (sender == shutdown_button_) { |
| 138 shell->metrics()->RecordUserMetricsAction(ash::UMA_TRAY_SHUT_DOWN); | 135 shell->RecordUserMetricsAction(wm::WmUserMetricsAction::TRAY_SHUT_DOWN); |
| 139 shell->lock_state_controller()->RequestShutdown(); | 136 tray_delegate->RequestShutdown(); |
| 140 } else if (sender == lock_button_) { | 137 } else if (sender == lock_button_) { |
| 141 shell->metrics()->RecordUserMetricsAction(ash::UMA_TRAY_LOCK_SCREEN); | 138 shell->RecordUserMetricsAction(wm::WmUserMetricsAction::TRAY_LOCK_SCREEN); |
| 142 tray_delegate->RequestLockScreen(); | 139 tray_delegate->RequestLockScreen(); |
| 143 } else { | 140 } else { |
| 144 NOTREACHED(); | 141 NOTREACHED(); |
| 145 } | 142 } |
| 146 } | 143 } |
| 147 | 144 |
| 148 void DateDefaultView::OnShutdownPolicyChanged(bool reboot_on_shutdown) { | 145 void DateDefaultView::OnShutdownPolicyChanged(bool reboot_on_shutdown) { |
| 149 if (!shutdown_button_) | 146 if (!shutdown_button_) |
| 150 return; | 147 return; |
| 151 | 148 |
| 152 shutdown_button_->SetTooltipText(l10n_util::GetStringUTF16( | 149 shutdown_button_->SetTooltipText(l10n_util::GetStringUTF16( |
| 153 reboot_on_shutdown ? IDS_ASH_STATUS_TRAY_REBOOT | 150 reboot_on_shutdown ? IDS_ASH_STATUS_TRAY_REBOOT |
| 154 : IDS_ASH_STATUS_TRAY_SHUTDOWN)); | 151 : IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
| 155 } | 152 } |
| 156 | 153 |
| 157 } // namespace ash | 154 } // namespace ash |
| OLD | NEW |