changeset 8227:14e5adfe280d

Fixed RT-37517 Notify windows of notifications
author loneid
date Tue, 15 Jul 2014 16:40:28 +0400
parents 5c3e2f51fb81
children 6520dd0eb491
files modules/web/src/main/native/Source/WebCore/TargetJava.pri modules/web/src/main/native/Source/WebCore/platform/java/NotificationClientJava.h modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp
diffstat 3 files changed, 45 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/modules/web/src/main/native/Source/WebCore/TargetJava.pri	Fri Jul 11 18:23:38 2014 +0400
+++ b/modules/web/src/main/native/Source/WebCore/TargetJava.pri	Tue Jul 15 16:40:28 2014 +0400
@@ -233,6 +233,7 @@
     platform/java/IDNJava.h \
     platform/java/InspectorClientJava.h \
     platform/java/JavaEnv.h \
+    platform/java/NotificationClientJava.h \
     platform/java/PlatformStrategiesJava.h \
     platform/java/RenderThemeJava.h \
     platform/java/ScrollbarThemeJava.h \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/web/src/main/native/Source/WebCore/platform/java/NotificationClientJava.h	Tue Jul 15 16:40:28 2014 +0400
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ */
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "NotificationClient.h"
+
+namespace WebCore {
+// Empty stub for NotificationClient; to be implemented later
+class NotificationClientJava: public NotificationClient {
+public:
+    // since WebKit Notification API doesn't provide a method to remove a NotificationClient,
+    // notificationClient is to be instantiated on WebPage creation and remain till the app termination
+    static NotificationClientJava* instance() {
+        static NotificationClientJava inst;
+        return &inst;
+    }
+    NotificationClientJava() {}
+    bool show(Notification* n) {return false;}
+    void cancel(Notification*) {}
+    void notificationObjectDestroyed(Notification*) {}
+    void notificationControllerDestroyed() {}
+#if ENABLE(LEGACY_NOTIFICATIONS)
+    void requestPermission(ScriptExecutionContext*, PassRefPtr<VoidCallback>) {}
+#endif
+#if ENABLE(NOTIFICATIONS)
+    void requestPermission(ScriptExecutionContext*, PassRefPtr<NotificationPermissionCallback>) {}
+#endif
+    void cancelRequestsForPermission(ScriptExecutionContext*) {}
+    Permission checkPermission(ScriptExecutionContext*) {return PermissionDenied;}
+    ~NotificationClientJava() {}
+};
+
+} // namespace WebCore
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
--- a/modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp	Fri Jul 11 18:23:38 2014 +0400
+++ b/modules/web/src/main/native/Source/WebCore/platform/java/WebPage.cpp	Tue Jul 15 16:40:28 2014 +0400
@@ -87,6 +87,11 @@
 #include "com_sun_webkit_event_WCKeyEvent.h"
 #include "com_sun_webkit_event_WCMouseEvent.h"
 
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "NotificationController.h"
+#include "NotificationClientJava.h"
+#endif
+
 namespace WebCore {
 
 WebPage::WebPage(PassOwnPtr<Page> page)
@@ -96,6 +101,11 @@
     , m_syncLayers(false)
 #endif
 {
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+    if(!NotificationController::clientFrom(m_page.get())) {
+        provideNotification(m_page.get(), NotificationClientJava::instance());
+    }
+#endif
 }
 
 WebPage::~WebPage()