Diff
Modified: trunk/Source/WebKit/ChangeLog (135558 => 135559)
--- trunk/Source/WebKit/ChangeLog 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/ChangeLog 2012-11-23 06:39:18 UTC (rev 135559)
@@ -1,3 +1,16 @@
+2012-11-22 Jeff Rogers <[email protected]>
+
+ [BlackBerry] Update Web Notifications Implementation
+ https://bugs.webkit.org/show_bug.cgi?id=102621
+
+ Reviewed by George Staikos.
+
+ Reviewed internally by George Staikos and Joe Mason.
+ Internal PR 172120
+ Add new Notification files and remove obsolete ones.
+
+ * PlatformBlackBerry.cmake:
+
2012-11-22 Simon Hausmann <[email protected]>, Pierre Rossi <[email protected]>
[Qt] Separate QWidget dependant code into separate WebKitWidgets static library
Modified: trunk/Source/WebKit/PlatformBlackBerry.cmake (135558 => 135559)
--- trunk/Source/WebKit/PlatformBlackBerry.cmake 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/PlatformBlackBerry.cmake 2012-11-23 06:39:18 UTC (rev 135559)
@@ -114,7 +114,7 @@
blackberry/WebCoreSupport/IconDatabaseClientBlackBerry.cpp
blackberry/WebCoreSupport/InspectorClientBlackBerry.cpp
blackberry/WebCoreSupport/NetworkInfoClientBlackBerry.cpp
- blackberry/WebCoreSupport/NotificationPresenterImpl.cpp
+ blackberry/WebCoreSupport/NotificationClientBlackBerry.cpp
blackberry/WebCoreSupport/PagePopupBlackBerry.cpp
blackberry/WebCoreSupport/NavigatorContentUtilsClientBlackBerry.cpp
blackberry/WebCoreSupport/SelectPopupClient.cpp
@@ -132,6 +132,7 @@
blackberry/WebKitSupport/InputHandler.cpp
blackberry/WebKitSupport/InRegionScrollableArea.cpp
blackberry/WebKitSupport/InspectorOverlayBlackBerry.cpp
+ blackberry/WebKitSupport/NotificationManager.cpp
blackberry/WebKitSupport/RenderQueue.cpp
blackberry/WebKitSupport/SelectionHandler.cpp
blackberry/WebKitSupport/SelectionOverlay.cpp
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.cpp (135558 => 135559)
--- trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.cpp 2012-11-23 06:39:18 UTC (rev 135559)
@@ -93,7 +93,7 @@
#include "NavigatorContentUtilsClientBlackBerry.h"
#endif
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-#include "NotificationPresenterImpl.h"
+#include "NotificationClientBlackBerry.h"
#endif
#include "Page.h"
#include "PageCache.h"
@@ -429,6 +429,9 @@
, m_autofillManager(AutofillManager::create(this))
, m_documentStyleRecalcPostponed(false)
, m_documentChildNeedsStyleRecalc(false)
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ , m_notificationManager(this)
+#endif
{
static bool isInitialized = false;
if (!isInitialized) {
@@ -561,7 +564,7 @@
#endif
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- WebCore::provideNotification(m_page, NotificationPresenterImpl::instance());
+ WebCore::provideNotification(m_page, new NotificationClientBlackBerry(this));
#endif
#if ENABLE(NAVIGATOR_CONTENT_UTILS)
@@ -5887,16 +5890,6 @@
return "";
}
-void WebPage::setAllowNotification(const BlackBerry::Platform::String& domain, bool allow)
-{
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
- static_cast<NotificationPresenterImpl*>(NotificationPresenterImpl::instance())->onPermission(domain.c_str(), allow);
-#else
- UNUSED_PARAM(domain);
- UNUSED_PARAM(allow);
-#endif
-}
-
void WebPage::setJavaScriptCanAccessClipboard(bool enabled)
{
d->m_page->settings()->setJavaScriptCanAccessClipboard(enabled);
@@ -6160,5 +6153,51 @@
InspectorInstrumentation::didComposite(m_page);
}
+void WebPage::updateNotificationPermission(const BlackBerry::Platform::String& requestId, bool allowed)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ d->notificationManager().updatePermission(requestId, allowed);
+#else
+ UNUSED_PARAM(requestId);
+ UNUSED_PARAM(allowed);
+#endif
}
+
+void WebPage::notificationClicked(const BlackBerry::Platform::String& notificationId)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ d->notificationManager().notificationClicked(notificationId);
+#else
+ UNUSED_PARAM(notificationId);
+#endif
}
+
+void WebPage::notificationClosed(const BlackBerry::Platform::String& notificationId)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ d->notificationManager().notificationClosed(notificationId);
+#else
+ UNUSED_PARAM(notificationId);
+#endif
+}
+
+void WebPage::notificationError(const BlackBerry::Platform::String& notificationId)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ d->notificationManager().notificationError(notificationId);
+#else
+ UNUSED_PARAM(notificationId);
+#endif
+}
+
+void WebPage::notificationShown(const BlackBerry::Platform::String& notificationId)
+{
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ d->notificationManager().notificationShown(notificationId);
+#else
+ UNUSED_PARAM(notificationId);
+#endif
+}
+
+}
+}
Modified: trunk/Source/WebKit/blackberry/Api/WebPage.h (135558 => 135559)
--- trunk/Source/WebKit/blackberry/Api/WebPage.h 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/Api/WebPage.h 2012-11-23 06:39:18 UTC (rev 135559)
@@ -268,8 +268,6 @@
BlackBerry::Platform::String textHasAttribute(const BlackBerry::Platform::String& query) const;
- void setAllowNotification(const BlackBerry::Platform::String& domain, bool allow);
-
Platform::WebContext webContext(TargetDetectionStrategy) const;
typedef intptr_t BackForwardId;
@@ -366,6 +364,12 @@
BlackBerry::Platform::String renderTreeAsText();
+ void updateNotificationPermission(const BlackBerry::Platform::String& requestId, bool allowed);
+ void notificationClicked(const BlackBerry::Platform::String& notificationId);
+ void notificationClosed(const BlackBerry::Platform::String& notificationId);
+ void notificationError(const BlackBerry::Platform::String& notificationId);
+ void notificationShown(const BlackBerry::Platform::String& notificationId);
+
private:
virtual ~WebPage();
Modified: trunk/Source/WebKit/blackberry/Api/WebPageClient.h (135558 => 135559)
--- trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/Api/WebPageClient.h 2012-11-23 06:39:18 UTC (rev 135559)
@@ -267,6 +267,19 @@
virtual void requestUserMedia(const Platform::WebUserMediaRequest&) = 0;
virtual void cancelUserMediaRequest(const Platform::WebUserMediaRequest&) = 0;
virtual void updateFindStringResult(int numMatches, int currentIndex) = 0;
+
+ // Match with NotificationClient::Permission.
+ enum Permission {
+ PermissionAllowed, // User has allowed notifications
+ PermissionNotAllowed, // User has not yet allowed
+ PermissionDenied // User has explicitly denied permission
+ };
+ virtual void requestNotificationPermission(const BlackBerry::Platform::String& /*requestId*/, const BlackBerry::Platform::String& /*origin*/) = 0;
+ virtual Permission checkNotificationPermission(const BlackBerry::Platform::String& /*origin*/) = 0;
+ virtual void showNotification(const BlackBerry::Platform::String& /*notificationId*/, const BlackBerry::Platform::String& /*title*/, const BlackBerry::Platform::String& /*body*/, const BlackBerry::Platform::String& /*iconUrl*/, const BlackBerry::Platform::String& /*tag*/, const BlackBerry::Platform::String& /*origin*/) = 0;
+ virtual void cancelNotification(const BlackBerry::Platform::String& /*id*/) = 0;
+ virtual void clearNotifications(const std::vector<BlackBerry::Platform::String>& /*notificationIds*/) = 0;
+ virtual void notificationDestroyed(const BlackBerry::Platform::String& /*notificationId*/) = 0;
};
} // namespace WebKit
} // namespace BlackBerry
Modified: trunk/Source/WebKit/blackberry/Api/WebPage_p.h (135558 => 135559)
--- trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/Api/WebPage_p.h 2012-11-23 06:39:18 UTC (rev 135559)
@@ -31,6 +31,9 @@
#include <EGL/egl.h>
#endif
#include "KURL.h"
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "NotificationManager.h"
+#endif
#include "PageClientBlackBerry.h"
#include "PlatformMouseEvent.h"
#include "ScriptSourceCode.h"
@@ -461,6 +464,10 @@
void willComposite();
void didComposite();
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ NotificationManager& notificationManager() { return m_notificationManager; };
+#endif
+
WebPage* m_webPage;
WebPageClient* m_client;
WebCore::InspectorClientBlackBerry* m_inspectorClient;
@@ -635,6 +642,11 @@
WebCore::IntPoint m_cachedHitTestContentPos;
WebCore::HitTestResult m_cachedHitTestResult;
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+ NotificationManager m_notificationManager;
+#endif
+
protected:
virtual ~WebPagePrivate();
};
Modified: trunk/Source/WebKit/blackberry/ChangeLog (135558 => 135559)
--- trunk/Source/WebKit/blackberry/ChangeLog 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/ChangeLog 2012-11-23 06:39:18 UTC (rev 135559)
@@ -1,3 +1,69 @@
+2012-11-22 Jeff Rogers <[email protected]>
+
+ [BlackBerry] Update Web Notifications Implementation
+ https://bugs.webkit.org/show_bug.cgi?id=102621
+
+ Reviewed by George Staikos.
+
+ Reviewed internally by George Staikos and Joe Mason
+ Internal PR 172120
+ Add new notifications implementation for the BlackBerry port. Rename
+ existing class to match Client naming. Adds NotificationManager
+ implementation for managing notifications and permissions, and logic
+ for passing the notifications to the platform provider.
+
+ * Api/WebPage.cpp:
+ (BlackBerry::WebKit::WebPagePrivate::WebPagePrivate):
+ (BlackBerry::WebKit::WebPagePrivate::init):
+ (BlackBerry::WebKit::WebPage::updateNotificationPermission):
+ (WebKit):
+ (BlackBerry::WebKit::WebPage::notificationClicked):
+ (BlackBerry::WebKit::WebPage::notificationClosed):
+ (BlackBerry::WebKit::WebPage::notificationError):
+ (BlackBerry::WebKit::WebPage::notificationShown):
+ * Api/WebPage.h:
+ * Api/WebPageClient.h:
+ * Api/WebPage_p.h:
+ (WebPagePrivate):
+ (BlackBerry::WebKit::WebPagePrivate::notificationManager):
+ * WebCoreSupport/NotificationClientBlackBerry.cpp: Added.
+ (WebCore):
+ (WebCore::NotificationClientBlackBerry::NotificationClientBlackBerry):
+ (WebCore::NotificationClientBlackBerry::show):
+ (WebCore::NotificationClientBlackBerry::cancel):
+ (WebCore::NotificationClientBlackBerry::clearNotifications):
+ (WebCore::NotificationClientBlackBerry::notificationObjectDestroyed):
+ (WebCore::NotificationClientBlackBerry::notificationControllerDestroyed):
+ (WebCore::NotificationClientBlackBerry::requestPermission):
+ (WebCore::NotificationClientBlackBerry::cancelRequestsForPermission):
+ (WebCore::NotificationClientBlackBerry::checkPermission):
+ * WebCoreSupport/NotificationClientBlackBerry.h: Added.
+ (WebKit):
+ (WebCore):
+ (NotificationClientBlackBerry):
+ * WebCoreSupport/NotificationPresenterImpl.cpp: Removed.
+ * WebCoreSupport/NotificationPresenterImpl.h: Removed.
+ * WebKitSupport/NotificationManager.cpp: Added.
+ (WebKit):
+ (BlackBerry::WebKit::NotificationManager::NotificationManager):
+ (BlackBerry::WebKit::NotificationManager::~NotificationManager):
+ (BlackBerry::WebKit::NotificationManager::show):
+ (BlackBerry::WebKit::NotificationManager::cancel):
+ (BlackBerry::WebKit::NotificationManager::clearNotifications):
+ (BlackBerry::WebKit::NotificationManager::notificationObjectDestroyed):
+ (BlackBerry::WebKit::NotificationManager::requestPermission):
+ (BlackBerry::WebKit::NotificationManager::cancelRequestsForPermission):
+ (BlackBerry::WebKit::NotificationManager::checkPermission):
+ (BlackBerry::WebKit::NotificationManager::updatePermission):
+ (BlackBerry::WebKit::NotificationManager::notificationClicked):
+ (BlackBerry::WebKit::NotificationManager::notificationClosed):
+ (BlackBerry::WebKit::NotificationManager::notificationError):
+ (BlackBerry::WebKit::NotificationManager::notificationShown):
+ (BlackBerry::WebKit::NotificationManager::removeNotificationFromContextMap):
+ * WebKitSupport/NotificationManager.h: Added.
+ (WebKit):
+ (NotificationManager):
+
2012-11-22 Mike Fenton <[email protected]>
[BlackBerry] Guard against a lost focusedNode that input handler isn't yet informed of.
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationClientBlackBerry.cpp (0 => 135559)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationClientBlackBerry.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationClientBlackBerry.cpp 2012-11-23 06:39:18 UTC (rev 135559)
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "NotificationClientBlackBerry.h"
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "Notification.h"
+#include "NotificationPermissionCallback.h"
+#include "ScriptExecutionContext.h"
+#include "VoidCallback.h"
+#include "WebPage_p.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+NotificationClientBlackBerry::NotificationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate* webPagePrivate)
+ : m_webPagePrivate(webPagePrivate)
+{
+}
+
+bool NotificationClientBlackBerry::show(Notification* notification)
+{
+ m_webPagePrivate->notificationManager().show(notification);
+ return true;
+}
+
+void NotificationClientBlackBerry::cancel(Notification* notification)
+{
+ m_webPagePrivate->notificationManager().cancel(notification);
+}
+
+
+void NotificationClientBlackBerry::clearNotifications(ScriptExecutionContext* context)
+{
+ m_webPagePrivate->notificationManager().clearNotifications(context);
+}
+
+void NotificationClientBlackBerry::notificationObjectDestroyed(Notification* notification)
+{
+ m_webPagePrivate->notificationManager().notificationObjectDestroyed(notification);
+}
+
+void NotificationClientBlackBerry::notificationControllerDestroyed()
+{
+ delete this;
+}
+
+void NotificationClientBlackBerry::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
+{
+ m_webPagePrivate->notificationManager().requestPermission(context, callback);
+}
+
+void NotificationClientBlackBerry::requestPermission(ScriptExecutionContext* context, PassRefPtr<NotificationPermissionCallback> callback)
+{
+ m_webPagePrivate->notificationManager().requestPermission(context, callback);
+}
+
+void NotificationClientBlackBerry::cancelRequestsForPermission(ScriptExecutionContext* context)
+{
+ m_webPagePrivate->notificationManager().cancelRequestsForPermission(context);
+}
+
+NotificationClient::Permission NotificationClientBlackBerry::checkPermission(ScriptExecutionContext* context)
+{
+ return m_webPagePrivate->notificationManager().checkPermission(context);
+}
+
+}
+
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Added: trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationClientBlackBerry.h (0 => 135559)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationClientBlackBerry.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationClientBlackBerry.h 2012-11-23 06:39:18 UTC (rev 135559)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef NotificationClientBlackBerry_h
+#define NotificationClientBlackBerry_h
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "NotificationClient.h"
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+}
+}
+
+namespace WebCore {
+
+class NotificationClientBlackBerry : public NotificationClient {
+public:
+ NotificationClientBlackBerry(BlackBerry::WebKit::WebPagePrivate*);
+
+ virtual bool show(Notification*);
+ virtual void cancel(Notification*);
+ virtual void clearNotifications(ScriptExecutionContext*);
+ virtual void notificationObjectDestroyed(Notification*);
+ virtual void notificationControllerDestroyed();
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ virtual void requestPermission(ScriptExecutionContext*, PassRefPtr<VoidCallback>);
+#endif
+#if ENABLE(NOTIFICATIONS)
+ virtual void requestPermission(ScriptExecutionContext*, PassRefPtr<NotificationPermissionCallback>);
+#endif
+ virtual void cancelRequestsForPermission(ScriptExecutionContext*);
+ virtual Permission checkPermission(ScriptExecutionContext*);
+
+private:
+ BlackBerry::WebKit::WebPagePrivate* m_webPagePrivate;
+};
+
+}
+
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#endif // NotificationClientBlackBerry_h
Deleted: trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp (135558 => 135559)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp 2012-11-23 06:39:18 UTC (rev 135559)
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "config.h"
-#include "NotificationPresenterImpl.h"
-
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-#include <BlackBerryPlatformString.h>
-#include <Event.h>
-#include <Notification.h>
-#include <NotificationPresenterBlackBerry.h>
-#include <ScriptExecutionContext.h>
-#include <UUID.h>
-
-
-namespace WebCore {
-
-NotificationClient* NotificationPresenterImpl::instance()
-{
- static NotificationPresenterImpl* s_instance = 0;
- if (!s_instance)
- s_instance = new NotificationPresenterImpl;
- return s_instance;
-}
-
-NotificationPresenterImpl::NotificationPresenterImpl()
-{
- m_platformPresenter = adoptPtr(BlackBerry::Platform::NotificationPresenterBlackBerry::create(this));
-}
-
-NotificationPresenterImpl::~NotificationPresenterImpl()
-{
-}
-
-bool NotificationPresenterImpl::show(Notification* notification)
-{
- ASSERT(notification);
- ASSERT(notification->scriptExecutionContext());
- RefPtr<Notification> n = notification;
- if (m_notifications.contains(n))
- return false;
-
- if (checkPermission(notification->scriptExecutionContext()) != NotificationClient::PermissionAllowed)
- return false;
-
- String uuid = createCanonicalUUIDString();
- m_notifications.add(n, uuid);
- String message;
- if (n->isHTML()) {
- // FIXME: Load and display HTML content.
- message = n->url().string();
- } else {
- // FIXME: Strip the content into one line.
- message = n->contents().title + ": " + n->contents().body;
- }
-
- m_platformPresenter->show(uuid, message);
- return true;
-}
-
-void NotificationPresenterImpl::cancel(Notification* notification)
-{
- ASSERT(notification);
- RefPtr<Notification> n = notification;
-
- NotificationMap::iterator it = m_notifications.find(n);
- if (it == m_notifications.end())
- return;
-
- m_platformPresenter->cancel(it->value);
- m_notifications.remove(it);
-}
-
-void NotificationPresenterImpl::notificationObjectDestroyed(Notification* notification)
-{
- ASSERT(notification);
- cancel(notification);
-}
-
-void NotificationPresenterImpl::notificationControllerDestroyed()
-{
-}
-
-void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
-{
- ASSERT(context);
- m_permissionRequests.add(context, callback);
- m_platformPresenter->requestPermission(context->url().host());
-}
-
-void NotificationPresenterImpl::onPermission(const BlackBerry::Platform::String& domain, bool isAllowed)
-{
- ASSERT(!domain.empty());
- PermissionRequestMap::iterator it = m_permissionRequests.begin();
- for (; it != m_permissionRequests.end(); ++it) {
- if (it->key->url().host() != domain)
- continue;
-
- if (isAllowed) {
- m_allowedDomains.add(domain);
- it->value->handleEvent();
- } else
- m_allowedDomains.remove(domain);
-
- m_permissionRequests.remove(it);
- return;
- }
-}
-
-void NotificationPresenterImpl::cancelRequestsForPermission(ScriptExecutionContext*)
-{
- // Because we are using modal dialogs to request permission, it's impossible to cancel them.
-}
-
-NotificationClient::Permission NotificationPresenterImpl::checkPermission(ScriptExecutionContext* context)
-{
- ASSERT(context);
- // FIXME: Should store the permission information into file permanently instead of in m_allowedDomains.
- // The suggested place to do this is in m_platformPresenter->checkPermission().
- if (m_allowedDomains.contains(context->url().host()))
- return NotificationClient::PermissionAllowed;
- return NotificationClient::PermissionNotAllowed;
-}
-
-// This function is called in platform side.
-void NotificationPresenterImpl::notificationClicked(const BlackBerry::Platform::String& id)
-{
- ASSERT(!id.empty());
- NotificationMap::iterator it = m_notifications.begin();
- for (; it != m_notifications.end(); ++it) {
- if (it->value == id && it->key->scriptExecutionContext()) {
- RefPtr<Notification> notification = it->key;
- it->key->dispatchEvent(Event::create(eventNames().clickEvent, false, true));
- m_notifications.remove(notification);
- return;
- }
- }
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Deleted: trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h (135558 => 135559)
--- trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h 2012-11-23 06:07:30 UTC (rev 135558)
+++ trunk/Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h 2012-11-23 06:39:18 UTC (rev 135559)
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef NotificationPresenterImpl_h
-#define NotificationPresenterImpl_h
-
-#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-#include <NotificationAckListener.h>
-#include <NotificationClient.h>
-#include <NotificationPresenterBlackBerry.h>
-#include <wtf/HashMap.h>
-#include <wtf/HashSet.h>
-#include <wtf/OwnPtr.h>
-#include <wtf/text/StringHash.h>
-
-namespace BlackBerry {
-namespace Platform {
-class String;
-}
-}
-
-namespace WebCore {
-
-class NotificationPresenterImpl : public WebCore::NotificationClient, public BlackBerry::Platform::NotificationAckListener {
-public:
- static NotificationClient* instance();
- virtual ~NotificationPresenterImpl();
-
- // Requests that a notification be shown.
- virtual bool show(WebCore::Notification*);
-
- // Requests that a notification that has already been shown be canceled.
- virtual void cancel(WebCore::Notification*);
-
- // Informs the presenter that a WebCore::Notification object has been destroyed
- // (such as by a page transition). The presenter may continue showing
- // the notification, but must not attempt to call the event handlers.
- virtual void notificationObjectDestroyed(WebCore::Notification*);
-
- virtual void notificationControllerDestroyed();
-
- // Requests user permission to show desktop notifications from a particular
- // script context. The callback parameter should be run when the user has
- // made a decision.
- virtual void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::VoidCallback>);
-
- // Cancel all outstanding requests for the ScriptExecutionContext.
- virtual void cancelRequestsForPermission(WebCore::ScriptExecutionContext*);
-
- // Checks the current level of permission.
- virtual Permission checkPermission(WebCore::ScriptExecutionContext*);
-
- // Interfaces inherited from NotificationAckListener.
- virtual void notificationClicked(const BlackBerry::Platform::String& id);
- virtual void onPermission(const BlackBerry::Platform::String& domain, bool isAllowed);
-
-private:
- NotificationPresenterImpl();
-
-private:
- OwnPtr<BlackBerry::Platform::NotificationPresenterBlackBerry> m_platformPresenter;
-
- typedef HashMap<RefPtr<WebCore::Notification>, String> NotificationMap;
- NotificationMap m_notifications;
-
- typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, RefPtr<WebCore::VoidCallback> > PermissionRequestMap;
- PermissionRequestMap m_permissionRequests;
-
- HashSet<String> m_allowedDomains;
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
-#endif // NotificationPresenterImpl_h
Added: trunk/Source/WebKit/blackberry/WebKitSupport/NotificationManager.cpp (0 => 135559)
--- trunk/Source/WebKit/blackberry/WebKitSupport/NotificationManager.cpp (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/NotificationManager.cpp 2012-11-23 06:39:18 UTC (rev 135559)
@@ -0,0 +1,231 @@
+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "NotificationManager.h"
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "UUID.h"
+#include "UserGestureIndicator.h"
+#include "WebPage_p.h"
+
+#include <BlackBerryPlatformString.h>
+
+#include <vector>
+
+using namespace WebCore;
+
+namespace BlackBerry {
+namespace WebKit {
+
+NotificationManager::NotificationManager(WebPagePrivate* webPagePrivate)
+ : m_webPagePrivate(webPagePrivate)
+{
+}
+
+NotificationManager::~NotificationManager()
+{
+}
+
+bool NotificationManager::show(Notification* notification)
+{
+ String notificationID = createCanonicalUUIDString();
+ m_notificationMap.set(notification, notificationID);
+ m_notificationIDMap.set(notificationID, notification);
+
+ NotificationContextMap::iterator it = m_notificationContextMap.add(notification->scriptExecutionContext(), Vector<String>()).iterator;
+ it->second.append(notificationID);
+
+ m_webPagePrivate->client()->showNotification(notificationID, notification->title(), notification->body(), notification->iconURL().string(), notification->tag(), notification->scriptExecutionContext()->securityOrigin()->toString());
+ return true;
+}
+
+void NotificationManager::cancel(Notification* notification)
+{
+ String notificationID = m_notificationMap.get(notification);
+ if (!notificationID)
+ return;
+
+ m_webPagePrivate->client()->cancelNotification(notificationID);
+}
+
+void NotificationManager::clearNotifications(ScriptExecutionContext* context)
+{
+ NotificationContextMap::iterator it = m_notificationContextMap.find(context);
+ if (it == m_notificationContextMap.end())
+ return;
+
+ Vector<String>& notificationIDs = it->second;
+ std::vector<BlackBerry::Platform::String> ids;
+ size_t count = notificationIDs.size();
+ for (size_t i = 0; i < count; ++i) {
+ ids.push_back(notificationIDs[i]);
+ RefPtr<Notification> notification = m_notificationIDMap.take(notificationIDs[i]);
+ if (!notification)
+ continue;
+
+ notification->finalize();
+ m_notificationMap.remove(notification);
+ }
+
+ m_webPagePrivate->client()->clearNotifications(ids);
+ m_notificationContextMap.remove(it);
+}
+
+void NotificationManager::notificationObjectDestroyed(Notification* notification)
+{
+ String notificationID = m_notificationMap.take(notification);
+ if (!notificationID)
+ return;
+
+ m_notificationIDMap.remove(notificationID);
+ removeNotificationFromContextMap(notificationID, notification);
+ m_webPagePrivate->client()->notificationDestroyed(notificationID);
+}
+
+#if ENABLE(LEGACY_NOTIFICATIONS)
+void NotificationManager::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
+{
+ SecurityOrigin* origin = context->securityOrigin();
+ String requestID = createCanonicalUUIDString();
+ m_originToIDMap.set(origin, requestID);
+ m_idToOriginMap.set(requestID, origin);
+ m_idToVoidCallbackMap.set(requestID, callback);
+ m_webPagePrivate->client()->requestNotificationPermission(requestID, origin->toString());
+}
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+void NotificationManager::requestPermission(ScriptExecutionContext* context, PassRefPtr<NotificationPermissionCallback> callback)
+{
+ SecurityOrigin* origin = context->securityOrigin();
+ String requestID = createCanonicalUUIDString();
+ m_originToIDMap.set(origin, requestID);
+ m_idToOriginMap.set(requestID, origin);
+ m_idToCallbackMap.set(requestID, callback);
+ m_webPagePrivate->client()->requestNotificationPermission(requestID, origin->toString());
+}
+#endif
+
+void NotificationManager::cancelRequestsForPermission(ScriptExecutionContext* context)
+{
+ SecurityOrigin* origin = context->securityOrigin();
+ String requestID = m_originToIDMap.take(origin);
+ if (!requestID)
+ return;
+
+ m_idToOriginMap.remove(requestID);
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ m_idToVoidCallbackMap.remove(requestID);
+#endif
+#if ENABLE(NOTIFICATIONS)
+ m_idToCallbackMap.remove(requestID);
+#endif
+}
+
+NotificationClient::Permission NotificationManager::checkPermission(ScriptExecutionContext* context)
+{
+ return static_cast<NotificationClient::Permission>(m_webPagePrivate->client()->checkNotificationPermission(context->securityOrigin()->toString()));
+}
+
+void NotificationManager::updatePermission(const String& requestID, bool allowed)
+{
+ RefPtr<WebCore::SecurityOrigin> origin = m_idToOriginMap.take(requestID);
+ m_originToIDMap.remove(origin);
+
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ RefPtr<VoidCallback> voidCallback = m_idToVoidCallbackMap.take(requestID);
+ if (voidCallback) {
+ voidCallback->handleEvent();
+ return;
+ }
+#endif
+
+#if ENABLE(NOTIFICATIONS)
+ RefPtr<NotificationPermissionCallback> callback = m_idToCallbackMap.take(requestID);
+ if (!callback)
+ return;
+
+ callback->handleEvent(Notification::permissionString(allowed ? NotificationClient::PermissionAllowed : NotificationClient::PermissionDenied));
+#endif
+}
+
+void NotificationManager::notificationClicked(const String& notificationID)
+{
+ RefPtr<Notification> notification = m_notificationIDMap.get(notificationID);
+ if (!notification)
+ return;
+
+ // Indicate that this event is being dispatched in reaction to a user's interaction with a platform notification.
+ UserGestureIndicator indicator(DefinitelyProcessingUserGesture);
+ notification->dispatchClickEvent();
+}
+
+void NotificationManager::notificationClosed(const String& notificationID)
+{
+ RefPtr<Notification> notification = m_notificationIDMap.take(notificationID);
+ if (!notification)
+ return;
+
+ m_notificationMap.remove(notification);
+ removeNotificationFromContextMap(notificationID, notification.get());
+ notification->dispatchCloseEvent();
+}
+
+void NotificationManager::notificationError(const String& notificationID)
+{
+ RefPtr<Notification> notification = m_notificationIDMap.take(notificationID);
+ if (!notification)
+ return;
+
+ notification->dispatchErrorEvent();
+}
+
+void NotificationManager::notificationShown(const String& notificationID)
+{
+ RefPtr<Notification> notification = m_notificationIDMap.get(notificationID);
+ if (!notification)
+ return;
+
+ notification->dispatchShowEvent();
+}
+
+void NotificationManager::removeNotificationFromContextMap(const String& notificationID, Notification* notification)
+{
+ // This is a helper function for managing the hash maps.
+ NotificationContextMap::iterator it = m_notificationContextMap.find(notification->scriptExecutionContext());
+ ASSERT(it != m_notificationContextMap.end());
+ size_t index = it->second.find(notificationID);
+ ASSERT(index != notFound);
+ it->second.remove(index);
+ if (it->second.isEmpty())
+ m_notificationContextMap.remove(it);
+}
+
+}
+}
+
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
Added: trunk/Source/WebKit/blackberry/WebKitSupport/NotificationManager.h (0 => 135559)
--- trunk/Source/WebKit/blackberry/WebKitSupport/NotificationManager.h (rev 0)
+++ trunk/Source/WebKit/blackberry/WebKitSupport/NotificationManager.h 2012-11-23 06:39:18 UTC (rev 135559)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2011, 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef NotificationManager_h
+#define NotificationManager_h
+
+#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#include "Notification.h"
+#include "NotificationClient.h"
+#include "NotificationPermissionCallback.h"
+#include "ScriptExecutionContext.h"
+#include "SecurityOrigin.h"
+#include "VoidCallback.h"
+#include <wtf/HashMap.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+
+namespace BlackBerry {
+namespace WebKit {
+class WebPagePrivate;
+
+class NotificationManager {
+public:
+ NotificationManager(WebPagePrivate*);
+ ~NotificationManager();
+
+ bool show(WebCore::Notification*);
+ void cancel(WebCore::Notification*);
+ void clearNotifications(WebCore::ScriptExecutionContext*);
+ void notificationObjectDestroyed(WebCore::Notification*);
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::VoidCallback>);
+#endif
+#if ENABLE(NOTIFICATIONS)
+ void requestPermission(WebCore::ScriptExecutionContext*, PassRefPtr<WebCore::NotificationPermissionCallback>);
+#endif
+ void cancelRequestsForPermission(WebCore::ScriptExecutionContext*);
+ WebCore::NotificationClient::Permission checkPermission(WebCore::ScriptExecutionContext*);
+
+ void updatePermission(const String& requestID, bool allowed);
+
+ void notificationClicked(const String& notificationID);
+ void notificationClosed(const String& notificationID);
+ void notificationError(const String& notificationID);
+ void notificationShown(const String& notificationID);
+
+private:
+ void removeNotificationFromContextMap(const String& notificationID, WebCore::Notification*);
+
+ WebPagePrivate* m_webPagePrivate;
+ typedef HashMap<RefPtr<WebCore::Notification>, String> NotificationMap;
+ NotificationMap m_notificationMap;
+
+ typedef HashMap<String, RefPtr<WebCore::Notification> > NotificationIdMap;
+ NotificationIdMap m_notificationIDMap;
+
+ typedef HashMap<RefPtr<WebCore::ScriptExecutionContext>, Vector<String> > NotificationContextMap;
+ NotificationContextMap m_notificationContextMap;
+
+#if ENABLE(NOTIFICATIONS)
+ typedef HashMap<String, RefPtr<WebCore::NotificationPermissionCallback> > PermissionCallbackMap;
+ PermissionCallbackMap m_idToCallbackMap;
+#endif
+#if ENABLE(LEGACY_NOTIFICATIONS)
+ typedef HashMap<String, RefPtr<WebCore::VoidCallback> > VoidCallbackMap;
+ VoidCallbackMap m_idToVoidCallbackMap;
+#endif
+ typedef HashMap<RefPtr<WebCore::SecurityOrigin>, String> OriginMap;
+ OriginMap m_originToIDMap;
+
+ typedef HashMap<String, RefPtr<WebCore::SecurityOrigin> > OriginIdMap;
+ OriginIdMap m_idToOriginMap;
+};
+
+}
+}
+
+#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
+#endif // NotificationManager_h