Chromium Code Reviews| Index: ash/system/status_area_widget.cc |
| diff --git a/ash/system/status_area_widget.cc b/ash/system/status_area_widget.cc |
| index 4209f387ba12823a5bf77ef9cda35f4ffbe36259..c5a6418c08bec788fe9a85563ea35fcb7cf8551f 100644 |
| --- a/ash/system/status_area_widget.cc |
| +++ b/ash/system/status_area_widget.cc |
| @@ -14,9 +14,11 @@ |
| #include "ash/system/tray/system_tray.h" |
| #include "ash/system/tray/system_tray_delegate.h" |
| #include "ash/system/web_notification/web_notification_tray.h" |
| +#include "ash/wm/shelf_layout_manager.h" |
| #include "base/i18n/time_formatting.h" |
| #include "base/utf_string_conversions.h" |
| #include "ui/aura/window.h" |
| +#include "ui/gfx/screen.h" |
| namespace ash { |
| @@ -279,7 +281,8 @@ StatusAreaWidget::StatusAreaWidget() |
| : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), |
| system_tray_(NULL), |
| web_notification_tray_(NULL), |
| - login_status_(user::LOGGED_IN_NONE) { |
| + login_status_(user::LOGGED_IN_NONE), |
| + should_show_launcher_(false) { |
| views::Widget::InitParams params( |
| views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| params.delegate = status_area_widget_delegate_; |
| @@ -297,11 +300,19 @@ StatusAreaWidget::~StatusAreaWidget() { |
| } |
| void StatusAreaWidget::CreateTrayViews(ShellDelegate* shell_delegate) { |
| - AddWebNotificationTray(); |
| AddSystemTray(shell_delegate); |
| - // SetBorder() must be called after all trays have been created. |
| - web_notification_tray_->SetBorder(); |
| - system_tray_->SetBorder(); |
| + AddWebNotificationTray(); |
| + // Initialize() must be called after all trays have been created. |
| + if (system_tray_) { |
| + system_tray_->Initialize(); |
| + system_tray_->CreateItems(); |
|
sadrul
2012/08/15 16:47:01
Maybe CreateItems can be called from Initialize no
stevenjb
2012/08/15 21:51:04
Done.
|
| + } |
| + if (web_notification_tray_) { |
| + web_notification_tray_->Initialize(); |
| + } |
| + if (system_tray_delegate()) { |
| + UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus()); |
|
sadrul
2012/08/15 16:47:01
Can system_tray_delegate() be NULL here?
stevenjb
2012/08/15 21:51:04
Looks like not, removed test.
|
| + } |
| } |
| void StatusAreaWidget::Shutdown() { |
| @@ -318,7 +329,6 @@ void StatusAreaWidget::Shutdown() { |
| void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { |
| system_tray_ = new SystemTray(this); |
| status_area_widget_delegate_->AddTray(system_tray_); |
| - system_tray_->Initialize(); // Called after added to widget. |
| if (shell_delegate) { |
| system_tray_delegate_.reset( |
| @@ -326,9 +336,6 @@ void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { |
| } |
| if (!system_tray_delegate_.get()) |
| system_tray_delegate_.reset(new DummySystemTrayDelegate()); |
| - |
| - system_tray_->CreateItems(); // Called after delegate is created. |
| - UpdateAfterLoginStatusChange(system_tray_delegate_->GetUserLoginStatus()); |
| } |
| void StatusAreaWidget::AddWebNotificationTray() { |
| @@ -379,5 +386,26 @@ void StatusAreaWidget::UpdateAfterLoginStatusChange( |
| web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
| } |
| +void StatusAreaWidget::UpdateShouldShowLauncher() { |
| + bool should_show_launcher = |
| + (system_tray_ && system_tray_->IsSystemBubbleVisible()) || |
| + (web_notification_tray_ && |
| + web_notification_tray_->IsMessageCenterBubbleVisible()); |
| + if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) { |
| + // If the launcher is currently visible, don't hide the launcher |
| + // if the mouse is in this widget or in any notification bubbles. |
| + should_show_launcher = |
| + (GetWindowBoundsInScreen().Contains( |
| + gfx::Screen::GetCursorScreenPoint())) || |
| + (system_tray_ && system_tray_->IsMouseInNotificationBubble()) || |
| + (web_notification_tray_ && |
| + web_notification_tray_->IsMouseInNotificationBubble()); |
| + } |
| + if (should_show_launcher != should_show_launcher_) { |
| + should_show_launcher_ = should_show_launcher; |
| + Shell::GetInstance()->shelf()->UpdateAutoHideState(); |
| + } |
| +} |
| + |
| } // namespace internal |
| } // namespace ash |