Skip to content
Permalink
Browse files
Rename NotificationPresenter to NotificationClient
https://bugs.webkit.org/show_bug.cgi?id=80488
<rdar://problem/10965558>

Reviewed by Kentaro Hara.

Source/WebCore:

* notifications/NotificationCenter.h: Renamed from notifications/NotificationPresenter.h.

Refactor to use renamed WebCore::NotificationClient.
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* notifications/Notification.cpp:
(WebCore::Notification::Notification):
(WebCore::Notification::show):
(WebCore::Notification::cancel):
(WebCore::Notification::contextDestroyed):
(WebCore::Notification::finishLoading):
* notifications/NotificationCenter.cpp:
(WebCore::NotificationCenter::create):
(WebCore::NotificationCenter::NotificationCenter):
(WebCore::NotificationCenter::checkPermission):
(WebCore::NotificationCenter::requestPermission):
(WebCore::NotificationCenter::disconnectFrame):
* notifications/NotificationController.cpp:
(WebCore::NotificationController::NotificationController):
(WebCore::NotificationController::create):
(WebCore::NotificationController::clientFrom):
(WebCore::provideNotification):
* notifications/NotificationController.h:
(WebCore):
(NotificationController):
(WebCore::NotificationController::client):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::webkitNotifications):
* page/DOMWindow.h:
(DOMWindow):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::webkitNotifications):
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::WorkerThread):
* workers/WorkerThread.h:
(WebCore):
(WebCore::WorkerThread::getNotificationClient):
(WebCore::WorkerThread::setNotificationClient):
(WorkerThread):

Source/WebKit/blackberry:

Refactor to use renamed WebCore::NotificationClient.
* WebCoreSupport/NotificationPresenterImpl.cpp:
(WebCore::NotificationPresenterImpl::instance):
(WebCore::NotificationPresenterImpl::show):
(WebCore::NotificationPresenterImpl::checkPermission):
* WebCoreSupport/NotificationPresenterImpl.h:
(NotificationPresenterImpl):

Source/WebKit/chromium:

Refactor to use renamed WebCore::NotificationClient.
* src/AssertMatchingEnums.cpp:
* src/NotificationPresenterImpl.cpp:
(WebKit::NotificationPresenterImpl::checkPermission):
* src/NotificationPresenterImpl.h:
(NotificationPresenterImpl):

Source/WebKit/efl:

Refactor to use renamed WebCore::NotificationClient.
* WebCoreSupport/ChromeClientEfl.cpp:
(WebCore::ChromeClientEfl::notificationPresenter):
* WebCoreSupport/ChromeClientEfl.h:
(ChromeClientEfl):

Source/WebKit/mac:

Refactor to use renamed WebCore::NotificationClient.
* WebCoreSupport/WebNotificationClient.h:
* WebCoreSupport/WebNotificationClient.mm:
(WebNotificationClient::checkPermission):
* WebView/WebViewPrivate.h:

Source/WebKit/qt:

Refactor to use renamed WebCore::NotificationClient.
* WebCoreSupport/NotificationPresenterClientQt.cpp:
(WebCore::NotificationPresenterClientQt::checkPermission):
(WebCore::NotificationPresenterClientQt::allowNotificationForFrame):
* WebCoreSupport/NotificationPresenterClientQt.h:
(NotificationPresenterClientQt):

Source/WebKit/win:

Refactor to use renamed WebCore::NotificationClient.
* WebCoreSupport/WebChromeClient.h:
(WebChromeClient::notificationPresenter):
* WebCoreSupport/WebDesktopNotificationsDelegate.cpp:
(WebDesktopNotificationsDelegate::checkPermission):
* WebCoreSupport/WebDesktopNotificationsDelegate.h:
(WebDesktopNotificationsDelegate):

Source/WebKit/wince:

Refactor to use renamed WebCore::NotificationClient.
* WebCoreSupport/ChromeClientWinCE.h:
(ChromeClientWinCE):

Source/WebKit2:

