| 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/tray/system_tray.h" | 5 #include "ash/system/tray/system_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/shelf/wm_shelf.h" |
| 8 #include "ash/common/shelf/wm_shelf_util.h" | 10 #include "ash/common/shelf/wm_shelf_util.h" |
| 9 #include "ash/common/shell_window_ids.h" | 11 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/system/date/tray_date.h" | 12 #include "ash/common/system/date/tray_date.h" |
| 11 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
| 12 #include "ash/common/system/tray/system_tray_item.h" | 14 #include "ash/common/system/tray/system_tray_item.h" |
| 13 #include "ash/common/system/tray/tray_constants.h" | 15 #include "ash/common/system/tray/tray_constants.h" |
| 14 #include "ash/common/system/update/tray_update.h" | 16 #include "ash/common/system/update/tray_update.h" |
| 15 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 16 #include "ash/metrics/user_metrics_recorder.h" | 18 #include "ash/metrics/user_metrics_recorder.h" |
| 17 #include "ash/shelf/shelf_layout_manager.h" | |
| 18 #include "ash/shelf/shelf_util.h" | |
| 19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
| 20 #include "ash/system/audio/tray_audio.h" | 20 #include "ash/system/audio/tray_audio.h" |
| 21 #include "ash/system/cast/tray_cast.h" | 21 #include "ash/system/cast/tray_cast.h" |
| 22 #include "ash/system/status_area_widget.h" | 22 #include "ash/system/status_area_widget.h" |
| 23 #include "ash/system/tray/tray_bubble_wrapper.h" | 23 #include "ash/system/tray/tray_bubble_wrapper.h" |
| 24 #include "ash/system/tray_accessibility.h" | 24 #include "ash/system/tray_accessibility.h" |
| 25 #include "ash/system/user/login_status.h" | 25 #include "ash/system/user/login_status.h" |
| 26 #include "ash/system/user/tray_user.h" | 26 #include "ash/system/user/tray_user.h" |
| 27 #include "ash/system/user/tray_user_separator.h" | 27 #include "ash/system/user/tray_user_separator.h" |
| 28 #include "ash/system/web_notification/web_notification_tray.h" | 28 #include "ash/system/web_notification/web_notification_tray.h" |
| 29 #include "base/logging.h" | 29 #include "base/logging.h" |
| 30 #include "base/metrics/histogram.h" | 30 #include "base/metrics/histogram.h" |
| 31 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
| 32 #include "base/timer/timer.h" | 32 #include "base/timer/timer.h" |
| 33 #include "grit/ash_strings.h" | 33 #include "grit/ash_strings.h" |
| 34 #include "ui/aura/window_event_dispatcher.h" | |
| 35 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 36 #include "ui/compositor/layer.h" | 35 #include "ui/compositor/layer.h" |
| 37 #include "ui/display/display.h" | 36 #include "ui/display/display.h" |
| 38 #include "ui/display/screen.h" | 37 #include "ui/display/screen.h" |
| 39 #include "ui/events/event_constants.h" | 38 #include "ui/events/event_constants.h" |
| 40 #include "ui/gfx/canvas.h" | 39 #include "ui/gfx/canvas.h" |
| 41 #include "ui/gfx/skia_util.h" | 40 #include "ui/gfx/skia_util.h" |
| 42 #include "ui/views/border.h" | 41 #include "ui/views/border.h" |
| 43 #include "ui/views/controls/label.h" | 42 #include "ui/views/controls/label.h" |
| 44 #include "ui/views/layout/box_layout.h" | 43 #include "ui/views/layout/box_layout.h" |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 default_bubble_height_ = system_bubble_->bubble_view()->height(); | 523 default_bubble_height_ = system_bubble_->bubble_view()->height(); |
| 525 | 524 |
| 526 if (detailed && items.size() > 0) | 525 if (detailed && items.size() > 0) |
| 527 detailed_item_ = items[0]; | 526 detailed_item_ = items[0]; |
| 528 else | 527 else |
| 529 detailed_item_ = NULL; | 528 detailed_item_ = NULL; |
| 530 | 529 |
| 531 UpdateNotificationBubble(); // State changed, re-create notifications. | 530 UpdateNotificationBubble(); // State changed, re-create notifications. |
| 532 if (!notification_bubble_) | 531 if (!notification_bubble_) |
| 533 UpdateWebNotifications(); | 532 UpdateWebNotifications(); |
| 534 GetShelfLayoutManager()->UpdateAutoHideState(); | 533 GetShelf()->UpdateAutoHideState(); |
| 535 | 534 |
| 536 // When we show the system menu in our alternate shelf layout, we need to | 535 // When we show the system menu in our alternate shelf layout, we need to |
| 537 // tint the background. | 536 // tint the background. |
| 538 if (full_system_tray_menu_) | 537 if (full_system_tray_menu_) |
| 539 SetDrawBackgroundAsActive(true); | 538 SetDrawBackgroundAsActive(true); |
| 540 } | 539 } |
| 541 | 540 |
| 542 void SystemTray::UpdateNotificationBubble() { | 541 void SystemTray::UpdateNotificationBubble() { |
| 543 // Only show the notification bubble if we have notifications. | 542 // Only show the notification bubble if we have notifications. |
| 544 if (notification_items_.empty()) { | 543 if (notification_items_.empty()) { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 } | 643 } |
| 645 | 644 |
| 646 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { | 645 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { |
| 647 UpdateWebNotifications(); | 646 UpdateWebNotifications(); |
| 648 } | 647 } |
| 649 | 648 |
| 650 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { | 649 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { |
| 651 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { | 650 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { |
| 652 DestroySystemBubble(); | 651 DestroySystemBubble(); |
| 653 UpdateNotificationBubble(); // State changed, re-create notifications. | 652 UpdateNotificationBubble(); // State changed, re-create notifications. |
| 654 GetShelfLayoutManager()->UpdateAutoHideState(); | 653 GetShelf()->UpdateAutoHideState(); |
| 655 } else if (notification_bubble_.get() && | 654 } else if (notification_bubble_.get() && |
| 656 bubble_view == notification_bubble_->bubble_view()) { | 655 bubble_view == notification_bubble_->bubble_view()) { |
| 657 DestroyNotificationBubble(); | 656 DestroyNotificationBubble(); |
| 658 } | 657 } |
| 659 } | 658 } |
| 660 | 659 |
| 661 void SystemTray::ClickedOutsideBubble() { | 660 void SystemTray::ClickedOutsideBubble() { |
| 662 if (!system_bubble_ || system_bubble_->is_persistent()) | 661 if (!system_bubble_ || system_bubble_->is_persistent()) |
| 663 return; | 662 return; |
| 664 HideBubbleWithView(system_bubble_->bubble_view()); | 663 HideBubbleWithView(system_bubble_->bubble_view()); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 .work_area() | 759 .work_area() |
| 761 .height(); | 760 .height(); |
| 762 if (work_area_height > 0) { | 761 if (work_area_height > 0) { |
| 763 UMA_HISTOGRAM_CUSTOM_COUNTS( | 762 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 764 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 763 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 765 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 764 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 766 } | 765 } |
| 767 } | 766 } |
| 768 | 767 |
| 769 } // namespace ash | 768 } // namespace ash |
| OLD | NEW |