| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/android/vr_shell/vr_tab_helper.h" | 5 #include "chrome/browser/android/vr_shell/vr_tab_helper.h" |
| 6 | 6 |
| 7 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" | 7 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h" |
| 8 #include "content/public/browser/render_view_host.h" | 8 #include "content/public/browser/render_view_host.h" |
| 9 #include "content/public/common/web_preferences.h" | 9 #include "content/public/common/web_preferences.h" |
| 10 #include "device/vr/android/gvr/gvr_delegate_provider.h" | 10 #include "device/vr/android/gvr/gvr_delegate_provider.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 WebPreferences web_prefs = | 30 WebPreferences web_prefs = |
| 31 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); | 31 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); |
| 32 web_prefs.page_popups_suppressed = is_in_vr_; | 32 web_prefs.page_popups_suppressed = is_in_vr_; |
| 33 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); | 33 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); |
| 34 } | 34 } |
| 35 | 35 |
| 36 /* static */ | 36 /* static */ |
| 37 bool VrTabHelper::IsInVr(content::WebContents* contents) { | 37 bool VrTabHelper::IsInVr(content::WebContents* contents) { |
| 38 VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); | 38 VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); |
| 39 if (!vr_tab_helper) { |
| 40 // This can only happen for unittests. |
| 41 VrTabHelper::CreateForWebContents(contents); |
| 42 vr_tab_helper = VrTabHelper::FromWebContents(contents); |
| 43 } |
| 39 return vr_tab_helper->is_in_vr(); | 44 return vr_tab_helper->is_in_vr(); |
| 40 } | 45 } |
| 41 | 46 |
| 42 } // namespace vr_shell | 47 } // namespace vr_shell |
| OLD | NEW |