Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/logout_button/logout_button_tray.h" | 5 #include "ash/system/logout_button/logout_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/shelf/shelf_types.h" | 7 #include "ash/shelf/shelf_types.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/system/logout_button/logout_confirmation_dialog_view.h" | |
| 9 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
| 10 #include "ash/system/tray/system_tray_delegate.h" | 11 #include "ash/system/tray/system_tray_delegate.h" |
|
bartfab (slow)
2013/10/24 13:11:02
No longer used.
binjin
2013/10/25 13:03:10
Done.
| |
| 11 #include "ash/system/tray/system_tray_notifier.h" | 12 #include "ash/system/tray/system_tray_notifier.h" |
| 12 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_utils.h" | 14 #include "ash/system/tray/tray_utils.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 16 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
| 17 #include "ui/events/event.h" | 18 #include "ui/events/event.h" |
| 18 #include "ui/gfx/font.h" | 19 #include "ui/gfx/font.h" |
| 19 #include "ui/gfx/insets.h" | 20 #include "ui/gfx/insets.h" |
| 20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 set_min_size(gfx::Size(0, GetShelfItemHeight())); | 92 set_min_size(gfx::Size(0, GetShelfItemHeight())); |
| 92 } | 93 } |
| 93 | 94 |
| 94 LogoutButton::~LogoutButton() { | 95 LogoutButton::~LogoutButton() { |
| 95 } | 96 } |
| 96 | 97 |
| 97 LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget) | 98 LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget) |
| 98 : TrayBackgroundView(status_area_widget), | 99 : TrayBackgroundView(status_area_widget), |
| 99 button_(NULL), | 100 button_(NULL), |
| 100 login_status_(user::LOGGED_IN_NONE), | 101 login_status_(user::LOGGED_IN_NONE), |
| 101 show_logout_button_in_tray_(false) { | 102 show_logout_button_in_tray_(false), |
| 103 confirm_dialog_(NULL) { | |
| 102 button_ = new LogoutButton(this); | 104 button_ = new LogoutButton(this); |
| 103 tray_container()->AddChildView(button_); | 105 tray_container()->AddChildView(button_); |
| 104 tray_container()->set_border(NULL); | 106 tray_container()->set_border(NULL); |
| 105 Shell::GetInstance()->system_tray_notifier()->AddLogoutButtonObserver(this); | 107 Shell::GetInstance()->system_tray_notifier()->AddLogoutButtonObserver(this); |
| 106 } | 108 } |
| 107 | 109 |
| 108 LogoutButtonTray::~LogoutButtonTray() { | 110 LogoutButtonTray::~LogoutButtonTray() { |
| 109 Shell::GetInstance()->system_tray_notifier()-> | 111 Shell::GetInstance()->system_tray_notifier()-> |
| 110 RemoveLogoutButtonObserver(this); | 112 RemoveLogoutButtonObserver(this); |
| 111 } | 113 } |
| 112 | 114 |
| 115 void LogoutButtonTray::ShowConfirmDialog() { | |
|
bartfab (slow)
2013/10/24 13:11:02
How about calling this EnsureConfirmationDialogSho
binjin
2013/10/25 13:03:10
Done.
| |
| 116 if (!confirm_dialog_) { | |
| 117 confirm_dialog_ = new LogoutConfirmationDialogView(this); | |
| 118 confirm_dialog_->InitAndShow(); | |
| 119 } | |
| 120 } | |
| 121 | |
| 122 void LogoutButtonTray::CloseConfirmDialog() { | |
|
bartfab (slow)
2013/10/24 13:11:02
How about calling this EnsureConfirmationDialogClo
binjin
2013/10/25 13:03:10
Done.
| |
| 123 if (!confirm_dialog_) { | |
| 124 confirm_dialog_->GetWidget()->Close(); | |
| 125 } | |
| 126 } | |
| 127 | |
| 128 void LogoutButtonTray::RemoveConfirmDialogInstance( | |
| 129 LogoutConfirmationDialogView *instance) { | |
| 130 if (confirm_dialog_ == instance) { | |
|
bartfab (slow)
2013/10/24 13:11:02
- No curly braces for single-line conditionals.
-
binjin
2013/10/25 13:03:10
Done.
| |
| 131 confirm_dialog_ = NULL; | |
| 132 } | |
| 133 } | |
| 134 | |
| 113 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { | 135 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 114 TrayBackgroundView::SetShelfAlignment(alignment); | 136 TrayBackgroundView::SetShelfAlignment(alignment); |
| 115 tray_container()->set_border(NULL); | 137 tray_container()->set_border(NULL); |
| 116 } | 138 } |
| 117 | 139 |
| 118 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { | 140 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { |
| 119 return button_->GetText(); | 141 return button_->GetText(); |
| 120 } | 142 } |
| 121 | 143 |
| 122 void LogoutButtonTray::HideBubbleWithView( | 144 void LogoutButtonTray::HideBubbleWithView( |
| 123 const views::TrayBubbleView* bubble_view) { | 145 const views::TrayBubbleView* bubble_view) { |
| 124 } | 146 } |
| 125 | 147 |
| 126 bool LogoutButtonTray::ClickedOutsideBubble() { | 148 bool LogoutButtonTray::ClickedOutsideBubble() { |
| 127 return false; | 149 return false; |
| 128 } | 150 } |
| 129 | 151 |
| 130 void LogoutButtonTray::OnShowLogoutButtonInTrayChanged(bool show) { | 152 void LogoutButtonTray::OnShowLogoutButtonInTrayChanged(bool show) { |
| 131 show_logout_button_in_tray_ = show; | 153 show_logout_button_in_tray_ = show; |
| 132 UpdateVisibility(); | 154 UpdateVisibility(); |
| 133 } | 155 } |
| 134 | 156 |
| 135 void LogoutButtonTray::ButtonPressed(views::Button* sender, | 157 void LogoutButtonTray::ButtonPressed(views::Button* sender, |
| 136 const ui::Event& event) { | 158 const ui::Event& event) { |
| 137 DCHECK_EQ(sender, button_); | 159 DCHECK_EQ(sender, button_); |
| 138 Shell::GetInstance()->system_tray_delegate()->SignOut(); | 160 ShowConfirmDialog(); |
| 139 } | 161 } |
| 140 | 162 |
| 141 void LogoutButtonTray::UpdateAfterLoginStatusChange( | 163 void LogoutButtonTray::UpdateAfterLoginStatusChange( |
| 142 user::LoginStatus login_status) { | 164 user::LoginStatus login_status) { |
| 143 login_status_ = login_status; | 165 login_status_ = login_status; |
| 144 const base::string16 title = | 166 const base::string16 title = |
| 145 GetLocalizedSignOutStringForStatus(login_status, false); | 167 GetLocalizedSignOutStringForStatus(login_status, false); |
| 146 button_->SetText(title); | 168 button_->SetText(title); |
| 147 button_->SetAccessibleName(title); | 169 button_->SetAccessibleName(title); |
| 148 UpdateVisibility(); | 170 UpdateVisibility(); |
| 149 } | 171 } |
| 150 | 172 |
| 151 void LogoutButtonTray::UpdateVisibility() { | 173 void LogoutButtonTray::UpdateVisibility() { |
| 152 SetVisible(show_logout_button_in_tray_ && | 174 SetVisible(show_logout_button_in_tray_ && |
| 153 login_status_ != user::LOGGED_IN_NONE && | 175 login_status_ != user::LOGGED_IN_NONE && |
| 154 login_status_ != user::LOGGED_IN_LOCKED); | 176 login_status_ != user::LOGGED_IN_LOCKED); |
| 177 if (!show_logout_button_in_tray_) { | |
|
bartfab (slow)
2013/10/24 13:11:02
No curly braces for single-line conditionals.
binjin
2013/10/25 13:03:10
Done.
| |
| 178 CloseConfirmDialog(); | |
| 179 } | |
| 155 } | 180 } |
| 156 | 181 |
| 157 } // namespace internal | 182 } // namespace internal |
| 158 } // namespace ash | 183 } // namespace ash |
| OLD | NEW |