| 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" |
| 17 #include "chrome/browser/profiles/profile_info_cache.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "ui/message_center/message_center_util.h" | 19 #include "ui/message_center/message_center_util.h" |
| 16 | 20 |
| 17 @class NSUserNotificationCenter; | 21 @class NSUserNotificationCenter; |
| 18 | 22 |
| 19 // Since NSUserNotification and NSUserNotificationCenter are new classes in | 23 // Since NSUserNotification and NSUserNotificationCenter are new classes in |
| 20 // 10.8, they cannot simply be declared with an @interface. An @implementation | 24 // 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 | 25 // 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 | 26 // 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 | 27 // use that instead, because sizeof(id<Protocol>) == sizeof(Class*). In order to |
| 24 // instantiate, use NSClassFromString and simply assign the alloc/init'd result | 28 // instantiate, use NSClassFromString and simply assign the alloc/init'd result |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 delete model; | 98 delete model; |
| 95 } | 99 } |
| 96 | 100 |
| 97 //////////////////////////////////////////////////////////////////////////////// | 101 //////////////////////////////////////////////////////////////////////////////// |
| 98 | 102 |
| 99 // static | 103 // static |
| 100 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { | 104 NotificationUIManager* NotificationUIManager::Create(PrefService* local_state) { |
| 101 // TODO(rsesek): Remove this function and merge it with the one in | 105 // TODO(rsesek): Remove this function and merge it with the one in |
| 102 // notification_ui_manager.cc. | 106 // notification_ui_manager.cc. |
| 103 if (DelegatesToMessageCenter()) { | 107 if (DelegatesToMessageCenter()) { |
| 108 ProfileInfoCache* profile_info_cache = |
| 109 &g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 110 scoped_ptr<message_center::NotifierSettingsProvider> settings_provider( |
| 111 new MessageCenterSettingsController(profile_info_cache)); |
| 104 return new MessageCenterNotificationManager( | 112 return new MessageCenterNotificationManager( |
| 105 g_browser_process->message_center(), local_state); | 113 g_browser_process->message_center(), |
| 114 local_state, |
| 115 settings_provider.Pass()); |
| 106 } | 116 } |
| 107 | 117 |
| 108 BalloonNotificationUIManager* balloon_manager = NULL; | 118 BalloonNotificationUIManager* balloon_manager = NULL; |
| 109 if (base::mac::IsOSMountainLionOrLater()) | 119 if (base::mac::IsOSMountainLionOrLater()) |
| 110 balloon_manager = new NotificationUIManagerMac(local_state); | 120 balloon_manager = new NotificationUIManagerMac(local_state); |
| 111 else | 121 else |
| 112 balloon_manager = new BalloonNotificationUIManager(local_state); | 122 balloon_manager = new BalloonNotificationUIManager(local_state); |
| 113 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); | 123 balloon_manager->SetBalloonCollection(BalloonCollection::Create()); |
| 114 return balloon_manager; | 124 return balloon_manager; |
| 115 } | 125 } |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 notification->Click(); | 337 notification->Click(); |
| 328 } | 338 } |
| 329 | 339 |
| 330 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center | 340 - (BOOL)userNotificationCenter:(NSUserNotificationCenter*)center |
| 331 shouldPresentNotification:(id<CrUserNotification>)nsNotification { | 341 shouldPresentNotification:(id<CrUserNotification>)nsNotification { |
| 332 // Always display notifications, regardless of whether the app is foreground. | 342 // Always display notifications, regardless of whether the app is foreground. |
| 333 return YES; | 343 return YES; |
| 334 } | 344 } |
| 335 | 345 |
| 336 @end | 346 @end |
| OLD | NEW |