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) |