diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-05-12 15:59:20 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2022-05-25 06:57:22 +0000 |
commit | f7eaed5286974984ba5f9e3189d8f49d03e99f81 (patch) | |
tree | caed19b2af2024f35449fb0b781d0a25e09d4f8f /chromium/components/webxr | |
parent | 9729c4479fe23554eae6e6dd1f30ff488f470c84 (diff) | |
download | qtwebengine-chromium-f7eaed5286974984ba5f9e3189d8f49d03e99f81.tar.gz |
BASELINE: Update Chromium to 100.0.4896.167
Change-Id: I98cbeb5d7543d966ffe04d8cefded0c493a11333
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/components/webxr')
-rw-r--r-- | chromium/components/webxr/OWNERS | 5 | ||||
-rw-r--r-- | chromium/components/webxr/README.md | 21 | ||||
-rw-r--r-- | chromium/components/webxr/android/BUILD.gn | 6 | ||||
-rw-r--r-- | chromium/components/webxr/android/DEPS | 2 | ||||
-rw-r--r-- | chromium/components/webxr/android/arcore_device_provider.cc | 17 | ||||
-rw-r--r-- | chromium/components/webxr/android/arcore_device_provider.h | 11 | ||||
-rw-r--r-- | chromium/components/webxr/android/arcore_install_helper.cc | 90 | ||||
-rw-r--r-- | chromium/components/webxr/android/arcore_install_helper.h | 15 | ||||
-rw-r--r-- | chromium/components/webxr/android/xr_install_helper_delegate.h | 42 | ||||
-rw-r--r-- | chromium/components/webxr/android/xr_install_infobar.cc | 65 | ||||
-rw-r--r-- | chromium/components/webxr/android/xr_install_infobar.h | 58 |
11 files changed, 81 insertions, 251 deletions
diff --git a/chromium/components/webxr/OWNERS b/chromium/components/webxr/OWNERS index 2310121e00b..d37fd2d118a 100644 --- a/chromium/components/webxr/OWNERS +++ b/chromium/components/webxr/OWNERS @@ -1,2 +1,7 @@ alcooper@chromium.org +bajones@chromium.org bialpio@chromium.org +klausw@chromium.org + +# WebXR Test related +bsheedy@chromium.org diff --git a/chromium/components/webxr/README.md b/chromium/components/webxr/README.md new file mode 100644 index 00000000000..af0dd75a82d --- /dev/null +++ b/chromium/components/webxr/README.md @@ -0,0 +1,21 @@ +# WebXR Component + +## WebXR Overview +The web-exposed interface to WebXR begins in [Blink](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/modules/xr/README.md). +This code (with the help of the `VRService` [mojom interface](https://source.chromium.org/chromium/chromium/src/+/main:device/vr/public/mojom/README.md)) +talks with the [browser process](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/xr/README.md) +to broker a connection directly with the corresponding [device code](https://source.chromium.org/chromium/chromium/src/+/main:device/vr/README.md). +Note that this device code is often hosted in a separate XR utility process, and +thus the [isolated_xr_device service](https://source.chromium.org/chromium/chromium/src/+/main:content/services/isolated_xr_device/README.md) +needs to assist the browser in brokering these connections. The code that talks +directly with a device or its corresponding SDK/API (e.g. OpenXR) is often +referred to as a "Runtime" throughout XR code. It is responsible for querying or +formatting the data into/out of the expected WebXR formats. + +## Component Code +This component code may depend on code in both //device and //content. It is +intended for code that is necessary for a given runtime to work, but cannot be +added under //device due to layering violations. Often this is because there may +need to be customizable extension points added for different embedders. This +includes code such as rendering utilizing the viz framework, or extension +methods for embedders to customize the install flow for some runtimes. diff --git a/chromium/components/webxr/android/BUILD.gn b/chromium/components/webxr/android/BUILD.gn index e3fa950a42c..003d0fe8797 100644 --- a/chromium/components/webxr/android/BUILD.gn +++ b/chromium/components/webxr/android/BUILD.gn @@ -21,9 +21,6 @@ source_set("android") { sources = [ "ar_compositor_delegate_provider.cc", "ar_compositor_delegate_provider.h", - "xr_install_helper_delegate.h", - "xr_install_infobar.cc", - "xr_install_infobar.h", ] if (enable_arcore) { @@ -40,8 +37,7 @@ source_set("android") { deps = [ ":android_utils", "//base", - "//components/infobars/android", - "//components/infobars/core", + "//components/messages/android", "//components/resources:android_resources", "//components/strings", "//components/webxr:webxr", diff --git a/chromium/components/webxr/android/DEPS b/chromium/components/webxr/android/DEPS index 6d6e0dfbce3..4193c509af2 100644 --- a/chromium/components/webxr/android/DEPS +++ b/chromium/components/webxr/android/DEPS @@ -1,5 +1,5 @@ include_rules = [ - "+components/infobars", + "+components/messages", "+components/resources/android/theme_resources.h", "+components/strings/grit/components_strings.h", "+content/public/android/java/src/org/chromium/content_public", diff --git a/chromium/components/webxr/android/arcore_device_provider.cc b/chromium/components/webxr/android/arcore_device_provider.cc index 6bb16b5181e..714e8c06b0a 100644 --- a/chromium/components/webxr/android/arcore_device_provider.cc +++ b/chromium/components/webxr/android/arcore_device_provider.cc @@ -19,16 +19,7 @@ ArCoreDeviceProvider::ArCoreDeviceProvider( ArCoreDeviceProvider::~ArCoreDeviceProvider() = default; -void ArCoreDeviceProvider::Initialize( - base::RepeatingCallback<void(device::mojom::XRDeviceId, - device::mojom::VRDisplayInfoPtr, - device::mojom::XRDeviceDataPtr, - mojo::PendingRemote<device::mojom::XRRuntime>)> - add_device_callback, - base::RepeatingCallback<void(device::mojom::XRDeviceId)> - remove_device_callback, - base::OnceClosure initialization_complete, - device::XrFrameSinkClientFactory xr_frame_sink_client_factory) { +void ArCoreDeviceProvider::Initialize(device::VRDeviceProviderClient* client) { if (device::IsArCoreSupported()) { DVLOG(2) << __func__ << ": ARCore is supported, creating device"; @@ -37,14 +28,14 @@ void ArCoreDeviceProvider::Initialize( std::make_unique<device::ArImageTransportFactory>(), std::make_unique<webxr::MailboxToSurfaceBridgeFactoryImpl>(), std::make_unique<webxr::ArCoreJavaUtils>(compositor_delegate_provider_), - std::move(xr_frame_sink_client_factory)); + client->GetXrFrameSinkClientFactory()); - add_device_callback.Run( + client->AddRuntime( arcore_device_->GetId(), arcore_device_->GetVRDisplayInfo(), arcore_device_->GetDeviceData(), arcore_device_->BindXRRuntime()); } initialized_ = true; - std::move(initialization_complete).Run(); + client->OnProviderInitialized(); } bool ArCoreDeviceProvider::Initialized() { diff --git a/chromium/components/webxr/android/arcore_device_provider.h b/chromium/components/webxr/android/arcore_device_provider.h index 15b43d19c2a..74af836b143 100644 --- a/chromium/components/webxr/android/arcore_device_provider.h +++ b/chromium/components/webxr/android/arcore_device_provider.h @@ -28,16 +28,7 @@ class ArCoreDeviceProvider : public device::VRDeviceProvider { ArCoreDeviceProvider& operator=(const ArCoreDeviceProvider&) = delete; ~ArCoreDeviceProvider() override; - void Initialize( - base::RepeatingCallback<void( - device::mojom::XRDeviceId, - device::mojom::VRDisplayInfoPtr, - device::mojom::XRDeviceDataPtr, - mojo::PendingRemote<device::mojom::XRRuntime>)> add_device_callback, - base::RepeatingCallback<void(device::mojom::XRDeviceId)> - remove_device_callback, - base::OnceClosure initialization_complete, - device::XrFrameSinkClientFactory xr_frame_sink_client_factory) override; + void Initialize(device::VRDeviceProviderClient* client) override; bool Initialized() override; private: diff --git a/chromium/components/webxr/android/arcore_install_helper.cc b/chromium/components/webxr/android/arcore_install_helper.cc index b87a22a1e15..bd8612e462e 100644 --- a/chromium/components/webxr/android/arcore_install_helper.cc +++ b/chromium/components/webxr/android/arcore_install_helper.cc @@ -8,29 +8,20 @@ #include <utility> #include "base/bind.h" -#include "base/memory/weak_ptr.h" -#include "components/infobars/android/confirm_infobar.h" -#include "components/infobars/core/infobar.h" -#include "components/infobars/core/infobar_delegate.h" -#include "components/infobars/core/infobar_manager.h" +#include "components/messages/android/message_dispatcher_bridge.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/webxr_utils.h" -#include "components/webxr/android/xr_install_helper_delegate.h" -#include "components/webxr/android/xr_install_infobar.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents.h" +#include "ui/base/l10n/l10n_util.h" using base::android::AttachCurrentThread; namespace webxr { -ArCoreInstallHelper::ArCoreInstallHelper( - std::unique_ptr<XrInstallHelperDelegate> install_delegate) - : install_delegate_(std::move(install_delegate)) { - DCHECK(install_delegate_); - +ArCoreInstallHelper::ArCoreInstallHelper() { // As per documentation, it's recommended to issue a call to // ArCoreApk.checkAvailability() early in application lifecycle & ignore the // result so that subsequent calls can return cached result: @@ -72,7 +63,7 @@ void ArCoreInstallHelper::EnsureInstalled( // ARCore is not installed or requires an update. if (Java_ArCoreInstallUtils_shouldRequestInstallSupportedArCore( AttachCurrentThread())) { - ShowInfoBar(render_process_id, render_frame_id); + ShowMessage(render_process_id, render_frame_id); return; } @@ -81,25 +72,13 @@ void ArCoreInstallHelper::EnsureInstalled( OnRequestInstallSupportedArCoreResult(nullptr, true); } -void ArCoreInstallHelper::ShowInfoBar(int render_process_id, +void ArCoreInstallHelper::ShowMessage(int render_process_id, int render_frame_id) { DVLOG(1) << __func__; - infobars::InfoBarManager* infobar_manager = - install_delegate_->GetInfoBarManager( - GetWebContents(render_process_id, render_frame_id)); - - // We can't show an infobar without an |infobar_manager|, so if it's null, - // report that we are not installed and stop processing. - if (!infobar_manager) { - DVLOG(2) << __func__ << ": infobar_manager is null"; - RunInstallFinishedCallback(false); - return; - } - ArCoreAvailability availability = static_cast<ArCoreAvailability>( Java_ArCoreInstallUtils_getArCoreInstallStatus(AttachCurrentThread())); - int message_text = -1; + int message_title = -1; int button_text = -1; switch (availability) { case ArCoreAvailability::kUnsupportedDeviceNotCapable: { @@ -110,12 +89,12 @@ void ArCoreInstallHelper::ShowInfoBar(int render_process_id, case ArCoreAvailability::kUnknownError: case ArCoreAvailability::kUnknownTimedOut: case ArCoreAvailability::kSupportedNotInstalled: { - message_text = IDS_AR_CORE_CHECK_INFOBAR_INSTALL_TEXT; + message_title = IDS_AR_CORE_CHECK_MESSAGE_INSTALL_TITLE; button_text = IDS_INSTALL; break; } case ArCoreAvailability::kSupportedApkTooOld: { - message_text = IDS_AR_CORE_CHECK_INFOBAR_UPDATE_TEXT; + message_title = IDS_AR_CORE_CHECK_MESSAGE_UPDATE_TITLE; button_text = IDS_UPDATE; break; } @@ -124,33 +103,46 @@ void ArCoreInstallHelper::ShowInfoBar(int render_process_id, break; } - DCHECK_NE(-1, message_text); + DCHECK_NE(-1, message_title); DCHECK_NE(-1, button_text); - // Binding ourself as a weak ref is okay, since our destructor will still - // guarantee that the callback is run if we are destroyed while waiting for - // the callback from the infobar. - // TODO(ijamardo, https://crbug.com/838833): Add icon for AR info bar. - auto delegate = std::make_unique<XrInstallInfoBar>( - infobars::InfoBarDelegate::InfoBarIdentifier::AR_CORE_UPGRADE_ANDROID, - IDR_ANDROID_AR_CORE_INSALL_ICON, message_text, button_text, - base::BindOnce(&ArCoreInstallHelper::OnInfoBarResponse, - weak_ptr_factory_.GetWeakPtr(), render_process_id, - render_frame_id)); - - infobar_manager->AddInfoBar( - std::make_unique<infobars::ConfirmInfoBar>(std::move(delegate))); + message_ = std::make_unique<messages::MessageWrapper>( + messages::MessageIdentifier::AR_CORE_UPGRADE, + base::BindOnce(&ArCoreInstallHelper::HandleMessagePrimaryAction, + base::Unretained(this), render_process_id, + render_frame_id), + base::BindOnce(&ArCoreInstallHelper::HandleMessageDismissed, + base::Unretained(this))); + + message_->SetTitle(l10n_util::GetStringUTF16(message_title)); + message_->SetDescription( + l10n_util::GetStringUTF16(IDS_AR_CORE_CHECK_MESSAGE_DESCRIPTION)); + message_->SetPrimaryButtonText(l10n_util::GetStringUTF16(button_text)); + messages::MessageDispatcherBridge* message_dispatcher_bridge = + messages::MessageDispatcherBridge::Get(); + message_->SetIconResourceId(message_dispatcher_bridge->MapToJavaDrawableId( + IDR_ANDROID_AR_CORE_INSALL_ICON)); + + message_dispatcher_bridge->EnqueueMessage( + message_.get(), GetWebContents(render_process_id, render_frame_id), + messages::MessageScopeType::NAVIGATION, + messages::MessagePriority::kNormal); } -void ArCoreInstallHelper::OnInfoBarResponse(int render_process_id, - int render_frame_id, - bool try_install) { - DVLOG(1) << __func__ << ": try_install=" << try_install; - if (!try_install) { +void ArCoreInstallHelper::HandleMessageDismissed( + messages::DismissReason dismiss_reason) { + // If the message is dismissed for any reason other than the primary action + // button click to install/update ARCore, indicate to the deferred callback + // that no installation/update was facilitated. + if (dismiss_reason != messages::DismissReason::PRIMARY_ACTION) { OnRequestInstallSupportedArCoreResult(nullptr, false); - return; } + DCHECK(message_); + message_.reset(); +} +void ArCoreInstallHelper::HandleMessagePrimaryAction(int render_process_id, + int render_frame_id) { // When completed, java will call: OnRequestInstallSupportedArCoreResult Java_ArCoreInstallUtils_requestInstallSupportedArCore( AttachCurrentThread(), java_install_utils_, diff --git a/chromium/components/webxr/android/arcore_install_helper.h b/chromium/components/webxr/android/arcore_install_helper.h index 0813df3454c..e06f4d6c736 100644 --- a/chromium/components/webxr/android/arcore_install_helper.h +++ b/chromium/components/webxr/android/arcore_install_helper.h @@ -11,10 +11,11 @@ #include "base/android/scoped_java_ref.h" #include "base/callback.h" #include "base/memory/weak_ptr.h" +#include "components/messages/android/message_enums.h" +#include "components/messages/android/message_wrapper.h" #include "content/public/browser/xr_install_helper.h" namespace webxr { -class XrInstallHelperDelegate; // Equivalent of ArCoreApk.Availability enum. // For detailed description, please see: @@ -36,8 +37,7 @@ enum class ArCoreAvailability : int { // XrIntegrationClient. class ArCoreInstallHelper : public content::XrInstallHelper { public: - explicit ArCoreInstallHelper( - std::unique_ptr<XrInstallHelperDelegate> install_delegate); + explicit ArCoreInstallHelper(); ~ArCoreInstallHelper() override; ArCoreInstallHelper(const ArCoreInstallHelper&) = delete; @@ -53,15 +53,14 @@ class ArCoreInstallHelper : public content::XrInstallHelper { void OnRequestInstallSupportedArCoreResult(JNIEnv* env, bool success); private: - void ShowInfoBar(int render_process_id, int render_frame_id); - void OnInfoBarResponse(int render_process_id, - int render_frame_id, - bool try_install); + void ShowMessage(int render_process_id, int render_frame_id); + void HandleMessagePrimaryAction(int render_process_id, int render_frame_id); + void HandleMessageDismissed(messages::DismissReason dismiss_reason); void RunInstallFinishedCallback(bool succeeded); base::OnceCallback<void(bool)> install_finished_callback_; base::android::ScopedJavaGlobalRef<jobject> java_install_utils_; - std::unique_ptr<XrInstallHelperDelegate> install_delegate_; + std::unique_ptr<messages::MessageWrapper> message_; // Must be last. base::WeakPtrFactory<ArCoreInstallHelper> weak_ptr_factory_{this}; diff --git a/chromium/components/webxr/android/xr_install_helper_delegate.h b/chromium/components/webxr/android/xr_install_helper_delegate.h deleted file mode 100644 index 4df3bc21c9a..00000000000 --- a/chromium/components/webxr/android/xr_install_helper_delegate.h +++ /dev/null @@ -1,42 +0,0 @@ -// 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. - -#ifndef COMPONENTS_WEBXR_ANDROID_XR_INSTALL_HELPER_DELEGATE_H_ -#define COMPONENTS_WEBXR_ANDROID_XR_INSTALL_HELPER_DELEGATE_H_ - -namespace content { -class WebContents; -} - -namespace infobars { -class InfoBarManager; -} - -namespace webxr { - -// Helper class for InstallHelpers to gain access to other components. Since the -// InstallHelpers are intended to be plumbed through content/public's -// XrIntegrationClient, they may not contain direct references to other -// component types. This provides a means for embedders to pass accessors for -// other component types to the InstallHelpers. -class XrInstallHelperDelegate { - public: - virtual ~XrInstallHelperDelegate() = default; - - XrInstallHelperDelegate(const XrInstallHelperDelegate&) = delete; - XrInstallHelperDelegate& operator=(const XrInstallHelperDelegate&) = delete; - - // Gets the InfoBarManager for the provided web_contents, which can be used to - // display the installation confirmation message. It is acceptable to return - // a null InfoBarManager, but installation may fail after doing so. - virtual infobars::InfoBarManager* GetInfoBarManager( - content::WebContents* web_contents) = 0; - - protected: - XrInstallHelperDelegate() = default; -}; - -} // namespace webxr - -#endif // COMPONENTS_WEBXR_ANDROID_XR_INSTALL_HELPER_DELEGATE_H_ diff --git a/chromium/components/webxr/android/xr_install_infobar.cc b/chromium/components/webxr/android/xr_install_infobar.cc deleted file mode 100644 index 167e841fc95..00000000000 --- a/chromium/components/webxr/android/xr_install_infobar.cc +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 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 "components/webxr/android/xr_install_infobar.h" - -#include <string> - -#include "base/callback.h" -#include "components/infobars/core/confirm_infobar_delegate.h" -#include "components/infobars/core/infobar_delegate.h" -#include "ui/base/l10n/l10n_util.h" - -namespace webxr { - -XrInstallInfoBar::XrInstallInfoBar( - InfoBarIdentifier identifier, - int icon_id, - int message_id, - int ok_button_id, - base::OnceCallback<void(bool)> install_callback) - : identifier_(identifier), - icon_id_(icon_id), - message_id_(message_id), - ok_button_id_(ok_button_id), - install_callback_(std::move(install_callback)) {} - -XrInstallInfoBar::~XrInstallInfoBar() = default; - -infobars::InfoBarDelegate::InfoBarIdentifier XrInstallInfoBar::GetIdentifier() - const { - return identifier_; -} - -int XrInstallInfoBar::GetIconId() const { - return icon_id_; -} - -int XrInstallInfoBar::GetButtons() const { - return BUTTON_OK; -} - -std::u16string XrInstallInfoBar::GetButtonLabel(InfoBarButton button) const { - DCHECK_EQ(BUTTON_OK, button); - return l10n_util::GetStringUTF16(ok_button_id_); -} - -std::u16string XrInstallInfoBar::GetMessageText() const { - return l10n_util::GetStringUTF16(message_id_); -} - -bool XrInstallInfoBar::Accept() { - std::move(install_callback_).Run(true); - return true; -} - -bool XrInstallInfoBar::Cancel() { - std::move(install_callback_).Run(false); - return true; -} - -void XrInstallInfoBar::InfoBarDismissed() { - std::move(install_callback_).Run(false); -} -} // namespace webxr diff --git a/chromium/components/webxr/android/xr_install_infobar.h b/chromium/components/webxr/android/xr_install_infobar.h deleted file mode 100644 index 67882c90971..00000000000 --- a/chromium/components/webxr/android/xr_install_infobar.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (c) 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. - -#ifndef COMPONENTS_WEBXR_ANDROID_XR_INSTALL_INFOBAR_H_ -#define COMPONENTS_WEBXR_ANDROID_XR_INSTALL_INFOBAR_H_ - -#include <string> - -#include "base/callback.h" -#include "components/infobars/core/confirm_infobar_delegate.h" -#include "components/infobars/core/infobar_delegate.h" - -namespace webxr { - -// An interface derived from InfoBarDelegate implemented by objects wishing to -// control a ConfirmInfoBar. -class XrInstallInfoBar : public ConfirmInfoBarDelegate { - public: - // Constructor for XrInstallInfoBar, the callback is guaranteed to be called, - // if the InfoBar is accepted, cancelled, or dismissed. The Callback will be - // passed a bool indicating whether the result of the InfoBar was "accepted." - XrInstallInfoBar(InfoBarIdentifier identifier, - int icon_id, - int message_id, - int ok_button_id, - base::OnceCallback<void(bool)> install_callback); - ~XrInstallInfoBar() override; - - infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; - int GetIconId() const override; - std::u16string GetMessageText() const override; - int GetButtons() const override; - std::u16string GetButtonLabel(InfoBarButton button) const override; - - private: - // Called when the OK button is pressed. If this function returns true, the - // infobar is then immediately closed. Subclasses MUST NOT return true if in - // handling this call something triggers the infobar to begin closing. - bool Accept() override; - - // Called when the Cancel button is pressed. If this function returns true, - // the infobar is then immediately closed. Subclasses MUST NOT return true if - // in handling this call something triggers the infobar to begin closing. - bool Cancel() override; - - // Called when the user clicks on the close button to dismiss the infobar. - void InfoBarDismissed() override; - - const infobars::InfoBarDelegate::InfoBarIdentifier identifier_; - const int icon_id_; - const int message_id_; - const int ok_button_id_; - base::OnceCallback<void(bool)> install_callback_; -}; -} // namespace webxr - -#endif // COMPONENTS_WEBXR_ANDROID_XR_INSTALL_INFOBAR_H_ |