Skip to content

Commit 0166bef

Browse files
committed
Merge pull request nwjs#2908 from jtg-gg/nw12-notification
nw12 notification
2 parents e46d09d + 9b40f46 commit 0166bef

12 files changed

+108
-183
lines changed

src/nw_notification_manager.cc

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,6 @@ NotificationManager* NotificationManager::getSingleton() {
5959
return singleton_;
6060
}
6161

62-
63-
#if 0
64-
void NotificationManager::ImageDownloadCallback(int id, int http_status, const GURL& image_url, const std::vector<SkBitmap>& bitmaps, const std::vector<gfx::Size>& size) {
65-
NotificationManager *singleton = getSingleton();
66-
DesktopNotificationParams params = singleton->desktop_notification_params_[id];
67-
singleton->AddDesktopNotification(params.params_, params.render_process_id_, params.render_frame_id_, params.notification_id_, params.worker_, &bitmaps);
68-
singleton->desktop_notification_params_.erase(id);
69-
}
70-
#endif
71-
72-
bool NotificationManager::AddDesktopNotification(const content::ShowDesktopNotificationHostMsgParams& params,
73-
const int render_process_id,
74-
const int notification_id,
75-
const bool worker) {
76-
NOTIMPLEMENTED();
77-
return false;
78-
}
79-
8062
bool NotificationManager::DesktopNotificationPostClick(int render_process_id, int notification_id) {
8163
content::RenderProcessHost* rfh = content::RenderProcessHost::FromID(render_process_id);
8264
if (!rfh)
@@ -110,6 +92,7 @@ bool NotificationManager::DesktopNotificationPostError(int render_process_id, in
11092
if (!rfh)
11193
return false;
11294

95+
// Google remove the error notification messaging !!
11396
rfh->Send(new PlatformNotificationMsg_DidError(rfh->GetRoutingID(), notification_id));
11497
#endif
11598
return true;

src/nw_notification_manager.h

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,14 @@ class NotificationManager{
3232
protected:
3333
explicit NotificationManager();
3434

35-
// icon image download callback
36-
static void ImageDownloadCallback(int id, int http_status, const GURL& image_url, const std::vector<SkBitmap>& bitmaps, const std::vector<gfx::Size>& size);
37-
struct DesktopNotificationParams {
38-
content::ShowDesktopNotificationHostMsgParams params_;
39-
int render_process_id_;
40-
int render_frame_id_;
41-
int notification_id_;
42-
bool worker_;
43-
};
44-
45-
// map used to stored desktop notification params used by ImageDownloadCallback
46-
std::map<int, DesktopNotificationParams> desktop_notification_params_;
47-
4835
public:
4936
virtual ~NotificationManager();
5037
static NotificationManager* getSingleton();
51-
virtual bool AddDesktopNotification(
52-
const content::ShowDesktopNotificationHostMsgParams& params,
53-
const int render_process_id,
54-
const int notification_id,
55-
const bool worker) = 0;
38+
virtual bool AddDesktopNotification(const content::ShowDesktopNotificationHostMsgParams& params,
39+
const int render_process_id,
40+
const int notification_id,
41+
const bool worker) = 0;
42+
5643
virtual bool CancelDesktopNotification(int render_process_id, int notification_id) = 0;
5744

5845
bool DesktopNotificationPostClick(int render_process_id, int notification_id);

src/nw_notification_manager_linux.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ void NotificationManagerLinux::onClose(NotifyNotification *notif)
7070
};
7171

7272
bool NotificationManagerLinux::AddDesktopNotification(const content::ShowDesktopNotificationHostMsgParams& params,
73-
const int render_process_id,
74-
const int notification_id,
75-
const bool worker) {
76-
73+
const int render_process_id,
74+
const int notification_id,
75+
const bool worker) {
76+
content::Shell* shell = content::Shell::windows()[0];
7777
SkBitmap bitmap;
78-
79-
bitmap = params.icon;
78+
if(params.icon.getSize()) {
79+
bitmap = params.icon;
80+
} else {
81+
bitmap = shell->window()->app_icon().AsBitmap();
82+
}
8083

8184
NotifyNotification * notif;
8285
NotificationMap::iterator i = getNotification(notification_id);

src/nw_notification_manager_linux.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class NotificationManagerLinux : public NotificationManager {
4444
explicit NotificationManagerLinux();
4545
virtual ~NotificationManagerLinux();
4646
virtual bool AddDesktopNotification(const content::ShowDesktopNotificationHostMsgParams& params,
47-
const int render_process_id,
48-
const int notification_id,
49-
const bool worker) override;
47+
const int render_process_id,
48+
const int notification_id,
49+
const bool worker) override;
5050
virtual bool CancelDesktopNotification(int render_process_id, int notification_id) override;
5151
};
5252

src/nw_notification_manager_mac.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ class NotificationManagerMac : public NotificationManager {
2929
public:
3030
explicit NotificationManagerMac();
3131
virtual ~NotificationManagerMac(){}
32+
3233
virtual bool AddDesktopNotification(const content::ShowDesktopNotificationHostMsgParams& params,
33-
const int render_process_id, const int notification_id, const bool worker) override;
34+
const int render_process_id, const int notification_id, const bool worker) override;
35+
3436
virtual bool CancelDesktopNotification(int render_process_id, int notification_id) override;
3537

3638
};

src/nw_notification_manager_mac.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ -(void)userNotificationCenter:(NSUserNotificationCenter *)center didActivateNoti
8989
[notification setInformativeText : base::SysUTF16ToNSString(params.body)];
9090
notification.hasActionButton = YES;
9191

92-
if (params.icon.width() > 0) {
92+
if (params.icon.getSize() > 0 && base::mac::IsOSMavericksOrLater()) {
9393
// try to get the notification icon image given by image download callback
9494
gfx::Image icon = gfx::Image::CreateFrom1xBitmap(params.icon);
9595

0 commit comments

Comments
 (0)