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 18 matching lines...) Expand all Loading... | |
| 29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" | 31 #include "chrome/browser/ui/cocoa/notifications/notification_builder_mac.h" |
| 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 "net/base/registry_controlled_domains/registry_controlled_domain.h" | |
| 39 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onConstants.h" | 40 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onConstants.h" |
| 40 #include "third_party/crashpad/crashpad/client/crashpad_client.h" | 41 #include "third_party/crashpad/crashpad/client/crashpad_client.h" |
| 41 #include "ui/base/l10n/l10n_util_mac.h" | 42 #include "ui/base/l10n/l10n_util_mac.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 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 ? notification.message() | 189 ? notification.message() |
| 189 : (notification.items().at(0).title + base::UTF8ToUTF16(" - ") + | 190 : (notification.items().at(0).title + base::UTF8ToUTF16(" - ") + |
| 190 notification.items().at(0).message); | 191 notification.items().at(0).message); |
| 191 | 192 |
| 192 [builder setContextMessage:base::SysUTF16ToNSString(context_message)]; | 193 [builder setContextMessage:base::SysUTF16ToNSString(context_message)]; |
| 193 | 194 |
| 194 bool requires_attribution = | 195 bool requires_attribution = |
| 195 notification.context_message().empty() && | 196 notification.context_message().empty() && |
| 196 notification_type != NotificationCommon::EXTENSION; | 197 notification_type != NotificationCommon::EXTENSION; |
| 197 | 198 |
| 198 base::string16 subtitle = | 199 NSString* subtitle = |
|
Peter Beverloo
2017/04/18 13:43:45
Could we maybe split this out into a helper functi
Miguel Garcia
2017/04/18 14:44:24
Done.
| |
| 199 requires_attribution | 200 requires_attribution |
| 200 ? url_formatter::FormatOriginForSecurityDisplay( | 201 ? base::SysUTF8ToNSString( |
| 201 url::Origin(notification.origin_url()), | 202 net::registry_controlled_domains::GetDomainAndRegistry( |
| 202 url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS) | 203 notification.origin_url(), |
| 203 : notification.context_message(); | 204 net::registry_controlled_domains:: |
| 205 INCLUDE_PRIVATE_REGISTRIES)) | |
|
Peter Beverloo
2017/04/18 13:43:45
The concern I have with this is that IP addresses
Miguel Garcia
2017/04/18 14:44:24
True, localhost was also affected so I went with a
| |
| 206 : base::SysUTF16ToNSString(notification.context_message()); | |
| 204 | 207 |
| 205 [builder setSubTitle:base::SysUTF16ToNSString(subtitle)]; | 208 [builder setSubTitle:subtitle]; |
| 206 if (!notification.icon().IsEmpty()) { | 209 if (!notification.icon().IsEmpty()) { |
| 207 [builder setIcon:notification.icon().ToNSImage()]; | 210 [builder setIcon:notification.icon().ToNSImage()]; |
| 208 } | 211 } |
| 209 | 212 |
| 210 [builder setShowSettingsButton:(notification_type != | 213 [builder setShowSettingsButton:(notification_type != |
| 211 NotificationCommon::EXTENSION)]; | 214 NotificationCommon::EXTENSION)]; |
| 212 std::vector<message_center::ButtonInfo> buttons = notification.buttons(); | 215 std::vector<message_center::ButtonInfo> buttons = notification.buttons(); |
| 213 if (!buttons.empty()) { | 216 if (!buttons.empty()) { |
| 214 DCHECK_LE(buttons.size(), blink::kWebNotificationMaxActions); | 217 DCHECK_LE(buttons.size(), blink::kWebNotificationMaxActions); |
| 215 NSString* buttonOne = SysUTF16ToNSString(buttons[0].title); | 218 NSString* buttonOne = SysUTF16ToNSString(buttons[0].title); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 base::scoped_nsobject<CrXPCMachPort> xpcPort( | 558 base::scoped_nsobject<CrXPCMachPort> xpcPort( |
| 556 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); | 559 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); |
| 557 [proxy setMachExceptionPort:xpcPort]; | 560 [proxy setMachExceptionPort:xpcPort]; |
| 558 setExceptionPort_ = YES; | 561 setExceptionPort_ = YES; |
| 559 } | 562 } |
| 560 | 563 |
| 561 return proxy; | 564 return proxy; |
| 562 } | 565 } |
| 563 | 566 |
| 564 @end | 567 @end |
| OLD | NEW |