Commit ba016de1 authored by Gustav Sennton's avatar Gustav Sennton Committed by Commit Bot

[WebView Support Library] Pass and fetch list of supported features.

We need some way for either side (android support library + chromium) of
the webview support library to tell what features the other side of the
support library supports. We do this by passing a list of integers
across the boundary. These integers will each represent a feature (which
will be defined in a class in the boundary interface package).

Add a single feature to the list of features to support (visual state
callback).

Bug: 740082
Change-Id: I791af590cb846d536d01d63649ab6cfffe558ee9
Reviewed-on: https://chromium-review.googlesource.com/941805
Commit-Queue: Gustav Sennton <gsennton@chromium.org>
Reviewed-by: default avatarNate Fischer <ntfschr@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542169}
parent 0c7d65f2
......@@ -8,12 +8,14 @@ import("//build/config/android/rules.gni")
android_library("boundary_interface_java") {
java_files = [
"src/org/chromium/support_lib_boundary/StaticsBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/SupportLibraryInfoBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/VisualStateCallbackBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebSettingsBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebViewProviderBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebViewProviderFactoryBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/WebkitToCompatConverterBoundaryInterface.java",
"src/org/chromium/support_lib_boundary/util/BoundaryInterfaceReflectionUtil.java",
"src/org/chromium/support_lib_boundary/util/Features.java",
]
proguard_configs = [ "proguard.flags" ]
......
// Copyright 2018 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;
/**
* Contains information about the WebView support library side, e.g. which features are supported on
* that side.
* This is passed to the WebView APK code on support library initialization.
*/
public interface SupportLibraryInfoBoundaryInterface { String[] getSupportedFeatures(); }
......@@ -14,4 +14,5 @@ public interface WebViewProviderFactoryBoundaryInterface {
/* SupportLibraryWebViewChromium */ InvocationHandler createWebView(WebView webview);
/* SupportLibWebkitToCompatConverter */ InvocationHandler getWebkitToCompatConverter();
/* StaticsAdapter */ InvocationHandler getStatics();
String[] getSupportedFeatures();
}
// Copyright 2018 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.util;
/**
* Class containing all the features the support library can support.
* This class lives in the boundary interface directory so that the Android Support Library and
* Chromium can share its definition.
*/
public class Features {
// This class just contains constants representing features.
private Features() {}
// WebViewCompat.postVisualStateCallback
public static final String VISUAL_STATE_CALLBACK = "VISUAL_STATE_CALLBACK";
}
......@@ -20,8 +20,10 @@ public class SupportLibReflectionUtil {
* Changing the signature of this method will break existing WebView Support Library versions!
*/
@UsedByReflection("WebView Support Library")
public static InvocationHandler createWebViewProviderFactory() {
final SupportLibWebViewChromiumFactory factory = new SupportLibWebViewChromiumFactory();
public static InvocationHandler createWebViewProviderFactory(
/* SupportLibraryInfo */ InvocationHandler supportLibraryInfo) {
final SupportLibWebViewChromiumFactory factory =
new SupportLibWebViewChromiumFactory(supportLibraryInfo);
return BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(factory);
}
}
......@@ -15,8 +15,10 @@ import com.android.webview.chromium.WebViewChromiumAwInit;
import com.android.webview.chromium.WebkitToSharedGlueConverter;
import org.chromium.support_lib_boundary.StaticsBoundaryInterface;
import org.chromium.support_lib_boundary.SupportLibraryInfoBoundaryInterface;
import org.chromium.support_lib_boundary.WebViewProviderFactoryBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
import org.chromium.support_lib_boundary.util.Features;
import java.lang.reflect.InvocationHandler;
import java.util.List;
......@@ -28,14 +30,23 @@ class SupportLibWebViewChromiumFactory implements WebViewProviderFactoryBoundary
// SupportLibWebkitToCompatConverterAdapter
private final InvocationHandler mCompatConverterAdapter;
private final WebViewChromiumAwInit mAwInit;
private final String[] mSupportLibrarySupportedFeatures;
private final String[] mWebViewSupportedFeatures =
new String[] {Features.VISUAL_STATE_CALLBACK};
// Initialization guarded by mAwInit.getLock()
private InvocationHandler mStatics;
public SupportLibWebViewChromiumFactory() {
public SupportLibWebViewChromiumFactory(
/* SupportLibraryInfo */ InvocationHandler supportLibraryInfo) {
mCompatConverterAdapter = BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(
new SupportLibWebkitToCompatConverterAdapter());
mAwInit = WebkitToSharedGlueConverter.getGlobalAwInit();
mSupportLibrarySupportedFeatures =
BoundaryInterfaceReflectionUtil
.castToSuppLibClass(
SupportLibraryInfoBoundaryInterface.class, supportLibraryInfo)
.getSupportedFeatures();
}
@Override
......@@ -85,4 +96,9 @@ class SupportLibWebViewChromiumFactory implements WebViewProviderFactoryBoundary
}
return mStatics;
}
@Override
public String[] getSupportedFeatures() {
return mWebViewSupportedFeatures;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment