Skip to content

Commit 19995c7

Browse files
committed
Update documentation
1 parent c40c483 commit 19995c7

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

browser-api/src/main/java/com/duckduckgo/browser/api/AddDocumentStartJavaScriptBrowserPlugin.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@
1616

1717
package com.duckduckgo.browser.api
1818

19+
import com.duckduckgo.common.utils.plugins.PluginPoint
1920
import com.duckduckgo.js.messaging.api.AddDocumentStartJavaScript
2021

22+
/**
23+
* Interface to provide implementations of [AddDocumentStartJavaScript] to the browser, through
24+
* [PluginPoint]<[AddDocumentStartJavaScript]>
25+
*/
2126
interface AddDocumentStartJavaScriptBrowserPlugin {
27+
/**
28+
* Provides an implementation of [AddDocumentStartJavaScript] to be used by the browser.
29+
* @return an instance of [AddDocumentStartJavaScript]
30+
*/
2231
fun addDocumentStartJavaScript(): AddDocumentStartJavaScript
2332
}

js-messaging/js-messaging-api/src/main/java/com/duckduckgo/js/messaging/api/AddDocumentStartJavaScript.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@ package com.duckduckgo.js.messaging.api
1919
import android.webkit.WebView
2020

2121
/**
22-
* Plugin interface for injecting JavaScript code that executes at document start.
23-
* * Allows plugins to inject JavaScript that will be executed before any other scripts on the page.
22+
* Interface for adding JavaScript code that executes at document start, before any other scripts on the page.
2423
* Useful for privacy protections and that need to run as early as possible and/or on iframes.
2524
*/
2625
interface AddDocumentStartJavaScript {
26+
/**
27+
* Adds JavaScript code into the provided [WebView] to be executed at document start.
28+
* Notes:
29+
* - If a different script already exists in this instance, it will be replaced.
30+
* - It's not recommended to call this multiple times on the same WebView instance.
31+
* If possible, we should rely on messaging to update the script behavior instead.
32+
*
33+
* @param webView the WebView where the script will be added
34+
*/
2735
suspend fun addDocumentStartJavaScript(webView: WebView)
2836

2937
val context: String
@@ -52,12 +60,16 @@ interface AddDocumentStartJavaScriptScriptStrategy {
5260
*/
5361
val allowedOriginRules: Set<String>
5462

63+
/**
64+
* The context of the script
65+
* @return context string
66+
*/
5567
val context: String
5668
}
5769

5870
interface AddDocumentStartScriptDelegate {
5971
/**
60-
* Creates an AddDocumentStartJavaScriptPlugin implementation with the given [AddDocumentStartJavaScriptScriptStrategy].
72+
* Creates an [AddDocumentStartJavaScript] implementation with the given [AddDocumentStartJavaScriptScriptStrategy].
6173
* @param strategy the strategy to use for determining injection behavior
6274
* @return [AddDocumentStartJavaScript] implementation
6375
*/

0 commit comments

Comments
 (0)