Skip to content
  • jonlee@apple.com's avatar
    Create skeleton framework for notifications support in WK2 · 6c095456
    jonlee@apple.com authored
    https://bugs.webkit.org/show_bug.cgi?id=73253
    <rdar://problem/10356943>
    
    Source/JavaScriptCore:
    
    * Configurations/FeatureDefines.xcconfig: Split out ENABLE_NOTIFICATIONS based on platform.
    
    Source/WebCore:
    
    Reviewed by Sam Weinig.
    
    Some refactoring was done to make notifications follow a similar pattern to our other clients, like
    geolocation and context menu.
    
    * Configurations/FeatureDefines.xcconfig: Split out ENABLE_NOTIFICATIONS based on platform.
    * WebCore.xcodeproj/project.pbxproj: Adding new NotificationController class, and exposing
    Notification and NotificationController as private headers.
    * Target.pri: Ditto.
    * WebCore.gypi: Ditto.
    
    * notifications/NotificationContents.h: Converted class to struct. Members need to be accessible
    in order to do WK2 argument encoding.
    (WebCore::NotificationContents::NotificationContents):
    
    * notifications/Notification.cpp: Update style of entire file.
    (WebCore::Notification::Notification): Added default constructor (for WK2), and minor refactoring
    with NotificationContents.
    * notifications/Notification.h: Added set methods for WK2 serialization. Also, update indenting.
    (WebCore::Notification::setHTML): Added.
    (WebCore::Notification::setURL): Added.
    (WebCore::Notification::contents): Added const version for WK2.
    * notifications/NotificationCenter.h: Update style.
    
    * notifications/NotificationController.cpp: Added.
    (WebCore::NotificationController::NotificationController):
    (WebCore::NotificationController::~NotificationController):
    * notifications/NotificationController.h: Added.
    (WebCore::NotificationController::client):
    * notifications/NotificationPresenter.h: This acts like a client, and should probably be renamed as such.
    Removed ifdef for exposure to WK2.
    (WebCore::NotificationPresenter::~NotificationPresenter): Moved as protected instead of public.
    
    * page/DOMWindow.cpp:
    (WebCore::DOMWindow::webkitNotifications):  We move the request for the notification client from the chrome
    to the controller.
    * page/Page.cpp:
    (WebCore::Page::Page): The page now owns a notification controller.
    (WebCore::Page::PageClients::PageClients): Add notification client as a page client.
    * page/Page.h:
    (WebCore::Page::notificationController): Retrieve the notification controller.
    
    * page/ChromeClient.h: We move the request for the notification client from the chrome to the controller.
    Remove notificationPresenter().
    * page/Chrome.cpp: Remove notificationPresenter().
    * page/Chrome.h: Remove notificationPresenter().
    * loader/EmptyClients.h: Remove notificationPresenter().
    
    Source/WebKit:
    
    Reviewed by Sam Weinig.
    
    * WebKit.xcodeproj/project.pbxproj: Add WebNotificationClient class.
    
    Source/WebKit/chromium:
    
    Reviewed by Sam Weinig.
    
    Remove notificationPresenter() from the chrome client, since it is now managed by
    the notification controller.
    
    * src/ChromeClientImpl.cpp:
    * src/ChromeClientImpl.h:
    * src/WebNotification.cpp:
    (WebKit::WebNotification::title): Refactoring with NotificationContents conversion to struct.
    (WebKit::WebNotification::body): Ditto.
    * src/WebViewImpl.cpp:
    (WebKit::WebViewImpl::WebViewImpl): Set notification client in web view's page clients.
    
    Source/WebKit/mac:
    
    Reviewed by Sam Weinig.
    
    * Configurations/FeatureDefines.xcconfig: Split out ENABLE_NOTIFICATIONS based on platform.
    
    * WebCoreSupport/WebNotificationClient.h: Added.
    (WebNotificationClient::webView):
    * WebCoreSupport/WebNotificationClient.mm: Added. Implemented as stubs for now.
    (WebNotificationClient::WebNotificationClient):
    (WebNotificationClient::show):
    (WebNotificationClient::cancel):
    (WebNotificationClient::notificationObjectDestroyed):
    (WebNotificationClient::requestPermission):
    (WebNotificationClient::cancelRequestsForPermission):
    (WebNotificationClient::checkPermission):
    * WebView/WebView.mm: Set PageClient's notification client to an instance of this stubbed class.
    
    Source/WebKit/qt:
    
    Reviewed by Sam Weinig.
    
    * Api/qwebpage.cpp: Add notification client to pageClients.
    (QWebPagePrivate::QWebPagePrivate):
    * WebCoreSupport/ChromeClientQt.cpp: Remove notification client from ChromeClient implementation.
    * WebCoreSupport/ChromeClientQt.h:
    * WebCoreSupport/NotificationPresenterClientQt.cpp: Refactor with change of NotificationContents to struct
    (WebCore::NotificationWrapper::title):
    (WebCore::NotificationWrapper::message):
    (WebCore::NotificationPresenterClientQt::displayNotification):
    (WebCore::NotificationPresenterClientQt::cancel):
    (WebCore::NotificationPresenterClientQt::notificationClicked):
    (WebCore::NotificationPresenterClientQt::dumpReplacedIdText):
    (WebCore::NotificationPresenterClientQt::dumpShowText):
    
    Source/WebKit2:
    
    Reviewed by Sam Weinig.
    
    * WebKit2.xcodeproj/project.pbxproj: Added classes for notification support.
    * win/WebKit2.vcproj: Ditto.
    * Target.pri: Ditto.
    * Configurations/FeatureDefines.xcconfig: Split out ENABLE_NOTIFICATIONS based on platform.
    * DerivedSources.make: Add Notifications to VPATH.
    * Platform/CoreIPC/MessageID.h: List WebNotificationManagerProxy as a class with messages.
    * Scripts/webkit2/messages.py: Mark WebCore::NotificationContents as a struct.
    
    * Shared/API/c/WKBase.h: Map opaque types to NotificationProvider, NotificationManager, and Notification.
    * UIProcess/API/C/WKAPICast.h: Map WK types toNotificationProvider, NotificationManager, and Notification.
    * Shared/APIObject.h: Add Notification and NotificationManager as APIObjects.
    * Shared/WebCoreArgumentCoders.cpp: Added coders for KURL.
    (CoreIPC::::encode):
    (CoreIPC::::decode):
    * Shared/WebCoreArgumentCoders.h:
    
    * UIProcess/WebNotification.cpp: Added.
    (WebKit::WebNotification::WebNotification):
    (WebKit::WebNotification::~WebNotification):
    (WebKit::WebNotification::encode):
    (WebKit::WebNotification::decode):
    * UIProcess/WebNotification.h: Added.
    (WebKit::WebNotification::create):
    (WebKit::WebNotification::title):
    (WebKit::WebNotification::body):
    (WebKit::WebNotification::type):
    * UIProcess/API/C/WKNotification.cpp: Added as API.
    (WKNotificationGetTypeID):
    (WKNotificationCopyTitle):
    (WKNotificationCopyBody):
    * UIProcess/API/C/WKNotification.h: Added as API.
    
    * WebProcess/Notifications/WebNotificationManager.h: Added. Contains for now show() and cancel().
    The rest of the notification client methods will be added later. These two functions send messages
    to the manager proxy.
    * WebProcess/Notifications/WebNotificationManager.cpp: Added.
    (WebKit::WebNotificationManager::WebNotificationManager):
    (WebKit::WebNotificationManager::~WebNotificationManager):
    (WebKit::WebNotificationManager::show):
    (WebKit::WebNotificationManager::cancel):
    
    * UIProcess/WebNotificationManagerProxy.cpp: Added.
    (WebKit::WebNotificationManagerProxy::create):
    (WebKit::WebNotificationManagerProxy::WebNotificationManagerProxy):
    (WebKit::WebNotificationManagerProxy::~WebNotificationManagerProxy):
    (WebKit::WebNotificationManagerProxy::invalidate):
    (WebKit::WebNotificationManagerProxy::initializeProvider):
    (WebKit::WebNotificationManagerProxy::didReceiveMessage):
    (WebKit::WebNotificationManagerProxy::show):
    (WebKit::WebNotificationManagerProxy::cancel):
    * UIProcess/WebNotificationManagerProxy.h: Added.
    (WebKit::WebNotificationManagerProxy::clearContext):
    (WebKit::WebNotificationManagerProxy::type):
    * UIProcess/WebNotificationManagerProxy.messages.in: Added.
    * UIProcess/API/C/WKNotificationManager.cpp: Added.
    (WKNotificationManagerGetTypeID):
    (WKNotificationManagerSetProvider):
    * UIProcess/API/C/WKNotificationManager.h: Added.
    
    * UIProcess/WebContext.h: Add the notification manager to the web context.
    (WebKit::WebContext::notificationManagerProxy): Access the manager.
    * UIProcess/WebContext.cpp:
    (WebKit::WebContext::WebContext): Boilerplate for managers.
    (WebKit::WebContext::~WebContext): Boilerplate for managers.
    (WebKit::WebContext::disconnectProcess): Boilerplate for managers.
    (WebKit::WebContext::didReceiveMessage): Forward messages to the notification manager.
    * UIProcess/API/C/WKContext.cpp: Expose as API.
    (WKContextGetNotificationManager):
    * UIProcess/API/C/WKContext.h: Expose as API.
    
    * UIProcess/API/C/WKNotificationProvider.h: Added.
    * UIProcess/WebNotificationProvider.h: Added as APIClient.
    * UIProcess/WebNotificationProvider.cpp: Added.
    (WebKit::WebNotificationProvider::show): Forward call to the client.
    (WebKit::WebNotificationProvider::cancel): Forward call to the client.
    * UIProcess/WebProcessProxy.cpp:
    (WebKit::WebProcessProxy::didReceiveMessage): Forward messages for notification manager to the context.
    
    * WebProcess/WebCoreSupport/WebChromeClient.cpp: Remove notificationPresenter().
    * WebProcess/WebCoreSupport/WebChromeClient.h: Remove notificationPresenter().
    
    * WebProcess/WebCoreSupport/WebNotificationClient.h: Added. Forwards client methods to manager.
    * WebProcess/WebCoreSupport/WebNotificationClient.cpp: Added. Mostly stub implementation for now.
    (WebKit::WebNotificationClient::WebNotificationClient):
    (WebKit::WebNotificationClient::~WebNotificationClient):
    (WebKit::WebNotificationClient::show):
    (WebKit::WebNotificationClient::cancel):
    (WebKit::WebNotificationClient::notificationObjectDestroyed):
    (WebKit::WebNotificationClient::requestPermission):
    (WebKit::WebNotificationClient::cancelRequestsForPermission):
    (WebKit::WebNotificationClient::checkPermission):
    
    * WebProcess/WebPage/WebPage.h: Added WebNotificationClient as one of its page clients.
    * WebProcess/WebPage/WebPage.cpp:
    (WebKit::WebPage::WebPage): Set the notification client to WebNotificationClient.
    * WebProcess/WebProcess.h: Added WebNotificationManager.
    (WebKit::WebProcess::notificationManager):
    * WebProcess/WebProcess.cpp:
    (WebKit::WebProcess::WebProcess): Initialize notificaton manager.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@101307 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    6c095456