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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "ui/views/view.h" | 44 #include "ui/views/view.h" |
45 | 45 |
46 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
47 #include "ash/system/chromeos/audio/tray_audio_chromeos.h" | 47 #include "ash/system/chromeos/audio/tray_audio_chromeos.h" |
48 #include "ash/system/chromeos/brightness/tray_brightness.h" | 48 #include "ash/system/chromeos/brightness/tray_brightness.h" |
49 #include "ash/system/chromeos/enterprise/tray_enterprise.h" | 49 #include "ash/system/chromeos/enterprise/tray_enterprise.h" |
50 #include "ash/system/chromeos/managed/tray_locally_managed_user.h" | 50 #include "ash/system/chromeos/managed/tray_locally_managed_user.h" |
51 #include "ash/system/chromeos/network/tray_network.h" | 51 #include "ash/system/chromeos/network/tray_network.h" |
52 #include "ash/system/chromeos/network/tray_sms.h" | 52 #include "ash/system/chromeos/network/tray_sms.h" |
53 #include "ash/system/chromeos/network/tray_vpn.h" | 53 #include "ash/system/chromeos/network/tray_vpn.h" |
| 54 #include "ash/system/chromeos/power/power_status.h" |
54 #include "ash/system/chromeos/power/tray_power.h" | 55 #include "ash/system/chromeos/power/tray_power.h" |
55 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" | 56 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" |
56 #include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" | 57 #include "ash/system/chromeos/screen_security/screen_capture_tray_item.h" |
57 #include "ash/system/chromeos/screen_security/screen_share_tray_item.h" | 58 #include "ash/system/chromeos/screen_security/screen_share_tray_item.h" |
58 #include "ash/system/chromeos/session/tray_session_length_limit.h" | 59 #include "ash/system/chromeos/session/tray_session_length_limit.h" |
59 #include "ash/system/chromeos/settings/tray_settings.h" | 60 #include "ash/system/chromeos/settings/tray_settings.h" |
60 #include "ash/system/chromeos/tray_caps_lock.h" | 61 #include "ash/system/chromeos/tray_caps_lock.h" |
61 #include "ash/system/chromeos/tray_display.h" | 62 #include "ash/system/chromeos/tray_display.h" |
62 #include "ash/system/chromeos/tray_tracing.h" | 63 #include "ash/system/chromeos/tray_tracing.h" |
63 #include "ash/system/tray/media_security/multi_profile_media_tray_item.h" | 64 #include "ash/system/tray/media_security/multi_profile_media_tray_item.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 UpdateWebNotifications(); | 396 UpdateWebNotifications(); |
396 } | 397 } |
397 | 398 |
398 void SystemTray::DestroyNotificationBubble() { | 399 void SystemTray::DestroyNotificationBubble() { |
399 if (notification_bubble_) { | 400 if (notification_bubble_) { |
400 notification_bubble_.reset(); | 401 notification_bubble_.reset(); |
401 UpdateWebNotifications(); | 402 UpdateWebNotifications(); |
402 } | 403 } |
403 } | 404 } |
404 | 405 |
| 406 base::string16 SystemTray::GetAccessibleNameForTray() { |
| 407 base::string16 time = GetAccessibleTimeString(base::Time::Now()); |
| 408 base::string16 battery = base::ASCIIToUTF16(""); |
| 409 #if defined(OS_CHROMEOS) |
| 410 battery = PowerStatus::Get()->GetAccessibleNameString(false); |
| 411 #endif |
| 412 return l10n_util::GetStringFUTF16( |
| 413 IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, time, battery); |
| 414 } |
| 415 |
405 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { | 416 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { |
406 // Don't attempt to align the arrow if the shelf is on the left or right. | 417 // Don't attempt to align the arrow if the shelf is on the left or right. |
407 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM && | 418 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM && |
408 shelf_alignment() != SHELF_ALIGNMENT_TOP) | 419 shelf_alignment() != SHELF_ALIGNMENT_TOP) |
409 return TrayBubbleView::InitParams::kArrowDefaultOffset; | 420 return TrayBubbleView::InitParams::kArrowDefaultOffset; |
410 | 421 |
411 std::map<SystemTrayItem*, views::View*>::const_iterator it = | 422 std::map<SystemTrayItem*, views::View*>::const_iterator it = |
412 tray_item_map_.find(item); | 423 tray_item_map_.find(item); |
413 if (it == tray_item_map_.end()) | 424 if (it == tray_item_map_.end()) |
414 return TrayBubbleView::InitParams::kArrowDefaultOffset; | 425 return TrayBubbleView::InitParams::kArrowDefaultOffset; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 height = std::max( | 592 height = std::max( |
582 0, work_area.height() - bubble_view->GetBoundsInScreen().y()); | 593 0, work_area.height() - bubble_view->GetBoundsInScreen().y()); |
583 } else { | 594 } else { |
584 height = std::max( | 595 height = std::max( |
585 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y()); | 596 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y()); |
586 } | 597 } |
587 } | 598 } |
588 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); | 599 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); |
589 } | 600 } |
590 | 601 |
| 602 base::string16 SystemTray::GetAccessibleTimeString( |
| 603 const base::Time& now) const { |
| 604 base::HourClockType hour_type = |
| 605 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType(); |
| 606 return base::TimeFormatTimeOfDayWithHourClockType( |
| 607 now, hour_type, base::kKeepAmPm); |
| 608 } |
| 609 |
591 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { | 610 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { |
592 if (alignment == shelf_alignment()) | 611 if (alignment == shelf_alignment()) |
593 return; | 612 return; |
594 TrayBackgroundView::SetShelfAlignment(alignment); | 613 TrayBackgroundView::SetShelfAlignment(alignment); |
595 UpdateAfterShelfAlignmentChange(alignment); | 614 UpdateAfterShelfAlignmentChange(alignment); |
596 // Destroy any existing bubble so that it is rebuilt correctly. | 615 // Destroy any existing bubble so that it is rebuilt correctly. |
597 CloseSystemBubbleAndDeactivateSystemTray(); | 616 CloseSystemBubbleAndDeactivateSystemTray(); |
598 // Rebuild any notification bubble. | 617 // Rebuild any notification bubble. |
599 if (notification_bubble_) { | 618 if (notification_bubble_) { |
600 notification_bubble_.reset(); | 619 notification_bubble_.reset(); |
601 UpdateNotificationBubble(); | 620 UpdateNotificationBubble(); |
602 } | 621 } |
603 } | 622 } |
604 | 623 |
605 void SystemTray::AnchorUpdated() { | 624 void SystemTray::AnchorUpdated() { |
606 if (notification_bubble_) { | 625 if (notification_bubble_) { |
607 notification_bubble_->bubble_view()->UpdateBubble(); | 626 notification_bubble_->bubble_view()->UpdateBubble(); |
608 // Ensure that the notification buble is above the shelf/status area. | 627 // Ensure that the notification buble is above the shelf/status area. |
609 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); | 628 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); |
610 UpdateBubbleViewArrow(notification_bubble_->bubble_view()); | 629 UpdateBubbleViewArrow(notification_bubble_->bubble_view()); |
611 } | 630 } |
612 if (system_bubble_) { | 631 if (system_bubble_) { |
613 system_bubble_->bubble_view()->UpdateBubble(); | 632 system_bubble_->bubble_view()->UpdateBubble(); |
614 UpdateBubbleViewArrow(system_bubble_->bubble_view()); | 633 UpdateBubbleViewArrow(system_bubble_->bubble_view()); |
615 } | 634 } |
616 } | 635 } |
617 | 636 |
618 base::string16 SystemTray::GetAccessibleNameForTray() { | |
619 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ACCESSIBLE_NAME); | |
620 } | |
621 | |
622 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { | 637 void SystemTray::BubbleResized(const TrayBubbleView* bubble_view) { |
623 UpdateWebNotifications(); | 638 UpdateWebNotifications(); |
624 } | 639 } |
625 | 640 |
626 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { | 641 void SystemTray::HideBubbleWithView(const TrayBubbleView* bubble_view) { |
627 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { | 642 if (system_bubble_.get() && bubble_view == system_bubble_->bubble_view()) { |
628 DestroySystemBubble(); | 643 DestroySystemBubble(); |
629 UpdateNotificationBubble(); // State changed, re-create notifications. | 644 UpdateNotificationBubble(); // State changed, re-create notifications. |
630 GetShelfLayoutManager()->UpdateAutoHideState(); | 645 GetShelfLayoutManager()->UpdateAutoHideState(); |
631 } else if (notification_bubble_.get() && | 646 } else if (notification_bubble_.get() && |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 system_bubble_.reset(); | 722 system_bubble_.reset(); |
708 // When closing a system bubble with the alternate shelf layout, we need to | 723 // When closing a system bubble with the alternate shelf layout, we need to |
709 // turn off the active tinting of the shelf. | 724 // turn off the active tinting of the shelf. |
710 if (full_system_tray_menu_) { | 725 if (full_system_tray_menu_) { |
711 SetDrawBackgroundAsActive(false); | 726 SetDrawBackgroundAsActive(false); |
712 full_system_tray_menu_ = false; | 727 full_system_tray_menu_ = false; |
713 } | 728 } |
714 } | 729 } |
715 | 730 |
716 } // namespace ash | 731 } // namespace ash |
OLD | NEW |