728f0f985b
* Implements support for silent notifications on Windows and OS X * Exposes bool `silent` to Linux notification presenters
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
// Copyright (c) 2015 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef BROWSER_NOTIFICATION_H_
|
|
#define BROWSER_NOTIFICATION_H_
|
|
|
|
#include "base/memory/weak_ptr.h"
|
|
#include "base/strings/string16.h"
|
|
|
|
class GURL;
|
|
class SkBitmap;
|
|
|
|
namespace brightray {
|
|
|
|
class NotificationDelegate;
|
|
class NotificationPresenter;
|
|
|
|
class Notification {
|
|
public:
|
|
// Shows the notification.
|
|
virtual void Show(const base::string16& title,
|
|
const base::string16& msg,
|
|
const GURL& icon_url,
|
|
const SkBitmap& icon,
|
|
const bool silent) = 0;
|
|
// Closes the notification, this instance will be destroyed after the
|
|
// notification gets closed.
|
|
virtual void Dismiss() = 0;
|
|
|
|
base::WeakPtr<Notification> GetWeakPtr() {
|
|
return weak_factory_.GetWeakPtr();
|
|
}
|
|
|
|
NotificationDelegate* delegate() const { return delegate_; }
|
|
NotificationPresenter* presenter() const { return presenter_; }
|
|
|
|
protected:
|
|
Notification(NotificationDelegate* delegate,
|
|
NotificationPresenter* presenter);
|
|
virtual ~Notification();
|
|
|
|
// delete this.
|
|
void Destroy();
|
|
|
|
private:
|
|
friend class NotificationPresenter;
|
|
|
|
// Can only be called by NotificationPresenter, the caller is responsible of
|
|
// freeing the returned instance.
|
|
static Notification* Create(NotificationDelegate* delegate,
|
|
NotificationPresenter* presenter);
|
|
|
|
NotificationDelegate* delegate_;
|
|
NotificationPresenter* presenter_;
|
|
|
|
base::WeakPtrFactory<Notification> weak_factory_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Notification);
|
|
};
|
|
|
|
} // namespace brightray
|
|
|
|
#endif // BROWSER_NOTIFICATION_H_
|