@@ -19,11 +19,19 @@ package com.duckduckgo.js.messaging.api
19
19
import android.webkit.WebView
20
20
21
21
/* *
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.
24
23
* Useful for privacy protections and that need to run as early as possible and/or on iframes.
25
24
*/
26
25
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
+ */
27
35
suspend fun addDocumentStartJavaScript (webView : WebView )
28
36
29
37
val context: String
@@ -52,12 +60,16 @@ interface AddDocumentStartJavaScriptScriptStrategy {
52
60
*/
53
61
val allowedOriginRules: Set <String >
54
62
63
+ /* *
64
+ * The context of the script
65
+ * @return context string
66
+ */
55
67
val context: String
56
68
}
57
69
58
70
interface AddDocumentStartScriptDelegate {
59
71
/* *
60
- * Creates an AddDocumentStartJavaScriptPlugin implementation with the given [AddDocumentStartJavaScriptScriptStrategy].
72
+ * Creates an [AddDocumentStartJavaScript] implementation with the given [AddDocumentStartJavaScriptScriptStrategy].
61
73
* @param strategy the strategy to use for determining injection behavior
62
74
* @return [AddDocumentStartJavaScript] implementation
63
75
*/
0 commit comments