summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/notifications/desktop_notification_service.cc2
-rw-r--r--chrome/browser/notifications/desktop_notification_service_win.cc58
-rw-r--r--chrome/chrome_browser.gypi1
3 files changed, 61 insertions, 0 deletions
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index 013ee88..d8029f0 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -368,6 +368,7 @@ void DesktopNotificationService::RequestPermission(
}
}
+#if !defined(OS_WIN)
void DesktopNotificationService::ShowNotification(
const Notification& notification) {
GetUIManager()->Add(notification, profile_);
@@ -380,6 +381,7 @@ bool DesktopNotificationService::CancelDesktopNotification(
false));
return GetUIManager()->CancelById(proxy->id());
}
+#endif // OS_WIN
bool DesktopNotificationService::ShowDesktopNotification(
const content::ShowDesktopNotificationHostMsgParams& params,
diff --git a/chrome/browser/notifications/desktop_notification_service_win.cc b/chrome/browser/notifications/desktop_notification_service_win.cc
new file mode 100644
index 0000000..3cba517
--- /dev/null
+++ b/chrome/browser/notifications/desktop_notification_service_win.cc
@@ -0,0 +1,58 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/notifications/desktop_notification_service.h"
+
+#include "base/logging.h"
+#include "base/win/metro.h"
+#include "chrome/browser/notifications/notification.h"
+#include "chrome/browser/notifications/notification_ui_manager.h"
+#include "chrome/browser/notifications/notification_ui_manager.h"
+
+typedef void (*MetroDisplayNotification)(
+ const char* origin_url, const char* icon_url, const wchar_t* title,
+ const wchar_t* body, const wchar_t* display_source,
+ const char* notification_id);
+
+typedef bool (*MetroCancelNotification)(const char* notification_id);
+
+bool DesktopNotificationService::CancelDesktopNotification(
+ int process_id, int route_id, int notification_id) {
+ scoped_refptr<NotificationObjectProxy> proxy(
+ new NotificationObjectProxy(process_id, route_id, notification_id,
+ false));
+ if (base::win::GetMetroModule()) {
+ MetroCancelNotification cancel_metro_notification =
+ reinterpret_cast<MetroCancelNotification>(GetProcAddress(
+ base::win::GetMetroModule(), "CancelNotification"));
+ DCHECK(cancel_metro_notification);
+ if (cancel_metro_notification(proxy->id().c_str()))
+ return true;
+ }
+ return GetUIManager()->CancelById(proxy->id());
+}
+
+void DesktopNotificationService::ShowNotification(
+ const Notification& notification) {
+ if (base::win::GetMetroModule()) {
+ MetroDisplayNotification display_metro_notification =
+ reinterpret_cast<MetroDisplayNotification>(GetProcAddress(
+ base::win::GetMetroModule(), "DisplayNotification"));
+ DCHECK(display_metro_notification);
+ if (!notification.is_html()) {
+ display_metro_notification(notification.origin_url().spec().c_str(),
+ notification.content_url().spec().c_str(),
+ notification.title().c_str(),
+ notification.body().c_str(),
+ notification.display_source().c_str(),
+ notification.notification_id().c_str());
+ return;
+ } else {
+ NOTREACHED() << "We don't support HTML notifications in Windows 8 metro";
+ }
+ }
+ GetUIManager()->Add(notification, profile_);
+}
+
+
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index fdaa267..8b75d49 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1457,6 +1457,7 @@
'browser/notifications/desktop_notification_service.h',
'browser/notifications/desktop_notification_service_factory.cc',
'browser/notifications/desktop_notification_service_factory.h',
+ 'browser/notifications/desktop_notification_service_win.cc',
'browser/notifications/notification.cc',
'browser/notifications/notification.h',
'browser/notifications/notification_delegate.h',