| 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/memory/scoped_ptr.h" |
| 9 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| 10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/notifications/notification.h" | 12 #include "chrome/browser/notifications/notification.h" |
| 12 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" | 13 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
| 13 #include "chrome/browser/notifications/message_center_notification_manager.h" | 14 #include "chrome/browser/notifications/message_center_notification_manager.h" |
| 15 #include "chrome/browser/notifications/message_center_settings_controller.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 15 #include "ui/message_center/message_center_util.h" | 17 #include "ui/message_center/message_center_util.h" |
| 16 | 18 |
| 17 @class NSUserNotificationCenter; | 19 @class NSUserNotificationCenter; |
| 18 | 20 |
| 19 // Since NSUserNotification and NSUserNotificationCenter are new classes in | 21 // Since NSUserNotification and NSUserNotificationCenter are new classes in |
| 20 // 10.8, they cannot simply be declared with an @interface. An @implementation | 22 // 10.8, they cannot simply be declared with an @interface. An @implementation |
| 21 // is needed to link, but providing one would cause a runtime conflict when | 23 // is needed to link, but providing one would cause a runtime conflict when |
| 22 // running on 10.8. Instead, provide the interface defined as a protocol and | 24 // running on 10.8. Instead, provide the interface defined as a protocol and |
| 23 // use that instead, because sizeof(id<Protocol>) == sizeof(Class*). In order to | 25 // use that instead, because sizeof(id<Protocol>) == sizeof(Class*). In order to |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 delete model; | 96 delete model; |
| 95 } | 97 } |
| 96 | 98 |
| 97 //////////////////////////////////////////////////////////////////////////////// | 99 //////////////////////////////////////////////////////////////////////////////// |
| 98 | 100 |
| 99 // static | 101 // static |
| 100 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { | 102 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
| 101 // TODO(rsesek): Remove this function and merge it with the one in | 103 // TODO(rsesek): Remove this function and merge it with the one in |
| 102 // notification_ui_manager.cc. | 104 // notification_ui_manager.cc. |
| 103 if (DelegatesToMessageCenter()) { | 105 if (DelegatesToMessageCenter()) { |
| 106 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider( |
| 107 new MessageCenterSettingsController); |
| 104 return new MessageCenterNotificationManager( | 108 return new MessageCenterNotificationManager( |
| 105 g_browser_process->message_center(), local_state); | 109 g_browser_process->message_center(), |
| 110 local_state, |
| 111 settings_provider.Pass()); |
| 106 } | 112 } |
| 107 | 113 |
| 108 BalloonNotificationUIManager* balloon_manager = NULL; | 114 BalloonNotificationUIManager* balloon_manager = NULL; |
| 109 if (base::mac::IsOSMountainLionOrLater()) | 115 if (base::mac::IsOSMountainLionOrLater()) |
| 110 balloon_manager = new NotificationUIManagerMac(local_state); | 116 balloon_manager = new NotificationUIManagerMac(local_state); |
| 111 else | 117 else |
| 112 balloon_manager = new BalloonNotificationUIManager(local_state); | 118 balloon_manager = new BalloonNotificationUIManager(local_state); |
| 113 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); | 119 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); |
| 114 return balloon_manager; | 120 return balloon_manager; |
| 115 } | 121 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 notification->Click(); | 333 notification->Click(); |
| 328 } | 334 } |
| 329 | 335 |
| 330 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 336 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
| 331 shouldPresentNotification:(id<CrUserNotification>)nsNotification { | 337 shouldPresentNotification:(id<CrUserNotification>)nsNotification { |
| 332 // Always display notifications, regardless of whether the app is foreground. | 338 // Always display notifications, regardless of whether the app is foreground. |
| 333 return YES; | 339 return YES; |
| 334 } | 340 } |
| 335 | 341 |
| 336 @end | 342 @end |
| OLD | NEW |