Refactor to use renamed WebCore::NotificationClient.
* UIProcess/Notifications/WebNotificationManagerProxy.h:
* WebProcess/Notifications/NotificationPermissionRequestManager.cpp:
(WebKit::NotificationPermissionRequestManager::startRequest):
(WebKit::NotificationPermissionRequestManager::permissionLevel):
* WebProcess/Notifications/NotificationPermissionRequestManager.h:
(NotificationPermissionRequestManager):
* WebProcess/Notifications/WebNotificationManager.cpp:
(WebKit::WebNotificationManager::policyForOrigin):
* WebProcess/Notifications/WebNotificationManager.h:
(WebNotificationManager):
* WebProcess/WebCoreSupport/WebNotificationClient.cpp:
(WebKit::WebNotificationClient::checkPermission):
* WebProcess/WebCoreSupport/WebNotificationClient.h:
(WebNotificationClient):

Tools:

Refactor to use renamed WebCore::NotificationClient.
* DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp:
(DRTDesktopNotificationPresenter::checkNotificationPermission):

Canonical link: https://commits.webkit.org/97972@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@110381 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
qanat committed Mar 10, 2012
1 parent b3629d4 commit f5279ef4fca7673c240bd99e679897b93fa0a082
Showing with 333 additions and 146 deletions.
  1. +52 −0 Source/WebCore/ChangeLog
  2. +1 −1 Source/WebCore/GNUmakefile.list.am
  3. +1 −1 Source/WebCore/Target.pri
  4. +1 −5 Source/WebCore/WebCore.exp.in
  5. +1 −1 Source/WebCore/WebCore.gypi
  6. +2 −2 Source/WebCore/WebCore.vcproj/WebCore.vcproj
  7. +4 −4 Source/WebCore/WebCore.xcodeproj/project.pbxproj
  8. +15 −15 Source/WebCore/notifications/Notification.cpp
  9. +15 −14 Source/WebCore/notifications/NotificationCenter.cpp
  10. +7 −7 Source/WebCore/notifications/NotificationCenter.h
  11. +8 −8 Source/WebCore/notifications/{NotificationPresenter.h → NotificationClient.h}
  12. +5 −5 Source/WebCore/notifications/NotificationController.cpp
  13. +6 −6 Source/WebCore/notifications/NotificationController.h
  14. +1 −1 Source/WebCore/page/DOMWindow.cpp
  15. +1 −1 Source/WebCore/page/DOMWindow.h
  16. +1 −1 Source/WebCore/workers/WorkerContext.cpp
  17. +1 −1 Source/WebCore/workers/WorkerThread.cpp
  18. +4 −4 Source/WebCore/workers/WorkerThread.h
  19. +16 −0 Source/WebKit/blackberry/ChangeLog
  20. +5 −5 Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.cpp
  21. +3 −3 Source/WebKit/blackberry/WebCoreSupport/NotificationPresenterImpl.h
  22. +15 −0 Source/WebKit/chromium/ChangeLog
  23. +4 −4 Source/WebKit/chromium/src/AssertMatchingEnums.cpp
  24. +2 −2 Source/WebKit/chromium/src/NotificationPresenterImpl.cpp
  25. +3 −3 Source/WebKit/chromium/src/NotificationPresenterImpl.h
  26. +14 −0 Source/WebKit/efl/ChangeLog
  27. +1 −1 Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.cpp
  28. +2 −2 Source/WebKit/efl/WebCoreSupport/ChromeClientEfl.h
  29. +14 −0 Source/WebKit/mac/ChangeLog
  30. +3 −3 Source/WebKit/mac/WebCoreSupport/WebNotificationClient.h
  31. +8 −8 Source/WebKit/mac/WebCoreSupport/WebNotificationClient.mm
  32. +1 −1 Source/WebKit/mac/WebView/WebViewPrivate.h
  33. +15 −0 Source/WebKit/qt/ChangeLog
  34. +3 −3 Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.cpp
  35. +5 −5 Source/WebKit/qt/WebCoreSupport/NotificationPresenterClientQt.h
  36. +16 −0 Source/WebKit/win/ChangeLog
  37. +1 −1 Source/WebKit/win/WebCoreSupport/WebChromeClient.h
  38. +2 −2 Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.cpp
  39. +4 −4 Source/WebKit/win/WebCoreSupport/WebDesktopNotificationsDelegate.h
  40. +12 −0 Source/WebKit/wince/ChangeLog
  41. +1 −1 Source/WebKit/wince/WebCoreSupport/ChromeClientWinCE.h
  42. +24 −0 Source/WebKit2/ChangeLog
  43. +1 −1 Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h
  44. +4 −4 Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.cpp
  45. +2 −2 Source/WebKit2/WebProcess/Notifications/NotificationPermissionRequestManager.h
  46. +4 −4 Source/WebKit2/WebProcess/Notifications/WebNotificationManager.cpp
  47. +2 −2 Source/WebKit2/WebProcess/Notifications/WebNotificationManager.h
  48. +2 −2 Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.cpp
  49. +3 −3 Source/WebKit2/WebProcess/WebCoreSupport/WebNotificationClient.h
  50. +12 −0 Tools/ChangeLog
  51. +3 −3 Tools/DumpRenderTree/win/DRTDesktopNotificationPresenter.cpp
