Skip to content

Commit

Permalink
WebLayer: hook up WebAR.
Browse files Browse the repository at this point in the history
For now, there is no install flow. See bug 1177948.

See added README for testing instructions.

Bug: 1057106,1177948

Binary-Size: Size increase tracked as crbug.com/1181386
Change-Id: I40c2221c4cf92660b644e6c5c9443ecfca08b1b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2693787
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Andrew Grieve <agrieve@chromium.org>
Reviewed-by: Clark DuVall <cduvall@chromium.org>
Reviewed-by: Richard Coles <torne@chromium.org>
Reviewed-by: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#857179}
  • Loading branch information
Evan Stade authored and Chromium LUCI CQ committed Feb 24, 2021
1 parent a35630d commit 781d52d
Show file tree
Hide file tree
Showing 30 changed files with 439 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
tools:ignore="MissingLeanbackLauncher"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<queries> # DIFF-ANCHOR: 0c3a615d
<queries> # DIFF-ANCHOR: 5a71ec1f
<intent> # DIFF-ANCHOR: 28c960ba
<action android:name="android.media.browse.MediaBrowserService"/>
</intent> # DIFF-ANCHOR: 28c960ba
</queries> # DIFF-ANCHOR: 0c3a615d
<package android:name="com.google.ar.core"/>
</queries> # DIFF-ANCHOR: 5a71ec1f
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-feature android:name="android.software.leanback" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand All @@ -30,6 +31,14 @@
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity> # DIFF-ANCHOR: ea1a94af
<activity # DIFF-ANCHOR: 28dc9019
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="false"
android:launchMode="singleTop"
android:name="com.google.ar.core.InstallActivity"
android:theme="@android:style/Theme.Material.Light.Dialog.Alert">
</activity> # DIFF-ANCHOR: 28dc9019
<activity # DIFF-ANCHOR: a4438884
android:exported="true"
android:icon="@drawable/icon_webview"
Expand Down Expand Up @@ -66,6 +75,7 @@
</activity-alias> # DIFF-ANCHOR: b7cc06e9
<meta-data android:name="$PACKAGE.WebViewLibrary" android:value="libwebviewchromium.so"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<meta-data android:name="com.google.ar.core.min_apk_version" android:value="202940000"/>
<meta-data android:name="org.chromium.content.browser.NUM_PRIVILEGED_SERVICES" android:value="0"/>
<meta-data android:name="org.chromium.content.browser.NUM_SANDBOXED_SERVICES" android:value="40"/>
<provider # DIFF-ANCHOR: a5e78e63
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
tools:ignore="MissingLeanbackLauncher"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<queries> # DIFF-ANCHOR: 0c3a615d
<queries> # DIFF-ANCHOR: 5a71ec1f
<intent> # DIFF-ANCHOR: 28c960ba
<action android:name="android.media.browse.MediaBrowserService"/>
</intent> # DIFF-ANCHOR: 28c960ba
</queries> # DIFF-ANCHOR: 0c3a615d
<package android:name="com.google.ar.core"/>
</queries> # DIFF-ANCHOR: 5a71ec1f
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-feature android:name="android.software.leanback" android:required="false"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
Expand All @@ -30,6 +31,14 @@
android:name="com.google.android.gms.common.api.GoogleApiActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
</activity> # DIFF-ANCHOR: ea1a94af
<activity # DIFF-ANCHOR: 28dc9019
android:configChanges="keyboardHidden|orientation|screenSize"
android:excludeFromRecents="true"
android:exported="false"
android:launchMode="singleTop"
android:name="com.google.ar.core.InstallActivity"
android:theme="@android:style/Theme.Material.Light.Dialog.Alert">
</activity> # DIFF-ANCHOR: 28dc9019
<activity # DIFF-ANCHOR: a4438884
android:exported="true"
android:icon="@drawable/icon_webview"
Expand Down Expand Up @@ -66,6 +75,7 @@
</activity-alias> # DIFF-ANCHOR: b7cc06e9
<meta-data android:name="$PACKAGE.WebViewLibrary" android:value="libmonochrome.so"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/>
<meta-data android:name="com.google.ar.core.min_apk_version" android:value="202940000"/>
<meta-data android:name="org.chromium.content.browser.NUM_PRIVILEGED_SERVICES" android:value="0"/>
<meta-data android:name="org.chromium.content.browser.NUM_SANDBOXED_SERVICES" android:value="40"/>
<provider # DIFF-ANCHOR: a5e78e63
Expand Down
23 changes: 23 additions & 0 deletions android_webview/system_webview_apk_tmpl.gni
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

