Merge pull request #211 from 3v1n0/notifications-tags

Notifications tags
This commit is contained in:
Cheng Zhao 2016-04-13 20:12:37 +09:00
commit 2f107fcbe1
8 changed files with 13 additions and 1 deletions

View file

@ -80,6 +80,7 @@ LibnotifyNotification::~LibnotifyNotification() {
void LibnotifyNotification::Show(const base::string16& title, void LibnotifyNotification::Show(const base::string16& title,
const base::string16& body, const base::string16& body,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) { const bool silent) {
@ -108,6 +109,11 @@ void LibnotifyNotification::Show(const base::string16& title,
g_object_unref(pixbuf); g_object_unref(pixbuf);
} }
if (!tag.empty()) {
GQuark id = g_quark_from_string(tag.c_str());
g_object_set(G_OBJECT(notification_), "id", id, NULL);
}
GError* error = nullptr; GError* error = nullptr;
libnotify_loader_.notify_notification_show(notification_, &error); libnotify_loader_.notify_notification_show(notification_, &error);
if (error) { if (error) {

View file

@ -22,6 +22,7 @@ class LibnotifyNotification : public Notification {
// Notification: // Notification:
void Show(const base::string16& title, void Show(const base::string16& title,
const base::string16& msg, const base::string16& msg,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) override; const bool silent) override;

View file

@ -22,6 +22,7 @@ class CocoaNotification : public Notification {
// Notification: // Notification:
void Show(const base::string16& title, void Show(const base::string16& title,
const base::string16& msg, const base::string16& msg,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) override; const bool silent) override;

View file

@ -30,6 +30,7 @@ CocoaNotification::~CocoaNotification() {
void CocoaNotification::Show(const base::string16& title, void CocoaNotification::Show(const base::string16& title,
const base::string16& body, const base::string16& body,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) { const bool silent) {

View file

@ -21,6 +21,7 @@ class Notification {
// Shows the notification. // Shows the notification.
virtual void Show(const base::string16& title, virtual void Show(const base::string16& title,
const base::string16& msg, const base::string16& msg,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) = 0; const bool silent) = 0;

View file

@ -37,7 +37,7 @@ void OnWebNotificationAllowed(
auto notification = presenter->CreateNotification(adapter.get()); auto notification = presenter->CreateNotification(adapter.get());
if (notification) { if (notification) {
ignore_result(adapter.release()); // it will release itself automatically. ignore_result(adapter.release()); // it will release itself automatically.
notification->Show(data.title, data.body, data.icon, icon, data.silent); notification->Show(data.title, data.body, data.tag, data.icon, icon, data.silent);
*cancel_callback = base::Bind(&RemoveNotification, notification); *cancel_callback = base::Bind(&RemoveNotification, notification);
} }
} }

View file

@ -84,6 +84,7 @@ WindowsToastNotification::~WindowsToastNotification() {
void WindowsToastNotification::Show( void WindowsToastNotification::Show(
const base::string16& title, const base::string16& title,
const base::string16& msg, const base::string16& msg,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) { const bool silent) {

View file

@ -41,6 +41,7 @@ class WindowsToastNotification : public Notification {
// Notification: // Notification:
void Show(const base::string16& title, void Show(const base::string16& title,
const base::string16& msg, const base::string16& msg,
const std::string& tag,
const GURL& icon_url, const GURL& icon_url,
const SkBitmap& icon, const SkBitmap& icon,
const bool silent) override; const bool silent) override;