Commit e45cb2a5 authored by Suman Kancherla's avatar Suman Kancherla Committed by Commit Bot

[vr] Added additional state for in-headset display for windows

Bug: 912767
Change-Id: I872e6809c4bf8af1d68f4e59cd43ff475958db2a
Reviewed-on: https://chromium-review.googlesource.com/c/1370906
Commit-Queue: Suman Kancherla <sumankancherla@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarBill Orr <billorr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#616099}
parent 9575b315
...@@ -51,6 +51,36 @@ bool VrTabHelper::IsInVr(content::WebContents* contents) { ...@@ -51,6 +51,36 @@ bool VrTabHelper::IsInVr(content::WebContents* contents) {
return vr_tab_helper->is_in_vr(); return vr_tab_helper->is_in_vr();
} }
/* static */
bool VrTabHelper::IsContentDisplayedInHeadset(content::WebContents* contents) {
if (!contents)
return false;
VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents);
if (!vr_tab_helper) {
VrTabHelper::CreateForWebContents(contents);
vr_tab_helper = VrTabHelper::FromWebContents(contents);
}
return vr_tab_helper->is_content_displayed_in_headset();
}
/* static */
void VrTabHelper::SetIsContentDisplayedInHeadset(content::WebContents* contents,
bool state) {
if (!contents)
return;
VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents);
if (!vr_tab_helper) {
VrTabHelper::CreateForWebContents(contents);
vr_tab_helper = VrTabHelper::FromWebContents(contents);
}
vr_tab_helper->SetIsContentDisplayedInHeadset(state);
}
void VrTabHelper::SetIsContentDisplayedInHeadset(bool state) {
is_content_displayed_in_headset_ = state;
}
bool VrTabHelper::IsUiSuppressedInVr(content::WebContents* contents, bool VrTabHelper::IsUiSuppressedInVr(content::WebContents* contents,
UiSuppressedElement element) { UiSuppressedElement element) {
if (!IsInVr(contents)) if (!IsInVr(contents))
......
...@@ -21,8 +21,18 @@ class VrTabHelper : public content::WebContentsUserData<VrTabHelper> { ...@@ -21,8 +21,18 @@ class VrTabHelper : public content::WebContentsUserData<VrTabHelper> {
// up on the WebContents. // up on the WebContents.
void SetIsInVr(bool is_in_vr); void SetIsInVr(bool is_in_vr);
bool is_content_displayed_in_headset() const {
return is_content_displayed_in_headset_;
}
void SetIsContentDisplayedInHeadset(bool state);
static bool IsInVr(content::WebContents* contents); static bool IsInVr(content::WebContents* contents);
static bool IsContentDisplayedInHeadset(content::WebContents* contents);
static void SetIsContentDisplayedInHeadset(content::WebContents* contents,
bool state);
// If suppressed, this function will log a UMA stat. // If suppressed, this function will log a UMA stat.
static bool IsUiSuppressedInVr(content::WebContents* contents, static bool IsUiSuppressedInVr(content::WebContents* contents,
UiSuppressedElement element); UiSuppressedElement element);
...@@ -33,7 +43,21 @@ class VrTabHelper : public content::WebContentsUserData<VrTabHelper> { ...@@ -33,7 +43,21 @@ class VrTabHelper : public content::WebContentsUserData<VrTabHelper> {
friend class content::WebContentsUserData<VrTabHelper>; friend class content::WebContentsUserData<VrTabHelper>;
content::WebContents* web_contents_; content::WebContents* web_contents_;
// If is_in_vr_ is true, that means that the only content displayed is
// inside vr (for example, VR browsing or immersive experience
// on an Android phone with headset on).
// If is_content_displayed_in_headset_ is true, it means content is displayed
// both in VR and on the desktop (example: presenting WebXR
// content from a browser on Windows).
//
// If we have external monitors on Android, we'd want
// is_content_displayed_in_headset_ to be true there, and likewise
// is_in_vr_ could be true if content was only available in-headset on
// Windows.
// TODO(cassew): Rename below vars to more intuitive names.
bool is_in_vr_ = false; bool is_in_vr_ = false;
bool is_content_displayed_in_headset_ = false;
WEB_CONTENTS_USER_DATA_KEY_DECL(); WEB_CONTENTS_USER_DATA_KEY_DECL();
......
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