Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
WebKit Managed Notifications: Skeleton NotificationProvider.
<rdar://84275562> and https://bugs.webkit.org/show_bug.cgi?id=231786 Reviewed by Alex Christensen. Source/WebKit: No new tests (No behavior change yet) Currently WebNotificationManagerProxy manages dispatching out stuff to the NotificationProvider SPI that - for example - Safari on Mac implements. The interface between the ManagerProxy and the Provider is already the perfect way to add an alternative behavior. This introduces the skeleton class of an alternative NotificationProvider that will eventually implement WebKit-managed notifications. While under development it will have a global runtime switch so we can A/B test between the client-managed and WebKit-managed notifications. That switch would eventually be replaced by full compile-time behavior which would be decided by a shipping vendor. Note: This patch enables the new flag BUILT_IN_NOTIFICATIONS to get the new mechanisms building, but that flag by itself doesn't expose Notifications interfaces in WebCore. That will still require enabling NOTIFICATIONS separately. * SourcesCocoa.txt: * UIProcess/API/APINotificationProvider.h: (API::NotificationProvider::isClientReplaceable const): A temporary mechanism to prevent API clients from overriding the built-in NotificationProvider if the feature is enabled. Useful right now because existing Safari does that with existing SPI. * UIProcess/API/APIUIClient.h: (API::UIClient::decidePolicyForNotificationPermissionRequest): * UIProcess/API/Cocoa/WKUIDelegatePrivate.h: * UIProcess/Cocoa/UIDelegate.h: * UIProcess/Cocoa/UIDelegate.mm: (WebKit::UIDelegate::setDelegate): (WebKit::UIDelegate::UIClient::decidePolicyForNotificationPermissionRequest): * UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.h: Copied from Source/WebKit/UIProcess/API/APINotificationProvider.h. * UIProcess/Notifications/Cocoa/WebNotificationProviderCocoa.mm: Added. (WebKit::WebNotificationProviderCocoa::createIfEnabled): (WebKit::WebNotificationProviderCocoa::WebNotificationProviderCocoa): (WebKit::WebNotificationProviderCocoa::show): (WebKit::WebNotificationProviderCocoa::cancel): (WebKit::WebNotificationProviderCocoa::didDestroyNotification): (WebKit::WebNotificationProviderCocoa::clearNotifications): (WebKit::WebNotificationProviderCocoa::addNotificationManager): (WebKit::WebNotificationProviderCocoa::removeNotificationManager): (WebKit::WebNotificationProviderCocoa::notificationPermissions): * UIProcess/Notifications/WebNotificationManagerProxy.cpp: (WebKit::WebNotificationManagerProxy::WebNotificationManagerProxy): (WebKit::WebNotificationManagerProxy::setProvider): Fix changes to the Unified Build: * UIProcess/ios/WKHoverPlatter.h: * UIProcess/ios/WKHoverPlatter.mm: * WebKit.xcodeproj/project.pbxproj: Source/WebKitLegacy/mac: * WebCoreSupport/WebNotificationClient.mm: (-[WebNotificationPolicyListener NO_RETURN_DUE_TO_ASSERT]): (-[WebNotificationPolicyListener denyOnlyThisRequest]): Deleted. Source/WTF: * Scripts/Preferences/WebPreferencesDebug.yaml: * wtf/PlatformEnableCocoa.h: Canonical link: https://commits.webkit.org/243049@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@284240 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
18 changed files
with
306 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (C) 2021 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 met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. 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. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#if ENABLE(BUILT_IN_NOTIFICATIONS) && PLATFORM(COCOA) | ||
|
||
#include "APINotificationProvider.h" | ||
#include <wtf/Forward.h> | ||
|
||
namespace WebKit { | ||
|
||
class WebNotification; | ||
class WebNotificationManagerProxy; | ||
class WebPageProxy; | ||
|
||
class WebNotificationProviderCocoa : public API::NotificationProvider { | ||
WTF_MAKE_FAST_ALLOCATED; | ||
public: | ||
static std::unique_ptr<WebNotificationProviderCocoa> createIfEnabled(); | ||
explicit WebNotificationProviderCocoa(); | ||
|
||
void show(WebPageProxy&, WebNotification&) final; | ||
void cancel(WebNotification&) final; | ||
void didDestroyNotification(WebNotification&) final; | ||
void clearNotifications(const Vector<uint64_t>& notificationIDs) final; | ||
|
||
void addNotificationManager(WebNotificationManagerProxy&) final; | ||
void removeNotificationManager(WebNotificationManagerProxy&) final; | ||
|
||
bool isClientReplaceable() const final { return false; } | ||
|
||
HashMap<WTF::String, bool> notificationPermissions() final; | ||
}; | ||
|
||
} // namespace WebKit | ||
|
||
#endif // ENABLE(BUILT_IN_NOTIFICATIONS) && PLATFORM(COCOA) |
Oops, something went wrong.