summaryrefslogtreecommitdiff
path: root/chromium/components/js_injection/common/interfaces.mojom
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/components/js_injection/common/interfaces.mojom
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/js_injection/common/interfaces.mojom')
-rw-r--r--chromium/components/js_injection/common/interfaces.mojom65
1 files changed, 65 insertions, 0 deletions
diff --git a/chromium/components/js_injection/common/interfaces.mojom b/chromium/components/js_injection/common/interfaces.mojom
new file mode 100644
index 00000000000..0e5b1047f91
--- /dev/null
+++ b/chromium/components/js_injection/common/interfaces.mojom
@@ -0,0 +1,65 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+module js_injection.mojom;
+
+import "components/js_injection/common/origin_matcher.mojom";
+import "mojo/public/mojom/base/string16.mojom";
+import "third_party/blink/public/mojom/messaging/message_port_descriptor.mojom";
+
+// JsObject struct represents a JavaScript object we will inject in the main
+// JavaScript world of a frame. |js_object_name| will be used as the name
+// of the JavaScript object. We will inject the object if the frame's origin
+// matches |origin_matcher|. |js_to_browser_messaging| will be used for that
+// JavaScript object to send message back to browser side.
+struct JsObject {
+ mojo_base.mojom.String16 js_object_name;
+ pending_associated_remote<JsToBrowserMessaging> js_to_browser_messaging;
+ js_injection.mojom.OriginMatcher origin_matcher;
+};
+
+// DocumentStartJavaScript struct contains the JavaScript snippet |script| and
+// the corresponding |origin_matcher|. We will run the script if the frame's
+// origin matches any rules in the |origin_matcher|.
+struct DocumentStartJavaScript {
+ int32 script_id;
+ mojo_base.mojom.String16 script;
+ js_injection.mojom.OriginMatcher origin_matcher;
+};
+
+// For JavaScript postMessage() API, implemented by browser.
+interface JsToBrowserMessaging {
+ // Called from renderer, browser receives |message| and possible |ports|,
+ // The |message| is an opaque type and the contents are defined by the client
+ // of this API.
+ PostMessage(mojo_base.mojom.String16 message,
+ array<blink.mojom.MessagePortDescriptor> ports);
+
+ // When there is a new BrowserToJsMessaging created in renderer, we need to
+ // send/ it to browser, so browser could send message back to Js.
+ SetBrowserToJsMessaging(
+ pending_associated_remote<BrowserToJsMessaging> browser_to_js_messaging);
+};
+
+// For the browser to reply back to injected JavaScript object. Implemented by
+// the renderer.
+interface BrowserToJsMessaging {
+ // Called from browser, to send message to page.
+ OnPostMessage(mojo_base.mojom.String16 message);
+};
+
+// For browser to configure renderer, implemented by renderer.
+interface JsCommunication {
+ // Called from browser, to tell renderer that if we need to inject
+ // JavaScript objects to the frame based on the |js_objects| array.
+ SetJsObjects(array<js_injection.mojom.JsObject> js_objects);
+
+ // Called from browser, to add a script for a frame to run at document start
+ // stage. The script will run only if the frame's origin matches any of the
+ // allowed_origin_rules.
+ AddDocumentStartScript(js_injection.mojom.DocumentStartJavaScript script);
+
+ // Called from browser, to remove the script by the given script_id.
+ RemoveDocumentStartScript(int32 script_id);
+};