Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ash/system/status_area_widget.cc

Issue 10823350: Re-factor system tray code controlling launcher visibility (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 }; 299 };
298 300
299 } // namespace 301 } // namespace
300 302
301 namespace internal { 303 namespace internal {
302 304
303 StatusAreaWidget::StatusAreaWidget() 305 StatusAreaWidget::StatusAreaWidget()
304 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), 306 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate),
305 system_tray_(NULL), 307 system_tray_(NULL),
306 web_notification_tray_(NULL), 308 web_notification_tray_(NULL),
307 login_status_(user::LOGGED_IN_NONE) { 309 login_status_(user::LOGGED_IN_NONE),
310 should_show_launcher_(false) {
308 views::Widget::InitParams params( 311 views::Widget::InitParams params(
309 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 312 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
310 params.delegate = status_area_widget_delegate_; 313 params.delegate = status_area_widget_delegate_;
311 params.parent = 314 params.parent =
312 Shell::GetPrimaryRootWindowController()->GetContainer( 315 Shell::GetPrimaryRootWindowController()->GetContainer(
313 ash::internal::kShellWindowId_StatusContainer); 316 ash::internal::kShellWindowId_StatusContainer);
314 params.transparent = true; 317 params.transparent = true;
315 Init(params); 318 Init(params);
316 set_focus_on_creation(false); 319 set_focus_on_creation(false);
317 SetContentsView(status_area_widget_delegate_); 320 SetContentsView(status_area_widget_delegate_);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 user::LoginStatus login_status) { 399 user::LoginStatus login_status) {
397 if (login_status_ == login_status) 400 if (login_status_ == login_status)
398 return; 401 return;
399 login_status_ = login_status; 402 login_status_ = login_status;
400 if (system_tray_) 403 if (system_tray_)
401 system_tray_->UpdateAfterLoginStatusChange(login_status); 404 system_tray_->UpdateAfterLoginStatusChange(login_status);
402 if (web_notification_tray_) 405 if (web_notification_tray_)
403 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 406 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
404 } 407 }
405 408
409 void StatusAreaWidget::UpdateShouldShowLauncher() {
410 // If any bubble is visible, we should show the launcher.
411 bool should_show_launcher =
412 (system_tray_ && system_tray_->IsSystemBubbleVisible()) ||
413 (web_notification_tray_ &&
414 web_notification_tray_->IsMessageCenterBubbleVisible());
415 if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) {
416 // If the launcher is currently visible, don't hide the launcher if
417 // the mouse is in this widget or in any notification bubbles.
418 should_show_launcher =
419 (GetWindowBoundsInScreen().Contains(
420 gfx::Screen::GetCursorScreenPoint())) ||
421 (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
422 (web_notification_tray_ &&
423 web_notification_tray_->IsMouseInNotificationBubble());
424 }
425 if (should_show_launcher != should_show_launcher_) {
426 should_show_launcher_ = should_show_launcher;
427 Shell::GetInstance()->shelf()->UpdateAutoHideState();
428 }
429 }
430
406 } // namespace internal 431 } // namespace internal
407 } // namespace ash 432 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698