Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/android/vr_shell/vr_tab_helper.cc

Issue 2975593002: [vr] Deny permission requests in VR mode
Patch Set: . Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/android/vr_shell/vr_tab_helper.h"
6
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"
10 #include "device/vr/android/gvr/gvr_delegate_provider.h"
11
12 using content::WebContents;
13 using content::WebPreferences;
14
15 DEFINE_WEB_CONTENTS_USER_DATA_KEY(vr_shell::VrTabHelper);
16
17 namespace vr_shell {
18
19 VrTabHelper::VrTabHelper(content::WebContents* contents)
20 : web_contents_(contents) {}
21
22 VrTabHelper::~VrTabHelper() {}
23
24 void VrTabHelper::SetIsInVr(bool is_in_vr) {
25 if (is_in_vr_ == is_in_vr)
26 return;
27
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);
34 }
35
36 /* static */
37 bool VrTabHelper::IsInVr(content::WebContents* 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 }
44 return vr_tab_helper->is_in_vr();
45 }
46
47 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_tab_helper.h ('k') | chrome/browser/chrome_quota_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698