2015-12-24 14:06:41 +00:00
|
|
|
// 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"
|
|
|
|
|
2015-12-25 03:05:48 +00:00
|
|
|
class GURL;
|
2015-12-24 14:06:41 +00:00
|
|
|
class SkBitmap;
|
|
|
|
|
|
|
|
namespace brightray {
|
|
|
|
|
2015-12-25 02:16:07 +00:00
|
|
|
class NotificationDelegate;
|
|
|
|
class NotificationPresenter;
|
|
|
|
|
2015-12-24 14:06:41 +00:00
|
|
|
class Notification {
|
|
|
|
public:
|
2015-12-25 02:16:07 +00:00
|
|
|
// Shows the notification.
|
|
|
|
virtual void Show(const base::string16& title,
|
|
|
|
const base::string16& msg,
|
2016-04-13 03:31:56 +00:00
|
|
|
const std::string& tag,
|
2015-12-25 03:05:48 +00:00
|
|
|
const GURL& icon_url,
|
2016-01-21 00:36:41 +00:00
|
|
|
const SkBitmap& icon,
|
|
|
|
const bool silent) = 0;
|
2015-12-25 02:16:07 +00:00
|
|
|
// Closes the notification, this instance will be destroyed after the
|
|
|
|
// notification gets closed.
|
|
|
|
virtual void Dismiss() = 0;
|
2015-12-24 14:06:41 +00:00
|
|
|
|
2016-04-15 07:14:13 +00:00
|
|
|
// Should be called by derived classes.
|
|
|
|
void NotificationClicked();
|
|
|
|
void NotificationDismissed();
|
|
|
|
void NotificationFailed();
|
|
|
|
|
2015-12-24 14:06:41 +00:00
|
|
|
base::WeakPtr<Notification> GetWeakPtr() {
|
|
|
|
return weak_factory_.GetWeakPtr();
|
|
|
|
}
|
|
|
|
|
2015-12-25 02:16:07 +00:00
|
|
|
NotificationDelegate* delegate() const { return delegate_; }
|
|
|
|
NotificationPresenter* presenter() const { return presenter_; }
|
|
|
|
|
2015-12-24 14:06:41 +00:00
|
|
|
protected:
|
2015-12-25 02:16:07 +00:00
|
|
|
Notification(NotificationDelegate* delegate,
|
|
|
|
NotificationPresenter* presenter);
|
|
|
|
virtual ~Notification();
|
|
|
|
|
|
|
|
// delete this.
|
|
|
|
void Destroy();
|
2015-12-24 14:06:41 +00:00
|
|
|
|
|
|
|
private:
|
2015-12-25 02:16:07 +00:00
|
|
|
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_;
|
|
|
|
|
2015-12-24 14:06:41 +00:00
|
|
|
base::WeakPtrFactory<Notification> weak_factory_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Notification);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace brightray
|
|
|
|
|
|
|
|
#endif // BROWSER_NOTIFICATION_H_
|