Commit 26b6fcaf authored by Tim Volodine's avatar Tim Volodine Committed by Commit Bot

[WebLayer] Add GmsBridge upstream classes and the relevant build configs

In this patch:

- add the abstract GmsBridge class and its corresponsing upstream
  implementation (GmsBridgeImpl.java). GmsBridge class manages
  functionality related to Google Mobile Services (GMS).

- add the initialization of safebrowsing handler on WebLayer startup.

- add .gn build deps and targets needed for the relevant upstream
  targets. In the future a different GmsBridgeImpl class will be
  compiled-in depending on whether an internal clank/ checkout
  is present.

BUG=1015418

Change-Id: I5a45023a0ab6f31ce6db1daa7f62bf7c2579a84b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1876032Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Commit-Queue: Tim Volodine <timvolodine@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709447}
parent acb93c84
...@@ -38,6 +38,7 @@ android_library("java") { ...@@ -38,6 +38,7 @@ android_library("java") {
deps = [ deps = [
":client_java", ":client_java",
":gms_bridge_java",
":weblayer_resources", ":weblayer_resources",
"//base:base_java", "//base:base_java",
"//base:jni_java", "//base:jni_java",
...@@ -50,6 +51,10 @@ android_library("java") { ...@@ -50,6 +51,10 @@ android_library("java") {
srcjar_deps = [ ":weblayer_locale_config" ] srcjar_deps = [ ":weblayer_locale_config" ]
jar_excluded_patterns = [ "*/LocaleConfig.class" ] jar_excluded_patterns = [ "*/LocaleConfig.class" ]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ] annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
# TODO(timvolodine): once the downstream implementation of GmsBridgeImpl.java
# lands make sure to exclude this when "enable_chrome_android_internal" is true.
deps += [ ":gms_bridge_upstream_impl_java" ]
} }
generate_jni("jni") { generate_jni("jni") {
...@@ -77,6 +82,32 @@ android_library("client_java") { ...@@ -77,6 +82,32 @@ android_library("client_java") {
srcjar_deps = [ ":aidl" ] srcjar_deps = [ ":aidl" ]
} }
# Separate target to allow for a dependency on GmsCore without pulling in all of
# java classes. It compiles the abstract class; implementations are compiled
# separately.
android_library("gms_bridge_java") {
java_files = [
"org/chromium/weblayer_private/GmsBridge.java",
"org/chromium/weblayer_private/GmsBridgeImpl.java",
]
deps = [
"//base:base_java",
]
# The appropriate .class file will be loaded via a dependency to a library
# like :gms_bridge_upstream_impl_java below.
jar_excluded_patterns = [ "*/GmsBridgeImpl.class" ]
}
# This target compiles the implementation of GmsBridge for public targets.
android_library("gms_bridge_upstream_impl_java") {
java_files = [ "org/chromium/weblayer_private/GmsBridgeImpl.java" ]
deps = [
":gms_bridge_java",
]
}
android_aidl("aidl") { android_aidl("aidl") {
import_include = [ "org/chromium/weblayer_private/aidl" ] import_include = [ "org/chromium/weblayer_private/aidl" ]
sources = [ sources = [
......
// 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.
package org.chromium.weblayer_private;
import android.os.Handler;
import android.os.HandlerThread;
/**
* This class manages functionality related to Google Mobile Services (i.e. GMS).
* Platform specific implementations are provided in GmsBridgeImpl.java.
*/
public abstract class GmsBridge {
private static GmsBridge sInstance;
private static final Object sInstanceLock = new Object();
private static HandlerThread sHandlerThread;
private static Handler sHandler;
private static final Object sHandlerLock = new Object();
protected GmsBridge() {}
public static GmsBridge getInstance() {
synchronized (sInstanceLock) {
if (sInstance == null) {
// Load an instance of GmsBridgeImpl. Because this can change depending on
// the GN configuration, this may not be the GmsBridgeImpl defined upstream.
sInstance = new GmsBridgeImpl();
}
return sInstance;
}
}
// Return a handler appropriate for executing blocking Platform Service tasks.
public static Handler getHandler() {
synchronized (sHandlerLock) {
if (sHandler == null) {
sHandlerThread = new HandlerThread("GmsBridgeHandlerThread");
sHandlerThread.start();
sHandler = new Handler(sHandlerThread.getLooper());
}
}
return sHandler;
}
// Returns true if the WebLayer can use Google Mobile Services (GMS).
public boolean canUseGms() {
return false;
}
public void setSafeBrowsingHandler() {
// We don't have this specialized service here.
}
}
\ No newline at end of file
// 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.
package org.chromium.weblayer_private;
/**
* Instantiable version of {@link GmsBridge}, don't add anything to this class!
* Downstream targets may provide a different implementation.
*/
public class GmsBridgeImpl extends GmsBridge {}
# For safebrowsing related files
per-file *GmsBridge*=timvolodine@chromium.org
...@@ -104,6 +104,7 @@ public final class WebLayerImpl extends IWebLayer.Stub { ...@@ -104,6 +104,7 @@ public final class WebLayerImpl extends IWebLayer.Stub {
ContentUriUtils.setFileProviderUtil(new FileProviderHelper()); ContentUriUtils.setFileProviderUtil(new FileProviderHelper());
LibraryLoader.getInstance().ensureInitialized(LibraryProcessType.PROCESS_WEBLAYER); LibraryLoader.getInstance().ensureInitialized(LibraryProcessType.PROCESS_WEBLAYER);
GmsBridge.getInstance().setSafeBrowsingHandler();
final ValueCallback<Boolean> loadedCallback = (ValueCallback<Boolean>) ObjectWrapper.unwrap( final ValueCallback<Boolean> loadedCallback = (ValueCallback<Boolean>) ObjectWrapper.unwrap(
loadedCallbackWrapper, ValueCallback.class); loadedCallbackWrapper, ValueCallback.class);
......
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