Index: ash/system/logout_button/logout_button_tray.cc |
diff --git a/ash/system/logout_button/logout_button_tray.cc b/ash/system/logout_button/logout_button_tray.cc |
index c06073040c5c26822b641ecb479f29c65cae088f..7270c878aa7743c606fc031c23c19b54c1fcbcdf 100644 |
--- a/ash/system/logout_button/logout_button_tray.cc |
+++ b/ash/system/logout_button/logout_button_tray.cc |
@@ -6,8 +6,8 @@ |
#include "ash/shelf/shelf_types.h" |
#include "ash/shell.h" |
+#include "ash/system/logout_button/logout_confirmation_dialog_view.h" |
#include "ash/system/status_area_widget.h" |
-#include "ash/system/tray/system_tray_delegate.h" |
bartfab (slow)
2013/10/30 11:17:28
This is still used. system_tray_delegate() returns
binjin
2013/11/19 14:43:46
Done.
|
#include "ash/system/tray/system_tray_notifier.h" |
#include "ash/system/tray/tray_constants.h" |
#include "ash/system/tray/tray_utils.h" |
@@ -96,7 +96,6 @@ LogoutButton::~LogoutButton() { |
LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget) |
: TrayBackgroundView(status_area_widget), |
- button_(NULL), |
login_status_(user::LOGGED_IN_NONE), |
show_logout_button_in_tray_(false) { |
button_ = new LogoutButton(this); |
@@ -108,6 +107,21 @@ LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget) |
LogoutButtonTray::~LogoutButtonTray() { |
Shell::GetInstance()->system_tray_notifier()-> |
RemoveLogoutButtonObserver(this); |
+ if (confirmation_dialog_) { |
+ confirmation_dialog_->DeleteDelegate(); |
bartfab (slow)
2013/10/30 11:17:28
This is the wrong method. DeleteDelegate() is how
binjin
2013/11/19 14:43:46
Done.
|
+ } |
+} |
+ |
+void LogoutButtonTray::EnsureConfirmationDialogIsShowing() { |
+ if (!confirmation_dialog_) { |
+ confirmation_dialog_ = (new LogoutConfirmationDialogView())->AsWeakPtr(); |
+ confirmation_dialog_->Show(dialog_duration_); |
+ } |
+} |
+ |
+void LogoutButtonTray::EnsureConfirmationDialogIsClosed() { |
+ if (confirmation_dialog_) |
+ confirmation_dialog_->GetWidget()->Close(); |
bartfab (slow)
2013/10/30 11:17:28
Can you destroy the dialog here? Otherwise, we are
binjin
2013/11/19 14:43:46
Done.
|
} |
void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
@@ -132,10 +146,21 @@ void LogoutButtonTray::OnShowLogoutButtonInTrayChanged(bool show) { |
UpdateVisibility(); |
} |
+void LogoutButtonTray::OnLogoutDialogDurationChanged(int duration) { |
+ dialog_duration_ = base::TimeDelta::FromMilliseconds(duration); |
+ if (confirmation_dialog_) |
+ confirmation_dialog_->UpdateDialogDuration(dialog_duration_); |
+} |
+ |
void LogoutButtonTray::ButtonPressed(views::Button* sender, |
const ui::Event& event) { |
DCHECK_EQ(sender, button_); |
- Shell::GetInstance()->system_tray_delegate()->SignOut(); |
+ // Sign out immediately if kLogoutDialogDurationMs is non-positive. |
+ if (dialog_duration_ <= base::TimeDelta::FromSeconds(0)) { |
bartfab (slow)
2013/10/30 11:17:28
Nit: No curly braces for single-line conditionals.
binjin
2013/11/19 14:43:46
Done.
|
+ Shell::GetInstance()->system_tray_delegate()->SignOut(); |
+ } else { |
+ EnsureConfirmationDialogIsShowing(); |
+ } |
} |
void LogoutButtonTray::UpdateAfterLoginStatusChange( |
@@ -152,6 +177,8 @@ void LogoutButtonTray::UpdateVisibility() { |
SetVisible(show_logout_button_in_tray_ && |
login_status_ != user::LOGGED_IN_NONE && |
login_status_ != user::LOGGED_IN_LOCKED); |
+ if (!show_logout_button_in_tray_) |
+ EnsureConfirmationDialogIsClosed(); |
} |
} // namespace internal |