Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: Source/WebKit/chromium/src/NotificationPresenterImpl.cpp

Issue 12086041: Merge 140928 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1364/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/WebKit/chromium/src/NotificationPresenterImpl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/WebKit/chromium/src/NotificationPresenterImpl.cpp
===================================================================
--- Source/WebKit/chromium/src/NotificationPresenterImpl.cpp (revision 141072)
+++ Source/WebKit/chromium/src/NotificationPresenterImpl.cpp (working copy)
@@ -49,9 +49,10 @@
namespace WebKit {
+#if ENABLE(LEGACY_NOTIFICATIONS)
class VoidCallbackClient : public WebNotificationPermissionCallback {
public:
- VoidCallbackClient(PassRefPtr<VoidCallback> callback)
+ explicit VoidCallbackClient(PassRefPtr<VoidCallback> callback)
: m_callback(callback)
{
}
@@ -68,7 +69,34 @@
RefPtr<VoidCallback> m_callback;
};
+#endif // ENABLE(LEGACY_NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS)
+class NotificationPermissionCallbackClient : public WebNotificationPermissionCallback {
+public:
+ NotificationPermissionCallbackClient(WebNotificationPresenter* presenter, PassRefPtr<SecurityOrigin> securityOrigin, PassRefPtr<NotificationPermissionCallback> callback)
+ : m_presenter(presenter)
+ , m_securityOrigin(securityOrigin)
+ , m_callback(callback)
+ {
+ }
+
+ virtual void permissionRequestComplete()
+ {
+ if (m_callback)
+ m_callback->handleEvent(Notification::permissionString(static_cast<NotificationClient::Permission>(m_presenter->checkPermission(WebSecurityOrigin(m_securityOrigin)))));
+ delete this;
+ }
+
+private:
+ virtual ~NotificationPermissionCallbackClient() { }
+
+ WebNotificationPresenter* m_presenter;
+ RefPtr<SecurityOrigin> m_securityOrigin;
+ RefPtr<NotificationPermissionCallback> m_callback;
+};
+#endif // ENABLE(NOTIFICATIONS)
+
void NotificationPresenterImpl::initialize(WebNotificationPresenter* presenter)
{
m_presenter = presenter;
@@ -104,11 +132,20 @@
return static_cast<NotificationClient::Permission>(result);
}
+#if ENABLE(LEGACY_NOTIFICATIONS)
void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, PassRefPtr<VoidCallback> callback)
{
m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new VoidCallbackClient(callback));
}
+#endif // ENABLE(LEGACY_NOTIFICATIONS)
+#if ENABLE(NOTIFICATIONS)
+void NotificationPresenterImpl::requestPermission(ScriptExecutionContext* context, WTF::PassRefPtr<NotificationPermissionCallback> callback)
+{
+ m_presenter->requestPermission(WebSecurityOrigin(context->securityOrigin()), new NotificationPermissionCallbackClient(m_presenter, context->securityOrigin(), callback));
+}
+#endif // ENABLE(NOTIFICATIONS)
+
} // namespace WebKit
#endif // ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
« no previous file with comments | « Source/WebKit/chromium/src/NotificationPresenterImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698