2013-03-29 13:36:07 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Copyright (c) 2013 Adam Roben <adam@roben.org>. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE-CHROMIUM file.
|
|
|
|
|
2013-03-28 22:03:58 +00:00
|
|
|
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
|
|
|
|
#define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
|
|
|
|
|
|
|
|
#import "browser/notification_presenter.h"
|
|
|
|
|
2013-10-07 19:17:39 +00:00
|
|
|
#import "base/mac/scoped_nsobject.h"
|
2013-03-29 13:36:07 +00:00
|
|
|
#import <map>
|
2013-03-28 22:08:34 +00:00
|
|
|
|
|
|
|
@class BRYUserNotificationCenterDelegate;
|
2013-03-28 22:03:58 +00:00
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
|
|
|
class NotificationPresenterMac : public NotificationPresenter {
|
|
|
|
public:
|
|
|
|
NotificationPresenterMac();
|
|
|
|
~NotificationPresenterMac();
|
|
|
|
|
|
|
|
virtual void ShowNotification(
|
2015-03-09 02:37:13 +00:00
|
|
|
const content::PlatformNotificationData&,
|
2014-10-11 08:38:27 +00:00
|
|
|
scoped_ptr<content::DesktopNotificationDelegate> delegate,
|
|
|
|
base::Closure* cancel_callback) override;
|
2014-07-28 03:52:26 +00:00
|
|
|
|
|
|
|
// Get the delegate accroding from the notification object.
|
|
|
|
content::DesktopNotificationDelegate* GetDelegateFromNotification(
|
|
|
|
NSUserNotification* notification);
|
|
|
|
|
|
|
|
// Remove the notification object accroding to its delegate.
|
|
|
|
void RemoveNotification(content::DesktopNotificationDelegate* delegate);
|
2013-03-28 22:08:34 +00:00
|
|
|
|
|
|
|
private:
|
2014-07-28 03:52:26 +00:00
|
|
|
void CancelNotification(content::DesktopNotificationDelegate* delegate);
|
|
|
|
|
|
|
|
// The userInfo of NSUserNotification can not store pointers (because they are
|
|
|
|
// not in property list), so we have to track them in a C++ map.
|
|
|
|
// Also notice that the delegate acts as "ID" or "Key", because it is certain
|
|
|
|
// that each notification has a unique delegate.
|
|
|
|
typedef std::map<content::DesktopNotificationDelegate*, base::scoped_nsobject<NSUserNotification>>
|
|
|
|
NotificationsMap;
|
|
|
|
NotificationsMap notifications_map_;
|
|
|
|
|
2013-10-07 19:17:39 +00:00
|
|
|
base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
|
2013-03-28 22:03:58 +00:00
|
|
|
};
|
|
|
|
|
2013-11-17 23:20:17 +00:00
|
|
|
} // namespace brightray
|
2013-03-28 22:03:58 +00:00
|
|
|
|
|
|
|
#endif
|