| // 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 android_webview.mojom; |
| |
| import "mojo/public/mojom/base/string16.mojom"; |
| import "services/network/public/mojom/proxy_config.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 |allowed_origin_rules|. |js_to_java_messaging| will be used for |
| // that JavaScript object to send message back to browser (hence Java) side. |
| struct JsObject { |
| mojo_base.mojom.String16 js_object_name; |
| pending_associated_remote<JsToJavaMessaging> js_to_java_messaging; |
| network.mojom.ProxyBypassRules allowed_origin_rules; |
| }; |
| |
| // For JavaScript postMessage() API, implemented by browser. |
| interface JsToJavaMessaging { |
| // 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<handle<message_pipe>> ports); |
| |
| // When there is a new JavaToJsMessaging created in renderer, we need to send |
| // it to browser, so browser could send message back to Js. |
| SetJavaToJsMessaging( |
| pending_associated_remote<JavaToJsMessaging> java_to_js_messaging); |
| }; |
| |
| // For Java to reply back to injected JavaScript object. Implemented by |
| // renderer. |
| interface JavaToJsMessaging { |
| // Called from browser, to send message from Java to JavaScript. |
| OnPostMessage(mojo_base.mojom.String16 message); |
| }; |
| |
| // For browser to configure renderer, implemented by renderer. |
| interface JsJavaConfigurator { |
| // 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<android_webview.mojom.JsObject> js_objects); |
| }; |