| 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/login_status.h" | 8 #include "ash/common/login_status.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/wm_shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 SystemTray::~SystemTray() { | 142 SystemTray::~SystemTray() { |
| 143 // Destroy any child views that might have back pointers before ~View(). | 143 // Destroy any child views that might have back pointers before ~View(). |
| 144 system_bubble_.reset(); | 144 system_bubble_.reset(); |
| 145 notification_bubble_.reset(); | 145 notification_bubble_.reset(); |
| 146 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); | 146 for (std::vector<SystemTrayItem*>::iterator it = items_.begin(); |
| 147 it != items_.end(); ++it) { | 147 it != items_.end(); ++it) { |
| 148 (*it)->DestroyTrayView(); | 148 (*it)->DestroyTrayView(); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 void SystemTray::InitializeTrayItems( | 152 void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate, |
| 153 SystemTrayDelegate* delegate, | 153 WebNotificationTray* web_notification_tray, |
| 154 WebNotificationTray* web_notification_tray) { | 154 const gfx::Insets& insets) { |
| 155 DCHECK(web_notification_tray); | 155 DCHECK(web_notification_tray); |
| 156 web_notification_tray_ = web_notification_tray; | 156 web_notification_tray_ = web_notification_tray; |
| 157 TrayBackgroundView::Initialize(); | 157 TrayBackgroundView::Initialize(insets); |
| 158 CreateItems(delegate); | 158 CreateItems(delegate); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void SystemTray::Shutdown() { | 161 void SystemTray::Shutdown() { |
| 162 DCHECK(web_notification_tray_); | 162 DCHECK(web_notification_tray_); |
| 163 web_notification_tray_ = nullptr; | 163 web_notification_tray_ = nullptr; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { | 166 void SystemTray::CreateItems(SystemTrayDelegate* delegate) { |
| 167 WmShell* wm_shell = WmShell::Get(); | 167 WmShell* wm_shell = WmShell::Get(); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 } | 593 } |
| 594 | 594 |
| 595 base::string16 SystemTray::GetAccessibleTimeString( | 595 base::string16 SystemTray::GetAccessibleTimeString( |
| 596 const base::Time& now) const { | 596 const base::Time& now) const { |
| 597 base::HourClockType hour_type = | 597 base::HourClockType hour_type = |
| 598 WmShell::Get()->system_tray_delegate()->GetHourClockType(); | 598 WmShell::Get()->system_tray_delegate()->GetHourClockType(); |
| 599 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, | 599 return base::TimeFormatTimeOfDayWithHourClockType(now, hour_type, |
| 600 base::kKeepAmPm); | 600 base::kKeepAmPm); |
| 601 } | 601 } |
| 602 | 602 |
| 603 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { | 603 void SystemTray::SetShelfAlignment(ShelfAlignment alignment, |
| 604 const gfx::Insets& insets) { |
| 604 if (alignment == shelf_alignment()) | 605 if (alignment == shelf_alignment()) |
| 605 return; | 606 return; |
| 606 TrayBackgroundView::SetShelfAlignment(alignment); | 607 TrayBackgroundView::SetShelfAlignment(alignment, insets); |
| 607 UpdateAfterShelfAlignmentChange(alignment); | 608 UpdateAfterShelfAlignmentChange(alignment); |
| 608 // Destroy any existing bubble so that it is rebuilt correctly. | 609 // Destroy any existing bubble so that it is rebuilt correctly. |
| 609 CloseSystemBubbleAndDeactivateSystemTray(); | 610 CloseSystemBubbleAndDeactivateSystemTray(); |
| 610 // Rebuild any notification bubble. | 611 // Rebuild any notification bubble. |
| 611 if (notification_bubble_) { | 612 if (notification_bubble_) { |
| 612 notification_bubble_.reset(); | 613 notification_bubble_.reset(); |
| 613 UpdateNotificationBubble(); | 614 UpdateNotificationBubble(); |
| 614 // UpdateWebNotifications() should be called in UpdateNotificationBubble(). | 615 // UpdateWebNotifications() should be called in UpdateNotificationBubble(). |
| 615 } else if (!hide_notifications_) { | 616 } else if (!hide_notifications_) { |
| 616 UpdateWebNotifications(); | 617 UpdateWebNotifications(); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 763 .work_area() | 764 .work_area() |
| 764 .height(); | 765 .height(); |
| 765 if (work_area_height > 0) { | 766 if (work_area_height > 0) { |
| 766 UMA_HISTOGRAM_CUSTOM_COUNTS( | 767 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 767 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", | 768 "Ash.SystemMenu.PercentageOfWorkAreaHeightCoveredByMenu", |
| 768 100 * bubble_view->height() / work_area_height, 1, 300, 100); | 769 100 * bubble_view->height() / work_area_height, 1, 300, 100); |
| 769 } | 770 } |
| 770 } | 771 } |
| 771 | 772 |
| 772 } // namespace ash | 773 } // namespace ash |
| OLD | NEW |