Index: chrome/browser/android/vr_shell/vr_tab_helper.cc |
diff --git a/chrome/browser/android/vr_shell/vr_tab_helper.cc b/chrome/browser/android/vr_shell/vr_tab_helper.cc |
index 3121cd2eedb0618ccae118ae20436b73c3856b7f..20372ea0b463d2a42180bf9bc4f8ddb9b584464c 100644 |
--- a/chrome/browser/android/vr_shell/vr_tab_helper.cc |
+++ b/chrome/browser/android/vr_shell/vr_tab_helper.cc |
@@ -36,6 +36,11 @@ void VrTabHelper::SetIsInVr(bool is_in_vr) { |
/* static */ |
bool VrTabHelper::IsInVr(content::WebContents* contents) { |
VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); |
+ if (!vr_tab_helper) { |
+ // This can only happen for unittests. |
+ VrTabHelper::CreateForWebContents(contents); |
+ vr_tab_helper = VrTabHelper::FromWebContents(contents); |
+ } |
return vr_tab_helper->is_in_vr(); |
} |