summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard He <linyhe@microsoft.com>2022-04-25 23:09:58 +0000
committerCopybara-Service <copybara-worker@google.com>2022-04-25 16:18:33 -0700
commitadbc5fbb6ea990999a36402715f189ae6dba4a0c (patch)
tree8263699d82b242d554ce3f05a76958b533ac76b5
parentdba208a9fee576d917dc092c44576e3e4db1a872 (diff)
downloadwebview_support_interfaces-adbc5fbb6ea990999a36402715f189ae6dba4a0c.tar.gz
Replace String with WebMessagePayload for AndroidX WebMessage API
Design doc: https://docs.google.com/document/d/1nsQnwwY43OuA4PsSaMioiKA0c_M1eV1XX2q15YFA7cI/edit?usp=sharing This CL did not add new features. - Add a new boundary type WebMessagePayload to replace String WebMessage.getData(). - Add new data class MessagePayload in content/, and replace existing PostMessage API with the new type. - A followup change will add ArrayBuffer support in WebViewCompat.postMessageToMainFrame and WebChannelCompat.postMessage. How to test: run tests in existing AndroidX Webkit. Bug: 1023334 Change-Id: Ib5b35b974bee597a6efada75503c5288f7058c50 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3583520 Reviewed-by: Bo Liu <boliu@chromium.org> Reviewed-by: Richard Coles <torne@chromium.org> Reviewed-by: Peter Conn <peconn@chromium.org> Commit-Queue: Linyue He <linyhe@microsoft.com> Cr-Commit-Position: refs/heads/main@{#995852} NOKEYCHECK=True GitOrigin-RevId: bc7514a7cf7b67ffc3fb0698310a23246df5a7c5
-rw-r--r--BUILD.gn1
-rw-r--r--src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java3
-rw-r--r--src/org/chromium/support_lib_boundary/WebMessagePayloadBoundaryInterface.java28
-rw-r--r--src/org/chromium/support_lib_boundary/util/Features.java3
4 files changed, 35 insertions, 0 deletions
diff --git a/BUILD.gn b/BUILD.gn
index 348cbf5..c20f885 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -23,6 +23,7 @@ android_library("boundary_interface_java") {
"src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebMessageCallbackBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebMessageListenerBoundaryInterface.java",
+ "src/org/chromium/support_lib_boundary/WebMessagePayloadBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebMessagePortBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebResourceErrorBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebResourceRequestBoundaryInterface.java",
diff --git a/src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java b/src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java
index dff7990..93782d5 100644
--- a/src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java
+++ b/src/org/chromium/support_lib_boundary/WebMessageBoundaryInterface.java
@@ -10,7 +10,10 @@ import java.lang.reflect.InvocationHandler;
* Boundary interface for WebMessage.
*/
public interface WebMessageBoundaryInterface extends FeatureFlagHolderBoundaryInterface {
+ @Deprecated
String getData();
+ /* MessagePayload */ InvocationHandler getMessagePayload();
+
/* WebMessagePort */ InvocationHandler[] getPorts();
}
diff --git a/src/org/chromium/support_lib_boundary/WebMessagePayloadBoundaryInterface.java b/src/org/chromium/support_lib_boundary/WebMessagePayloadBoundaryInterface.java
new file mode 100644
index 0000000..1a4d6b5
--- /dev/null
+++ b/src/org/chromium/support_lib_boundary/WebMessagePayloadBoundaryInterface.java
@@ -0,0 +1,28 @@
+// Copyright 2022 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.
+
+package org.chromium.support_lib_boundary;
+
+import androidx.annotation.IntDef;
+import androidx.annotation.Nullable;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Boundary interface for WebMessagePayload.
+ */
+public interface WebMessagePayloadBoundaryInterface extends FeatureFlagHolderBoundaryInterface {
+ @WebMessagePayloadType
+ int getType();
+
+ @Nullable
+ String getAsString();
+
+ @Retention(RetentionPolicy.SOURCE)
+ @IntDef(flag = true, value = {WebMessagePayloadType.TYPE_STRING})
+ @interface WebMessagePayloadType {
+ int TYPE_STRING = 0;
+ }
+}
diff --git a/src/org/chromium/support_lib_boundary/util/Features.java b/src/org/chromium/support_lib_boundary/util/Features.java
index 1415361..97ca100 100644
--- a/src/org/chromium/support_lib_boundary/util/Features.java
+++ b/src/org/chromium/support_lib_boundary/util/Features.java
@@ -105,6 +105,9 @@ public class Features {
public static final String SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL =
"SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL";
+ // WebMessage.getMessagePayload
+ public static final String WEB_MESSAGE_GET_MESSAGE_PAYLOAD = "WEB_MESSAGE_GET_MESSAGE_PAYLOAD";
+
// WebMessagePortCompat.postMessage
public static final String WEB_MESSAGE_PORT_POST_MESSAGE = "WEB_MESSAGE_PORT_POST_MESSAGE";