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..08c3ea27fda0504da80e597fb568bdd0c411d7b7 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" |
#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); |
@@ -110,6 +109,19 @@ LogoutButtonTray::~LogoutButtonTray() { |
RemoveLogoutButtonObserver(this); |
} |
+void LogoutButtonTray::EnsureConfirmationDialogShown() { |
+ if (!confirm_dialog_) { |
+ confirm_dialog_ = (new LogoutConfirmationDialogView())->GetWeakPtr(); |
bartfab (slow)
2013/10/28 16:24:07
The construction in this line is hard to follow.
|
+ confirm_dialog_->Show(dialog_duration_); |
+ } |
+} |
+ |
+void LogoutButtonTray::EnsureConfirmationDialogClosed() { |
+ if (!confirm_dialog_) { |
bartfab (slow)
2013/10/28 16:24:07
You want the exact reverse: if (confirm_dialog_)
binjin
2013/10/29 16:07:05
Done.
|
+ confirm_dialog_->GetWidget()->Close(); |
+ } |
+} |
+ |
void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
TrayBackgroundView::SetShelfAlignment(alignment); |
tray_container()->set_border(NULL); |
@@ -132,10 +144,18 @@ void LogoutButtonTray::OnShowLogoutButtonInTrayChanged(bool show) { |
UpdateVisibility(); |
} |
+void LogoutButtonTray::OnLogoutDialogDurationChanged(int duration) { |
+ dialog_duration_ = base::TimeDelta::FromMilliseconds(duration); |
bartfab (slow)
2013/10/28 16:24:07
You need to update the dialog here. It should imme
binjin
2013/10/29 16:07:05
Done.
|
+} |
+ |
void LogoutButtonTray::ButtonPressed(views::Button* sender, |
const ui::Event& event) { |
DCHECK_EQ(sender, button_); |
- Shell::GetInstance()->system_tray_delegate()->SignOut(); |
+ if (dialog_duration_.InSeconds() <= 0) { |
bartfab (slow)
2013/10/28 16:24:07
The correct way to do this would be something like
binjin
2013/10/29 16:07:05
Done.
|
+ Shell::GetInstance()->system_tray_delegate()->SignOut(); |
+ } else { |
+ EnsureConfirmationDialogShown(); |
+ } |
} |
void LogoutButtonTray::UpdateAfterLoginStatusChange( |
@@ -152,6 +172,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_) |
+ EnsureConfirmationDialogClosed(); |
} |
} // namespace internal |