OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_platform_bridge_mac.h" | 5 #include "chrome/browser/notifications/notification_platform_bridge_mac.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/notifications/notification.h" | 14 #include "chrome/browser/notifications/notification.h" |
| 15 #include "chrome/browser/notifications/notification_builder_mac.h" |
15 #include "chrome/browser/notifications/notification_display_service_factory.h" | 16 #include "chrome/browser/notifications/notification_display_service_factory.h" |
16 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 17 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
17 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 18 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 20 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" | |
21 #include "chrome/grit/generated_resources.h" | 21 #include "chrome/grit/generated_resources.h" |
22 #include "components/url_formatter/elide_url.h" | 22 #include "components/url_formatter/elide_url.h" |
23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onConstants.h" | 23 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati
onConstants.h" |
24 #include "ui/base/l10n/l10n_util_mac.h" | 24 #include "ui/base/l10n/l10n_util_mac.h" |
25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
26 #include "url/origin.h" | 26 #include "url/origin.h" |
27 | 27 |
28 @class NSUserNotification; | 28 @class NSUserNotification; |
29 @class NSUserNotificationCenter; | 29 @class NSUserNotificationCenter; |
30 | 30 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 } | 128 } |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 [builder setOrigin:base::SysUTF8ToNSString(notification.origin_url().spec())]; | 132 [builder setOrigin:base::SysUTF8ToNSString(notification.origin_url().spec())]; |
133 [builder setNotificationId:base::SysUTF8ToNSString(notification_id)]; | 133 [builder setNotificationId:base::SysUTF8ToNSString(notification_id)]; |
134 [builder setProfileId:base::SysUTF8ToNSString(profile_id)]; | 134 [builder setProfileId:base::SysUTF8ToNSString(profile_id)]; |
135 [builder setIncognito:incognito]; | 135 [builder setIncognito:incognito]; |
136 | 136 |
137 NSUserNotification* toast = [builder buildUserNotification]; | 137 NSUserNotification* toast = [builder buildUserNotification]; |
| 138 |
138 [notification_center_ deliverNotification:toast]; | 139 [notification_center_ deliverNotification:toast]; |
139 } | 140 } |
140 | 141 |
141 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, | 142 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, |
142 const std::string& notification_id) { | 143 const std::string& notification_id) { |
143 NSString* candidate_id = base::SysUTF8ToNSString(notification_id); | 144 NSString* candidate_id = base::SysUTF8ToNSString(notification_id); |
144 | 145 |
145 NSString* current_profile_id = base::SysUTF8ToNSString(profile_id); | 146 NSString* current_profile_id = base::SysUTF8ToNSString(profile_id); |
146 for (NSUserNotification* toast in | 147 for (NSUserNotification* toast in |
147 [notification_center_ deliveredNotifications]) { | 148 [notification_center_ deliveredNotifications]) { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 [isIncognito boolValue], origin, persistentId, buttonIndex); | 254 [isIncognito boolValue], origin, persistentId, buttonIndex); |
254 } | 255 } |
255 | 256 |
256 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 257 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
257 shouldPresentNotification:(NSUserNotification*)nsNotification { | 258 shouldPresentNotification:(NSUserNotification*)nsNotification { |
258 // Always display notifications, regardless of whether the app is foreground. | 259 // Always display notifications, regardless of whether the app is foreground. |
259 return YES; | 260 return YES; |
260 } | 261 } |
261 | 262 |
262 @end | 263 @end |
OLD | NEW |