@@ -1,3 +1,55 @@
2012-03-09 Jon Lee <jonlee@apple.com>

Rename NotificationPresenter to NotificationClient
https://bugs.webkit.org/show_bug.cgi?id=80488
<rdar://problem/10965558>

Reviewed by Kentaro Hara.

* notifications/NotificationCenter.h: Renamed from notifications/NotificationPresenter.h.

Refactor to use renamed WebCore::NotificationClient.
* GNUmakefile.list.am:
* Target.pri:
* WebCore.exp.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* notifications/Notification.cpp:
(WebCore::Notification::Notification):
(WebCore::Notification::show):
(WebCore::Notification::cancel):
(WebCore::Notification::contextDestroyed):
(WebCore::Notification::finishLoading):
* notifications/NotificationCenter.cpp:
(WebCore::NotificationCenter::create):
(WebCore::NotificationCenter::NotificationCenter):
(WebCore::NotificationCenter::checkPermission):
(WebCore::NotificationCenter::requestPermission):
(WebCore::NotificationCenter::disconnectFrame):
* notifications/NotificationController.cpp:
(WebCore::NotificationController::NotificationController):
(WebCore::NotificationController::create):
(WebCore::NotificationController::clientFrom):
(WebCore::provideNotification):
* notifications/NotificationController.h:
(WebCore):
(NotificationController):
(WebCore::NotificationController::client):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::webkitNotifications):
* page/DOMWindow.h:
(DOMWindow):
* workers/WorkerContext.cpp:
(WebCore::WorkerContext::webkitNotifications):
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::WorkerThread):
* workers/WorkerThread.h:
(WebCore):
(WebCore::WorkerThread::getNotificationClient):
(WebCore::WorkerThread::setNotificationClient):
(WorkerThread):

2012-03-10 Julien Chaffraix <jchaffraix@webkit.org>

RenderObject with 'resize' different from 'none' should have a RenderLayer
@@ -2822,12 +2822,12 @@ webcore_sources += \
Source/WebCore/mathml/MathMLTextElement.h \
Source/WebCore/notifications/NotificationCenter.cpp \
Source/WebCore/notifications/NotificationCenter.h \
Source/WebCore/notifications/NotificationClient.h \
Source/WebCore/notifications/NotificationContents.h \
Source/WebCore/notifications/NotificationController.cpp \
Source/WebCore/notifications/NotificationController.h \
Source/WebCore/notifications/Notification.cpp \
Source/WebCore/notifications/Notification.h \
Source/WebCore/notifications/NotificationPresenter.h \
Source/WebCore/page/animation/AnimationBase.cpp \
Source/WebCore/page/animation/AnimationBase.h \
Source/WebCore/page/animation/AnimationController.cpp \
@@ -2078,7 +2078,7 @@ HEADERS += \
mathml/MathMLTextElement.h \
notifications/Notification.h \
notifications/NotificationCenter.h \
notifications/NotificationPresenter.h \
notifications/NotificationClient.h \
notifications/NotificationContents.h \
notifications/NotificationController.h \
page/animation/AnimationBase.h \
@@ -597,11 +597,6 @@ __ZN7WebCore19TextResourceDecoder6decodeEPKcm
__ZN7WebCore19TextResourceDecoderC1ERKN3WTF6StringERKNS_12TextEncodingEb
__ZN7WebCore19TextResourceDecoderD1Ev
__ZN7WebCore19applicationIsSafariEv

