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

Side by Side Diff: ash/system/web_notification/web_notification_tray.cc

Issue 10825389: Fix accessability for web notification tray. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix asan bug Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | ash/wm/shelf_layout_manager.cc » ('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/web_notification/web_notification_tray.h" 5 #include "ash/system/web_notification/web_notification_tray.h"
6 6
7 #include "ash/system/status_area_widget.h" 7 #include "ash/system/status_area_widget.h"
8 #include "ash/system/tray/system_tray.h"
9 #include "ash/system/tray/tray_bubble_view.h" 8 #include "ash/system/tray/tray_bubble_view.h"
10 #include "ash/system/tray/tray_constants.h" 9 #include "ash/system/tray/tray_constants.h"
11 #include "ash/system/tray/tray_views.h" 10 #include "ash/system/tray/tray_views.h"
12 #include "base/bind.h" 11 #include "base/bind.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
15 #include "base/timer.h" 14 #include "base/timer.h"
16 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
17 #include "grit/ash_strings.h" 16 #include "grit/ash_strings.h"
18 #include "grit/ui_resources.h" 17 #include "grit/ui_resources.h"
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 bubble_view_(NULL), 709 bubble_view_(NULL),
711 bubble_widget_(NULL), 710 bubble_widget_(NULL),
712 contents_view_(NULL), 711 contents_view_(NULL),
713 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { 712 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
714 views::View* anchor = tray->tray_container(); 713 views::View* anchor = tray->tray_container();
715 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY, 714 TrayBubbleView::InitParams init_params(TrayBubbleView::ANCHOR_TYPE_TRAY,
716 tray->shelf_alignment()); 715 tray->shelf_alignment());
717 init_params.bubble_width = kWebNotificationWidth; 716 init_params.bubble_width = kWebNotificationWidth;
718 if (bubble_type == BUBBLE_TYPE_MESAGE_CENTER) { 717 if (bubble_type == BUBBLE_TYPE_MESAGE_CENTER) {
719 init_params.max_height = kWebNotificationBubbleMaxHeight; 718 init_params.max_height = kWebNotificationBubbleMaxHeight;
719 init_params.can_activate = true;
720 } else { 720 } else {
721 init_params.arrow_color = kBackgroundColor; 721 init_params.arrow_color = kBackgroundColor;
722 init_params.close_on_deactivate = false; 722 init_params.close_on_deactivate = false;
723 } 723 }
724 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) { 724 if (tray_->shelf_alignment() == SHELF_ALIGNMENT_BOTTOM) {
725 gfx::Point bounds(anchor->width() / 2, 0); 725 gfx::Point bounds(anchor->width() / 2, 0);
726 ConvertPointToWidget(anchor, &bounds); 726 ConvertPointToWidget(anchor, &bounds);
727 init_params.arrow_offset = bounds.x(); 727 init_params.arrow_offset = bounds.x();
728 } 728 }
729 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params); 729 bubble_view_ = TrayBubbleView::Create(anchor, this, init_params);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 virtual void OnMouseExitedView() OVERRIDE { 783 virtual void OnMouseExitedView() OVERRIDE {
784 StartAutoCloseTimer(); 784 StartAutoCloseTimer();
785 tray_->UpdateShouldShowLauncher(); 785 tray_->UpdateShouldShowLauncher();
786 } 786 }
787 787
788 virtual void OnClickedOutsideView() OVERRIDE { 788 virtual void OnClickedOutsideView() OVERRIDE {
789 // May delete |this|. 789 // May delete |this|.
790 tray_->HideMessageCenterBubble(); 790 tray_->HideMessageCenterBubble();
791 } 791 }
792 792
793 virtual string16 GetAccessibleName() OVERRIDE {
794 return tray_->GetAccessibleName();
795 }
796
793 // Overridden from views::WidgetObserver: 797 // Overridden from views::WidgetObserver:
794 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE { 798 virtual void OnWidgetClosing(views::Widget* widget) OVERRIDE {
795 CHECK_EQ(bubble_widget_, widget); 799 CHECK_EQ(bubble_widget_, widget);
796 bubble_widget_ = NULL; 800 bubble_widget_ = NULL;
797 tray_->HideBubble(this); // Will destroy |this|. 801 tray_->HideBubble(this); // Will destroy |this|.
798 } 802 }
799 803
800 private: 804 private:
801 void UpdateBubbleView() { 805 void UpdateBubbleView() {
802 const WebNotificationList::Notifications& notifications = 806 const WebNotificationList::Notifications& notifications =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 count_label_->SetHorizontalAlignment(views::Label::ALIGN_CENTER); 851 count_label_->SetHorizontalAlignment(views::Label::ALIGN_CENTER);
848 count_label_->SetEnabledColor(kMessageCountDimmedColor); 852 count_label_->SetEnabledColor(kMessageCountDimmedColor);
849 853
850 tray_container()->set_size(gfx::Size(kTrayWidth, kTrayHeight)); 854 tray_container()->set_size(gfx::Size(kTrayWidth, kTrayHeight));
851 tray_container()->AddChildView(count_label_); 855 tray_container()->AddChildView(count_label_);
852 856
853 UpdateTray(); 857 UpdateTray();
854 } 858 }
855 859
856 WebNotificationTray::~WebNotificationTray() { 860 WebNotificationTray::~WebNotificationTray() {
861 // Release any child views that might have back pointers before ~View().
862 notification_list_.reset();
863 message_center_bubble_.reset();
864 notification_bubble_.reset();
857 } 865 }
858 866
859 void WebNotificationTray::SetDelegate(Delegate* delegate) { 867 void WebNotificationTray::SetDelegate(Delegate* delegate) {
860 DCHECK(!delegate_); 868 DCHECK(!delegate_);
861 delegate_ = delegate; 869 delegate_ = delegate;
862 } 870 }
863 871
864 // Add/Update/RemoveNotification are called by the client code, i.e the 872 // Add/Update/RemoveNotification are called by the client code, i.e the
865 // Delegate implementation or its proxy. 873 // Delegate implementation or its proxy.
866 874
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 void WebNotificationTray::AnchorUpdated() { 998 void WebNotificationTray::AnchorUpdated() {
991 if (notification_bubble_.get()) { 999 if (notification_bubble_.get()) {
992 notification_bubble_->bubble_view()->UpdateBubble(); 1000 notification_bubble_->bubble_view()->UpdateBubble();
993 // Ensure that the notification buble is above the launcher/status area. 1001 // Ensure that the notification buble is above the launcher/status area.
994 notification_bubble_->bubble_view()->GetWidget()->StackAtTop(); 1002 notification_bubble_->bubble_view()->GetWidget()->StackAtTop();
995 } 1003 }
996 if (message_center_bubble_.get()) 1004 if (message_center_bubble_.get())
997 message_center_bubble_->bubble_view()->UpdateBubble(); 1005 message_center_bubble_->bubble_view()->UpdateBubble();
998 } 1006 }
999 1007
1008 string16 WebNotificationTray::GetAccessibleName() {
1009 return l10n_util::GetStringUTF16(
1010 IDS_ASH_WEB_NOTIFICATION_TRAY_ACCESSIBLE_NAME);
1011 }
1012
1000 // Protected methods (invoked only from Bubble and its child classes) 1013 // Protected methods (invoked only from Bubble and its child classes)
1001 1014
1002 void WebNotificationTray::SendRemoveNotification(const std::string& id) { 1015 void WebNotificationTray::SendRemoveNotification(const std::string& id) {
1003 // If this is the only notification in the list, close the bubble. 1016 // If this is the only notification in the list, close the bubble.
1004 if (notification_list_->notifications().size() == 1 && 1017 if (notification_list_->notifications().size() == 1 &&
1005 id == notification_list_->GetFirstId()) { 1018 id == notification_list_->GetFirstId()) {
1006 HideMessageCenterBubble(); 1019 HideMessageCenterBubble();
1007 } 1020 }
1008 if (delegate_) 1021 if (delegate_)
1009 delegate_->NotificationRemoved(id); 1022 delegate_->NotificationRemoved(id);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 } else if (bubble == notification_bubble()) { 1113 } else if (bubble == notification_bubble()) {
1101 HideNotificationBubble(); 1114 HideNotificationBubble();
1102 } 1115 }
1103 } 1116 }
1104 1117
1105 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const { 1118 bool WebNotificationTray::HasNotificationForTest(const std::string& id) const {
1106 return notification_list_->HasNotification(id); 1119 return notification_list_->HasNotification(id);
1107 } 1120 }
1108 1121
1109 } // namespace ash 1122 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/web_notification/web_notification_tray.h ('k') | ash/wm/shelf_layout_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698