Reviewed by Adam Barth.
Refactor: NotificationCenter shouldn't hold its own copy of the ScriptExecutionContext*
when it inherits one from ActiveDOMObject.
https://bugs.webkit.org/show_bug.cgi?id=53815
* bindings/js/JSDesktopNotificationsCustom.cpp:
(WebCore::JSNotificationCenter::requestPermission):
* bindings/v8/custom/V8NotificationCenterCustom.cpp:
(WebCore::V8NotificationCenter::requestPermissionCallback):
* notifications/NotificationCenter.cpp:
(WebCore::NotificationCenter::NotificationCenter):
(WebCore::NotificationCenter::checkPermission):
(WebCore::NotificationCenter::requestPermission):
(WebCore::NotificationCenter::disconnectFrame):
* notifications/NotificationCenter.h:
(WebCore::NotificationCenter::createHTMLNotification):
(WebCore::NotificationCenter::createNotification):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77738
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2011-02-05 Nate Chapin <japhet@chromium.org>
+
+ Reviewed by Adam Barth.
+
+ Refactor: NotificationCenter shouldn't hold its own copy of the ScriptExecutionContext*
+ when it inherits one from ActiveDOMObject.
+ https://bugs.webkit.org/show_bug.cgi?id=53815
+
+ * bindings/js/JSDesktopNotificationsCustom.cpp:
+ (WebCore::JSNotificationCenter::requestPermission):
+ * bindings/v8/custom/V8NotificationCenterCustom.cpp:
+ (WebCore::V8NotificationCenter::requestPermissionCallback):
+ * notifications/NotificationCenter.cpp:
+ (WebCore::NotificationCenter::NotificationCenter):
+ (WebCore::NotificationCenter::checkPermission):
+ (WebCore::NotificationCenter::requestPermission):
+ (WebCore::NotificationCenter::disconnectFrame):
+ * notifications/NotificationCenter.h:
+ (WebCore::NotificationCenter::createHTMLNotification):
+ (WebCore::NotificationCenter::createNotification):
+
2011-02-04 Adam Barth <abarth@webkit.org>
Reviewed by Maciej Stachowiak.
JSValue JSNotificationCenter::requestPermission(ExecState* exec)
{
- ScriptExecutionContext* context = impl()->context();
+ ScriptExecutionContext* context = impl()->scriptExecutionContext();
// Make sure that script execution context is valid.
if (!context) {
{
INC_STATS(L"DOM.NotificationCenter.RequestPermission()");
NotificationCenter* notificationCenter = V8NotificationCenter::toNative(args.Holder());
- ScriptExecutionContext* context = notificationCenter->context();
+ ScriptExecutionContext* context = notificationCenter->scriptExecutionContext();
// Make sure that script execution context is valid.
if (!context)
NotificationCenter::NotificationCenter(ScriptExecutionContext* context, NotificationPresenter* presenter)
: ActiveDOMObject(context, this)
- , m_scriptExecutionContext(context)
, m_notificationPresenter(presenter) {}
int NotificationCenter::checkPermission()
{
- if (!presenter())
+ if (!presenter() || !scriptExecutionContext())
return NotificationPresenter::PermissionDenied;
- return m_notificationPresenter->checkPermission(m_scriptExecutionContext);
+ return m_notificationPresenter->checkPermission(scriptExecutionContext());
}
void NotificationCenter::requestPermission(PassRefPtr<VoidCallback> callback)
{
- if (!presenter())
+ if (!presenter() || !scriptExecutionContext())
return;
- m_notificationPresenter->requestPermission(m_scriptExecutionContext, callback);
+ m_notificationPresenter->requestPermission(scriptExecutionContext(), callback);
}
void NotificationCenter::disconnectFrame()
ASSERT(m_notificationPresenter);
if (!m_notificationPresenter)
return;
- m_notificationPresenter->cancelRequestsForPermission(m_scriptExecutionContext);
+ m_notificationPresenter->cancelRequestsForPermission(scriptExecutionContext());
m_notificationPresenter = 0;
- m_scriptExecutionContext = 0;
}
} // namespace WebCore
ec = SYNTAX_ERR;
return 0;
}
- return Notification::create(m_scriptExecutionContext->completeURL(URI), context(), ec, this);
+ return Notification::create(scriptExecutionContext()->completeURL(URI), scriptExecutionContext(), ec, this);
}
PassRefPtr<Notification> createNotification(const String& iconURI, const String& title, const String& body, ExceptionCode& ec)
ec = INVALID_STATE_ERR;
return 0;
}
- NotificationContents contents(iconURI.isEmpty() ? KURL() : m_scriptExecutionContext->completeURL(iconURI), title, body);
- return Notification::create(contents, context(), ec, this);
+ NotificationContents contents(iconURI.isEmpty() ? KURL() : scriptExecutionContext()->completeURL(iconURI), title, body);
+ return Notification::create(contents, scriptExecutionContext(), ec, this);
}
- ScriptExecutionContext* context() const { return m_scriptExecutionContext; }
NotificationPresenter* presenter() const { return m_notificationPresenter; }
int checkPermission();
private:
NotificationCenter(ScriptExecutionContext*, NotificationPresenter*);
- ScriptExecutionContext* m_scriptExecutionContext;
NotificationPresenter* m_notificationPresenter;
};