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

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

Issue 380943002: Added battery level and time to the status tray's accessible name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: view storage Created 6 years, 5 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
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/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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 UpdateWebNotifications(); 395 UpdateWebNotifications();
396 } 396 }
397 397
398 void SystemTray::DestroyNotificationBubble() { 398 void SystemTray::DestroyNotificationBubble() {
399 if (notification_bubble_) { 399 if (notification_bubble_) {
400 notification_bubble_.reset(); 400 notification_bubble_.reset();
401 UpdateWebNotifications(); 401 UpdateWebNotifications();
402 } 402 }
403 } 403 }
404 404
405 base::string16 SystemTray::GetAccessibleNameForTray() {
406 base::string16 time = GetAccessibleTimeString(base::Time::Now());
407 base::string16 battery = PowerStatus::Get()->GetAccessibleNameString(false);
408 return l10n_util::GetStringFUTF16(
409 IDS_ASH_STATUS_TRAY_ACCESSIBLE_DESCRIPTION, time, battery);
410 }
411
405 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const { 412 int SystemTray::GetTrayXOffset(SystemTrayItem* item) const {
406 // Don't attempt to align the arrow if the shelf is on the left or right. 413 // Don't attempt to align the arrow if the shelf is on the left or right.
407 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM && 414 if (shelf_alignment() != SHELF_ALIGNMENT_BOTTOM &&
408 shelf_alignment() != SHELF_ALIGNMENT_TOP) 415 shelf_alignment() != SHELF_ALIGNMENT_TOP)
409 return TrayBubbleView::InitParams::kArrowDefaultOffset; 416 return TrayBubbleView::InitParams::kArrowDefaultOffset;
410 417
411 std::map<SystemTrayItem*, views::View*>::const_iterator it = 418 std::map<SystemTrayItem*, views::View*>::const_iterator it =
412 tray_item_map_.find(item); 419 tray_item_map_.find(item);
413 if (it == tray_item_map_.end()) 420 if (it == tray_item_map_.end())
414 return TrayBubbleView::InitParams::kArrowDefaultOffset; 421 return TrayBubbleView::InitParams::kArrowDefaultOffset;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 height = std::max( 588 height = std::max(
582 0, work_area.height() - bubble_view->GetBoundsInScreen().y()); 589 0, work_area.height() - bubble_view->GetBoundsInScreen().y());
583 } else { 590 } else {
584 height = std::max( 591 height = std::max(
585 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y()); 592 0, bubble_view->GetBoundsInScreen().bottom() - work_area.y());
586 } 593 }
587 } 594 }
588 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height); 595 status_area_widget()->web_notification_tray()->SetSystemTrayHeight(height);
589 } 596 }
590 597
598 base::string16 SystemTray::GetAccessibleTimeString(
599 const base::Time& now) const {
600 base::HourClockType hour_type =
601 ash::Shell::GetInstance()->system_tray_delegate()->GetHourClockType();
602 return base::TimeFormatTimeOfDayWithHourClockType(
603 now, hour_type, base::kKeepAmPm);
604 }
605
591 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) { 606 void SystemTray::SetShelfAlignment(ShelfAlignment alignment) {
592 if (alignment == shelf_alignment()) 607 if (alignment == shelf_alignment())
593 return; 608 return;
594 TrayBackgroundView::SetShelfAlignment(alignment); 609 TrayBackgroundView::SetShelfAlignment(alignment);
595 UpdateAfterShelfAlignmentChange(alignment); 610 UpdateAfterShelfAlignmentChange(alignment);
596 // Destroy any existing bubble so that it is rebuilt correctly. 611 // Destroy any existing bubble so that it is rebuilt correctly.
597 CloseSystemBubbleAndDeactivateSystemTray(); 612 CloseSystemBubbleAndDeactivateSystemTray();
598 // Rebuild any notification bubble. 613 // Rebuild any notification bubble.
599 if (notification_bubble_) { 614 if (notification_bubble_) {
600 notification_bubble_.reset(); 615 notification_bubble_.reset();
601 UpdateNotificationBubble(); 616 UpdateNotificationBubble();
602 } 617 }
603 } 618 }
604 619
605 void SystemTray::AnchorUpdated() { 620 void SystemTray::AnchorUpdated() {
606 if (notification_bubble_) { 621 if (notification_bubble_) {
607 notification_bubble_->bubble_view()->UpdateBubble(); 622 notification_bubble_->bubble_view()->UpdateBubble();
608 // Ensure that the notification buble is above the shelf/status area. 623 // Ensure that the notification buble is above the shelf/status area.
609 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); 624 notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
610 UpdateBubbleViewArrow(notification_bubble_->bubble_view()); 625 UpdateBubbleViewArrow(notification_bubble_->bubble_view());
611 } 626 }
612 if (system_bubble_) { 627 if (system_bubble_) {
613 system_bubble_->bubble_view()->UpdateBubble(); 628 system_bubble_->bubble_view()->UpdateBubble();
614 UpdateBubbleViewArrow(system_bubble_->bubble_view()); 629 UpdateBubbleViewArrow(system_bubble_->bubble_view());
615 } 630 }
616 } 631 }
617 632
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) { 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.
630 GetShelfLayoutManager()->UpdateAutoHideState(); 641 GetShelfLayoutManager()->UpdateAutoHideState();
631 } else if (notification_bubble_.get() && 642 } else if (notification_bubble_.get() &&
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698