| 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/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/notifications/notification.h" | 11 #include "chrome/browser/notifications/notification.h" |
| 11 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" | 12 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
| 12 | |
| 13 #if defined(ENABLE_MESSAGE_CENTER) | |
| 14 #include "chrome/browser/browser_process.h" | |
| 15 #include "chrome/browser/notifications/message_center_notification_manager.h" | 13 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 16 #include "ui/message_center/message_center_util.h" | 14 #include "ui/message_center/message_center_util.h" |
| 17 #endif | |
| 18 | 15 |
| 19 @class NSUserNotificationCenter; | 16 @class NSUserNotificationCenter; |
| 20 | 17 |
| 21 // Since NSUserNotification and NSUserNotificationCenter are new classes in | 18 // Since NSUserNotification and NSUserNotificationCenter are new classes in |
| 22 // 10.8, they cannot simply be declared with an @interface. An @implementation | 19 // 10.8, they cannot simply be declared with an @interface. An @implementation |
| 23 // is needed to link, but providing one would cause a runtime conflict when | 20 // is needed to link, but providing one would cause a runtime conflict when |
| 24 // running on 10.8. Instead, provide the interface defined as a protocol and | 21 // running on 10.8. Instead, provide the interface defined as a protocol and |
| 25 // use that instead, because sizeof(id<Protocol>) == sizeof(Class*). In order to | 22 // use that instead, because sizeof(id<Protocol>) == sizeof(Class*). In order to |
| 26 // instantiate, use NSClassFromString and simply assign the alloc/init'd result | 23 // instantiate, use NSClassFromString and simply assign the alloc/init'd result |
| 27 // to an instance of the proper protocol. This way the compiler, linker, and | 24 // to an instance of the proper protocol. This way the compiler, linker, and |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 90 |
| 94 NotificationUIManagerMac::ControllerNotification::~ControllerNotification() { | 91 NotificationUIManagerMac::ControllerNotification::~ControllerNotification() { |
| 95 [view release]; | 92 [view release]; |
| 96 delete model; | 93 delete model; |
| 97 } | 94 } |
| 98 | 95 |
| 99 //////////////////////////////////////////////////////////////////////////////// | 96 //////////////////////////////////////////////////////////////////////////////// |
| 100 | 97 |
| 101 // static | 98 // static |
| 102 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { | 99 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
| 103 #if defined(ENABLE_MESSAGE_CENTER) | |
| 104 // TODO(rsesek): Remove this function and merge it with the one in | 100 // TODO(rsesek): Remove this function and merge it with the one in |
| 105 // notification_ui_manager.cc. | 101 // notification_ui_manager.cc. |
| 106 if (DelegatesToMessageCenter()) { | 102 if (DelegatesToMessageCenter()) { |
| 107 return new MessageCenterNotificationManager( | 103 return new MessageCenterNotificationManager( |
| 108 g_browser_process->message_center()); | 104 g_browser_process->message_center()); |
| 109 } | 105 } |
| 110 #endif | |
| 111 | 106 |
| 112 BalloonNotificationUIManager* balloon_manager = NULL; | 107 BalloonNotificationUIManager* balloon_manager = NULL; |
| 113 if (base::mac::IsOSMountainLionOrLater()) | 108 if (base::mac::IsOSMountainLionOrLater()) |
| 114 balloon_manager = new NotificationUIManagerMac(local_state); | 109 balloon_manager = new NotificationUIManagerMac(local_state); |
| 115 else | 110 else |
| 116 balloon_manager = new BalloonNotificationUIManager(local_state); | 111 balloon_manager = new BalloonNotificationUIManager(local_state); |
| 117 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); | 112 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); |
| 118 return balloon_manager; | 113 return balloon_manager; |
| 119 } | 114 } |
| 120 | 115 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 notification->Click(); | 307 notification->Click(); |
| 313 } | 308 } |
| 314 | 309 |
| 315 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 310 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
| 316 shouldPresentNotification:(id<CrUserNotification>)nsNotification { | 311 shouldPresentNotification:(id<CrUserNotification>)nsNotification { |
| 317 // Always display notifications, regardless of whether the app is foreground. | 312 // Always display notifications, regardless of whether the app is foreground. |
| 318 return YES; | 313 return YES; |
| 319 } | 314 } |
| 320 | 315 |
| 321 @end | 316 @end |
| OLD | NEW |