| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/metrics/user_metrics_recorder.h" | 8 #include "ash/metrics/user_metrics_recorder.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" | 9 #include "ash/shelf/shelf_layout_manager.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 height = std::max( | 581 height = std::max( |
| 582 0, work_area.height() - bubble_view->GetBoundsInScreen().y()); | 582 0, work_area.height() - bubble_view->GetBoundsInScreen().y()); |
| 583 } else { | 583 } else { |
| 584 height = std::max( | 584 height = std::max( |
| 585 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y()); | 585 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y()); |
| 586 } | 586 } |
| 587 } | 587 } |
| 588 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); | 588 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); |
| 589 } | 589 } |
| 590 | 590 |
| 591 base::string16 SystemTray::GetAccessibleTimeString( |
| 592 const base::Time& now) const { |
| 593 base::HourClockType hour_type = |
| 594 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); |
| 595 return base::TimeFormatTimeOfDayWithHourClockType( |
| 596 now, hour_type, base::kKeepAmPm); |
| 597 } |
| 598 |
| 591 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { | 599 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { |
| 592 if (alignment == shelf_alignment()) | 600 if (alignment == shelf_alignment()) |
| 593 return; | 601 return; |
| 594 TrayBackgroundView::SetShelfAlignment(alignment); | 602 TrayBackgroundView::SetShelfAlignment(alignment); |
| 595 UpdateAfterShelfAlignmentChange(alignment); | 603 UpdateAfterShelfAlignmentChange(alignment); |
| 596 // Destroy any existing bubble so that it is rebuilt correctly. | 604 // Destroy any existing bubble so that it is rebuilt correctly. |
| 597 CloseSystemBubbleAndDeactivateSystemTray(); | 605 CloseSystemBubbleAndDeactivateSystemTray(); |
| 598 // Rebuild any notification bubble. | 606 // Rebuild any notification bubble. |
| 599 if (notification_bubble_) { | 607 if (notification_bubble_) { |
| 600 notification_bubble_.reset(); | 608 notification_bubble_.reset(); |
| 601 UpdateNotificationBubble(); | 609 UpdateNotificationBubble(); |
| 602 } | 610 } |
| 603 } | 611 } |
| 604 | 612 |
| 605 void SystemTray::AnchorUpdated() { | 613 void SystemTray::AnchorUpdated() { |
| 606 if (notification_bubble_) { | 614 if (notification_bubble_) { |
| 607 notification_bubble_->bubble_view()->UpdateBubble(); | 615 notification_bubble_->bubble_view()->UpdateBubble(); |
| 608 // Ensure that the notification buble is above the shelf/status area. | 616 // Ensure that the notification buble is above the shelf/status area. |
| 609 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); | 617 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
| 610 UpdateBubbleViewArrow(notification_bubble_->bubble_view()); | 618 UpdateBubbleViewArrow(notification_bubble_->bubble_view()); |
| 611 } | 619 } |
| 612 if (system_bubble_) { | 620 if (system_bubble_) { |
| 613 system_bubble_->bubble_view()->UpdateBubble(); | 621 system_bubble_->bubble_view()->UpdateBubble(); |
| 614 UpdateBubbleViewArrow(system_bubble_->bubble_view()); | 622 UpdateBubbleViewArrow(system_bubble_->bubble_view()); |
| 615 } | 623 } |
| 616 } | 624 } |
| 617 | 625 |
| 618 base::string16 SystemTray::GetAccessibleNameForTray() { | 626 base::string16 SystemTray::GetAccessibleNameForTray() { |
| 619 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME); | 627 base::string16 time = GetAccessibleTimeString(base::Time::Now()); |
| 628 base::string16 battery = PowerStatus::Get()->GetShortAccessibleNameString(); |
| 629 return l10n_util::GetStringFUTF16( |
| 630 IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, time, battery); |
| 620 } | 631 } |
| 621 | 632 |
| 622 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { | 633 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { |
| 623 UpdateWebNotifications(); | 634 UpdateWebNotifications(); |
| 624 } | 635 } |
| 625 | 636 |
| 626 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { | 637 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { |
| 627 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { | 638 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { |
| 628 DestroySystemBubble(); | 639 DestroySystemBubble(); |
| 629 UpdateNotificationBubble(); // State changed, re-create notifications. | 640 UpdateNotificationBubble(); // State changed, re-create notifications. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 system_bubble_.reset(); | 718 system_bubble_.reset(); |
| 708 // When closing a system bubble with the alternate shelf layout, we need to | 719 // When closing a system bubble with the alternate shelf layout, we need to |
| 709 // turn off the active tinting of the shelf. | 720 // turn off the active tinting of the shelf. |
| 710 if (full_system_tray_menu_) { | 721 if (full_system_tray_menu_) { |
| 711 SetDrawBackgroundAsActive(false); | 722 SetDrawBackgroundAsActive(false); |
| 712 full_system_tray_menu_ = false; | 723 full_system_tray_menu_ = false; |
| 713 } | 724 } |
| 714 } | 725 } |
| 715 | 726 |
| 716 } // namespace ash | 727 } // namespace ash |
| OLD | NEW |