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

Side by Side Diff: ash/system/tray/system_tray.cc

Issue 20598004: Do not hide the web notification popups by the system tray, rather let them avoid (2nd) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 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
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/web_notification/web_notification_tray.h » ('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/tray/system_tray.h" 5 #include "ash/system/tray/system_tray.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/shelf/shelf_layout_manager.h" 8 #include "ash/shelf/shelf_layout_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell/panel_window.h" 10 #include "ash/shell/panel_window.h"
11 #include "ash/shell_window_ids.h" 11 #include "ash/shell_window_ids.h"
12 #include "ash/system/bluetooth/tray_bluetooth.h" 12 #include "ash/system/bluetooth/tray_bluetooth.h"
13 #include "ash/system/brightness/tray_brightness.h" 13 #include "ash/system/brightness/tray_brightness.h"
14 #include "ash/system/date/tray_date.h" 14 #include "ash/system/date/tray_date.h"
15 #include "ash/system/drive/tray_drive.h" 15 #include "ash/system/drive/tray_drive.h"
16 #include "ash/system/ime/tray_ime.h" 16 #include "ash/system/ime/tray_ime.h"
17 #include "ash/system/logout_button/tray_logout_button.h" 17 #include "ash/system/logout_button/tray_logout_button.h"
18 #include "ash/system/monitor/tray_monitor.h" 18 #include "ash/system/monitor/tray_monitor.h"
19 #include "ash/system/session_length_limit/tray_session_length_limit.h" 19 #include "ash/system/session_length_limit/tray_session_length_limit.h"
20 #include "ash/system/status_area_widget.h" 20 #include "ash/system/status_area_widget.h"
21 #include "ash/system/tray/system_tray_delegate.h" 21 #include "ash/system/tray/system_tray_delegate.h"
22 #include "ash/system/tray/system_tray_item.h" 22 #include "ash/system/tray/system_tray_item.h"
23 #include "ash/system/tray/tray_bubble_wrapper.h" 23 #include "ash/system/tray/tray_bubble_wrapper.h"
24 #include "ash/system/tray/tray_constants.h" 24 #include "ash/system/tray/tray_constants.h"
25 #include "ash/system/tray_accessibility.h" 25 #include "ash/system/tray_accessibility.h"
26 #include "ash/system/tray_caps_lock.h" 26 #include "ash/system/tray_caps_lock.h"
27 #include "ash/system/tray_update.h" 27 #include "ash/system/tray_update.h"
28 #include "ash/system/user/login_status.h" 28 #include "ash/system/user/login_status.h"
29 #include "ash/system/user/tray_user.h" 29 #include "ash/system/user/tray_user.h"
30 #include "ash/system/web_notification/web_notification_tray.h"
30 #include "base/command_line.h" 31 #include "base/command_line.h"
31 #include "base/logging.h" 32 #include "base/logging.h"
32 #include "base/strings/utf_string_conversions.h" 33 #include "base/strings/utf_string_conversions.h"
33 #include "base/timer/timer.h" 34 #include "base/timer/timer.h"
34 #include "grit/ash_strings.h" 35 #include "grit/ash_strings.h"
35 #include "ui/aura/root_window.h" 36 #include "ui/aura/root_window.h"
36 #include "ui/base/events/event_constants.h" 37 #include "ui/base/events/event_constants.h"
37 #include "ui/base/l10n/l10n_util.h" 38 #include "ui/base/l10n/l10n_util.h"
38 #include "ui/compositor/layer.h" 39 #include "ui/compositor/layer.h"
39 #include "ui/gfx/canvas.h" 40 #include "ui/gfx/canvas.h"
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 // Private methods. 367 // Private methods.
367 368
368 bool SystemTray::HasSystemBubbleType(SystemTrayBubble::BubbleType type) { 369 bool SystemTray::HasSystemBubbleType(SystemTrayBubble::BubbleType type) {
369 DCHECK(type != SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION); 370 DCHECK(type != SystemTrayBubble::BUBBLE_TYPE_NOTIFICATION);
370 return system_bubble_.get() && system_bubble_->bubble_type() == type; 371 return system_bubble_.get() && system_bubble_->bubble_type() == type;
371 } 372 }
372 373
373 void SystemTray::DestroySystemBubble() { 374 void SystemTray::DestroySystemBubble() {
374 system_bubble_.reset(); 375 system_bubble_.reset();
375 detailed_item_ = NULL; 376 detailed_item_ = NULL;
377 UpdateWebNotifications();
376 } 378 }
377 379
378 void SystemTray::DestroyNotificationBubble() { 380 void SystemTray::DestroyNotificationBubble() {
379 if (notification_bubble_) { 381 if (notification_bubble_) {
380 notification_bubble_.reset(); 382 notification_bubble_.reset();
381 status_area_widget()->SetHideWebNotifications(false); 383 UpdateWebNotifications();
382 } 384 }
383 } 385 }
384 386
385 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { 387 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const {
386 // Don't attempt to align the arrow if the shelf is on the left or right. 388 // Don't attempt to align the arrow if the shelf is on the left or right.
387 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM && 389 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM &&
388 shelf_alignment() != SHELF_ALIGNMENT_TOP) 390 shelf_alignment() != SHELF_ALIGNMENT_TOP)
389 return TrayBubbleView::InitParams::kArrowDefaultOffset; 391 return TrayBubbleView::InitParams::kArrowDefaultOffset;
390 392
391 std::map<SystemTrayItem*, views::View*>::const_iterator it = 393 std::map<SystemTrayItem*, views::View*>::const_iterator it =
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 // Save height of default view for creating detailed views directly. 472 // Save height of default view for creating detailed views directly.
471 if (!detailed) 473 if (!detailed)
472 default_bubble_height_ = system_bubble_->bubble_view()->height(); 474 default_bubble_height_ = system_bubble_->bubble_view()->height();
473 475
474 if (detailed && items.size() > 0) 476 if (detailed && items.size() > 0)
475 detailed_item_ = items[0]; 477 detailed_item_ = items[0];
476 else 478 else
477 detailed_item_ = NULL; 479 detailed_item_ = NULL;
478 480
479 UpdateNotificationBubble(); // State changed, re-create notifications. 481 UpdateNotificationBubble(); // State changed, re-create notifications.
480 status_area_widget()->SetHideWebNotifications(true); 482 if (!notification_bubble_)
483 UpdateWebNotifications();
481 GetShelfLayoutManager()->UpdateAutoHideState(); 484 GetShelfLayoutManager()->UpdateAutoHideState();
482 } 485 }
483 486
484 void SystemTray::UpdateNotificationBubble() { 487 void SystemTray::UpdateNotificationBubble() {
485 // Only show the notification bubble if we have notifications. 488 // Only show the notification bubble if we have notifications.
486 if (notification_items_.empty()) { 489 if (notification_items_.empty()) {
487 DestroyNotificationBubble(); 490 DestroyNotificationBubble();
488 return; 491 return;
489 } 492 }
490 // Destroy the existing bubble before constructing a new one. 493 // Destroy the existing bubble before constructing a new one.
(...skipping 29 matching lines...) Expand all
520 notification_bubble_->InitView(this, anchor, &init_params); 523 notification_bubble_->InitView(this, anchor, &init_params);
521 524
522 if (notification_bubble->bubble_view()->child_count() == 0) { 525 if (notification_bubble->bubble_view()->child_count() == 0) {
523 // It is possible that none of the items generated actual notifications. 526 // It is possible that none of the items generated actual notifications.
524 DestroyNotificationBubble(); 527 DestroyNotificationBubble();
525 return; 528 return;
526 } 529 }
527 if (hide_notifications_) 530 if (hide_notifications_)
528 notification_bubble->SetVisible(false); 531 notification_bubble->SetVisible(false);
529 else 532 else
530 status_area_widget()->SetHideWebNotifications(true); 533 UpdateWebNotifications();
534 }
535
536 void SystemTray::UpdateWebNotifications() {
537 TrayBubbleView* bubble_view = NULL;
538 if (notification_bubble_)
539 bubble_view = notification_bubble_->bubble_view();
540 else if (system_bubble_)
541 bubble_view = system_bubble_->bubble_view();
542
543 int height = 0;
544 if (bubble_view) {
545 gfx::Rect work_area = Shell::GetScreen()->GetDisplayNearestWindow(
546 bubble_view->GetWidget()->GetNativeView()).work_area();
547 if (GetShelfLayoutManager()->GetAlignment() != SHELF_ALIGNMENT_TOP) {
548 height = std::max(
549 0, work_area.height() - bubble_view->GetBoundsInScreen().y());
550 } else {
551 height = std::max(
552 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y());
553 }
554 }
555 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height);
531 } 556 }
532 557
533 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 558 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
534 if (alignment == shelf_alignment()) 559 if (alignment == shelf_alignment())
535 return; 560 return;
536 internal::TrayBackgroundView::SetShelfAlignment(alignment); 561 internal::TrayBackgroundView::SetShelfAlignment(alignment);
537 UpdateAfterShelfAlignmentChange(alignment); 562 UpdateAfterShelfAlignmentChange(alignment);
538 // Destroy any existing bubble so that it is rebuilt correctly. 563 // Destroy any existing bubble so that it is rebuilt correctly.
539 system_bubble_.reset(); 564 system_bubble_.reset();
540 // Rebuild any notification bubble. 565 // Rebuild any notification bubble.
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 ConvertPointToWidget(this, &point); 652 ConvertPointToWidget(this, &point);
628 arrow_offset = point.x(); 653 arrow_offset = point.x();
629 } 654 }
630 } 655 }
631 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset); 656 ShowDefaultViewWithOffset(BUBBLE_CREATE_NEW, arrow_offset);
632 } 657 }
633 return true; 658 return true;
634 } 659 }
635 660
636 } // namespace ash 661 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/web_notification/web_notification_tray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698