-
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.
Hook up IPC for registered scripts APIs.
https://bugs.webkit.org/show_bug.cgi?id=264823 rdar://118405149 Reviewed by Timothy Hatcher. This patch creates a WebExtensionRegisteredScriptParameters which will be used to pass information to the UI process for the scripts to be registered for scripting.RegisteredContentScripts. Also adds tests for error handling for these APIs in WKWebExtensionAPIScripting.Errors. This patch also restructures the WebExtensionAPIScripting class to match that of the other classes created for other extension APIs. * Source/WebKit/Scripts/webkit/messages.py: (types_that_cannot_be_forward_declared): * Source/WebKit/Shared/Extensions/WebExtensionDynamicScripts.serialization.in: * Source/WebKit/Shared/Extensions/WebExtensionRegisteredScriptParameters.h: Copied from Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIScripting.h. * Source/WebKit/UIProcess/Extensions/Cocoa/API/WebExtensionContextAPIScriptingCocoa.mm: (WebKit::WebExtensionContext::scriptingRegisterScripts): (WebKit::WebExtensionContext::scriptingUpdateRegisteredScripts): (WebKit::WebExtensionContext::scriptingGetRegisteredScripts): (WebKit::WebExtensionContext::scriptingUnregisterScripts): * Source/WebKit/UIProcess/Extensions/WebExtensionContext.h: * Source/WebKit/UIProcess/Extensions/WebExtensionContext.messages.in: * Source/WebKit/WebKit.xcodeproj/project.pbxproj: * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPIScriptingCocoa.mm: (WebKit::toWebAPI): (WebKit::WebExtensionAPIScripting::executeScript): (WebKit::WebExtensionAPIScripting::insertCSS): (WebKit::WebExtensionAPIScripting::removeCSS): (WebKit::WebExtensionAPIScripting::registerContentScripts): (WebKit::WebExtensionAPIScripting::getRegisteredContentScripts): (WebKit::WebExtensionAPIScripting::updateContentScripts): (WebKit::WebExtensionAPIScripting::unregisterContentScripts): (WebKit::WebExtensionAPIScripting::validateScript): (WebKit::WebExtensionAPIScripting::validateRegisteredScripts): (WebKit::WebExtensionAPIScripting::validateFilter): (WebKit::WebExtensionAPIScripting::parseTargetInjectionOptions): (WebKit::WebExtensionAPIScripting::parseScriptInjectionOptions): (WebKit::WebExtensionAPIScripting::parseCSSInjectionOptions): (WebKit::WebExtensionAPIScripting::parseRegisteredContentScripts): (WebKit::WebExtensionAPIScripting::hasValidExecutionWorld): (WebKit::parseTargetInjectionOptions): Deleted. (WebKit::parseScriptInjectionOptions): Deleted. (WebKit::parseCSSInjectionOptions): Deleted. (WebKit::WebExtensionAPIScripting::toWebAPI): Deleted. * Source/WebKit/WebProcess/Extensions/API/Cocoa/WebExtensionAPITabsCocoa.mm: (WebKit::WebExtensionAPITabs::executeScript): * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPIScripting.h: * Source/WebKit/WebProcess/Extensions/API/WebExtensionAPITabs.h: * Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebExtensionAPIScripting.mm: (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/270733@main
- Loading branch information
1 parent
eb96b31
commit 27ba8de
Showing
12 changed files
with
437 additions
and
108 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
53 changes: 53 additions & 0 deletions
53
Source/WebKit/Shared/Extensions/WebExtensionRegisteredScriptParameters.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,53 @@ | ||
/* | ||
* 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 <wtf/Forward.h> | ||
|
||
namespace WebKit { | ||
|
||
struct WebExtensionRegisteredScriptParameters { | ||
|
||
std::optional<Vector<String>> css; | ||
std::optional<Vector<String>> js; | ||
|
||
String identifier; | ||
WebExtension::InjectionTime injectionTime { WebExtension::InjectionTime::DocumentIdle }; | ||
|
||
std::optional<Vector<String>> excludedMatchPatterns; | ||
std::optional<Vector<String>> matchPatterns; | ||
|
||
bool allFrames { false }; | ||
bool persistAcrossSessions { true }; | ||
|
||
WebExtensionContentWorldType world { WebExtensionContentWorldType::ContentScript }; | ||
}; | ||
|
||
} // 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
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
Oops, something went wrong.