Commit fc608d5c authored by Alexander Cooper's avatar Alexander Cooper Committed by Commit Bot

Move ArCoreInstallHelper to //components/webxr

Moves ArCoreInstallHelper to components, including supporting classes
ArCoreShim(Impl) and ArCoreInstallUtils and XrInstallInfoBar.
In order to fully move ArCoreInstallUtils, a ArCoreDeviceUtils class was
created to manage the last "init" that comes from the ChromeActivity.
Note that this is a remnant of the AR DFM which other embedders likely
won't need, and could theoretically be removed from //chrome.

In moving the "Install" and "Update" strings, they are made a bit more
generic, since nothing in them is unique to ArCore. The
ic_ar_core_install install graphic is an identical SVG version of the
icon currently being used. As there is a TODO to replace it, a new
graphic is used to allow for easier replacing.

Bug: 1064073,960542
Change-Id: I96c2be6182a5e6d9f09d268e98dbaef94ce68275
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2453873
Commit-Queue: Alexander Cooper <alcooper@chromium.org>
Reviewed-by: default avatarClark DuVall <cduvall@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Auto-Submit: Alexander Cooper <alcooper@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816268}
parent a2ebd151
...@@ -570,6 +570,13 @@ android_library("chrome_java") { ...@@ -570,6 +570,13 @@ android_library("chrome_java") {
# Include sources from public_tab_management_java_sources.gni. # Include sources from public_tab_management_java_sources.gni.
sources += public_tab_management_java_sources sources += public_tab_management_java_sources
if (enable_arcore) {
deps += [
"//components/webxr/android:ar_java_base",
"//components/webxr/android:webxr_android_enums_java",
]
}
if (enable_vr) { if (enable_vr) {
deps += [ ":chrome_vr_java_resources" ] deps += [ ":chrome_vr_java_resources" ]
} }
...@@ -715,7 +722,6 @@ java_cpp_enum("chrome_android_java_enums_srcjar") { ...@@ -715,7 +722,6 @@ java_cpp_enum("chrome_android_java_enums_srcjar") {
java_cpp_enum("chrome_vr_android_java_enums_srcjar") { java_cpp_enum("chrome_vr_android_java_enums_srcjar") {
sources = [ sources = [
"//chrome/browser/android/vr/arcore_device/arcore_install_helper.h",
"//chrome/browser/android/vr/vrcore_install_helper.h", "//chrome/browser/android/vr/vrcore_install_helper.h",
"//chrome/browser/vr/text_edit_action.h", "//chrome/browser/vr/text_edit_action.h",
"//chrome/browser/vr/ui_test_input.h", "//chrome/browser/vr/ui_test_input.h",
...@@ -750,7 +756,11 @@ java_cpp_template("resource_id_javagen") { ...@@ -750,7 +756,11 @@ java_cpp_template("resource_id_javagen") {
"//components/resources/android/page_info_resource_id.h", "//components/resources/android/page_info_resource_id.h",
"//components/resources/android/permissions_resource_id.h", "//components/resources/android/permissions_resource_id.h",
"//components/resources/android/sms_resource_id.h", "//components/resources/android/sms_resource_id.h",
"//components/resources/android/webxr_resource_id.h",
"$root_gen_dir/device/vr/buildflags/buildflags.h",
] ]
deps = [ "//device/vr/buildflags" ]
} }
junit_binary("chrome_junit_tests") { junit_binary("chrome_junit_tests") {
...@@ -2572,7 +2582,7 @@ if (enable_arcore) { ...@@ -2572,7 +2582,7 @@ if (enable_arcore) {
# Include ArCore files directly instead of using bundles. # Include ArCore files directly instead of using bundles.
deps += [ deps += [
"//chrome/browser/android/vr:ar_java", "//components/webxr/android:ar_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java", "//third_party/arcore-android-sdk-client:com_google_ar_core_java",
] ]
......
...@@ -504,7 +504,7 @@ template("monochrome_public_common_apk_or_module_tmpl") { ...@@ -504,7 +504,7 @@ template("monochrome_public_common_apk_or_module_tmpl") {
if (!enable_chrome_module) { if (!enable_chrome_module) {
deps += [ deps += [
"//chrome/browser/android/vr:ar_java", "//components/webxr/android:ar_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java", "//third_party/arcore-android-sdk-client:com_google_ar_core_java",
] ]
} }
......
...@@ -13,7 +13,7 @@ _libarcore_dir = get_label_info( ...@@ -13,7 +13,7 @@ _libarcore_dir = get_label_info(
ar_module_desc = { ar_module_desc = {
name = "ar" name = "ar"
java_deps = [ java_deps = [
"//chrome/browser/android/vr:ar_java", "//components/webxr/android:ar_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java", "//third_party/arcore-android-sdk-client:com_google_ar_core_java",
] ]
android_manifest = "//chrome/android/features/ar/AndroidManifest.xml" android_manifest = "//chrome/android/features/ar/AndroidManifest.xml"
......
...@@ -16,6 +16,7 @@ class ResourceId { ...@@ -16,6 +16,7 @@ class ResourceId {
#include "components/resources/android/page_info_resource_id.h" #include "components/resources/android/page_info_resource_id.h"
#include "components/resources/android/permissions_resource_id.h" #include "components/resources/android/permissions_resource_id.h"
#include "components/resources/android/sms_resource_id.h" #include "components/resources/android/sms_resource_id.h"
#include "components/resources/android/webxr_resource_id.h"
}; };
return resourceList; return resourceList;
} }
......
// 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.chrome.browser.vr;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
/**
* Helper used to ensure that the ArCore device is appropriately "installed" in
* the browser after any requisite dependencies (e.g. the AR DFM), have been
* installed.
*/
@JNINamespace("vr")
public class ArCoreDeviceUtils {
/**
* Installs the ArCoreDeviceProvider, so that the browser can use an ArCore device.
* Should be called once any ArCore dependencies (except ArCore itself) have been installed.
*/
public static void installArCoreDeviceProviderFactory() {
ArCoreDeviceUtilsJni.get().installArCoreDeviceProviderFactory();
}
@NativeMethods
/* package */ interface ArCodeDeviceUtilsNative {
void installArCoreDeviceProviderFactory();
}
}
...@@ -17,7 +17,7 @@ public class ArDelegateImpl implements ArDelegate { ...@@ -17,7 +17,7 @@ public class ArDelegateImpl implements ArDelegate {
@Override @Override
public void init() { public void init() {
ArCoreInstallUtils.installArCoreDeviceProviderFactory(); ArCoreDeviceUtils.installArCoreDeviceProviderFactory();
} }
@Override @Override
......
...@@ -42,9 +42,8 @@ chrome_junit_test_java_sources += share_junit_test_java_sources ...@@ -42,9 +42,8 @@ chrome_junit_test_java_sources += share_junit_test_java_sources
if (enable_arcore) { if (enable_arcore) {
chrome_java_sources += [ chrome_java_sources += [
"java/src/org/chromium/chrome/browser/vr/ArCoreInstallUtils.java", "java/src/org/chromium/chrome/browser/vr/ArCoreDeviceUtils.java",
"java/src/org/chromium/chrome/browser/vr/ArCoreJavaUtils.java", "java/src/org/chromium/chrome/browser/vr/ArCoreJavaUtils.java",
"java/src/org/chromium/chrome/browser/vr/ArCoreShim.java",
"java/src/org/chromium/chrome/browser/vr/ArDelegateImpl.java", "java/src/org/chromium/chrome/browser/vr/ArDelegateImpl.java",
"java/src/org/chromium/chrome/browser/vr/ArImmersiveOverlay.java", "java/src/org/chromium/chrome/browser/vr/ArImmersiveOverlay.java",
] ]
......
...@@ -76,7 +76,7 @@ template("chrome_bundle") { ...@@ -76,7 +76,7 @@ template("chrome_bundle") {
java_deps = [ "//chrome/android:chrome_all_java" ] + _java_deps java_deps = [ "//chrome/android:chrome_all_java" ] + _java_deps
if (enable_arcore) { if (enable_arcore) {
java_deps += [ java_deps += [
"//chrome/browser/android/vr:ar_java", "//components/webxr/android:ar_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java", "//third_party/arcore-android-sdk-client:com_google_ar_core_java",
] ]
} }
......
...@@ -81,21 +81,6 @@ ...@@ -81,21 +81,6 @@
Site can use MIDI Site can use MIDI
</message> </message>
</if> </if>
<if expr="enable_arcore">
<!-- ARCore check infobar -->
<message name="IDS_AR_CORE_CHECK_INFOBAR_INSTALL_TEXT" desc="Text to be displayed in the ARCore check infobar. When a WebXR page is loaded, if ARCore is needed to display AR content and it is not installed, an infobar will be shown to the user prompting them to install ARCore.">
To view augmented reality content, install ARCore
</message>
<message name="IDS_AR_CORE_CHECK_INFOBAR_UPDATE_TEXT" desc="Text to be displayed in the ARCore check infobar. When a WebXR page is loaded, if ARCore is needed to display AR content and the installed ARCore is not up to date to the version needed by the implementation, an infobar will be shown to the user prompting them to update ARCore.">
To view augmented reality content, update ARCore
</message>
<message name="IDS_AR_CORE_CHECK_INFOBAR_INSTALL_BUTTON" desc="Text to be displayed in the ARCore check infobar confirm button for installing.">
Install
</message>
<message name="IDS_AR_CORE_CHECK_INFOBAR_UPDATE_BUTTON" desc="Title of button that will direct the user to update an app from the market (Play Store)">
Update
</message>
</if>
<!-- VR browser --> <!-- VR browser -->
<!-- TODO(https://crbug.com/731802): Only build these when the VR browser is supported. --> <!-- TODO(https://crbug.com/731802): Only build these when the VR browser is supported. -->
......
...@@ -46,9 +46,6 @@ DECLARE_RESOURCE_ID(IDR_ANDROID_INFOBAR_TRANSLATE, R.drawable.infobar_translate) ...@@ -46,9 +46,6 @@ DECLARE_RESOURCE_ID(IDR_ANDROID_INFOBAR_TRANSLATE, R.drawable.infobar_translate)
LINK_RESOURCE_ID(IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER, LINK_RESOURCE_ID(IDR_AUTOFILL_GOOGLE_PAY_WITH_DIVIDER,
R.drawable.google_pay_with_divider) R.drawable.google_pay_with_divider)
DECLARE_RESOURCE_ID(IDR_ERROR_OUTLINE_GOOGBLUE_24DP,
R.drawable.ic_error_outline_googblue_24dp)
// Autofill popup and keyboard accessory images. // Autofill popup and keyboard accessory images.
// We use Android's |VectorDrawableCompat| for the following images that are // We use Android's |VectorDrawableCompat| for the following images that are
// displayed using |DropdownAdapter|. // displayed using |DropdownAdapter|.
......
...@@ -58,6 +58,7 @@ void ResourceMapper::ConstructMap() { ...@@ -58,6 +58,7 @@ void ResourceMapper::ConstructMap() {
#include "components/resources/android/page_info_resource_id.h" #include "components/resources/android/page_info_resource_id.h"
#include "components/resources/android/permissions_resource_id.h" #include "components/resources/android/permissions_resource_id.h"
#include "components/resources/android/sms_resource_id.h" #include "components/resources/android/sms_resource_id.h"
#include "components/resources/android/webxr_resource_id.h"
#undef LINK_RESOURCE_ID #undef LINK_RESOURCE_ID
#undef DECLARE_RESOURCE_ID #undef DECLARE_RESOURCE_ID
// Make sure ID list sizes match up. // Make sure ID list sizes match up.
......
...@@ -61,16 +61,13 @@ static_library("vr_android") { ...@@ -61,16 +61,13 @@ static_library("vr_android") {
"vr_shell_delegate.h", "vr_shell_delegate.h",
"vrcore_install_helper.cc", "vrcore_install_helper.cc",
"vrcore_install_helper.h", "vrcore_install_helper.h",
"xr_install_infobar.cc",
"xr_install_infobar.h",
] ]
if (enable_arcore) { if (enable_arcore) {
sources += [ sources += [
"arcore_device/arcore_device_provider.cc", "arcore_device/arcore_device_provider.cc",
"arcore_device/arcore_device_provider.h", "arcore_device/arcore_device_provider.h",
"arcore_device/arcore_install_helper.cc", "arcore_device/arcore_device_utils.cc",
"arcore_device/arcore_install_helper.h",
"arcore_device/arcore_java_utils.cc", "arcore_device/arcore_java_utils.cc",
"arcore_device/arcore_java_utils.h", "arcore_device/arcore_java_utils.h",
"chrome_arcore_install_helper.cc", "chrome_arcore_install_helper.cc",
...@@ -89,7 +86,6 @@ static_library("vr_android") { ...@@ -89,7 +86,6 @@ static_library("vr_android") {
"//chrome/common:constants", "//chrome/common:constants",
"//components/browser_ui/util/android", "//components/browser_ui/util/android",
"//components/content_settings/core/browser", "//components/content_settings/core/browser",
"//components/infobars/core",
"//components/language/core/browser", "//components/language/core/browser",
"//components/omnibox/browser", "//components/omnibox/browser",
"//components/page_info", "//components/page_info",
...@@ -97,6 +93,7 @@ static_library("vr_android") { ...@@ -97,6 +93,7 @@ static_library("vr_android") {
"//components/rappor", "//components/rappor",
"//components/search_engines:search_engines", "//components/search_engines:search_engines",
"//components/webxr:webxr", "//components/webxr:webxr",
"//components/webxr/android",
"//content/public/browser", "//content/public/browser",
"//content/public/common", "//content/public/common",
"//device/vr", "//device/vr",
...@@ -178,20 +175,10 @@ group("module_factory") { ...@@ -178,20 +175,10 @@ group("module_factory") {
} }
} }
android_library("ar_java") {
deps = [
"//base:base_java",
"//chrome/android:chrome_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java",
]
sources = [ "//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreShimImpl.java" ]
}
if (enable_arcore) { if (enable_arcore) {
generate_jni("ar_jni_headers") { generate_jni("ar_jni_headers") {
sources = [ sources = [
"//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreInstallUtils.java", "//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreDeviceUtils.java",
"//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreJavaUtils.java", "//chrome/android/java/src/org/chromium/chrome/browser/vr/ArCoreJavaUtils.java",
] ]
} }
......
// 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.
#include <memory>
#include "chrome/browser/android/vr/ar_jni_headers/ArCoreDeviceUtils_jni.h"
#include "chrome/browser/android/vr/arcore_device/arcore_device_provider.h"
#include "device/vr/android/arcore/arcore_device_provider_factory.h"
namespace vr {
namespace {
class ArCoreDeviceProviderFactoryImpl
: public device::ArCoreDeviceProviderFactory {
public:
ArCoreDeviceProviderFactoryImpl() = default;
~ArCoreDeviceProviderFactoryImpl() override = default;
std::unique_ptr<device::VRDeviceProvider> CreateDeviceProvider() override;
private:
DISALLOW_COPY_AND_ASSIGN(ArCoreDeviceProviderFactoryImpl);
};
std::unique_ptr<device::VRDeviceProvider>
ArCoreDeviceProviderFactoryImpl::CreateDeviceProvider() {
return std::make_unique<device::ArCoreDeviceProvider>();
}
} // namespace
static void JNI_ArCoreDeviceUtils_InstallArCoreDeviceProviderFactory(
JNIEnv* env) {
device::ArCoreDeviceProviderFactory::Install(
std::make_unique<ArCoreDeviceProviderFactoryImpl>());
}
} // namespace vr
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
#include "chrome/browser/android/vr/chrome_arcore_install_helper.h" #include "chrome/browser/android/vr/chrome_arcore_install_helper.h"
#include "chrome/browser/android/vr/android_vr_utils.h" #include "chrome/browser/android/vr/android_vr_utils.h"
#include "chrome/browser/android/vr/arcore_device/arcore_install_helper.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "components/webxr/android/arcore_install_helper.h"
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
......
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
#define CHROME_BROWSER_ANDROID_VR_CHROME_ARCORE_INSTALL_HELPER_H_ #define CHROME_BROWSER_ANDROID_VR_CHROME_ARCORE_INSTALL_HELPER_H_
#include "base/callback.h" #include "base/callback.h"
#include "chrome/browser/android/vr/arcore_device/arcore_install_helper.h"
#include "chrome/browser/vr/vr_export.h" #include "chrome/browser/vr/vr_export.h"
#include "components/webxr/android/arcore_install_helper.h"
#include "content/public/browser/xr_install_helper.h" #include "content/public/browser/xr_install_helper.h"
namespace vr { namespace vr {
...@@ -29,7 +29,7 @@ class VR_EXPORT ChromeArCoreInstallHelper : public content::XrInstallHelper { ...@@ -29,7 +29,7 @@ class VR_EXPORT ChromeArCoreInstallHelper : public content::XrInstallHelper {
base::OnceCallback<void(bool)> install_callback) override; base::OnceCallback<void(bool)> install_callback) override;
private: private:
ArCoreInstallHelper arcore_install_helper_; webxr::ArCoreInstallHelper arcore_install_helper_;
}; };
} // namespace vr } // namespace vr
......
...@@ -44,6 +44,7 @@ per-file translate_strings.grdp=file://components/translate/OWNERS ...@@ -44,6 +44,7 @@ per-file translate_strings.grdp=file://components/translate/OWNERS
per-file undo_strings.grdp=file://components/undo/OWNERS per-file undo_strings.grdp=file://components/undo/OWNERS
per-file version_ui_strings.grdp=file://components/version_ui/OWNERS per-file version_ui_strings.grdp=file://components/version_ui/OWNERS
per-file web_contents_delegate_android_strings.grdp=file://components/embedder_support/android/delegate/OWNERS per-file web_contents_delegate_android_strings.grdp=file://components/embedder_support/android/delegate/OWNERS
per-file webxr_strings.grdp=file://components/webxr/OWNERS
# For web_dev_style related changes. # For web_dev_style related changes.
per-file .eslintrc.js=file://ui/webui/PLATFORM_OWNERS per-file .eslintrc.js=file://ui/webui/PLATFORM_OWNERS
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# found in the LICENSE file. # found in the LICENSE file.
import("//build/config/android/rules.gni") import("//build/config/android/rules.gni")
import("//device/vr/buildflags/buildflags.gni")
android_library("java") { android_library("java") {
sources = sources =
...@@ -138,5 +139,9 @@ android_resources("java_resources") { ...@@ -138,5 +139,9 @@ android_resources("java_resources") {
"java/res/values/values.xml", "java/res/values/values.xml",
] ]
if (enable_arcore) {
sources += [ "java/res-arcore/drawable/ic_ar_core_install.xml" ]
}
deps = [ "//ui/android:ui_java_resources" ] deps = [ "//ui/android:ui_java_resources" ]
} }
<?xml version="1.0" encoding="utf-8"?>
<!-- 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. -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:pathData="M0 0h24v24H0V0z"/>
<path
android:fillColor="@color/default_icon_color_blue"
android:pathData="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"/>
</vector>
...@@ -330,6 +330,9 @@ ...@@ -330,6 +330,9 @@
<if expr="is_ios"> <if expr="is_ios">
<part file="management_ios_strings.grdp" /> <part file="management_ios_strings.grdp" />
</if> </if>
<if expr="enable_vr">
<part file="webxr_strings.grdp" />
</if>
<!-- Generic terms --> <!-- Generic terms -->
<message name="IDS_CANCEL" desc="Used for Cancel on buttons"> <message name="IDS_CANCEL" desc="Used for Cancel on buttons">
...@@ -365,6 +368,12 @@ ...@@ -365,6 +368,12 @@
<message name="IDS_MENU" desc="The accessible name for the Menu. This is used as the aria-roledescription for context menus."> <message name="IDS_MENU" desc="The accessible name for the Menu. This is used as the aria-roledescription for context menus.">
Menu Menu
</message> </message>
<message name="IDS_INSTALL" desc="Text to be displayed when an action will trigger an installation (of a component, app from the Play Store, etc.).">
Install
</message>
<message name="IDS_UPDATE" desc="Text to be displayed when an action will trigger an update of an existing item (e.g. a component, app from the Play Store, etc.).">
Update
</message>
<if expr="is_android"> <if expr="is_android">
<message name="IDS_SHOW_CONTENT" desc="Generic label to show content for a feature. [CHAR-LIMIT=20]" formatter_data="android_java"> <message name="IDS_SHOW_CONTENT" desc="Generic label to show content for a feature. [CHAR-LIMIT=20]" formatter_data="android_java">
Show Show
......
...@@ -113,6 +113,9 @@ if (is_android) { ...@@ -113,6 +113,9 @@ if (is_android) {
"android/permissions_resource_id.h", "android/permissions_resource_id.h",
"android/sms_resource_id.h", "android/sms_resource_id.h",
"android/theme_resources.h", "android/theme_resources.h",
"android/webxr_resource_id.h",
] ]
public_deps = [ "//device/vr/buildflags" ]
} }
} }
include_rules = [
"+device/vr/buildflags/buildflags.h",
]
...@@ -18,6 +18,7 @@ enum { ...@@ -18,6 +18,7 @@ enum {
#include "components/resources/android/page_info_resource_id.h" #include "components/resources/android/page_info_resource_id.h"
#include "components/resources/android/permissions_resource_id.h" #include "components/resources/android/permissions_resource_id.h"
#include "components/resources/android/sms_resource_id.h" #include "components/resources/android/sms_resource_id.h"
#include "components/resources/android/webxr_resource_id.h"
ANDROID_COMPONENTS_RESOURCE_ID_MAX, ANDROID_COMPONENTS_RESOURCE_ID_MAX,
}; };
......
// 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.
// This file maps permissions resource IDs to Android resource IDs.
// Presence of regular include guards is checked by:
// 1. cpplint
// 2. a custom presubmit in src/PRESUBMIT.py
// 3. clang (but it only checks the guard is correct if present)
// Disable the first two with these magic comments:
// NOLINT(build/header_guard)
// no-include-guard-because-multiply-included
#include "device/vr/buildflags/buildflags.h"
// LINK_RESOURCE_ID is used for IDs that come from a .grd file.
#ifndef LINK_RESOURCE_ID
#error "LINK_RESOURCE_ID should be defined before including this file"
#endif
// DECLARE_RESOURCE_ID is used for IDs that don't have .grd entries, and
// are only declared in this file.
#ifndef DECLARE_RESOURCE_ID
#error "DECLARE_RESOURCE_ID should be defined before including this file"
#endif
#if BUILDFLAG(ENABLE_ARCORE)
DECLARE_RESOURCE_ID(IDR_ANDROID_AR_CORE_INSALL_ICON,
R.drawable.ic_ar_core_install)
#endif // ENABLE_ARCORE
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import("//build/config/locales.gni") import("//build/config/locales.gni")
import("//components/feed/features.gni") import("//components/feed/features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//ppapi/buildflags/buildflags.gni") import("//ppapi/buildflags/buildflags.gni")
import("//printing/buildflags/buildflags.gni") import("//printing/buildflags/buildflags.gni")
import("//tools/grit/grit_rule.gni") import("//tools/grit/grit_rule.gni")
...@@ -29,9 +30,11 @@ group("strings") { ...@@ -29,9 +30,11 @@ group("strings") {
grit("components_strings") { grit("components_strings") {
source = "../components_strings.grd" source = "../components_strings.grd"
defines = [ defines = [
"enable_arcore=$enable_arcore",
"enable_plugins=$enable_plugins", "enable_plugins=$enable_plugins",
"enable_print_preview=$enable_print_preview", "enable_print_preview=$enable_print_preview",
"enable_feed_v1=$enable_feed_v1", "enable_feed_v1=$enable_feed_v1",
"enable_vr=$enable_vr",
] ]
outputs = [ "grit/components_strings.h" ] outputs = [ "grit/components_strings.h" ]
......
...@@ -2,4 +2,4 @@ alcooper@chromium.org ...@@ -2,4 +2,4 @@ alcooper@chromium.org
bialpio@chromium.org bialpio@chromium.org
# TEAM: xr-dev@chromium.org # TEAM: xr-dev@chromium.org
# COMPONENT: Blink>WebXR # COMPONENT: Internals>XR
# 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.
import("//build/config/android/rules.gni")
import("//device/vr/buildflags/buildflags.gni")
assert(enable_vr)
source_set("android") {
sources = [
"xr_install_infobar.cc",
"xr_install_infobar.h",
]
if (enable_arcore) {
sources += [
"arcore_install_helper.cc",
"arcore_install_helper.h",
]
}
deps = [
"//base",
"//components/infobars/core",
"//components/resources:android_resources",
"//components/strings",
"//content/public/browser",
"//ui/base",
]
if (enable_arcore) {
deps += [ ":ar_jni_headers" ]
}
libs = [ "android" ]
}
android_library("ar_java_base") {
deps = [
":webxr_android_enums_java",
"//base:base_java",
"//base:jni_java",
"//content/public/android:content_java",
"//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/android_deps:androidx_appcompat_appcompat_java",
"//third_party/android_deps:androidx_appcompat_appcompat_resources_java",
"//ui/android:ui_java",
]
sources = [
"//components/webxr/android/java/src/org/chromium/components/webxr/ArCoreInstallUtils.java",
"//components/webxr/android/java/src/org/chromium/components/webxr/ArCoreShim.java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
resources_package = "org.chromium.components.webxr"
}
android_library("ar_java") {
deps = [
":ar_java_base",
":webxr_android_enums_java",
"//base:base_java",
"//third_party/arcore-android-sdk-client:com_google_ar_core_java",
]
sources = [ "//components/webxr/android/java/src/org/chromium/components/webxr/ArCoreShimImpl.java" ]
}
if (enable_arcore) {
generate_jni("ar_jni_headers") {
sources = [ "//components/webxr/android/java/src/org/chromium/components/webxr/ArCoreInstallUtils.java" ]
}
}
java_cpp_enum("webxr_android_enums") {
sources = [ "arcore_install_helper.h" ]
}
android_library("webxr_android_enums_java") {
deps = [ "//third_party/android_deps:androidx_annotation_annotation_java" ]
srcjar_deps = [ ":webxr_android_enums" ]
}
include_rules = [
"+components/infobars",
"+components/resources/android/theme_resources.h",
"+components/strings/grit/components_strings.h",
"+content/public/android/java/src/org/chromium/content_public",
"+ui/android",
"+ui/base",
]
...@@ -2,45 +2,46 @@ ...@@ -2,45 +2,46 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/android/vr/arcore_device/arcore_install_helper.h" #include "components/webxr/android/arcore_install_helper.h"
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "base/bind.h" #include "base/bind.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/android/android_theme_resources.h"
#include "chrome/browser/android/vr/android_vr_utils.h"
#include "chrome/browser/android/vr/ar_jni_headers/ArCoreInstallUtils_jni.h"
#include "chrome/browser/android/vr/arcore_device/arcore_device_provider.h"
#include "chrome/browser/android/vr/xr_install_infobar.h"
#include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
#include "components/infobars/core/infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h"
#include "components/infobars/core/infobar_manager.h" #include "components/infobars/core/infobar_manager.h"
#include "device/vr/android/arcore/arcore_device_provider_factory.h" #include "components/resources/android/theme_resources.h"
#include "components/strings/grit/components_strings.h"
#include "components/webxr/android/ar_jni_headers/ArCoreInstallUtils_jni.h"
#include "components/webxr/android/xr_install_infobar.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
using base::android::AttachCurrentThread; using base::android::AttachCurrentThread;
namespace vr { namespace webxr {
namespace { namespace {
class ArCoreDeviceProviderFactoryImpl content::WebContents* GetWebContents(int render_process_id,
: public device::ArCoreDeviceProviderFactory { int render_frame_id) {
public: content::RenderFrameHost* render_frame_host =
ArCoreDeviceProviderFactoryImpl() = default; content::RenderFrameHost::FromID(render_process_id, render_frame_id);
~ArCoreDeviceProviderFactoryImpl() override = default; DCHECK(render_frame_host);
std::unique_ptr<device::VRDeviceProvider> CreateDeviceProvider() override;
content::WebContents* web_contents =
private: content::WebContents::FromRenderFrameHost(render_frame_host);
DISALLOW_COPY_AND_ASSIGN(ArCoreDeviceProviderFactoryImpl); DCHECK(web_contents);
};
return web_contents;
std::unique_ptr<device::VRDeviceProvider>
ArCoreDeviceProviderFactoryImpl::CreateDeviceProvider() {
return std::make_unique<device::ArCoreDeviceProvider>();
} }
base::android::ScopedJavaLocalRef<jobject> GetJavaWebContents(
int render_process_id,
int render_frame_id) {
return GetWebContents(render_process_id, render_frame_id)
->GetJavaWebContents();
}
} // namespace } // namespace
ArCoreInstallHelper::ArCoreInstallHelper() { ArCoreInstallHelper::ArCoreInstallHelper() {
...@@ -117,12 +118,12 @@ void ArCoreInstallHelper::ShowInfoBar( ...@@ -117,12 +118,12 @@ void ArCoreInstallHelper::ShowInfoBar(
case ArCoreAvailability::kUnknownTimedOut: case ArCoreAvailability::kUnknownTimedOut:
case ArCoreAvailability::kSupportedNotInstalled: { case ArCoreAvailability::kSupportedNotInstalled: {
message_text = IDS_AR_CORE_CHECK_INFOBAR_INSTALL_TEXT; message_text = IDS_AR_CORE_CHECK_INFOBAR_INSTALL_TEXT;
button_text = IDS_AR_CORE_CHECK_INFOBAR_INSTALL_BUTTON; button_text = IDS_INSTALL;
break; break;
} }
case ArCoreAvailability::kSupportedApkTooOld: { case ArCoreAvailability::kSupportedApkTooOld: {
message_text = IDS_AR_CORE_CHECK_INFOBAR_UPDATE_TEXT; message_text = IDS_AR_CORE_CHECK_INFOBAR_UPDATE_TEXT;
button_text = IDS_AR_CORE_CHECK_INFOBAR_UPDATE_BUTTON; button_text = IDS_UPDATE;
break; break;
} }
case ArCoreAvailability::kSupportedInstalled: case ArCoreAvailability::kSupportedInstalled:
...@@ -139,7 +140,7 @@ void ArCoreInstallHelper::ShowInfoBar( ...@@ -139,7 +140,7 @@ void ArCoreInstallHelper::ShowInfoBar(
// TODO(ijamardo, https://crbug.com/838833): Add icon for AR info bar. // TODO(ijamardo, https://crbug.com/838833): Add icon for AR info bar.
auto delegate = std::make_unique<XrInstallInfoBar>( auto delegate = std::make_unique<XrInstallInfoBar>(
infobars::InfoBarDelegate::InfoBarIdentifier::AR_CORE_UPGRADE_ANDROID, infobars::InfoBarDelegate::InfoBarIdentifier::AR_CORE_UPGRADE_ANDROID,
IDR_ERROR_OUTLINE_GOOGBLUE_24DP, message_text, button_text, IDR_ANDROID_AR_CORE_INSALL_ICON, message_text, button_text,
base::BindOnce(&ArCoreInstallHelper::OnInfoBarResponse, base::BindOnce(&ArCoreInstallHelper::OnInfoBarResponse,
weak_ptr_factory_.GetWeakPtr(), render_process_id, weak_ptr_factory_.GetWeakPtr(), render_process_id,
render_frame_id)); render_frame_id));
...@@ -176,10 +177,4 @@ void ArCoreInstallHelper::RunInstallFinishedCallback(bool succeeded) { ...@@ -176,10 +177,4 @@ void ArCoreInstallHelper::RunInstallFinishedCallback(bool succeeded) {
} }
} }
static void JNI_ArCoreInstallUtils_InstallArCoreDeviceProviderFactory( } // namespace webxr
JNIEnv* env) {
device::ArCoreDeviceProviderFactory::Install(
std::make_unique<ArCoreDeviceProviderFactoryImpl>());
}
} // namespace vr
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_VR_ARCORE_DEVICE_ARCORE_INSTALL_HELPER_H_ #ifndef COMPONENTS_WEBXR_ANDROID_ARCORE_INSTALL_HELPER_H_
#define CHROME_BROWSER_ANDROID_VR_ARCORE_DEVICE_ARCORE_INSTALL_HELPER_H_ #define COMPONENTS_WEBXR_ANDROID_ARCORE_INSTALL_HELPER_H_
#include "base/android/jni_android.h" #include "base/android/jni_android.h"
#include "base/android/scoped_java_ref.h" #include "base/android/scoped_java_ref.h"
...@@ -14,11 +14,11 @@ namespace infobars { ...@@ -14,11 +14,11 @@ namespace infobars {
class InfoBarManager; class InfoBarManager;
} }
namespace vr { namespace webxr {
// Equivalent of ArCoreApk.Availability enum. // Equivalent of ArCoreApk.Availability enum.
// For detailed description, please see: // For detailed description, please see:
// https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/ArCoreApk.Availability // https://developers.google.com/ar/reference/java/arcore/reference/com/google/ar/core/ArCoreApk.Availability
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.vr // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.webxr
enum class ArCoreAvailability : int { enum class ArCoreAvailability : int {
kSupportedApkTooOld = 0, kSupportedApkTooOld = 0,
kSupportedInstalled = 1, kSupportedInstalled = 1,
...@@ -61,6 +61,6 @@ class ArCoreInstallHelper { ...@@ -61,6 +61,6 @@ class ArCoreInstallHelper {
base::WeakPtrFactory<ArCoreInstallHelper> weak_ptr_factory_{this}; base::WeakPtrFactory<ArCoreInstallHelper> weak_ptr_factory_{this};
}; };
} // namespace vr } // namespace webxr
#endif // CHROME_BROWSER_ANDROID_VR_ARCORE_DEVICE_ARCORE_INSTALL_HELPER_H_ #endif // COMPONENTS_WEBXR_ANDROID_ARCORE_INSTALL_HELPER_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.vr; package org.chromium.components.webxr;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.app.Application;
...@@ -21,7 +21,7 @@ import org.chromium.ui.base.WindowAndroid; ...@@ -21,7 +21,7 @@ import org.chromium.ui.base.WindowAndroid;
/** /**
* Installs AR DFM and ArCore runtimes. * Installs AR DFM and ArCore runtimes.
*/ */
@JNINamespace("vr") @JNINamespace("webxr")
public class ArCoreInstallUtils { public class ArCoreInstallUtils {
/** /**
* Helper class to store a reference to the ArCoreInstallUtils instance and activity * Helper class to store a reference to the ArCoreInstallUtils instance and activity
...@@ -99,7 +99,7 @@ public class ArCoreInstallUtils { ...@@ -99,7 +99,7 @@ public class ArCoreInstallUtils {
try { try {
sArCoreInstance = sArCoreInstance =
(ArCoreShim) Class.forName("org.chromium.chrome.browser.vr.ArCoreShimImpl") (ArCoreShim) Class.forName("org.chromium.components.webxr.ArCoreShimImpl")
.newInstance(); .newInstance();
} catch (ClassNotFoundException e) { } catch (ClassNotFoundException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
...@@ -217,13 +217,8 @@ public class ArCoreInstallUtils { ...@@ -217,13 +217,8 @@ public class ArCoreInstallUtils {
sInstallRequest = null; sInstallRequest = null;
} }
public static void installArCoreDeviceProviderFactory() {
ArCoreInstallUtilsJni.get().installArCoreDeviceProviderFactory();
}
@NativeMethods @NativeMethods
/* package */ interface ArInstallHelperNative { /* package */ interface ArInstallHelperNative {
void onRequestInstallSupportedArCoreResult(long nativeArCoreInstallHelper, boolean success); void onRequestInstallSupportedArCoreResult(long nativeArCoreInstallHelper, boolean success);
void installArCoreDeviceProviderFactory();
} }
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.vr; package org.chromium.components.webxr;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.chrome.browser.vr; package org.chromium.components.webxr;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
...@@ -11,11 +11,11 @@ import com.google.ar.core.ArCoreApk; ...@@ -11,11 +11,11 @@ import com.google.ar.core.ArCoreApk;
import org.chromium.base.StrictModeContext; import org.chromium.base.StrictModeContext;
import org.chromium.base.annotations.UsedByReflection; import org.chromium.base.annotations.UsedByReflection;
import org.chromium.chrome.browser.vr.ArCoreShim.InstallStatus; import org.chromium.components.webxr.ArCoreShim.InstallStatus;
@UsedByReflection("ArCoreJavaUtils.java") @UsedByReflection("ArCoreInstallUtils.java")
class ArCoreShimImpl implements ArCoreShim { class ArCoreShimImpl implements ArCoreShim {
@UsedByReflection("ArCoreJavaUtils.java") @UsedByReflection("ArCoreInstallUtils.java")
public ArCoreShimImpl() {} public ArCoreShimImpl() {}
@Override @Override
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/android/vr/xr_install_infobar.h" #include "components/webxr/android/xr_install_infobar.h"
#include "base/callback.h" #include "base/callback.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "components/infobars/core/infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace vr { namespace webxr {
XrInstallInfoBar::XrInstallInfoBar( XrInstallInfoBar::XrInstallInfoBar(
InfoBarIdentifier identifier, InfoBarIdentifier identifier,
...@@ -61,4 +61,4 @@ bool XrInstallInfoBar::Cancel() { ...@@ -61,4 +61,4 @@ bool XrInstallInfoBar::Cancel() {
void XrInstallInfoBar::InfoBarDismissed() { void XrInstallInfoBar::InfoBarDismissed() {
std::move(install_callback_).Run(false); std::move(install_callback_).Run(false);
} }
} // namespace vr } // namespace webxr
...@@ -2,15 +2,15 @@ ...@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_ANDROID_VR_XR_INSTALL_INFOBAR_H_ #ifndef COMPONENTS_WEBXR_ANDROID_XR_INSTALL_INFOBAR_H_
#define CHROME_BROWSER_ANDROID_VR_XR_INSTALL_INFOBAR_H_ #define COMPONENTS_WEBXR_ANDROID_XR_INSTALL_INFOBAR_H_
#include "base/callback.h" #include "base/callback.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "components/infobars/core/confirm_infobar_delegate.h" #include "components/infobars/core/confirm_infobar_delegate.h"
#include "components/infobars/core/infobar_delegate.h" #include "components/infobars/core/infobar_delegate.h"
namespace vr { namespace webxr {
// An interface derived from InfoBarDelegate implemented by objects wishing to // An interface derived from InfoBarDelegate implemented by objects wishing to
// control a ConfirmInfoBar. // control a ConfirmInfoBar.
...@@ -49,6 +49,6 @@ class XrInstallInfoBar : public ConfirmInfoBarDelegate { ...@@ -49,6 +49,6 @@ class XrInstallInfoBar : public ConfirmInfoBarDelegate {
const int ok_button_id_; const int ok_button_id_;
base::OnceCallback<void(bool)> install_callback_; base::OnceCallback<void(bool)> install_callback_;
}; };
} // namespace vr } // namespace webxr
#endif // CHROME_BROWSER_ANDROID_VR_XR_INSTALL_INFOBAR_H_ #endif // COMPONENTS_WEBXR_ANDROID_XR_INSTALL_INFOBAR_H_
<?xml version="1.0" encoding="utf-8"?>
<!-- WebXR specific strings (included from components_strings.grd). -->
<grit-part>
<if expr="enable_arcore">
<!-- ARCore check infobar -->
<message name="IDS_AR_CORE_CHECK_INFOBAR_INSTALL_TEXT" desc="Text to be displayed in the ARCore check infobar. When a WebXR page is loaded, if ARCore is needed to display AR content and it is not installed, an infobar will be shown to the user prompting them to install ARCore.">
To view augmented reality content, install ARCore
</message>
<message name="IDS_AR_CORE_CHECK_INFOBAR_UPDATE_TEXT" desc="Text to be displayed in the ARCore check infobar. When a WebXR page is loaded, if ARCore is needed to display AR content and the installed ARCore is not up to date to the version needed by the implementation, an infobar will be shown to the user prompting them to update ARCore.">
To view augmented reality content, update ARCore
</message>
</if>
</grit-part>
file://components/webxr/OWNERS
# COMPONENT: Internals>XR
This directory of image SHA-1 hashes is used to improve translations of UI
strings through context images for translators.
See also: [Chrome Translation Screenshots - Instructions & FAQ
](https://docs.google.com/document/d/1nwYWDny20icMSpLUuV_LgrlbWKrYpbXOERUIZNH636o/edit#heading=h.2t7lc4cxo2au)
...@@ -42,6 +42,7 @@ void ConstructMap() { ...@@ -42,6 +42,7 @@ void ConstructMap() {
#include "components/resources/android/page_info_resource_id.h" #include "components/resources/android/page_info_resource_id.h"
#include "components/resources/android/permissions_resource_id.h" #include "components/resources/android/permissions_resource_id.h"
#include "components/resources/android/sms_resource_id.h" #include "components/resources/android/sms_resource_id.h"
#include "components/resources/android/webxr_resource_id.h"
#undef LINK_RESOURCE_ID #undef LINK_RESOURCE_ID
#undef DECLARE_RESOURCE_ID #undef DECLARE_RESOURCE_ID
// Make sure ID list sizes match up. // Make sure ID list sizes match up.
......
...@@ -56,7 +56,11 @@ java_cpp_template("resource_id_javagen") { ...@@ -56,7 +56,11 @@ java_cpp_template("resource_id_javagen") {
"//components/resources/android/page_info_resource_id.h", "//components/resources/android/page_info_resource_id.h",
"//components/resources/android/permissions_resource_id.h", "//components/resources/android/permissions_resource_id.h",
"//components/resources/android/sms_resource_id.h", "//components/resources/android/sms_resource_id.h",
"//components/resources/android/webxr_resource_id.h",
"$root_gen_dir/device/vr/buildflags/buildflags.h",
] ]
deps = [ "//device/vr/buildflags" ]
} }
java_strings_grd("weblayer_strings_grd") { java_strings_grd("weblayer_strings_grd") {
......
...@@ -15,6 +15,7 @@ class ResourceId { ...@@ -15,6 +15,7 @@ class ResourceId {
#include "components/resources/android/page_info_resource_id.h" #include "components/resources/android/page_info_resource_id.h"
#include "components/resources/android/permissions_resource_id.h" #include "components/resources/android/permissions_resource_id.h"
#include "components/resources/android/sms_resource_id.h" #include "components/resources/android/sms_resource_id.h"
#include "components/resources/android/webxr_resource_id.h"
}; };
return resourceList; return resourceList;
} }
......
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