| 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 "chrome/browser/notifications/notification_ui_manager_mac.h" | 5 #include "chrome/browser/notifications/notification_ui_manager_mac.h" |
| 6 | 6 |
| 7 #include "base/mac/cocoa_protocols.h" | 7 #include "base/mac/cocoa_protocols.h" |
| 8 #include "base/mac/mac_util.h" | 8 #include "base/mac/mac_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 NotificationUIManagerMac::~NotificationUIManagerMac() { | 122 NotificationUIManagerMac::~NotificationUIManagerMac() { |
| 123 CancelAll(); | 123 CancelAll(); |
| 124 } | 124 } |
| 125 | 125 |
| 126 void NotificationUIManagerMac::Add(const Notification& notification, | 126 void NotificationUIManagerMac::Add(const Notification& notification, |
| 127 Profile* profile) { | 127 Profile* profile) { |
| 128 if (notification.is_html()) { | 128 if (notification.is_html()) { |
| 129 builtin_manager_->Add(notification, profile); | 129 builtin_manager_->Add(notification, profile); |
| 130 } else { | 130 } else { |
| 131 id<CrUserNotification> replacee = FindNotificationWithReplacementId( | 131 if (!notification.replace_id().empty()) { |
| 132 notification.replace_id()); | 132 id<CrUserNotification> replacee = FindNotificationWithReplacementId( |
| 133 if (replacee) | 133 notification.replace_id()); |
| 134 RemoveNotification(replacee); | 134 if (replacee) |
| 135 RemoveNotification(replacee); |
| 136 } |
| 135 | 137 |
| 136 // Owned by ControllerNotification. | 138 // Owned by ControllerNotification. |
| 137 id<CrUserNotification> ns_notification = | 139 id<CrUserNotification> ns_notification = |
| 138 [[NSClassFromString(@"NSUserNotification") alloc] init]; | 140 [[NSClassFromString(@"NSUserNotification") alloc] init]; |
| 139 | 141 |
| 140 ns_notification.title = base::SysUTF16ToNSString(notification.title()); | 142 ns_notification.title = base::SysUTF16ToNSString(notification.title()); |
| 141 ns_notification.subtitle = | 143 ns_notification.subtitle = |
| 142 base::SysUTF16ToNSString(notification.display_source()); | 144 base::SysUTF16ToNSString(notification.display_source()); |
| 143 ns_notification.informativeText = | 145 ns_notification.informativeText = |
| 144 base::SysUTF16ToNSString(notification.body()); | 146 base::SysUTF16ToNSString(notification.body()); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 notification->Click(); | 300 notification->Click(); |
| 299 } | 301 } |
| 300 | 302 |
| 301 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 303 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
| 302 shouldPresentNotification:(id<CrUserNotification>)nsNotification { | 304 shouldPresentNotification:(id<CrUserNotification>)nsNotification { |
| 303 // Always display notifications, regardless of whether the app is foreground. | 305 // Always display notifications, regardless of whether the app is foreground. |
| 304 return YES; | 306 return YES; |
| 305 } | 307 } |
| 306 | 308 |
| 307 @end | 309 @end |
| OLD | NEW |