From af81723b47791fdec366e214c42646dec0a4564d Mon Sep 17 00:00:00 2001 From: Gustav Sennton Date: Wed, 15 Nov 2017 14:05:13 +0000 Subject: [WebView] Add directory for interfaces between support library and glue We will build a set of interfaces to communicate between the WebView support library (statically built into apps), and the WebView support library glue layer (built into the WebView APK, loaded into app processes at run-time). To allow Chromium and the Android Support Library to share these interfaces we put them in their own directory, and mirror that directory publicly so that they can be referenced by the support library. This CL creates the interface directory, and adds some examples of interfaces. BUG=755506 Change-Id: I3f7040c4ab88c7e0d26379aebc4b74fb53eee1de Reviewed-on: https://chromium-review.googlesource.com/768712 Commit-Queue: Gustav Sennton Reviewed-by: Richard Coles Cr-Original-Commit-Position: refs/heads/master@{#516688} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: b1ea1aff463b4c061a3c7f60894129bff89e8bb1 --- BUILD.gn | 19 +++++++++++++++++++ DEPS | 10 ++++++++++ .../VisualStateCallbackInterface.java | 9 +++++++++ .../support_lib_boundary/WebSettingsInterface.java | 16 ++++++++++++++++ .../support_lib_boundary/WebViewProvider.java | 16 ++++++++++++++++ .../support_lib_boundary/WebViewProviderFactory.java | 16 ++++++++++++++++ 6 files changed, 86 insertions(+) create mode 100644 BUILD.gn create mode 100644 DEPS create mode 100644 src/org/chromium/support_lib_boundary/VisualStateCallbackInterface.java create mode 100644 src/org/chromium/support_lib_boundary/WebSettingsInterface.java create mode 100644 src/org/chromium/support_lib_boundary/WebViewProvider.java create mode 100644 src/org/chromium/support_lib_boundary/WebViewProviderFactory.java diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000..66f2fee --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,19 @@ +# Copyright 2017 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. + +import("//build/config/android/config.gni") +import("//build/config/android/rules.gni") + +android_library("boundary_interface_java") { + java_files = [ + "src/org/chromium/support_lib_boundary/VisualStateCallbackInterface.java", + "src/org/chromium/support_lib_boundary/WebSettingsInterface.java", + "src/org/chromium/support_lib_boundary/WebViewProvider.java", + "src/org/chromium/support_lib_boundary/WebViewProviderFactory.java", + ] + + # We can't use ANY deps here, the support library should be able to build + # these interfaces without any other chromium dependencies. + deps = [] +} diff --git a/DEPS b/DEPS new file mode 100644 index 0000000..7721534 --- /dev/null +++ b/DEPS @@ -0,0 +1,10 @@ + +# This directory cannot depend on ANYTHING else in chromium +# These negative rules just rule out some of the major components. +include_rules = [ + "-base", + "-chrome", + "-components", + "-content", + "-services", +] diff --git a/src/org/chromium/support_lib_boundary/VisualStateCallbackInterface.java b/src/org/chromium/support_lib_boundary/VisualStateCallbackInterface.java new file mode 100644 index 0000000..1511191 --- /dev/null +++ b/src/org/chromium/support_lib_boundary/VisualStateCallbackInterface.java @@ -0,0 +1,9 @@ +// Copyright 2017 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; + +/** + */ +public interface VisualStateCallbackInterface { void onComplete(long requestId); } diff --git a/src/org/chromium/support_lib_boundary/WebSettingsInterface.java b/src/org/chromium/support_lib_boundary/WebSettingsInterface.java new file mode 100644 index 0000000..c138afb --- /dev/null +++ b/src/org/chromium/support_lib_boundary/WebSettingsInterface.java @@ -0,0 +1,16 @@ +// Copyright 2017 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; + +// Technically this interface is not needed until we add a method to WebSettings with an +// android.webkit parameter or android.webkit return value. But for forwards compatibility all +// app-facing classes should have a boundary-interface that the WebView glue layer can build +// against. +/** + */ +public interface WebSettingsInterface { + void setSafeBrowsingEnabled(boolean enabled); + boolean getSafeBrowsingEnabled(); +} diff --git a/src/org/chromium/support_lib_boundary/WebViewProvider.java b/src/org/chromium/support_lib_boundary/WebViewProvider.java new file mode 100644 index 0000000..977902d --- /dev/null +++ b/src/org/chromium/support_lib_boundary/WebViewProvider.java @@ -0,0 +1,16 @@ +// Copyright 2017 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 java.lang.reflect.InvocationHandler; + +/** + */ +public interface WebViewProvider { + void insertVisualStateCallback(long requestId, + InvocationHandler + /* org.chromium.sup_lib_boundary.VisualStateCallback */ callbackInvoHandler); + InvocationHandler /* org.chromium.sup_lib_boundary.WebSettingsInterface */ getSettings(); +} diff --git a/src/org/chromium/support_lib_boundary/WebViewProviderFactory.java b/src/org/chromium/support_lib_boundary/WebViewProviderFactory.java new file mode 100644 index 0000000..734e281 --- /dev/null +++ b/src/org/chromium/support_lib_boundary/WebViewProviderFactory.java @@ -0,0 +1,16 @@ +// Copyright 2017 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 java.lang.reflect.InvocationHandler; + +/** + */ +public interface WebViewProviderFactory { + // android.webkit.WebViewProvider is in the SystemApi, not public, so we pass it as an Object + // here. + InvocationHandler /* org.chromium.sup_lib_boundary.WebViewProvider */ createWebView( + Object /* android.webkit.WebViewProvider */ webviewProvider); +} -- cgit v1.2.3