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

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

Issue 2095663004: Revert of mash: Convert TrayBackgroundView to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.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/common/ash_switches.h" 7 #include "ash/common/ash_switches.h"
8 #include "ash/common/session/session_state_delegate.h" 8 #include "ash/common/session/session_state_delegate.h"
9 #include "ash/common/shelf/wm_shelf.h" 9 #include "ash/common/shelf/wm_shelf.h"
10 #include "ash/common/shelf/wm_shelf_util.h" 10 #include "ash/common/shelf/wm_shelf_util.h"
11 #include "ash/common/shell_window_ids.h" 11 #include "ash/common/shell_window_ids.h"
12 #include "ash/common/system/date/tray_date.h" 12 #include "ash/common/system/date/tray_date.h"
13 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
14 #include "ash/common/system/tray/system_tray_item.h" 14 #include "ash/common/system/tray/system_tray_item.h"
15 #include "ash/common/system/tray/tray_bubble_wrapper.h"
16 #include "ash/common/system/tray/tray_constants.h" 15 #include "ash/common/system/tray/tray_constants.h"
17 #include "ash/common/system/tray_accessibility.h" 16 #include "ash/common/system/tray_accessibility.h"
18 #include "ash/common/system/update/tray_update.h" 17 #include "ash/common/system/update/tray_update.h"
19 #include "ash/common/wm_lookup.h" 18 #include "ash/common/wm_lookup.h"
20 #include "ash/common/wm_root_window_controller.h" 19 #include "ash/common/wm_root_window_controller.h"
21 #include "ash/common/wm_shell.h" 20 #include "ash/common/wm_shell.h"
22 #include "ash/common/wm_window.h" 21 #include "ash/common/wm_window.h"
23 #include "ash/metrics/user_metrics_recorder.h" 22 #include "ash/metrics/user_metrics_recorder.h"
24 #include "ash/shell.h" 23 #include "ash/shell.h"
25 #include "ash/system/cast/tray_cast.h" 24 #include "ash/system/cast/tray_cast.h"
26 #include "ash/system/status_area_widget.h" 25 #include "ash/system/status_area_widget.h"
26 #include "ash/system/tray/tray_bubble_wrapper.h"
27 #include "ash/system/user/login_status.h" 27 #include "ash/system/user/login_status.h"
28 #include "ash/system/user/tray_user.h" 28 #include "ash/system/user/tray_user.h"
29 #include "ash/system/user/tray_user_separator.h" 29 #include "ash/system/user/tray_user_separator.h"
30 #include "ash/system/web_notification/web_notification_tray.h" 30 #include "ash/system/web_notification/web_notification_tray.h"
31 #include "base/logging.h" 31 #include "base/logging.h"
32 #include "base/metrics/histogram.h" 32 #include "base/metrics/histogram.h"
33 #include "base/strings/utf_string_conversions.h" 33 #include "base/strings/utf_string_conversions.h"
34 #include "base/timer/timer.h" 34 #include "base/timer/timer.h"
35 #include "grit/ash_strings.h" 35 #include "grit/ash_strings.h"
36 #include "ui/base/l10n/l10n_util.h" 36 #include "ui/base/l10n/l10n_util.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_; 124 std::unique_ptr<TrayBubbleWrapper> bubble_wrapper_;
125 bool is_persistent_; 125 bool is_persistent_;
126 126
127 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper); 127 DISALLOW_COPY_AND_ASSIGN(SystemBubbleWrapper);
128 }; 128 };
129 129
130 130
131 // SystemTray 131 // SystemTray
132 132
133 SystemTray::SystemTray(StatusAreaWidget* status_area_widget) 133 SystemTray::SystemTray(StatusAreaWidget* status_area_widget)
134 : TrayBackgroundView(status_area_widget->wm_shelf()), 134 : TrayBackgroundView(status_area_widget),
135 status_area_widget_(status_area_widget),
136 items_(), 135 items_(),
137 detailed_item_(nullptr), 136 detailed_item_(nullptr),
138 default_bubble_height_(0), 137 default_bubble_height_(0),
139 hide_notifications_(false), 138 hide_notifications_(false),
140 full_system_tray_menu_(false), 139 full_system_tray_menu_(false),
141 tray_accessibility_(nullptr), 140 tray_accessibility_(nullptr),
142 tray_cast_(nullptr), 141 tray_cast_(nullptr),
143 tray_date_(nullptr), 142 tray_date_(nullptr),
144 tray_update_(nullptr), 143 tray_update_(nullptr),
145 screen_capture_tray_item_(nullptr), 144 screen_capture_tray_item_(nullptr),
146 screen_share_tray_item_(nullptr) { 145 screen_share_tray_item_(nullptr) {
147 DCHECK(status_area_widget_);
148 SetContentsBackground(); 146 SetContentsBackground();
149 } 147 }
150 148
151 SystemTray::~SystemTray() { 149 SystemTray::~SystemTray() {
152 // Destroy any child views that might have back pointers before ~View(). 150 // Destroy any child views that might have back pointers before ~View().
153 system_bubble_.reset(); 151 system_bubble_.reset();
154 notification_bubble_.reset(); 152 notification_bubble_.reset();
155 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); 153 for (std::vector<SystemTrayItem*>::iterator it = items_.begin();
156 it != items_.end(); 154 it != items_.end();
157 ++it) { 155 ++it) {
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 default_bubble_height_ = system_bubble_->bubble_view()->height(); 525 default_bubble_height_ = system_bubble_->bubble_view()->height();
528 526
529 if (detailed && items.size() > 0) 527 if (detailed && items.size() > 0)
530 detailed_item_ = items[0]; 528 detailed_item_ = items[0];
531 else 529 else
532 detailed_item_ = NULL; 530 detailed_item_ = NULL;
533 531
534 UpdateNotificationBubble(); // State changed, re-create notifications. 532 UpdateNotificationBubble(); // State changed, re-create notifications.
535 if (!notification_bubble_) 533 if (!notification_bubble_)
536 UpdateWebNotifications(); 534 UpdateWebNotifications();
537 shelf()->UpdateAutoHideState(); 535 GetShelf()->UpdateAutoHideState();
538 536
539 // When we show the system menu in our alternate shelf layout, we need to 537 // When we show the system menu in our alternate shelf layout, we need to
540 // tint the background. 538 // tint the background.
541 if (full_system_tray_menu_) 539 if (full_system_tray_menu_)
542 SetDrawBackgroundAsActive(true); 540 SetDrawBackgroundAsActive(true);
543 } 541 }
544 542
545 void SystemTray::UpdateNotificationBubble() { 543 void SystemTray::UpdateNotificationBubble() {
546 // Only show the notification bubble if we have notifications. 544 // Only show the notification bubble if we have notifications.
547 if (notification_items_.empty()) { 545 if (notification_items_.empty()) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 596
599 int height = 0; 597 int height = 0;
600 if (bubble_view) { 598 if (bubble_view) {
601 gfx::Rect work_area = 599 gfx::Rect work_area =
602 display::Screen::GetScreen() 600 display::Screen::GetScreen()
603 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView()) 601 ->GetDisplayNearestWindow(bubble_view->GetWidget()->GetNativeView())
604 .work_area(); 602 .work_area();
605 height = 603 height =
606 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y()); 604 std::max(0, work_area.height() - bubble_view->GetBoundsInScreen().y());
607 } 605 }
608 status_area_widget_->web_notification_tray()->SetSystemTrayHeight(height); 606 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height);
609 } 607 }
610 608
611 base::string16 SystemTray::GetAccessibleTimeString( 609 base::string16 SystemTray::GetAccessibleTimeString(
612 const base::Time& now) const { 610 const base::Time& now) const {
613 base::HourClockType hour_type = 611 base::HourClockType hour_type =
614 ash::WmShell::Get()->system_tray_delegate()->GetHourClockType(); 612 ash::WmShell::Get()->system_tray_delegate()->GetHourClockType();
615 return base::TimeFormatTimeOfDayWithHourClockType( 613 return base::TimeFormatTimeOfDayWithHourClockType(
616 now, hour_type, base::kKeepAmPm); 614 now, hour_type, base::kKeepAmPm);
617 } 615 }
618 616
(...skipping 28 matching lines...) Expand all
647 } 645 }
648 646
649 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { 647 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) {
650 UpdateWebNotifications(); 648 UpdateWebNotifications();
651 } 649 }
652 650
653 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { 651 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) {
654 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { 652 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) {
655 DestroySystemBubble(); 653 DestroySystemBubble();
656 UpdateNotificationBubble(); // State changed, re-create notifications. 654 UpdateNotificationBubble(); // State changed, re-create notifications.
657 shelf()->UpdateAutoHideState(); 655 GetShelf()->UpdateAutoHideState();
658 } else if (notification_bubble_.get() && 656 } else if (notification_bubble_.get() &&
659 bubble_view == notification_bubble_->bubble_view()) { 657 bubble_view == notification_bubble_->bubble_view()) {
660 DestroyNotificationBubble(); 658 DestroyNotificationBubble();
661 } 659 }
662 } 660 }
663 661
664 void SystemTray::ClickedOutsideBubble() { 662 void SystemTray::ClickedOutsideBubble() {
665 if (!system_bubble_ || system_bubble_->is_persistent()) 663 if (!system_bubble_ || system_bubble_->is_persistent())
666 return; 664 return;
667 HideBubbleWithView(system_bubble_->bubble_view()); 665 HideBubbleWithView(system_bubble_->bubble_view());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 .work_area() 773 .work_area()
776 .height(); 774 .height();
777 if (work_area_height > 0) { 775 if (work_area_height > 0) {
778 UMA_HISTOGRAM_CUSTOM_COUNTS( 776 UMA_HISTOGRAM_CUSTOM_COUNTS(
779 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", 777 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu",
780 100 * bubble_view->height() / work_area_height, 1, 300, 100); 778 100 * bubble_view->height() / work_area_height, 1, 300, 100);
781 } 779 }
782 } 780 }
783 781
784 } // namespace ash 782 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/tray/system_tray.h ('k') | ash/system/tray/system_tray_bubble.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698