Snap for 6940384 from 021571f9ab2fb3cf7c162fa43f2a6329dcda89b4 to androidx-autofill-release
Change-Id: I2af5acc63080188c4adba8b1feedab0f6156b76a
diff --git a/.gitignore b/.gitignore
index b415ae7..aec6a57 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
# For Android Studio, when we mirror this repo into the Android tree
*.iml
+.gradle/
+.settings/
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
deleted file mode 100644
index b11a3e8..0000000
--- a/AndroidManifest.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="org.chromium.support_lib_boundary">
- <!-- This AndroidManifest file only exists to provide package name needed by
- gradle script to build these interfaces as part of AndroidX. -->
-</manifest>
diff --git a/BUILD.gn b/BUILD.gn
index 58f0787..d3c7500 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -6,12 +6,13 @@
import("//build/config/android/rules.gni")
android_library("boundary_interface_java") {
- java_files = [
+ sources = [
"src/org/chromium/support_lib_boundary/FeatureFlagHolderBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/IsomorphicObjectBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/JsReplyProxyBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/ProxyControllerBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/SafeBrowsingResponseBoundaryInterface.java",
+ "src/org/chromium/support_lib_boundary/ScriptReferenceBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/ServiceWorkerClientBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/ServiceWorkerControllerBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/ServiceWorkerWebSettingsBoundaryInterface.java",
@@ -37,13 +38,27 @@
proguard_configs = [ "proguard.flags" ]
- # We can't use ANY deps here, the support library should be able to build
- # these interfaces without any other chromium dependencies.
- deps = []
+ # Our choice of deps is limited, because boundary_interfaces/ must continue to
+ # build when we mirror this into AndroidX. We are only permitted to depend on
+ # core Android classes and other AndroidX classes (must be in the androidx.*
+ # package name).
+ deps = [ "//third_party/android_deps:androidx_annotation_annotation_java" ]
+}
- # This is to verify the boundary interfaces compile and lint correctly against
- # the minSdkVersion of the webkit support library module. As the minSdkVersion
- # of the support library increases, so should this value. See
+android_apk("boundary_interface_example_apk") {
+ apk_name = "BoundaryInterfaceExample"
+
+ # Use a dummy android manifest since this code is copied to androidx.
+ android_manifest = "//build/android/AndroidManifest.xml"
+
+ # This is to verify that the boundary interfaces compile and lint correctly
+ # against the minSdkVersion of the webkit support library module. As the
+ # minSdkVersion of the support library increases, so should this value. See
# http://crbug.com/828184 for more details.
min_sdk_version = 14
+
+ # Explicitly enable lint for this apk.
+ enable_lint = true
+
+ deps = [ ":boundary_interface_java" ]
}
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 2b29cae..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,26 +0,0 @@
-// 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.
-
-// This file is to build WebView boundary interfaces as part of the AndroidX webkit library.
-// It is not meant to be used or build any targets in chromium project.
-
-import androidx.build.SupportConfig
-
-plugins {
- id('com.android.library')
-}
-
-android {
- // COMPILE_SDK_VERSION provided by AndroidX build scripts to build all AndroidX modules.
- compileSdkVersion SupportConfig.COMPILE_SDK_VERSION
-
- sourceSets {
- main.manifest.srcFile 'AndroidManifest.xml'
- main.java.srcDirs += ['src']
- }
-
- buildTypes.all {
- consumerProguardFiles 'proguard.flags'
- }
-}
diff --git a/src/org/chromium/support_lib_boundary/ScriptReferenceBoundaryInterface.java b/src/org/chromium/support_lib_boundary/ScriptReferenceBoundaryInterface.java
new file mode 100644
index 0000000..6358e00
--- /dev/null
+++ b/src/org/chromium/support_lib_boundary/ScriptReferenceBoundaryInterface.java
@@ -0,0 +1,12 @@
+// Copyright 2020 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;
+
+/**
+ * Boundary interface for AwContents.addDocumentStartJavascript().
+ */
+public interface ScriptReferenceBoundaryInterface {
+ void remove();
+}
diff --git a/src/org/chromium/support_lib_boundary/StaticsBoundaryInterface.java b/src/org/chromium/support_lib_boundary/StaticsBoundaryInterface.java
index 648d416..c2d3864 100644
--- a/src/org/chromium/support_lib_boundary/StaticsBoundaryInterface.java
+++ b/src/org/chromium/support_lib_boundary/StaticsBoundaryInterface.java
@@ -9,12 +9,14 @@
import android.webkit.ValueCallback;
import java.util.List;
+import java.util.Set;
/**
* Boundary interface for WebViewFactoryProvider.Statics.
*/
public interface StaticsBoundaryInterface {
void initSafeBrowsing(Context context, ValueCallback<Boolean> callback);
+ void setSafeBrowsingAllowlist(Set<String> hosts, ValueCallback<Boolean> callback);
void setSafeBrowsingWhitelist(List<String> hosts, ValueCallback<Boolean> callback);
Uri getSafeBrowsingPrivacyPolicyUrl();
boolean isMultiProcessEnabled();
diff --git a/src/org/chromium/support_lib_boundary/WebViewProviderBoundaryInterface.java b/src/org/chromium/support_lib_boundary/WebViewProviderBoundaryInterface.java
index bb677ef..843d387 100644
--- a/src/org/chromium/support_lib_boundary/WebViewProviderBoundaryInterface.java
+++ b/src/org/chromium/support_lib_boundary/WebViewProviderBoundaryInterface.java
@@ -20,6 +20,8 @@
void addWebMessageListener(String jsObjectName, String[] allowedOriginRules,
/* WebMessageListener */ InvocationHandler listener);
void removeWebMessageListener(String jsObjectName);
+ /* ScriptReference */ InvocationHandler addDocumentStartJavaScript(
+ String script, String[] allowedOriginRules);
WebViewClient getWebViewClient();
WebChromeClient getWebChromeClient();
/* WebViewRenderer */ InvocationHandler getWebViewRenderer();
diff --git a/src/org/chromium/support_lib_boundary/WebViewProviderFactoryBoundaryInterface.java b/src/org/chromium/support_lib_boundary/WebViewProviderFactoryBoundaryInterface.java
index 15db689..902a04b 100644
--- a/src/org/chromium/support_lib_boundary/WebViewProviderFactoryBoundaryInterface.java
+++ b/src/org/chromium/support_lib_boundary/WebViewProviderFactoryBoundaryInterface.java
@@ -18,4 +18,5 @@
/* SupportLibraryServiceWorkerController */ InvocationHandler getServiceWorkerController();
/* SupportLibraryTracingController */ InvocationHandler getTracingController();
/* SupportLibraryProxyController */ InvocationHandler getProxyController();
+ void setSupportLibraryVersion(String version);
}
diff --git a/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java b/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java
index 931cc89..c2dc613 100644
--- a/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java
+++ b/src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java
@@ -3,10 +3,12 @@
// found in the LICENSE file.
package org.chromium.support_lib_boundary.util;
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
import android.os.Build;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.annotation.RequiresApi;
+
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -19,7 +21,6 @@
*/
// Although this is not enforced in chromium, this is a requirement enforced when this file is
// mirrored into AndroidX. See http://b/120770118 for details.
-@SuppressLint("BanTargetApiAnnotation")
public class BoundaryInterfaceReflectionUtil {
/**
* Check if an object is an instance of {@code className}, resolving {@code className} in
@@ -61,29 +62,57 @@
/**
* Returns an implementation of the boundary interface named clazz, by delegating method calls
* to the {@link InvocationHandler} invocationHandler.
+ *
+ * <p>A {@code null} {@link InvocationHandler} is treated as representing a {@code null} object.
+ *
+ * @param clazz a {@link Class} object representing the desired boundary interface.
+ * @param invocationHandler an {@link InvocationHandler} compatible with this boundary
+ * interface.
*/
- public static <T> T castToSuppLibClass(Class<T> clazz, InvocationHandler invocationHandler) {
+ @Nullable
+ public static <T> T castToSuppLibClass(
+ @NonNull Class<T> clazz, @Nullable InvocationHandler invocationHandler) {
+ if (invocationHandler == null) return null;
return clazz.cast(
Proxy.newProxyInstance(BoundaryInterfaceReflectionUtil.class.getClassLoader(),
new Class[] {clazz}, invocationHandler));
}
/**
- * Create an {@link java.lang.reflect.InvocationHandler} that delegates method calls to
- * {@param delegate}, making sure that the {@link java.lang.reflect.Method} and parameters being
- * passed to {@param delegate} exist in the same {@link java.lang.ClassLoader} as {@param
- * delegate}.
+ * Create an {@link InvocationHandler} that delegates method calls to {@code delegate}, making
+ * sure that the {@link Method} and parameters being passed exist in the same {@link
+ * ClassLoader} as {@code delegate}.
+ *
+ * <p>A {@code null} delegate is represented with a {@code null} {@link InvocationHandler}.
+ *
+ * @param delegate the object which the resulting {@link InvocationHandler} should delegate
+ * method calls to.
+ * @return an InvocationHandlerWithDelegateGetter wrapping {@code delegate}
*/
- @TargetApi(Build.VERSION_CODES.KITKAT)
- public static InvocationHandler createInvocationHandlerFor(final Object delegate) {
+ @RequiresApi(Build.VERSION_CODES.KITKAT)
+ @Nullable
+ public static InvocationHandler createInvocationHandlerFor(@Nullable final Object delegate) {
+ if (delegate == null) return null;
return new InvocationHandlerWithDelegateGetter(delegate);
}
/**
- * Plural version of {@link #createInvocationHandlerFor(Object)}.
+ * Plural version of {@link #createInvocationHandlerFor(Object)}. The resulting array will be
+ * the same length as {@code delegates}, where the nth {@code InvocationHandler} wraps the nth
+ * delegate object.
+ *
+ * <p>A {@code null} array of delegates is represented with a {@code null} array of {@link
+ * InvocationHandler}s. Any individual {@code null} delegate is represented with a {@code null}
+ * {@link InvocationHandler}.
+
+ * @param delegates an array of objects to which to delegate.
+ * @return an array of InvocationHandlerWithDelegateGetter instances, each delegating to
+ * the corresponding member of {@code delegates}.
*/
- @TargetApi(Build.VERSION_CODES.KITKAT)
- public static InvocationHandler[] createInvocationHandlersForArray(final Object[] delegates) {
+ @RequiresApi(Build.VERSION_CODES.KITKAT)
+ @Nullable
+ public static InvocationHandler[] createInvocationHandlersForArray(
+ @Nullable final Object[] delegates) {
if (delegates == null) return null;
InvocationHandler[] handlers = new InvocationHandler[delegates.length];
@@ -97,8 +126,16 @@
* Assuming that the given InvocationHandler was created in the current classloader and is an
* InvocationHandlerWithDelegateGetter, return the object the InvocationHandler delegates its
* method calls to.
+ *
+ * <p>A {@code null} {@link InvocationHandler} is treated as wrapping a {@code null} delegate.
+ *
+ * @param invocationHandler a {@link Nullable} InvocationHandlerWithDelegateGetter.
+ * @return the corresponding delegate.
*/
- public static Object getDelegateFromInvocationHandler(InvocationHandler invocationHandler) {
+ @Nullable
+ public static Object getDelegateFromInvocationHandler(
+ @Nullable InvocationHandler invocationHandler) {
+ if (invocationHandler == null) return null;
InvocationHandlerWithDelegateGetter objectHolder =
(InvocationHandlerWithDelegateGetter) invocationHandler;
return objectHolder.getDelegate();
@@ -109,11 +146,11 @@
* This allows us to pass InvocationHandlers across the support library boundary and later
* unwrap the objects used as delegates within those InvocationHandlers.
*/
- @TargetApi(Build.VERSION_CODES.KITKAT)
+ @RequiresApi(Build.VERSION_CODES.KITKAT)
private static class InvocationHandlerWithDelegateGetter implements InvocationHandler {
private final Object mDelegate;
- public InvocationHandlerWithDelegateGetter(final Object delegate) {
+ public InvocationHandlerWithDelegateGetter(@NonNull final Object delegate) {
mDelegate = delegate;
}
@@ -130,6 +167,10 @@
}
}
+ /**
+ * Gets the delegate object (which is never {@code null}).
+ */
+ @NonNull
public Object getDelegate() {
return mDelegate;
}
diff --git a/src/org/chromium/support_lib_boundary/util/Features.java b/src/org/chromium/support_lib_boundary/util/Features.java
index 40cd85b..d3a5039 100644
--- a/src/org/chromium/support_lib_boundary/util/Features.java
+++ b/src/org/chromium/support_lib_boundary/util/Features.java
@@ -47,6 +47,9 @@
// WebViewCompat.startSafeBrowsing
public static final String START_SAFE_BROWSING = "START_SAFE_BROWSING";
+ // WebViewCompat.setSafeBrowsingAllowlist
+ public static final String SAFE_BROWSING_ALLOWLIST = "SAFE_BROWSING_ALLOWLIST";
+
// WebViewCompat.setSafeBrowsingWhitelist
public static final String SAFE_BROWSING_WHITELIST = "SAFE_BROWSING_WHITELIST";
@@ -173,4 +176,10 @@
// WebViewCompat.addWebMessageListener
// WebViewCompat.removeWebMessageListener
public static final String WEB_MESSAGE_LISTENER = "WEB_MESSAGE_LISTENER";
+
+ // WebViewProviderFactoryAdapter.setSupportLibraryVersion
+ public static final String SET_SUPPORT_LIBRARY_VERSION = "SET_SUPPORT_LIBRARY_VERSION";
+
+ // WebViewCompat.addDocumentStartJavascript
+ public static final String DOCUMENT_START_SCRIPT = "DOCUMENT_START_SCRIPT:1";
}