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

Unified Diff: ash/common/system/date/date_default_view.cc

Issue 2497123002: chromeos: Move device shutdown handling out of chrome into ash (Closed)
Patch Set: rebase Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/date/date_default_view.h ('k') | ash/common/system/tiles/tiles_default_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/system/date/date_default_view.cc
diff --git a/ash/common/system/date/date_default_view.cc b/ash/common/system/date/date_default_view.cc
index 8eedc082f0d7a95f217810b2e8b70985bfd0b1a1..c27ed1a118636da94301c0eebac494c5db7c3eed 100644
--- a/ash/common/system/date/date_default_view.cc
+++ b/ash/common/system/date/date_default_view.cc
@@ -6,11 +6,11 @@
#include "ash/common/metrics/user_metrics_action.h"
#include "ash/common/session/session_state_delegate.h"
+#include "ash/common/shutdown_controller.h"
#include "ash/common/system/date/date_view.h"
#include "ash/common/system/tray/special_popup_row.h"
#include "ash/common/system/tray/system_tray.h"
#include "ash/common/system/tray/system_tray_controller.h"
-#include "ash/common/system/tray/system_tray_delegate.h"
#include "ash/common/system/tray/tray_constants.h"
#include "ash/common/system/tray/tray_popup_header_button.h"
#include "ash/common/wm_shell.h"
@@ -44,8 +44,7 @@ DateDefaultView::DateDefaultView(SystemTrayItem* owner, LoginStatus login)
: help_button_(nullptr),
shutdown_button_(nullptr),
lock_button_(nullptr),
- date_view_(nullptr),
- weak_factory_(this) {
+ date_view_(nullptr) {
SetLayoutManager(new views::FillLayout);
date_view_ = new tray::DateView(owner);
@@ -90,6 +89,11 @@ DateDefaultView::DateDefaultView(SystemTrayItem* owner, LoginStatus login)
shutdown_button_->SetTooltipText(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN));
view->AddViewToRowNonMd(shutdown_button_, true);
+ // This object is recreated every time the menu opens. Don't bother updating
+ // the tooltip if the shutdown policy changes while the menu is open.
+ bool reboot = WmShell::Get()->shutdown_controller()->reboot_on_shutdown();
+ shutdown_button_->SetTooltipText(l10n_util::GetStringUTF16(
+ reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN));
}
if (shell->GetSessionStateDelegate()->CanLockScreen()) {
@@ -101,20 +105,10 @@ DateDefaultView::DateDefaultView(SystemTrayItem* owner, LoginStatus login)
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCK));
view->AddViewToRowNonMd(lock_button_, true);
}
- SystemTrayDelegate* system_tray_delegate = shell->system_tray_delegate();
- system_tray_delegate->AddShutdownPolicyObserver(this);
- system_tray_delegate->ShouldRebootOnShutdown(base::Bind(
- &DateDefaultView::OnShutdownPolicyChanged, weak_factory_.GetWeakPtr()));
#endif // !defined(OS_WIN)
}
-DateDefaultView::~DateDefaultView() {
- // We need the check as on shell destruction, the delegate is destroyed first.
- SystemTrayDelegate* system_tray_delegate =
- WmShell::Get()->system_tray_delegate();
- if (system_tray_delegate)
- system_tray_delegate->RemoveShutdownPolicyObserver(this);
-}
+DateDefaultView::~DateDefaultView() {}
views::View* DateDefaultView::GetHelpButtonView() {
return help_button_;
@@ -154,13 +148,4 @@ void DateDefaultView::ButtonPressed(views::Button* sender,
date_view_->CloseSystemBubble();
}
-void DateDefaultView::OnShutdownPolicyChanged(bool reboot_on_shutdown) {
- if (!shutdown_button_)
- return;
-
- shutdown_button_->SetTooltipText(l10n_util::GetStringUTF16(
- reboot_on_shutdown ? IDS_ASH_STATUS_TRAY_REBOOT
- : IDS_ASH_STATUS_TRAY_SHUTDOWN));
-}
-
} // namespace ash
« no previous file with comments | « ash/common/system/date/date_default_view.h ('k') | ash/common/system/tiles/tiles_default_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698