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

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

Issue 10909220: Removes caching of whether the launcher should be visible from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: auto-hide Created 8 years, 3 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
« no previous file with comments | « ash/system/status_area_widget.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 }; 296 };
297 297
298 } // namespace 298 } // namespace
299 299
300 namespace internal { 300 namespace internal {
301 301
302 StatusAreaWidget::StatusAreaWidget() 302 StatusAreaWidget::StatusAreaWidget()
303 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate), 303 : status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate),
304 system_tray_(NULL), 304 system_tray_(NULL),
305 web_notification_tray_(NULL), 305 web_notification_tray_(NULL),
306 login_status_(user::LOGGED_IN_NONE), 306 login_status_(user::LOGGED_IN_NONE) {
307 should_show_launcher_(false) {
308 views::Widget::InitParams params( 307 views::Widget::InitParams params(
309 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); 308 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
310 params.delegate = status_area_widget_delegate_; 309 params.delegate = status_area_widget_delegate_;
311 params.parent = 310 params.parent =
312 Shell::GetPrimaryRootWindowController()->GetContainer( 311 Shell::GetPrimaryRootWindowController()->GetContainer(
313 ash::internal::kShellWindowId_StatusContainer); 312 ash::internal::kShellWindowId_StatusContainer);
314 params.transparent = true; 313 params.transparent = true;
315 Init(params); 314 Init(params);
316 set_focus_on_creation(false); 315 set_focus_on_creation(false);
317 SetContentsView(status_area_widget_delegate_); 316 SetContentsView(status_area_widget_delegate_);
(...skipping 18 matching lines...) Expand all
336 // Destroy the trays early, causing them to be removed from the view 335 // Destroy the trays early, causing them to be removed from the view
337 // hierarchy. Do not used scoped pointers since we don't want to destroy them 336 // hierarchy. Do not used scoped pointers since we don't want to destroy them
338 // in the destructor if Shutdown() is not called (e.g. in tests). 337 // in the destructor if Shutdown() is not called (e.g. in tests).
339 system_tray_delegate_.reset(); 338 system_tray_delegate_.reset();
340 system_tray_ = NULL; 339 system_tray_ = NULL;
341 delete system_tray_; 340 delete system_tray_;
342 web_notification_tray_ = NULL; 341 web_notification_tray_ = NULL;
343 delete web_notification_tray_; 342 delete web_notification_tray_;
344 } 343 }
345 344
345 bool StatusAreaWidget::ShouldShowLauncher() const {
346 if ((system_tray_ && system_tray_->HasSystemBubble()) ||
347 (web_notification_tray_ &&
348 web_notification_tray_->IsMessageCenterBubbleVisible()))
349 return true;
350
351 if (!Shell::GetInstance()->shelf()->IsVisible())
352 return false;
353
354 // If the launcher is currently visible, don't hide the launcher if the mouse
355 // is in any of the notification bubbles.
356 return (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
357 (web_notification_tray_ &&
358 web_notification_tray_->IsMouseInNotificationBubble());
359 }
360
346 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) { 361 void StatusAreaWidget::AddSystemTray(ShellDelegate* shell_delegate) {
347 system_tray_ = new SystemTray(this); 362 system_tray_ = new SystemTray(this);
348 status_area_widget_delegate_->AddTray(system_tray_); 363 status_area_widget_delegate_->AddTray(system_tray_);
349 364
350 if (shell_delegate) { 365 if (shell_delegate) {
351 system_tray_delegate_.reset( 366 system_tray_delegate_.reset(
352 shell_delegate->CreateSystemTrayDelegate(system_tray_)); 367 shell_delegate->CreateSystemTrayDelegate(system_tray_));
353 } 368 }
354 if (!system_tray_delegate_.get()) 369 if (!system_tray_delegate_.get())
355 system_tray_delegate_.reset(new DummySystemTrayDelegate()); 370 system_tray_delegate_.reset(new DummySystemTrayDelegate());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 user::LoginStatus login_status) { 411 user::LoginStatus login_status) {
397 if (login_status_ == login_status) 412 if (login_status_ == login_status)
398 return; 413 return;
399 login_status_ = login_status; 414 login_status_ = login_status;
400 if (system_tray_) 415 if (system_tray_)
401 system_tray_->UpdateAfterLoginStatusChange(login_status); 416 system_tray_->UpdateAfterLoginStatusChange(login_status);
402 if (web_notification_tray_) 417 if (web_notification_tray_)
403 web_notification_tray_->UpdateAfterLoginStatusChange(login_status); 418 web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
404 } 419 }
405 420
406 void StatusAreaWidget::UpdateShouldShowLauncher() {
407 // If any bubble is visible, we should show the launcher.
408 bool should_show_launcher =
409 (system_tray_ && system_tray_->HasSystemBubble()) ||
410 (web_notification_tray_ &&
411 web_notification_tray_->IsMessageCenterBubbleVisible());
412 if (!should_show_launcher && Shell::GetInstance()->shelf()->IsVisible()) {
413 // If the launcher is currently visible, don't hide the launcher if
414 // the mouse is in this widget or in any notification bubbles.
415 should_show_launcher =
416 (GetWindowBoundsInScreen().Contains(
417 gfx::Screen::GetCursorScreenPoint())) ||
418 (system_tray_ && system_tray_->IsMouseInNotificationBubble()) ||
419 (web_notification_tray_ &&
420 web_notification_tray_->IsMouseInNotificationBubble());
421 }
422 if (should_show_launcher != should_show_launcher_) {
423 should_show_launcher_ = should_show_launcher;
424 Shell::GetInstance()->shelf()->UpdateAutoHideState();
425 }
426 }
427
428 } // namespace internal 421 } // namespace internal
429 } // namespace ash 422 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/status_area_widget.h ('k') | ash/system/tray/system_tray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698