Chromium Code Reviews| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 32 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" | 32 #include "chrome/browser/ui/cocoa/notifications/notification_constants_mac.h" |
| 33 #import "chrome/browser/ui/cocoa/notifications/notification_delivery.h" | 33 #import "chrome/browser/ui/cocoa/notifications/notification_delivery.h" |
| 34 #import "chrome/browser/ui/cocoa/notifications/notification_response_builder_mac .h" | 34 #import "chrome/browser/ui/cocoa/notifications/notification_response_builder_mac .h" |
| 35 #include "chrome/common/features.h" | 35 #include "chrome/common/features.h" |
| 36 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
| 37 #include "components/crash/content/app/crashpad.h" | 37 #include "components/crash/content/app/crashpad.h" |
| 38 #include "components/url_formatter/elide_url.h" | 38 #include "components/url_formatter/elide_url.h" |
| 39 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onConstants.h" | 39 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onConstants.h" |
| 40 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 40 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
| 41 #include "ui/base/l10n/l10n_util_mac.h" | 41 #include "ui/base/l10n/l10n_util_mac.h" |
| 42 #include "ui/message_center/notification_types.h" | |
| 42 #include "url/gurl.h" | 43 #include "url/gurl.h" |
| 43 #include "url/origin.h" | 44 #include "url/origin.h" |
| 44 | 45 |
| 45 @class NSUserNotification; | 46 @class NSUserNotification; |
| 46 @class NSUserNotificationCenter; | 47 @class NSUserNotificationCenter; |
| 47 | 48 |
| 48 // The mapping from web notifications to NsUserNotification works as follows | 49 // The mapping from web notifications to NsUserNotification works as follows |
| 49 | 50 |
| 50 // notification#title in NSUserNotification.title | 51 // notification#title in NSUserNotification.title |
| 51 // notification#message in NSUserNotification.informativeText | 52 // notification#message in NSUserNotification.informativeText |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 [builder setOrigin:base::SysUTF8ToNSString(notification.origin_url().spec())]; | 248 [builder setOrigin:base::SysUTF8ToNSString(notification.origin_url().spec())]; |
| 248 [builder setNotificationId:base::SysUTF8ToNSString(notification_id)]; | 249 [builder setNotificationId:base::SysUTF8ToNSString(notification_id)]; |
| 249 [builder setProfileId:base::SysUTF8ToNSString(profile_id)]; | 250 [builder setProfileId:base::SysUTF8ToNSString(profile_id)]; |
| 250 [builder setIncognito:incognito]; | 251 [builder setIncognito:incognito]; |
| 251 [builder setNotificationType:[NSNumber numberWithInteger:notification_type]]; | 252 [builder setNotificationType:[NSNumber numberWithInteger:notification_type]]; |
| 252 | 253 |
| 253 // Send persistent notifications to the XPC service so they | 254 // Send persistent notifications to the XPC service so they |
| 254 // can be displayed as alerts. Chrome itself can only display | 255 // can be displayed as alerts. Chrome itself can only display |
| 255 // banners. | 256 // banners. |
| 256 // Progress Notifications are always considered persistent. | 257 // Progress Notifications are always considered persistent. |
| 257 if (notification.never_timeout() || notification.progress() > 0) { | 258 if (notification.never_timeout() || |
| 259 notification.type() == message_center::NOTIFICATION_TYPE_PROGRESS) { | |
|
Peter Beverloo
2017/04/18 13:40:09
Presumably we should use this for prefixing the ti
Miguel Garcia
2017/04/18 13:50:25
Done.
| |
| 258 NSDictionary* dict = [builder buildDictionary]; | 260 NSDictionary* dict = [builder buildDictionary]; |
| 259 [alert_dispatcher_ dispatchNotification:dict]; | 261 [alert_dispatcher_ dispatchNotification:dict]; |
| 260 } else { | 262 } else { |
| 261 NSUserNotification* toast = [builder buildUserNotification]; | 263 NSUserNotification* toast = [builder buildUserNotification]; |
| 262 [notification_center_ deliverNotification:toast]; | 264 [notification_center_ deliverNotification:toast]; |
| 263 } | 265 } |
| 264 } | 266 } |
| 265 | 267 |
| 266 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, | 268 void NotificationPlatformBridgeMac::Close(const std::string& profile_id, |
| 267 const std::string& notification_id) { | 269 const std::string& notification_id) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 base::scoped_nsobject<CrXPCMachPort> xpcPort( | 557 base::scoped_nsobject<CrXPCMachPort> xpcPort( |
| 556 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); | 558 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); |
| 557 [proxy setMachExceptionPort:xpcPort]; | 559 [proxy setMachExceptionPort:xpcPort]; |
| 558 setExceptionPort_ = YES; | 560 setExceptionPort_ = YES; |
| 559 } | 561 } |
| 560 | 562 |
| 561 return proxy; | 563 return proxy; |
| 562 } | 564 } |
| 563 | 565 |
| 564 @end | 566 @end |
| OLD | NEW |