import("//android_webview/variables.gni")
import("//base/android/resource_exclusions.gni")
import("//build/config/android/abi.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/config/locales.gni")
import("//build/util/version.gni")
import("//chrome/android/trichrome.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//tools/v8_context_snapshot/v8_context_snapshot.gni")
import("//weblayer/variables.gni")
import("//weblayer/weblayer_resource_exclusions.gni")
Expand Down Expand Up @@ -151,6 +153,15 @@ template("system_webview_apk_or_module_tmpl") {
}
}

_libarcore_dir = get_label_info(
"//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)",
"target_out_dir") + "/com_google_ar_core_java/jni"
not_needed([ "_libarcore_dir" ])

_include_arcore =
webview_includes_weblayer && enable_arcore && !_exclude_weblayer_java &&
(_include_secondary_support || _include_primary_support)

if (_include_primary_support) {
deps += [
"//android_webview:webview_primary_abi_assets",
Expand All @@ -162,6 +173,10 @@ template("system_webview_apk_or_module_tmpl") {
loadable_modules +=
[ "$root_out_dir/libchromium_android_linker$shlib_extension" ]
}
if (_include_arcore) {
loadable_modules +=
[ "$_libarcore_dir/$android_app_abi/libarcore_sdk_c.so" ]
}
}
if (_include_secondary_support) {
_trampoline = "//third_party/crashpad/crashpad/handler:crashpad_handler_trampoline($android_secondary_abi_toolchain)"
Expand All @@ -177,6 +192,14 @@ template("system_webview_apk_or_module_tmpl") {
secondary_abi_loadable_modules +=
[ "$_secondary_out_dir/libchromium_android_linker$shlib_extension" ]
}
if (_include_arcore) {
secondary_abi_loadable_modules +=
[ "$_libarcore_dir/$android_app_secondary_abi/libarcore_sdk_c.so" ]
}
}

if (_include_arcore) {
deps += [ "//third_party/arcore-android-sdk-client:com_google_ar_core__unpack_aar" ]
}

if (!_use_trichrome_library || android_64bit_target_cpu) {
Expand Down
12 changes: 8 additions & 4 deletions base/android/java/src/org/chromium/base/BundleUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ public static String getNativeLibraryPath(String libraryName, String splitName)

// SplitCompat is installed on the application context, so check there for library paths
// which were added to that ClassLoader.
path = ((BaseDexClassLoader) ContextUtils.getApplicationContext().getClassLoader())
.findLibrary(libraryName);
if (path != null) {
return path;
ClassLoader classLoader = ContextUtils.getApplicationContext().getClassLoader();
// In WebLayer, the class loader will be a class loader from
// ClassLoaderContextWrapperFactory.
if (classLoader instanceof BaseDexClassLoader) {
path = ((BaseDexClassLoader) classLoader).findLibrary(libraryName);
if (path != null) {
return path;
}
}

return getSplitApkLibraryPath(libraryName, splitName);
Expand Down
28 changes: 16 additions & 12 deletions chrome/android/chrome_public_apk_tmpl.gni
Original file line number Diff line number Diff line change
Expand Up @@ -400,21 +400,25 @@ template("monochrome_public_common_apk_or_module_tmpl") {
]
}

_libarcore_dir = get_label_info(
"//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)",
"target_out_dir") + "/com_google_ar_core_java/jni"

if (android_64bit_target_cpu) {
if (invoker.is_64_bit_browser) {
loadable_modules +=
[ "$_libarcore_dir/arm64-v8a/libarcore_sdk_c.so" ]
# For Trichrome, the native library is added to TrichromeLibrary.apk so it's not needed here.
if (is_monochrome) {
_libarcore_dir = get_label_info(
"//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)",
"target_out_dir") +
"/com_google_ar_core_java/jni"

if (android_64bit_target_cpu) {
if (invoker.is_64_bit_browser) {
loadable_modules +=
[ "$_libarcore_dir/arm64-v8a/libarcore_sdk_c.so" ]
} else {
secondary_abi_loadable_modules +=
[ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ]
}
} else {
secondary_abi_loadable_modules +=
loadable_modules +=
[ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ]
}
} else {
loadable_modules +=
[ "$_libarcore_dir/armeabi-v7a/libarcore_sdk_c.so" ]
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
apk_path=lib/armeabi-v7a/libarcore_sdk_c.so, compress=False, alignment=4096
apk_path=lib/armeabi-v7a/libchromium_android_linker.so, compress=False, alignment=4096
apk_path=assets/chrome_100_percent.pak, compress=False, alignment=4
apk_path=assets/locales/af.pak, compress=False, alignment=4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
apk_path=lib/armeabi-v7a/libarcore_sdk_c.so, compress=False, alignment=4096
apk_path=lib/armeabi-v7a/libchromium_android_linker.so, compress=False, alignment=4096
apk_path=assets/chrome_100_percent.pak, compress=False, alignment=4
apk_path=assets/locales/af.pak, compress=False, alignment=4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apk_path=lib/armeabi-v7a/libarcore_sdk_c.so, compress=False, alignment=4096
apk_path=lib/armeabi-v7a/libcrashpad_handler_trampoline.so, compress=False, alignment=4096
apk_path=lib/armeabi-v7a/libmonochrome.so, compress=False, alignment=4096
apk_path=assets/icudtl.dat, compress=False, alignment=4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
apk_path=lib/armeabi-v7a/libarcore_sdk_c.so, compress=False, alignment=4096
apk_path=lib/armeabi-v7a/libcrashpad_handler_trampoline.so, compress=False, alignment=4096
apk_path=lib/armeabi-v7a/libmonochrome.so, compress=False, alignment=4096
apk_path=assets/icudtl.dat, compress=False, alignment=4
Expand Down
26 changes: 26 additions & 0 deletions chrome/android/trichrome.gni
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/abi.gni")
import("//build/config/android/config.gni")
import("//build/config/android/rules.gni")
import("//build/util/version.gni")
import("//chrome/android/chrome_public_apk_tmpl.gni")
import("//chrome/android/modules/buildflags.gni")
import("//device/vr/buildflags/buildflags.gni")

if (!defined(default_trichrome_certdigest)) {
default_trichrome_certdigest =
Expand Down Expand Up @@ -177,6 +179,30 @@ template("trichrome_library_apk_tmpl") {
[ "$_secondary_out_dir/libcrashpad_handler_trampoline.so" ]
}

if (enable_arcore) {
_libarcore_dir = get_label_info(
"//third_party/arcore-android-sdk-client:com_google_ar_core_java($default_toolchain)",
"target_out_dir") + "/com_google_ar_core_java/jni"
not_needed([ "_libarcore_dir" ])

_arcore_extra_deps = [ "//third_party/arcore-android-sdk-client:com_google_ar_core__unpack_aar" ]
not_needed([ "_arcore_extra_deps" ])

if (_include_primary_support) {
loadable_modules +=
[ "$_libarcore_dir/$android_app_abi/libarcore_sdk_c.so" ]
deps += _arcore_extra_deps
}
if (_include_secondary_support) {
if (enable_arcore) {
secondary_abi_loadable_modules += [
"$_libarcore_dir/$android_app_secondary_abi/libarcore_sdk_c.so",
]
deps += _arcore_extra_deps
}
}
}

# http://crbug.com/1042107.
if (is_component_build) {
main_component_library = "libmonochrome.cr.so"
Expand Down
2 changes: 1 addition & 1 deletion components/webxr/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ android_library("ar_java_base") {
"//third_party/androidx:androidx_annotation_annotation_java",
"//third_party/androidx:androidx_appcompat_appcompat_java",
"//third_party/androidx:androidx_appcompat_appcompat_resources_java",
"//ui/android:ui_java",
"//ui/android:ui_no_recycler_view_java",
]

sources = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import androidx.annotation.NonNull;

import org.chromium.base.ContextUtils;
import org.chromium.base.Log;
import org.chromium.content_public.browser.ScreenOrientationDelegate;
import org.chromium.content_public.browser.ScreenOrientationProvider;
Expand Down Expand Up @@ -126,7 +127,8 @@ public void onSurfaceVisible() {
mNotificationToast.cancel();
}
int resId = R.string.immersive_fullscreen_api_notification;
mNotificationToast = Toast.makeText(mActivity, resId, Toast.LENGTH_LONG);
mNotificationToast =
Toast.makeText(ContextUtils.getApplicationContext(), resId, Toast.LENGTH_LONG);
mNotificationToast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
mNotificationToast.show();
}
Expand Down
6 changes: 4 additions & 2 deletions device/vr/android/arcore/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ component("arcore") {
"type_converters.h",
]

public_deps = [ "//device/vr/public/cpp" ]
public_deps = [
"//device/vr:vr_base",
"//device/vr/public/cpp",
]

deps = [
"//base",
"//device/vr:vr_base",
"//device/vr:vr_util",
"//device/vr/android:vr_android",
"//mojo/public/cpp/bindings",
Expand Down
14 changes: 14 additions & 0 deletions weblayer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import("//build/config/ui.gni")
import("//build/config/win/console_app.gni")
import("//build/config/win/manifest.gni")
import("//components/spellcheck/spellcheck_build_features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//gpu/vulkan/features.gni")
import("//media/media_options.gni")
import("//mojo/public/tools/bindings/mojom.gni")
Expand Down Expand Up @@ -474,6 +475,7 @@ source_set("weblayer_lib_base") {
"//content/public/common",
"//content/public/renderer",
"//content/public/utility",
"//device/vr/buildflags",
"//gpu/config",
"//net",
"//net:net_resources",
Expand Down Expand Up @@ -516,6 +518,18 @@ source_set("weblayer_lib_base") {
deps += [ "//components/captive_portal/content" ]
}

if (enable_arcore) {
assert(is_android)
sources += [
"browser/xr/xr_integration_client_impl.cc",
"browser/xr/xr_integration_client_impl.h",
]
deps += [
"//components/webxr/android",
"//device/vr/android/arcore",
]
}

if (use_browser_spellchecker) {
deps += [
"//components/spellcheck/browser",
Expand Down
1 change: 1 addition & 0 deletions weblayer/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ include_rules = [
"+components/page_info/android",
"+components/payments/core",
"+components/security_state/core/security_state.h",
"+device/vr/buildflags",
"+third_party/metrics_proto/omnibox_input_type.pb.h",
]
4 changes: 3 additions & 1 deletion weblayer/app/content_main_delegate_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "device/vr/buildflags/buildflags.h"
#include "media/base/media_switches.h"
#include "services/network/public/cpp/features.h"
#include "third_party/blink/public/common/features.h"
Expand Down Expand Up @@ -152,10 +153,11 @@ bool ContentMainDelegateImpl::BasicStartupComplete(int* exit_code) {
std::vector<base::Feature> disabled_features = {
// TODO(crbug.com/1025627): make webauth work with WebLayer.
::features::kWebAuth,
// TODO(crbug.com/1057106): make web-xr work with WebLayer.
#if !BUILDFLAG(ENABLE_ARCORE)
::features::kWebXr,
::features::kWebXrArModule,
::features::kWebXrHitTest,
#endif
// TODO(crbug.com/1057770): make Background Fetch work with WebLayer.
::features::kBackgroundFetch,
// TODO(crbug.com/1130989): Support GetInstalledRelatedApps on WebLayer.
Expand Down
2 changes: 2 additions & 0 deletions weblayer/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ include_rules = [
"+components/web_cache/browser",
"+components/webapps/browser",
"+components/webrtc",
"+components/webxr",
"+content/public",
"+device/vr/public",
"+google_apis",
"+mojo/public",
"+net",
Expand Down
16 changes: 16 additions & 0 deletions weblayer/browser/content_browser_client_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@
#include "weblayer/browser/captive_portal_service_factory.h"
#endif

#if BUILDFLAG(ENABLE_ARCORE)
#include "weblayer/browser/xr/xr_integration_client_impl.h"
#endif

namespace switches {
// Specifies a list of hosts for whom we bypass proxy settings and use direct
// connections. Ignored if --proxy-auto-detect or --no-proxy-server are also
Expand Down Expand Up @@ -1100,6 +1104,18 @@ ContentBrowserClientImpl::CreateSpeechRecognitionManagerDelegate() {
return new WebLayerSpeechRecognitionManagerDelegate();
}

#if BUILDFLAG(ENABLE_ARCORE)
content::XrIntegrationClient*
ContentBrowserClientImpl::GetXrIntegrationClient() {
if (!XrIntegrationClientImpl::IsEnabled())
return nullptr;

if (!xr_integration_client_)
xr_integration_client_ = std::make_unique<XrIntegrationClientImpl>();
return xr_integration_client_.get();
}
#endif // BUILDFLAG(ENABLE_ARCORE)

ukm::UkmService* ContentBrowserClientImpl::GetUkmService() {
#if defined(OS_ANDROID)
return WebLayerMetricsServiceClient::GetInstance()->GetUkmService();
Expand Down
Loading

0 comments on commit 781d52d

Please sign in to comment.