diff options
Diffstat (limited to 'WebCore/notifications')
-rw-r--r-- | WebCore/notifications/Notification.cpp | 18 | ||||
-rw-r--r-- | WebCore/notifications/Notification.h | 7 | ||||
-rw-r--r-- | WebCore/notifications/Notification.idl | 8 | ||||
-rw-r--r-- | WebCore/notifications/NotificationCenter.cpp | 4 | ||||
-rw-r--r-- | WebCore/notifications/NotificationCenter.h | 8 | ||||
-rw-r--r-- | WebCore/notifications/NotificationContents.h | 6 | ||||
-rw-r--r-- | WebCore/notifications/NotificationPresenter.h | 6 |
7 files changed, 28 insertions, 29 deletions
diff --git a/WebCore/notifications/Notification.cpp b/WebCore/notifications/Notification.cpp index ed30800..182f713 100644 --- a/WebCore/notifications/Notification.cpp +++ b/WebCore/notifications/Notification.cpp @@ -42,24 +42,24 @@ namespace WebCore { -Notification::Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) +Notification::Notification(const KURL& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) : ActiveDOMObject(context, this) , m_isHTML(true) , m_isShowing(false) , m_presenter(provider) { ASSERT(m_presenter); - Document* document = context->isDocument() ? static_cast<Document*>(context) : 0; - if (m_presenter->checkPermission(context->url(), document) != NotificationPresenter::PermissionAllowed) { + if (m_presenter->checkPermission(context->url()) != NotificationPresenter::PermissionAllowed) { ec = SECURITY_ERR; return; } - m_notificationURL = context->completeURL(url); - if (url.isEmpty() || !m_notificationURL.isValid()) { + if (url.isEmpty() || !url.isValid()) { ec = SYNTAX_ERR; return; } + + m_notificationURL = url; } Notification::Notification(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) @@ -70,14 +70,12 @@ Notification::Notification(const NotificationContents& contents, ScriptExecution , m_presenter(provider) { ASSERT(m_presenter); - Document* document = context->isDocument() ? static_cast<Document*>(context) : 0; - if (m_presenter->checkPermission(context->url(), document) != NotificationPresenter::PermissionAllowed) { + if (m_presenter->checkPermission(context->url()) != NotificationPresenter::PermissionAllowed) { ec = SECURITY_ERR; return; } - - KURL icon = context->completeURL(contents.icon()); - if (!icon.isEmpty() && !icon.isValid()) { + + if (!contents.icon().isEmpty() && !contents.icon().isValid()) { ec = SYNTAX_ERR; return; } diff --git a/WebCore/notifications/Notification.h b/WebCore/notifications/Notification.h index 6545579..98cbfdf 100644 --- a/WebCore/notifications/Notification.h +++ b/WebCore/notifications/Notification.h @@ -55,7 +55,7 @@ namespace WebCore { class Notification : public RefCounted<Notification>, public ActiveDOMObject, public EventTarget { public: - static Notification* create(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) { return new Notification(url, context, ec, provider); } + static Notification* create(const KURL& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) { return new Notification(url, context, ec, provider); } static Notification* create(const NotificationContents& contents, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider) { return new Notification(contents, context, ec, provider); } virtual ~Notification(); @@ -65,6 +65,7 @@ namespace WebCore { bool isHTML() { return m_isHTML; } KURL url() { return m_notificationURL; } + KURL iconURL() { return m_contents.icon(); } NotificationContents& contents() { return m_contents; } DEFINE_ATTRIBUTE_EVENT_LISTENER(display); @@ -79,8 +80,8 @@ namespace WebCore { virtual Notification* toNotification() { return this; } private: - Notification(const String& url, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider); - Notification(const NotificationContents& fields, ScriptExecutionContext* context, ExceptionCode& ec, NotificationPresenter* provider); + Notification(const KURL&, ScriptExecutionContext*, ExceptionCode&, NotificationPresenter*); + Notification(const NotificationContents&, ScriptExecutionContext*, ExceptionCode&, NotificationPresenter*); // EventTarget interface virtual void refEventTarget() { ref(); } diff --git a/WebCore/notifications/Notification.idl b/WebCore/notifications/Notification.idl index b17546a..b99da96 100644 --- a/WebCore/notifications/Notification.idl +++ b/WebCore/notifications/Notification.idl @@ -43,12 +43,12 @@ module threads { attribute EventListener onclose; // EventTarget interface - [Custom] void addEventListener(in DOMString type, - in EventListener listener, - in boolean useCapture); - [Custom] void removeEventListener(in DOMString type, + [JSCCustom] void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture); + [JSCCustom] void removeEventListener(in DOMString type, + in EventListener listener, + in boolean useCapture); boolean dispatchEvent(in Event evt) raises(EventException); }; diff --git a/WebCore/notifications/NotificationCenter.cpp b/WebCore/notifications/NotificationCenter.cpp index ad9fbec..8089d87 100644 --- a/WebCore/notifications/NotificationCenter.cpp +++ b/WebCore/notifications/NotificationCenter.cpp @@ -49,9 +49,7 @@ int NotificationCenter::checkPermission() { if (!presenter()) return NotificationPresenter::PermissionDenied; - return m_notificationPresenter->checkPermission( - m_scriptExecutionContext->url(), - m_scriptExecutionContext->isDocument() ? static_cast<Document*>(m_scriptExecutionContext) : 0); + return m_notificationPresenter->checkPermission(m_scriptExecutionContext->url()); } void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback) diff --git a/WebCore/notifications/NotificationCenter.h b/WebCore/notifications/NotificationCenter.h index ae3dc02..acf1ae5 100644 --- a/WebCore/notifications/NotificationCenter.h +++ b/WebCore/notifications/NotificationCenter.h @@ -55,7 +55,11 @@ namespace WebCore { ec = INVALID_STATE_ERR; return 0; } - return Notification::create(KURL(ParsedURLString, URI), context(), ec, presenter()); + if (URI.isEmpty()) { + ec = SYNTAX_ERR; + return 0; + } + return Notification::create(m_scriptExecutionContext->completeURL(URI), context(), ec, presenter()); } Notification* createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec) @@ -64,7 +68,7 @@ namespace WebCore { ec = INVALID_STATE_ERR; return 0; } - NotificationContents contents(iconURI, title, body); + NotificationContents contents(iconURI.isEmpty() ? KURL() : m_scriptExecutionContext->completeURL(iconURI), title, body); return Notification::create(contents, context(), ec, presenter()); } diff --git a/WebCore/notifications/NotificationContents.h b/WebCore/notifications/NotificationContents.h index ebdc514..5807f30 100644 --- a/WebCore/notifications/NotificationContents.h +++ b/WebCore/notifications/NotificationContents.h @@ -38,17 +38,17 @@ namespace WebCore { class NotificationContents { public: NotificationContents() {} - NotificationContents(const String& iconUrl, const String& title, const String& body) + NotificationContents(const KURL& iconUrl, const String& title, const String& body) : m_icon(iconUrl) , m_title(title) , m_body(body) {} - String icon() const { return m_icon; } + KURL icon() const { return m_icon; } String title() const { return m_title; } String body() const { return m_body; } private: - String m_icon; + KURL m_icon; String m_title; String m_body; }; diff --git a/WebCore/notifications/NotificationPresenter.h b/WebCore/notifications/NotificationPresenter.h index 3df03bb..193eb2b 100644 --- a/WebCore/notifications/NotificationPresenter.h +++ b/WebCore/notifications/NotificationPresenter.h @@ -71,10 +71,8 @@ namespace WebCore { // made a decision. virtual void requestPermission(SecurityOrigin*, PassRefPtr<VoidCallback>) = 0; - // Checks the current level of permission for the specified URL. If the - // URL is a document (as opposed to a worker or other ScriptExecutionContext), - // |document| will also be provided. - virtual Permission checkPermission(const KURL&, Document*) = 0; + // Checks the current level of permission. + virtual Permission checkPermission(const KURL&) = 0; }; } // namespace WebCore |