| 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" |
| 9 #include "content/public/common/web_preferences.h" |
| 8 #include "device/vr/android/gvr/gvr_delegate_provider.h" | 10 #include "device/vr/android/gvr/gvr_delegate_provider.h" |
| 9 | 11 |
| 12 using content::WebContents; |
| 13 using content::WebPreferences; |
| 14 |
| 10 DEFINE_WEB_CONTENTS_USER_DATA_KEY(vr_shell::VrTabHelper); | 15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(vr_shell::VrTabHelper); |
| 11 | 16 |
| 12 namespace vr_shell { | 17 namespace vr_shell { |
| 13 | 18 |
| 14 VrTabHelper::VrTabHelper(content::WebContents* contents) {} | 19 VrTabHelper::VrTabHelper(content::WebContents* contents) |
| 20 : web_contents_(contents) {} |
| 21 |
| 15 VrTabHelper::~VrTabHelper() {} | 22 VrTabHelper::~VrTabHelper() {} |
| 16 | 23 |
| 17 void VrTabHelper::SetIsInVr(bool is_in_vr) { | 24 void VrTabHelper::SetIsInVr(bool is_in_vr) { |
| 25 if (is_in_vr_ == is_in_vr) |
| 26 return; |
| 27 |
| 18 is_in_vr_ = is_in_vr; | 28 is_in_vr_ = is_in_vr; |
| 29 |
| 30 WebPreferences web_prefs = |
| 31 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); |
| 32 web_prefs.page_popups_suppressed = is_in_vr_; |
| 33 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); |
| 19 } | 34 } |
| 20 | 35 |
| 21 /* static */ | 36 /* static */ |
| 22 bool VrTabHelper::IsInVr(content::WebContents* contents) { | 37 bool VrTabHelper::IsInVr(content::WebContents* contents) { |
| 23 VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); | 38 VrTabHelper* vr_tab_helper = VrTabHelper::FromWebContents(contents); |
| 24 return vr_tab_helper->is_in_vr(); | 39 return vr_tab_helper->is_in_vr(); |
| 25 } | 40 } |
| 26 | 41 |
| 27 } // namespace vr_shell | 42 } // namespace vr_shell |
| OLD | NEW |