#if ENABLE(NOTIFICATIONS)
__ZN7WebCore19provideNotificationEPNS_4PageEPNS_21NotificationPresenterE
#endif

__ZN7WebCore20DisplaySleepDisablerC1EPKc
__ZN7WebCore20DisplaySleepDisablerD1Ev
__ZN7WebCore20NodeRenderingContextC1EPNS_4NodeE
@@ -2128,6 +2123,7 @@ __ZN7WebCore12Notification17dispatchShowEventEv
__ZN7WebCore12Notification18dispatchClickEventEv
__ZN7WebCore12Notification18dispatchCloseEventEv
__ZN7WebCore12Notification18dispatchErrorEventEv
__ZN7WebCore19provideNotificationEPNS_4PageEPNS_18NotificationClientE
#endif

#if ENABLE(THREADED_SCROLLING)
@@ -208,9 +208,9 @@
'Modules/webdatabase/SQLTransactionErrorCallback.h',
'Modules/webdatabase/StorageTracker.h',
'Modules/webdatabase/StorageTrackerClient.h',
'notifications/NotificationClient.h',
'notifications/NotificationContents.h',
'notifications/NotificationController.h',
'notifications/NotificationPresenter.h',
'page/Chrome.h',
'page/ChromeClient.h',
'page/Console.h',
@@ -53594,11 +53594,11 @@
>
</File>
<File
RelativePath="..\notifications\NotificationContents.h"
RelativePath="..\notifications\NotificationClient.h"
>
</File>
<File
RelativePath="..\notifications\NotificationPresenter.h"
RelativePath="..\notifications\NotificationContents.h"
>
</File>
</Filter>
@@ -911,7 +911,7 @@
31FB1A6C120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31FB1A6B120A5D6900DC02A0 /* JSDeviceMotionEventCustom.cpp */; };
3314ACEB10892086000F0E56 /* JSExceptionBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3314ACE910892086000F0E56 /* JSExceptionBase.cpp */; };
3314ACEC10892086000F0E56 /* JSExceptionBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 3314ACEA10892086000F0E56 /* JSExceptionBase.h */; };
33503C9A10179A74003B47E1 /* NotificationPresenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503C9910179A74003B47E1 /* NotificationPresenter.h */; settings = {ATTRIBUTES = (Private, ); }; };
33503C9A10179A74003B47E1 /* NotificationClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503C9910179A74003B47E1 /* NotificationClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
33503CA310179AD7003B47E1 /* JSNotification.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33503C9F10179AD7003B47E1 /* JSNotification.cpp */; };
33503CA410179AD7003B47E1 /* JSNotification.h in Headers */ = {isa = PBXBuildFile; fileRef = 33503CA010179AD7003B47E1 /* JSNotification.h */; };
33503CA510179AD7003B47E1 /* JSNotificationCenter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33503CA110179AD7003B47E1 /* JSNotificationCenter.cpp */; };
@@ -7769,7 +7769,7 @@
3314ACEA10892086000F0E56 /* JSExceptionBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExceptionBase.h; sourceTree = "<group>"; };
333F704E0FB49CA2008E12A6 /* Notification.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Notification.idl; path = notifications/Notification.idl; sourceTree = "<group>"; };
333F704F0FB49CA2008E12A6 /* Notification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Notification.h; path = notifications/Notification.h; sourceTree = "<group>"; };
33503C9910179A74003B47E1 /* NotificationPresenter.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = NotificationPresenter.h; path = notifications/NotificationPresenter.h; sourceTree = "<group>"; };
33503C9910179A74003B47E1 /* NotificationClient.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = NotificationClient.h; path = notifications/NotificationClient.h; sourceTree = "<group>"; };
33503C9F10179AD7003B47E1 /* JSNotification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotification.cpp; sourceTree = "<group>"; };
33503CA010179AD7003B47E1 /* JSNotification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSNotification.h; sourceTree = "<group>"; };
33503CA110179AD7003B47E1 /* JSNotificationCenter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotificationCenter.cpp; sourceTree = "<group>"; };
@@ -14391,10 +14391,10 @@
3390CA510FFC157B00921962 /* NotificationCenter.cpp */,
3390CA520FFC157B00921962 /* NotificationCenter.h */,
3390CA530FFC157B00921962 /* NotificationCenter.idl */,
33503C9910179A74003B47E1 /* NotificationClient.h */,
3390CA540FFC157B00921962 /* NotificationContents.h */,
3128CA67147331520074C72A /* NotificationController.cpp */,
3128CA6A147331630074C72A /* NotificationController.h */,
33503C9910179A74003B47E1 /* NotificationPresenter.h */,
);
name = notifications;
sourceTree = "<group>";
@@ -23569,7 +23569,7 @@
3390CA560FFC157B00921962 /* NotificationCenter.h in Headers */,
3390CA580FFC157B00921962 /* NotificationContents.h in Headers */,
3128CA6B147331630074C72A /* NotificationController.h in Headers */,
33503C9A10179A74003B47E1 /* NotificationPresenter.h in Headers */,
33503C9A10179A74003B47E1 /* NotificationClient.h in Headers */,
98EB1F951313FE0500D0E1EA /* NotImplemented.h in Headers */,
1A569D0B0D7E2B82007C3983 /* NP_jsobject.h in Headers */,
1A927FD21416A15B003A83C8 /* npapi.h in Headers */,
@@ -39,8 +39,8 @@
#include "ErrorEvent.h"
#include "EventNames.h"
#include "NotificationCenter.h"
#include "NotificationClient.h"
#include "NotificationContents.h"
#include "NotificationPresenter.h"
#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "ThreadableLoader.h"
@@ -59,8 +59,8 @@ Notification::Notification(const KURL& url, ScriptExecutionContext* context, Exc
, m_state(Idle)
, m_notificationCenter(provider)
{
ASSERT(m_notificationCenter->presenter());
if (m_notificationCenter->presenter()->checkPermission(context) != NotificationPresenter::PermissionAllowed) {
ASSERT(m_notificationCenter->client());
if (m_notificationCenter->client()->checkPermission(context) != NotificationClient::PermissionAllowed) {
ec = SECURITY_ERR;
return;
}
@@ -80,8 +80,8 @@ Notification::Notification(const NotificationContents& contents, ScriptExecution
, m_state(Idle)
, m_notificationCenter(provider)
{
ASSERT(m_notificationCenter->presenter());
if (m_notificationCenter->presenter()->checkPermission(context) != NotificationPresenter::PermissionAllowed) {
ASSERT(m_notificationCenter->client());
if (m_notificationCenter->client()->checkPermission(context) != NotificationClient::PermissionAllowed) {
ec = SECURITY_ERR;
return;
}
@@ -127,19 +127,19 @@ void Notification::show()
// handling of ondisplay may rely on that.
if (m_state == Idle) {
m_state = Showing;
if (m_notificationCenter->presenter())
m_notificationCenter->presenter()->show(this);
if (m_notificationCenter->client())
m_notificationCenter->client()->show(this);
}
} else
startLoading();
#elif PLATFORM(MAC)
if (m_state == Idle && m_notificationCenter->presenter()) {
m_notificationCenter->presenter()->show(this);
if (m_state == Idle && m_notificationCenter->client()) {
m_notificationCenter->client()->show(this);
m_state = Showing;
}
#else
// prevent double-showing
if (m_state == Idle && m_notificationCenter->presenter() && m_notificationCenter->presenter()->show(this))
if (m_state == Idle && m_notificationCenter->client() && m_notificationCenter->client()->show(this))
m_state = Showing;
#endif
}
@@ -154,8 +154,8 @@ void Notification::cancel()
stopLoading();
break;
case Showing:
if (m_notificationCenter->presenter())
m_notificationCenter->presenter()->cancel(this);
if (m_notificationCenter->client())
m_notificationCenter->client()->cancel(this);
break;
case Cancelled:
break;
@@ -175,8 +175,8 @@ EventTargetData* Notification::ensureEventTargetData()
void Notification::contextDestroyed()
{
ActiveDOMObject::contextDestroyed();
if (m_notificationCenter->presenter())
m_notificationCenter->presenter()->notificationObjectDestroyed(this);
if (m_notificationCenter->client())
m_notificationCenter->client()->notificationObjectDestroyed(this);
}

void Notification::startLoading()
@@ -234,7 +234,7 @@ void Notification::didFailRedirectCheck()
void Notification::finishLoading()
{
if (m_state == Loading) {
if (m_notificationCenter->presenter() && m_notificationCenter->presenter()->show(this))
if (m_notificationCenter->client() && m_notificationCenter->client()->show(this))
m_state = Showing;
}
unsetPendingActivity(this);
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -35,46 +36,46 @@
#include "NotificationCenter.h"

#include "Document.h"
#include "NotificationPresenter.h"
#include "NotificationClient.h"
#include "VoidCallback.h"
#include "WorkerContext.h"

namespace WebCore {

PassRefPtr<NotificationCenter> NotificationCenter::create(ScriptExecutionContext* context, NotificationPresenter* presenter)
PassRefPtr<NotificationCenter> NotificationCenter::create(ScriptExecutionContext* context, NotificationClient* client)
{
RefPtr<NotificationCenter> notificationCenter(adoptRef(new NotificationCenter(context, presenter)));
RefPtr<NotificationCenter> notificationCenter(adoptRef(new NotificationCenter(context, client)));
notificationCenter->suspendIfNeeded();
return notificationCenter.release();
}

NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationPresenter* presenter)
NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationClient* client)
: ActiveDOMObject(context, this)
, m_notificationPresenter(presenter) {}
, m_client(client) { }

int NotificationCenter::checkPermission()
{
if (!presenter() || !scriptExecutionContext())
return NotificationPresenter::PermissionDenied;
return m_notificationPresenter->checkPermission(scriptExecutionContext());
if (!client() || !scriptExecutionContext())
return NotificationClient::PermissionDenied;
return m_client->checkPermission(scriptExecutionContext());
}

void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback)
{
if (!presenter() || !scriptExecutionContext())
if (!client() || !scriptExecutionContext())
return;
m_notificationPresenter->requestPermission(scriptExecutionContext(), callback);
m_client->requestPermission(scriptExecutionContext(), callback);
}

void NotificationCenter::disconnectFrame()
{
// Can be 0 if iframe was transferred into another page. In this case
// this method is invoked more then once.
if (!m_notificationPresenter)
if (!m_client)
return;
m_notificationPresenter->cancelRequestsForPermission(scriptExecutionContext());
m_notificationPresenter->clearNotifications(scriptExecutionContext());
m_notificationPresenter = 0;
m_client->cancelRequestsForPermission(scriptExecutionContext());
m_client->clearNotifications(scriptExecutionContext());
m_client = 0;
}

} // namespace WebCore
@@ -45,16 +45,16 @@

namespace WebCore {

class NotificationPresenter;
class NotificationClient;
class VoidCallback;

class NotificationCenter : public RefCounted<NotificationCenter>, public ActiveDOMObject {
public:
static PassRefPtr<NotificationCenter> create(ScriptExecutionContext*, NotificationPresenter*);
static PassRefPtr<NotificationCenter> create(ScriptExecutionContext*, NotificationClient*);

PassRefPtr<Notification> createHTMLNotification(const String& URI, ExceptionCode& ec)
{
if (!presenter()) {
if (!client()) {
ec = INVALID_STATE_ERR;
return 0;
}
@@ -67,25 +67,25 @@ class NotificationCenter : public RefCounted<NotificationCenter>, public ActiveD

PassRefPtr<Notification> createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
{
if (!presenter()) {
if (!client()) {
ec = INVALID_STATE_ERR;
return 0;
}
NotificationContents contents(iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(iconURI), title, body);
return Notification::create(contents, scriptExecutionContext(), ec, this);
}

NotificationPresenter* presenter() const { return m_notificationPresenter; }
NotificationClient* client() const { return m_client; }

int checkPermission();
void requestPermission(PassRefPtr<VoidCallback>);

void disconnectFrame();

private:
NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
NotificationCenter(ScriptExecutionContext*, NotificationClient*);

NotificationPresenter* m_notificationPresenter;
NotificationClient* m_client;
};

} // namespace WebCore

0 comments on commit f5279ef

Please sign in to comment.