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

Side by Side Diff: chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.mm

Issue 21308002: Update Mac notification tray behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h" 5 #include "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/i18n/number_formatting.h" 8 #include "base/i18n/number_formatting.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 base::MessageLoop::current()->PostTask(FROM_HERE, 69 base::MessageLoop::current()->PostTask(FROM_HERE,
70 base::Bind(&MessageCenterTrayBridge::OpenTrayWindow, 70 base::Bind(&MessageCenterTrayBridge::OpenTrayWindow,
71 weak_ptr_factory_.GetWeakPtr())); 71 weak_ptr_factory_.GetWeakPtr()));
72 return true; 72 return true;
73 } 73 }
74 74
75 void MessageCenterTrayBridge::HideMessageCenter() { 75 void MessageCenterTrayBridge::HideMessageCenter() {
76 [status_item_view_ setHighlight:NO]; 76 [status_item_view_ setHighlight:NO];
77 [tray_controller_ close]; 77 [tray_controller_ close];
78 tray_controller_.autorelease(); 78 tray_controller_.autorelease();
79 UpdateStatusItem();
79 } 80 }
80 81
81 bool MessageCenterTrayBridge::ShowNotifierSettings() { 82 bool MessageCenterTrayBridge::ShowNotifierSettings() {
82 // This method needs to be implemented when the context menu of each 83 // This method needs to be implemented when the context menu of each
83 // notification is ready and it contains 'settings' menu item. 84 // notification is ready and it contains 'settings' menu item.
84 return false; 85 return false;
85 } 86 }
86 87
87 void MessageCenterTrayBridge::UpdateStatusItem() { 88 void MessageCenterTrayBridge::UpdateStatusItem() {
88 // Only show the status item if there are notifications. 89 // Only show the status item if there are notifications.
Nico 2013/07/31 00:09:41 remove comment
dewittj 2013/07/31 00:37:09 Done.
89 if (message_center_->NotificationCount() == 0) {
90 [status_item_view_ removeItem];
91 status_item_view_.reset();
92 return;
93 }
94
95 if (!status_item_view_) { 90 if (!status_item_view_) {
96 status_item_view_.reset([[MCStatusItemView alloc] init]); 91 status_item_view_.reset([[MCStatusItemView alloc] init]);
97 [status_item_view_ setCallback:^{ tray_->ToggleMessageCenterBubble(); }]; 92 [status_item_view_ setCallback:^{ tray_->ToggleMessageCenterBubble(); }];
98 } 93 }
99 94
95 // We want a static message center icon while it's visible.
96 if (message_center()->IsMessageCenterVisible())
97 return;
98
100 size_t unread_count = message_center_->UnreadNotificationCount(); 99 size_t unread_count = message_center_->UnreadNotificationCount();
101 [status_item_view_ setUnreadCount:unread_count]; 100 bool quiet_mode = message_center_->IsQuietMode();
101 [status_item_view_ setUnreadCount:unread_count withQuietMode:quiet_mode];
102 102
103 string16 product_name = l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); 103 string16 product_name = l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME);
104 if (unread_count > 0) { 104 if (unread_count > 0) {
105 string16 unread_count_string = base::FormatNumber(unread_count); 105 string16 unread_count_string = base::FormatNumber(unread_count);
106 [status_item_view_ setToolTip: 106 [status_item_view_ setToolTip:
107 l10n_util::GetNSStringF(IDS_MESSAGE_CENTER_TOOLTIP_UNREAD, 107 l10n_util::GetNSStringF(IDS_MESSAGE_CENTER_TOOLTIP_UNREAD,
108 product_name, unread_count_string)]; 108 product_name, unread_count_string)];
109 } else { 109 } else {
110 [status_item_view_ setToolTip: 110 [status_item_view_ setToolTip:
111 l10n_util::GetNSStringF(IDS_MESSAGE_CENTER_TOOLTIP, product_name)]; 111 l10n_util::GetNSStringF(IDS_MESSAGE_CENTER_TOOLTIP, product_name)];
112 } 112 }
113 } 113 }
114 114
115 void MessageCenterTrayBridge::OpenTrayWindow() { 115 void MessageCenterTrayBridge::OpenTrayWindow() {
116 DCHECK(!tray_controller_); 116 DCHECK(!tray_controller_);
117 tray_controller_.reset( 117 tray_controller_.reset(
118 [[MCTrayController alloc] initWithMessageCenterTray:tray_.get()]); 118 [[MCTrayController alloc] initWithMessageCenterTray:tray_.get()]);
119 119
120 UpdateStatusItem(); 120 UpdateStatusItem();
121 121
122 [status_item_view_ setHighlight:YES]; 122 [status_item_view_ setHighlight:YES];
123 NSRect frame = [[status_item_view_ window] frame]; 123 NSRect frame = [[status_item_view_ window] frame];
124 [tray_controller_ showTrayAtRightOf:NSMakePoint(NSMinX(frame), 124 [tray_controller_ showTrayAtRightOf:NSMakePoint(NSMinX(frame),
125 NSMinY(frame)) 125 NSMinY(frame))
126 atLeftOf:NSMakePoint(NSMaxX(frame), 126 atLeftOf:NSMakePoint(NSMaxX(frame),
127 NSMinY(frame))]; 127 NSMinY(frame))];
128 } 128 }
OLDNEW
« no previous file with comments | « no previous file | ui/message_center/cocoa/status_item_view.h » ('j') | ui/message_center/cocoa/status_item_view.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698