| 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" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/i18n/number_formatting.h" | 12 #include "base/i18n/number_formatting.h" |
| 13 #include "base/mac/bundle_locations.h" | 13 #include "base/mac/bundle_locations.h" |
| 14 #include "base/mac/foundation_util.h" | 14 #include "base/mac/foundation_util.h" |
| 15 #include "base/mac/mac_util.h" | 15 #include "base/mac/mac_util.h" |
| 16 #include "base/mac/scoped_mach_port.h" | 16 #include "base/mac/scoped_mach_port.h" |
| 17 #include "base/mac/scoped_nsobject.h" | 17 #include "base/mac/scoped_nsobject.h" |
| 18 #include "base/metrics/histogram_macros.h" | 18 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/strings/nullable_string16.h" | 19 #include "base/strings/nullable_string16.h" |
| 20 #include "base/strings/string_number_conversions.h" | 20 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/strings/sys_string_conversions.h" | 21 #include "base/strings/sys_string_conversions.h" |
| 22 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/notifications/native_notification_display_service.h" | |
| 24 #include "chrome/browser/notifications/notification.h" | 23 #include "chrome/browser/notifications/notification.h" |
| 25 #include "chrome/browser/notifications/notification_common.h" | 24 #include "chrome/browser/notifications/notification_common.h" |
| 25 #include "chrome/browser/notifications/notification_display_service.h" |
| 26 #include "chrome/browser/notifications/notification_display_service_factory.h" | 26 #include "chrome/browser/notifications/notification_display_service_factory.h" |
| 27 #include "chrome/browser/notifications/persistent_notification_delegate.h" | 27 #include "chrome/browser/notifications/persistent_notification_delegate.h" |
| 28 #include "chrome/browser/notifications/platform_notification_service_impl.h" | 28 #include "chrome/browser/notifications/platform_notification_service_impl.h" |
| 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" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 const std::string& notification_id, | 72 const std::string& notification_id, |
| 73 int action_index, | 73 int action_index, |
| 74 Profile* profile) { | 74 Profile* profile) { |
| 75 if (!profile) { | 75 if (!profile) { |
| 76 // TODO(miguelg): Add UMA for this condition. | 76 // TODO(miguelg): Add UMA for this condition. |
| 77 // Perhaps propagate this through PersistentNotificationStatus. | 77 // Perhaps propagate this through PersistentNotificationStatus. |
| 78 LOG(WARNING) << "Profile not loaded correctly"; | 78 LOG(WARNING) << "Profile not loaded correctly"; |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 | 81 |
| 82 NotificationDisplayService* display_service = | 82 auto* display_service = |
| 83 NotificationDisplayServiceFactory::GetForProfile(profile); | 83 NotificationDisplayServiceFactory::GetForProfile(profile); |
| 84 | 84 |
| 85 static_cast<NativeNotificationDisplayService*>(display_service) | 85 display_service->ProcessNotificationOperation( |
| 86 ->ProcessNotificationOperation(operation, notification_type, origin, | 86 operation, notification_type, origin, notification_id, action_index, |
| 87 notification_id, action_index, | 87 base::NullableString16() /* reply */); |
| 88 base::NullableString16() /* reply */); | |
| 89 } | 88 } |
| 90 | 89 |
| 91 // Loads the profile and process the Notification response | 90 // Loads the profile and process the Notification response |
| 92 void DoProcessNotificationResponse(NotificationCommon::Operation operation, | 91 void DoProcessNotificationResponse(NotificationCommon::Operation operation, |
| 93 NotificationCommon::Type type, | 92 NotificationCommon::Type type, |
| 94 const std::string& profile_id, | 93 const std::string& profile_id, |
| 95 bool incognito, | 94 bool incognito, |
| 96 const std::string& origin, | 95 const std::string& origin, |
| 97 const std::string& notification_id, | 96 const std::string& notification_id, |
| 98 int32_t button_index) { | 97 int32_t button_index) { |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 base::scoped_nsobject<CrXPCMachPort> xpcPort( | 598 base::scoped_nsobject<CrXPCMachPort> xpcPort( |
| 600 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); | 599 [[CrXPCMachPort alloc] initWithMachSendRight:std::move(exceptionPort)]); |
| 601 [proxy setMachExceptionPort:xpcPort]; | 600 [proxy setMachExceptionPort:xpcPort]; |
| 602 setExceptionPort_ = YES; | 601 setExceptionPort_ = YES; |
| 603 } | 602 } |
| 604 | 603 |
| 605 return proxy; | 604 return proxy; |
| 606 } | 605 } |
| 607 | 606 |
| 608 @end | 607 @end |
| OLD | NEW |