electron/brightray/browser/notification_presenter_mac.h

57 lines
1.8 KiB
C
Raw Normal View History

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.
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
#define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_MAC_H_
2015-08-11 02:05:27 +00:00
#include "browser/notification_presenter.h"
2015-08-11 02:05:27 +00:00
#include <map>
#import <Foundation/Foundation.h>
#include "base/mac/scoped_nsobject.h"
@class BRYUserNotificationCenterDelegate;
namespace brightray {
class NotificationPresenterMac : public NotificationPresenter {
public:
NotificationPresenterMac();
~NotificationPresenterMac();
2015-03-14 18:34:53 +00:00
// NotificationPresenter:
void ShowNotification(
2015-03-09 02:37:13 +00:00
const content::PlatformNotificationData&,
2015-04-20 20:29:10 +00:00
const SkBitmap& icon,
2014-10-11 08:38:27 +00:00
scoped_ptr<content::DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback) override;
// 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);
private:
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_;
base::scoped_nsobject<BRYUserNotificationCenterDelegate> delegate_;
};
} // namespace brightray
#endif