OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/status_area_widget.h" | 5 #include "ash/system/status_area_widget.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/system/bluetooth/bluetooth_observer.h" | 11 #include "ash/system/bluetooth/bluetooth_observer.h" |
12 #include "ash/system/network/network_observer.h" | 12 #include "ash/system/network/network_observer.h" |
13 #include "ash/system/status_area_widget_delegate.h" | 13 #include "ash/system/status_area_widget_delegate.h" |
14 #include "ash/system/tray/system_tray.h" | 14 #include "ash/system/tray/system_tray.h" |
15 #include "ash/system/tray/system_tray_delegate.h" | 15 #include "ash/system/tray/system_tray_delegate.h" |
16 #include "ash/system/web_notification/web_notification_tray.h" | 16 #include "ash/system/web_notification/web_notification_tray.h" |
17 #include "ash/volume_control_delegate.h" | 17 #include "ash/volume_control_delegate.h" |
| 18 #include "ash/wm/shelf_layout_manager.h" |
18 #include "base/i18n/time_formatting.h" | 19 #include "base/i18n/time_formatting.h" |
19 #include "base/utf_string_conversions.h" | 20 #include "base/utf_string_conversions.h" |
20 #include "ui/aura/window.h" | 21 #include "ui/aura/window.h" |
| 22 #include "ui/gfx/screen.h" |
21 | 23 |
22 namespace ash { | 24 namespace ash { |
23 | 25 |
24 namespace { | 26 namespace { |
25 | 27 |
26 class DummyVolumeControlDelegate : public VolumeControlDelegate { | 28 class DummyVolumeControlDelegate : public VolumeControlDelegate { |
27 public: | 29 public: |
28 DummyVolumeControlDelegate() {} | 30 DummyVolumeControlDelegate() {} |
29 virtual ~DummyVolumeControlDelegate() {} | 31 virtual ~DummyVolumeControlDelegate() {} |
30 | 32 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 }; | 301 }; |
300 | 302 |
301 } // namespace | 303 } // namespace |
302 | 304 |
303 namespace internal { | 305 namespace internal { |
304 | 306 |
305 StatusAreaWidget::StatusAreaWidget() | 307 StatusAreaWidget::StatusAreaWidget() |
306 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), | 308 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), |
307 system_tray_(NULL), | 309 system_tray_(NULL), |
308 web_notification_tray_(NULL), | 310 web_notification_tray_(NULL), |
309 login_status_(user::LOGGED_IN_NONE) { | 311 login_status_(user::LOGGED_IN_NONE), |
| 312 should_show_launcher_(false) { |
310 views::Widget::InitParams params( | 313 views::Widget::InitParams params( |
311 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 314 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
312 params.delegate = status_area_widget_delegate_; | 315 params.delegate = status_area_widget_delegate_; |
313 params.parent = | 316 params.parent = |
314 Shell::GetPrimaryRootWindowController()->GetContainer( | 317 Shell::GetPrimaryRootWindowController()->GetContainer( |
315 ash::internal::kShellWindowId_StatusContainer); | 318 ash::internal::kShellWindowId_StatusContainer); |
316 params.transparent = true; | 319 params.transparent = true; |
317 Init(params); | 320 Init(params); |
318 set_focus_on_creation(false); | 321 set_focus_on_creation(false); |
319 SetContentsView(status_area_widget_delegate_); | 322 SetContentsView(status_area_widget_delegate_); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 user::LoginStatus login_status) { | 401 user::LoginStatus login_status) { |
399 if (login_status_ == login_status) | 402 if (login_status_ == login_status) |
400 return; | 403 return; |
401 login_status_ = login_status; | 404 login_status_ = login_status; |
402 if (system_tray_) | 405 if (system_tray_) |
403 system_tray_->UpdateAfterLoginStatusChange(login_status); | 406 system_tray_->UpdateAfterLoginStatusChange(login_status); |
404 if (web_notification_tray_) | 407 if (web_notification_tray_) |
405 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); | 408 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); |
406 } | 409 } |
407 | 410 |
| 411 void StatusAreaWidget::UpdateShouldShowLauncher() { |
| 412 // If any bubble is visible, we should show the launcher. |
| 413 bool should_show_launcher = |
| 414 (system_tray_ && system_tray_->IsSystemBubbleVisible()) || |
| 415 (web_notification_tray_ && |
| 416 web_notification_tray_->IsMessageCenterBubbleVisible()); |
| 417 if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) { |
| 418 // If the launcher is currently visible, don't hide the launcher if |
| 419 // the mouse is in this widget or in any notification bubbles. |
| 420 should_show_launcher = |
| 421 (GetWindowBoundsInScreen().Contains( |
| 422 gfx::Screen::GetCursorScreenPoint())) || |
| 423 (system_tray_ && system_tray_->IsMouseInNotificationBubble()) || |
| 424 (web_notification_tray_ && |
| 425 web_notification_tray_->IsMouseInNotificationBubble()); |
| 426 } |
| 427 if (should_show_launcher != should_show_launcher_) { |
| 428 should_show_launcher_ = should_show_launcher; |
| 429 Shell::GetInstance()->shelf()->UpdateAutoHideState(); |
| 430 } |
| 431 } |
| 432 |
408 } // namespace internal | 433 } // namespace internal |
409 } // namespace ash | 434 } // namespace ash |
OLD | NEW |