-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add empty stub for browser.notifications for Web Extensions behind te…
…st mode. https://webkit.org/b/264098 rdar://problem/117860475 Reviewed by Brian Weinstein. We don't support this API, but it is useful to have a stub for testing extensions that assume it is always present. * Source/WebKit/DerivedSources-input.xcfilelist: * Source/WebKit/DerivedSources-output.xcfilelist: * Source/WebKit/DerivedSources.make: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: Added new files. Xcode removed some duplicate entries for ExtensionKitSPI.h, it is still present in one place. * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINamespaceCocoa.mm: (WebKit::WebExtensionAPINamespace::isPropertyAllowed): Custom availability based on test mode and permissions. (WebKit::WebExtensionAPINamespace::notifications): Added. * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINotificationsCocoa.mm: Added. (WebKit::WebExtensionAPINotifications::onClicked): (WebKit::WebExtensionAPINotifications::onButtonClicked): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINamespace.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINotifications.h: Added. * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPINamespace.idl: * Source/WebKit/WebProcess/Extensions/Interfaces/WebExtensionAPINotifications.idl: Added. * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPINamespace.mm: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/270132@main
- Loading branch information
Showing
11 changed files
with
231 additions
and
7 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
59 changes: 59 additions & 0 deletions
59
Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPINotificationsCocoa.mm
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,59 @@ | ||
/* | ||
* Copyright (C) 2023 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. | ||
*/ | ||
|
||
#if !__has_feature(objc_arc) | ||
#error This file requires ARC. Add the "-fobjc-arc" compiler flag for this file. | ||
#endif | ||
|
||
#import "config.h" | ||
#import "WebExtensionAPINotifications.h" | ||
|
||
#if ENABLE(WK_WEB_EXTENSIONS) | ||
|
||
namespace WebKit { | ||
|
||
WebExtensionAPIEvent& WebExtensionAPINotifications::onClicked() | ||
{ | ||
// Documentation: https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/notifications/onClicked | ||
|
||
if (!m_onClicked) | ||
m_onClicked = WebExtensionAPIEvent::create(forMainWorld(), runtime(), extensionContext(), WebExtensionEventListenerType::NotificationsOnClicked); | ||
|
||
return *m_onClicked; | ||
} | ||
|
||
WebExtensionAPIEvent& WebExtensionAPINotifications::onButtonClicked() | ||
{ | ||
// Documentation: https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/notifications/onButtonClicked | ||
|
||
if (!m_onButtonClicked) | ||
m_onButtonClicked = WebExtensionAPIEvent::create(forMainWorld(), runtime(), extensionContext(), WebExtensionEventListenerType::NotificationsOnButtonClicked); | ||
|
||
return *m_onButtonClicked; | ||
} | ||
|
||
} // namespace WebKit | ||
|
||
#endif // ENABLE(WK_WEB_EXTENSIONS) |
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
52 changes: 52 additions & 0 deletions
52
Source/WebKit/WebProcess/Extensions/API/WebExtensionAPINotifications.h
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,52 @@ | ||
/* | ||
* Copyright (C) 2023 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(WK_WEB_EXTENSIONS) | ||
|
||
#include "JSWebExtensionAPINotifications.h" | ||
#include "WebExtensionAPIEvent.h" | ||
#include "WebExtensionAPIObject.h" | ||
|
||
namespace WebKit { | ||
|
||
class WebExtensionAPINotifications : public WebExtensionAPIObject, public JSWebExtensionWrappable { | ||
WEB_EXTENSION_DECLARE_JS_WRAPPER_CLASS(WebExtensionAPINotifications, notifications); | ||
|
||
public: | ||
#if PLATFORM(COCOA) | ||
WebExtensionAPIEvent& onClicked(); | ||
WebExtensionAPIEvent& onButtonClicked(); | ||
|
||
private: | ||
RefPtr<WebExtensionAPIEvent> m_onClicked; | ||
RefPtr<WebExtensionAPIEvent> m_onButtonClicked; | ||
#endif | ||
}; | ||
|
||
} // namespace WebKit | ||
|
||
#endif // ENABLE(WK_WEB_EXTENSIONS) |
Oops, something went wrong.