diff options
-rw-r--r-- | chrome/worker/webworkerclient_proxy.h | 7 | ||||
-rw-r--r-- | webkit/api/public/WebNotification.h | 106 | ||||
-rw-r--r-- | webkit/api/public/WebNotificationPermissionCallback.h | 51 | ||||
-rw-r--r-- | webkit/api/public/WebNotificationPresenter.h | 71 | ||||
-rw-r--r-- | webkit/api/public/WebWorkerClient.h | 5 | ||||
-rw-r--r-- | webkit/api/src/NotificationPresenterImpl.cpp | 113 | ||||
-rw-r--r-- | webkit/api/src/NotificationPresenterImpl.h | 68 | ||||
-rw-r--r-- | webkit/api/src/WebNotification.cpp | 133 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.cc | 7 | ||||
-rw-r--r-- | webkit/glue/chrome_client_impl.h | 4 | ||||
-rw-r--r-- | webkit/glue/webview_delegate.h | 7 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 8 | ||||
-rw-r--r-- | webkit/glue/webview_impl.h | 11 | ||||
-rw-r--r-- | webkit/glue/webworkerclient_impl.h | 5 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_worker/test_webworker.h | 4 | ||||
-rw-r--r-- | webkit/webkit.gyp | 7 |
16 files changed, 607 insertions, 0 deletions
diff --git a/chrome/worker/webworkerclient_proxy.h b/chrome/worker/webworkerclient_proxy.h index 8807d63..0d5987f 100644 --- a/chrome/worker/webworkerclient_proxy.h +++ b/chrome/worker/webworkerclient_proxy.h @@ -47,6 +47,13 @@ class WebWorkerClientProxy : public WebKit::WebWorkerClient, virtual void workerContextDestroyed(); virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client); + virtual WebKit::WebNotificationPresenter* notificationPresenter() { + // TODO(johnnyg): Notifications are not yet hooked up to workers. + // Coming soon. + NOTREACHED(); + return NULL; + } + // IPC::Channel::Listener implementation. virtual void OnMessageReceived(const IPC::Message& message); diff --git a/webkit/api/public/WebNotification.h b/webkit/api/public/WebNotification.h new file mode 100644 index 0000000..3d96c48 --- /dev/null +++ b/webkit/api/public/WebNotification.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 WebNotification_h +#define WebNotification_h + +#include "WebCommon.h" + +#if WEBKIT_IMPLEMENTATION +namespace WebCore { class Notification; } +namespace WTF { template <typename T> class PassRefPtr; } +#endif + +namespace WebKit { + class WebNotificationPrivate; + class WebURL; + class WebString; + + // Represents access to a desktop notification. + class WebNotification { + public: + WebNotification() : m_private(0) { } + WebNotification(const WebNotification& other) : m_private(0) { assign(other); } + + ~WebNotification() { reset(); } + + WEBKIT_API void reset(); + WEBKIT_API void assign(const WebNotification&); + + WebNotification& operator=(const WebNotification& other) { assign(other); return *this; } + + bool equals(const WebNotification& other) const { return m_private == other.m_private; } + + // Is the notification HTML vs. icon-title-text? + WEBKIT_API bool isHTML() const; + + // If HTML, the URL which contains the contents of the notification. + WEBKIT_API WebURL url() const; + + // If not HTML, the parameters for the icon-title-text notification. + WEBKIT_API WebString icon() const; + WEBKIT_API WebString title() const; + WEBKIT_API WebString body() const; + + // Called to indicate the notification has been displayed. + WEBKIT_API void dispatchDisplayEvent(); + + // Called to indicate an error has occurred with this notification. + WEBKIT_API void dispatchErrorEvent(const WebString& errorMessage); + + // Called to indicate the notification has been closed. If it was + // closed by the user (as opposed to automatically by the system), + // the byUser parameter will be true. + WEBKIT_API void dispatchCloseEvent(bool byUser); + +#if WEBKIT_IMPLEMENTATION + WebNotification(const WTF::PassRefPtr<WebCore::Notification>&); + WebNotification& operator=(const WTF::PassRefPtr<WebCore::Notification>&); + operator WTF::PassRefPtr<WebCore::Notification>() const; +#endif + + private: + void assign(WebNotificationPrivate*); + WebNotificationPrivate* m_private; + }; + + inline bool operator==(const WebNotification& a, const WebNotification& b) + { + return a.equals(b); + } + + inline bool operator!=(const WebNotification& a, const WebNotification& b) + { + return !a.equals(b); + } + +} // namespace WebKit + +#endif diff --git a/webkit/api/public/WebNotificationPermissionCallback.h b/webkit/api/public/WebNotificationPermissionCallback.h new file mode 100644 index 0000000..6b18dda --- /dev/null +++ b/webkit/api/public/WebNotificationPermissionCallback.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 WebNotificationPermissionCallback_h +#define WebNotificationPermissionCallback_h + +namespace WebKit { + + // Callback object used with WebNotificationPresenter. + class WebNotificationPermissionCallback { + public: + // Method to be invoked when the async permission request involving + // this object has been completed. + virtual void permissionRequestComplete() = 0; + + protected: + // This object is to be destroyed after the callback is invoked; + // it should not be directly destroyed. + ~WebNotificationPermissionCallback() {} + }; + +} // namespace WebKit + +#endif diff --git a/webkit/api/public/WebNotificationPresenter.h b/webkit/api/public/WebNotificationPresenter.h new file mode 100644 index 0000000..208a4f3 --- /dev/null +++ b/webkit/api/public/WebNotificationPresenter.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 WebNotificationPresenter_h +#define WebNotificationPresenter_h + +#include "WebString.h" + +namespace WebKit { + + class WebNotification; + class WebNotificationPermissionCallback; + + // Provides the services to show desktop notifications to the user. + class WebNotificationPresenter { + public: + enum Permission { + PermissionAllowed, // User has allowed permission to the origin. + PermissionNotAllowed, // User has not taken an action on the origin (defaults to not allowed). + PermissionDenied // User has explicitly denied permission from the origin. + }; + + // Shows a notification. + virtual bool show(const WebNotification&) = 0; + + // Cancels a notification previously shown, and removes it if being shown. + virtual void cancel(const WebNotification&) = 0; + + // Indiciates that the notification object subscribed to events for a previously shown notification is + // being destroyed. Does _not_ remove the notification if being shown, but detaches it from receiving events. + virtual void objectDestroyed(const WebNotification&) = 0; + + // Checks the permission level of a given origin. + virtual Permission checkPermission(const WebString& origin) = 0; + + // Requests permission for a given origin. This operation is asynchronous and the callback provided + // will be invoked when the permission decision is made. Callback pointer must remain + // valid until called. + virtual void requestPermission(const WebString& origin, WebNotificationPermissionCallback* callback) = 0; + }; + +} // namespace WebKit + +#endif diff --git a/webkit/api/public/WebWorkerClient.h b/webkit/api/public/WebWorkerClient.h index b9d8cef..c0aa1bd 100644 --- a/webkit/api/public/WebWorkerClient.h +++ b/webkit/api/public/WebWorkerClient.h @@ -34,6 +34,7 @@ #include "WebMessagePortChannel.h" namespace WebKit { + class WebNotificationPresenter; class WebString; class WebWorker; @@ -64,6 +65,10 @@ namespace WebKit { virtual void workerContextDestroyed() = 0; + // Returns the notification presenter for this worker context. Pointer + // is owned by the object implementing WebWorkerClient. + virtual WebNotificationPresenter* notificationPresenter() = 0; + // This can be called on any thread to create a nested worker. virtual WebWorker* createWorker(WebWorkerClient* client) = 0; diff --git a/webkit/api/src/NotificationPresenterImpl.cpp b/webkit/api/src/NotificationPresenterImpl.cpp new file mode 100644 index 0000000..d6a8afc --- /dev/null +++ b/webkit/api/src/NotificationPresenterImpl.cpp @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 "NotificationPresenterImpl.h" + +#if ENABLE(NOTIFICATIONS) + +#include "WebNotification.h" +#include "WebNotificationPermissionCallback.h" +#include "WebNotificationPresenter.h" + +#include "Notification.h" +#include "SecurityOrigin.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +// Ensure that our publicly defined enum values never get out of sync with the +// ones declared for use within WebCore. +#define COMPILE_ASSERT_MATCHING_ENUM(name) \ + COMPILE_ASSERT(int(WebNotificationPresenter::name) == int(NotificationPresenter::name), name) + +COMPILE_ASSERT_MATCHING_ENUM(PermissionAllowed); +COMPILE_ASSERT_MATCHING_ENUM(PermissionNotAllowed); +COMPILE_ASSERT_MATCHING_ENUM(PermissionDenied); + +class VoidCallbackClient : public WebNotificationPermissionCallback { +public: + VoidCallbackClient(PassRefPtr<VoidCallback> callback) + : m_callback(callback) + { + } + + virtual void permissionRequestComplete() + { + if (m_callback) + m_callback->handleEvent(); + delete this; + } + +private: + RefPtr<VoidCallback> m_callback; +}; + +void NotificationPresenterImpl::initialize(WebNotificationPresenter* presenter) +{ + m_presenter = presenter; +} + +bool NotificationPresenterImpl::isInitialized() +{ + return m_presenter != 0; +} + +bool NotificationPresenterImpl::show(Notification* notification) +{ + return m_presenter->show(PassRefPtr<Notification>(notification)); +} + +void NotificationPresenterImpl::cancel(Notification* notification) +{ + m_presenter->cancel(PassRefPtr<Notification>(notification)); +} + +void NotificationPresenterImpl::notificationObjectDestroyed(Notification* notification) +{ + m_presenter->objectDestroyed(PassRefPtr<Notification>(notification)); +} + +NotificationPresenter::Permission NotificationPresenterImpl::checkPermission(SecurityOrigin* origin) +{ + int result = m_presenter->checkPermission(origin->toString()); + return static_cast<NotificationPresenter::Permission>(result); +} + +void NotificationPresenterImpl::requestPermission(SecurityOrigin* origin, PassRefPtr<VoidCallback> callback) +{ + m_presenter->requestPermission(origin->toString(), new VoidCallbackClient(callback)); +} + +} // namespace WebKit + +#endif // ENABLE(NOTIFICATIONS) diff --git a/webkit/api/src/NotificationPresenterImpl.h b/webkit/api/src/NotificationPresenterImpl.h new file mode 100644 index 0000000..3e08f2e --- /dev/null +++ b/webkit/api/src/NotificationPresenterImpl.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 NotificationPresenterImpl_h +#define NotificationPresenterImpl_h + +#include "NotificationPresenter.h" +#include "VoidCallback.h" + +#include <wtf/HashMap.h> +#include <wtf/PassRefPtr.h> + +#if ENABLE(NOTIFICATIONS) + +namespace WebKit { + class WebNotificationPresenter; + + class NotificationPresenterImpl : public WebCore::NotificationPresenter { + public: + NotificationPresenterImpl() : m_presenter(0) { } + + void initialize(WebNotificationPresenter* presenter); + bool isInitialized(); + + // WebCore::NotificationPresenter implementation. + virtual bool show(WebCore::Notification* object); + virtual void cancel(WebCore::Notification* object); + virtual void notificationObjectDestroyed(WebCore::Notification* object); + virtual WebCore::NotificationPresenter::Permission checkPermission(WebCore::SecurityOrigin* origin); + virtual void requestPermission(WebCore::SecurityOrigin* origin, WTF::PassRefPtr<WebCore::VoidCallback> callback); + + private: + // WebNotificationPresenter that this object delegates to. + WebNotificationPresenter* m_presenter; + }; + +} // namespace WebKit + +#endif // ENABLE(NOTIFICATIONS) + +#endif diff --git a/webkit/api/src/WebNotification.cpp b/webkit/api/src/WebNotification.cpp new file mode 100644 index 0000000..46baab7 --- /dev/null +++ b/webkit/api/src/WebNotification.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2009 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * 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. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT + * OWNER OR 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 "WebNotification.h" + +#if ENABLE(NOTIFICATIONS) + +#include "WebString.h" +#include "WebURL.h" + +#include "Notification.h" +#include <wtf/PassRefPtr.h> + +using namespace WebCore; + +namespace WebKit { + +class WebNotificationPrivate : public Notification { +}; + +void WebNotification::reset() +{ + assign(0); +} + +void WebNotification::assign(const WebNotification& other) +{ + WebNotificationPrivate* p = const_cast<WebNotificationPrivate*>(other.m_private); + p->ref(); + assign(p); +} + +bool WebNotification::isHTML() const +{ + return m_private->isHTML(); +} + +WebURL WebNotification::url() const +{ + ASSERT(isHTML()); + return m_private->url(); +} + +WebString WebNotification::icon() const +{ + ASSERT(!isHTML()); + return m_private->contents().icon(); +} + +WebString WebNotification::title() const +{ + ASSERT(!isHTML()); + return m_private->contents().title(); +} + +WebString WebNotification::body() const +{ + ASSERT(!isHTML()); + return m_private->contents().body(); +} + +void WebNotification::dispatchDisplayEvent() +{ + m_private->dispatchDisplayEvent(); +} + +void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */) +{ + // FIXME: errorMessage not supported by WebCore yet + m_private->dispatchErrorEvent(); +} + +void WebNotification::dispatchCloseEvent(bool /* byUser */) +{ + // FIXME: byUser flag not supported by WebCore yet + m_private->dispatchCloseEvent(); +} + +WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notification) + : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef())) +{ +} + +WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification) +{ + assign(static_cast<WebNotificationPrivate*>(notification.releaseRef())); + return *this; +} + +WebNotification::operator WTF::PassRefPtr<Notification>() const +{ + return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_private)); +} + +void WebNotification::assign(WebNotificationPrivate* p) +{ + // p is already ref'd for us by the caller + if (m_private) + m_private->deref(); + m_private = p; +} + +} // namespace WebKit + +#endif // ENABLE(NOTIFICATIONS) diff --git a/webkit/glue/chrome_client_impl.cc b/webkit/glue/chrome_client_impl.cc index 75d30fd..5325a28 100644 --- a/webkit/glue/chrome_client_impl.cc +++ b/webkit/glue/chrome_client_impl.cc @@ -45,6 +45,7 @@ MSVC_POP_WARNING(); #include "webkit/api/public/WebRect.h" #include "webkit/api/public/WebTextDirection.h" #include "webkit/api/public/WebURLRequest.h" +#include "webkit/api/src/NotificationPresenterImpl.h" #include "webkit/api/src/WrappedResourceRequest.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/webframe_impl.h" @@ -642,3 +643,9 @@ void ChromeClientImpl::GetPopupMenuInfo(PopupContainer* popup_container, info->selectedIndex = popup_container->selectedIndex(); info->items.swap(output_items); } + +#if ENABLE(NOTIFICATIONS) +WebCore::NotificationPresenter* ChromeClientImpl::notificationPresenter() const { + return webview_->GetNotificationPresenter(); +} +#endif diff --git a/webkit/glue/chrome_client_impl.h b/webkit/glue/chrome_client_impl.h index 435e1f2..d95483d 100644 --- a/webkit/glue/chrome_client_impl.h +++ b/webkit/glue/chrome_client_impl.h @@ -148,6 +148,10 @@ class ChromeClientImpl : public WebCore::ChromeClientChromium { virtual PassOwnPtr<WebCore::HTMLParserQuirks> createHTMLParserQuirks() { return 0; } +#if ENABLE(NOTIFICATIONS) + virtual WebCore::NotificationPresenter* notificationPresenter() const; +#endif + private: void GetPopupMenuInfo(WebCore::PopupContainer* popup_container, WebKit::WebPopupMenuInfo* info); diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 6bf918c..386f2e8 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -53,6 +53,7 @@ class WebWorkerClient; class WebMediaPlayer; class WebMediaPlayerClient; class WebNode; +class WebNotificationPresenter; class WebURLRequest; class WebURLResponse; class WebWidget; @@ -549,6 +550,12 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { int new_width, int new_height) { } + // Called to retrieve the provider of desktop notifications. Pointer + // is owned by the implementation of WebViewDelegate. + virtual WebKit::WebNotificationPresenter* GetNotificationPresenter() { + return NULL; + } + // UIDelegate -------------------------------------------------------------- // Asks the browser to show a modal HTML dialog. The dialog is passed the diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 2a387df..c295303 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -1848,6 +1848,14 @@ WebCore::Node* WebViewImpl::GetNodeForWindowPos(int x, int y) { return result.innerNonSharedNode(); } +#if ENABLE(NOTIFICATIONS) +WebKit::NotificationPresenterImpl* WebViewImpl::GetNotificationPresenter() { + if (!notification_presenter_.isInitialized() && delegate_) + notification_presenter_.initialize(delegate_->GetNotificationPresenter()); + return ¬ification_presenter_; +} +#endif + void WebViewImpl::HideAutofillPopup() { HideAutoCompletePopup(); } diff --git a/webkit/glue/webview_impl.h b/webkit/glue/webview_impl.h index 5cc3c29..9161b1c 100644 --- a/webkit/glue/webview_impl.h +++ b/webkit/glue/webview_impl.h @@ -14,6 +14,7 @@ #include "skia/ext/platform_canvas.h" #include "webkit/api/public/WebPoint.h" #include "webkit/api/public/WebSize.h" +#include "webkit/api/src/NotificationPresenterImpl.h" #include "webkit/glue/back_forward_list_client_impl.h" #include "webkit/glue/webframe_impl.h" #include "webkit/glue/webpreferences.h" @@ -227,6 +228,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // the underlying Node for them. WebCore::Node* GetNodeForWindowPos(int x, int y); +#if ENABLE(NOTIFICATIONS) + // Returns the provider of desktop notifications. + WebKit::NotificationPresenterImpl* GetNotificationPresenter(); +#endif + protected: friend class WebView; // So WebView::Create can call our constructor friend class base::RefCounted<WebViewImpl>; @@ -366,6 +372,11 @@ class WebViewImpl : public WebView, public base::RefCounted<WebViewImpl> { // Inspector settings. std::wstring inspector_settings_; +#if ENABLE(NOTIFICATIONS) + // The provider of desktop notifications; + WebKit::NotificationPresenterImpl notification_presenter_; +#endif + // HACK: current_input_event is for ChromeClientImpl::show(), until we can fix // WebKit to pass enough information up into ChromeClient::show() so we can // decide if the window.open event was caused by a middle-mouse click diff --git a/webkit/glue/webworkerclient_impl.h b/webkit/glue/webworkerclient_impl.h index b9110ef..75310f4 100644 --- a/webkit/glue/webworkerclient_impl.h +++ b/webkit/glue/webworkerclient_impl.h @@ -68,6 +68,11 @@ class WebWorkerClientImpl : public WebCore::WorkerContextProxy, virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client) { return NULL; } + virtual WebKit::WebNotificationPresenter* notificationPresenter() { + // TODO(johnnyg): Notifications not yet supported in workers. + // Coming soon. + return NULL; + } private: virtual ~WebWorkerClientImpl(); diff --git a/webkit/tools/test_shell/test_worker/test_webworker.h b/webkit/tools/test_shell/test_worker/test_webworker.h index 3e987c0..ea6aaa8 100644 --- a/webkit/tools/test_shell/test_worker/test_webworker.h +++ b/webkit/tools/test_shell/test_worker/test_webworker.h @@ -11,6 +11,7 @@ #include "base/basictypes.h" #include "base/ref_counted.h" +#include "webkit/api/public/WebNotificationPresenter.h" #include "webkit/api/public/WebString.h" #include "webkit/api/public/WebWorker.h" #include "webkit/api/public/WebWorkerClient.h" @@ -56,6 +57,9 @@ class TestWebWorker : public WebKit::WebWorker, virtual WebKit::WebWorker* createWorker(WebKit::WebWorkerClient* client) { return NULL; } + virtual WebKit::WebNotificationPresenter* notificationPresenter() { + return NULL; + } private: friend class base::RefCounted<TestWebWorker>; diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 23c20ac..c2923ac 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -546,6 +546,7 @@ '--include', '../third_party/WebKit/WebCore/css', '--include', '../third_party/WebKit/WebCore/dom', '--include', '../third_party/WebKit/WebCore/html', + '--include', '../third_party/WebKit/WebCore/notifications', '--include', '../third_party/WebKit/WebCore/page', '--include', '../third_party/WebKit/WebCore/plugins', '--include', '../third_party/WebKit/WebCore/svg', @@ -1012,6 +1013,9 @@ 'api/public/WebNavigationType.h', 'api/public/WebNode.h', 'api/public/WebNonCopyable.h', + 'api/public/WebNotification.h', + 'api/public/WebNotificationPresenter.h', + 'api/public/WebNotificationPermissionCallback.h', 'api/public/WebPlugin.h', 'api/public/WebPluginContainer.h', 'api/public/WebPluginListBuilder.h', @@ -1056,6 +1060,8 @@ 'api/src/mac/WebScreenInfoFactory.mm', 'api/src/LocalizedStrings.cpp', 'api/src/MediaPlayerPrivateChromium.cpp', + 'api/src/NotificationPresenterImpl.h', + 'api/src/NotificationPresenterImpl.cpp', 'api/src/PlatformMessagePortChannel.cpp', 'api/src/PlatformMessagePortChannel.h', 'api/src/ResourceHandle.cpp', @@ -1085,6 +1091,7 @@ 'api/src/WebMediaPlayerClientImpl.cpp', 'api/src/WebMediaPlayerClientImpl.h', 'api/src/WebNode.cpp', + 'api/src/WebNotification.cpp', 'api/src/WebPluginContainerImpl.h', 'api/src/WebPluginContainerImpl.cpp', 'api/src/WebPluginListBuilderImpl.cpp', |