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

Side by Side Diff: device/vr/android/gvr/gvr_device_provider.cc

Issue 2493063004: Fix exiting WebVR via Android UI not fully exiting fullscreen. (Closed)
Patch Set: Rebase pt. 2 Created 4 years, 1 month 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
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "device/vr/android/gvr/gvr_device_provider.h" 5 #include "device/vr/android/gvr/gvr_device_provider.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/context_utils.h" 9 #include "base/android/context_utils.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 bool GvrDeviceProvider::RequestPresent() { 56 bool GvrDeviceProvider::RequestPresent() {
57 device::GvrDelegateProvider* delegate_provider = 57 device::GvrDelegateProvider* delegate_provider =
58 device::GvrDelegateProvider::GetInstance(); 58 device::GvrDelegateProvider::GetInstance();
59 if (!delegate_provider) 59 if (!delegate_provider)
60 return false; 60 return false;
61 61
62 // RequestWebVRPresent is async as a render thread may be created. 62 // RequestWebVRPresent is async as a render thread may be created.
63 return delegate_provider->RequestWebVRPresent(weak_ptr_factory_.GetWeakPtr()); 63 return delegate_provider->RequestWebVRPresent(weak_ptr_factory_.GetWeakPtr());
64 } 64 }
65 65
66 // VR presentation exit requested by the API.
66 void GvrDeviceProvider::ExitPresent() { 67 void GvrDeviceProvider::ExitPresent() {
67 if (!vr_device_) 68 SwitchToNonPresentingDelegate();
68 return;
69
70 device::GvrDelegateProvider* delegate_provider =
71 device::GvrDelegateProvider::GetInstance();
72 if (!delegate_provider)
73 return;
74
75 vr_device_->SetDelegate(delegate_provider->GetNonPresentingDelegate());
76
77 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
78 GAMEPAD_SOURCE_GVR);
79
80 delegate_provider->ExitWebVRPresent();
81 } 69 }
82 70
83 void GvrDeviceProvider::OnGvrDelegateReady( 71 void GvrDeviceProvider::OnGvrDelegateReady(
84 const base::WeakPtr<GvrDelegate>& delegate) { 72 const base::WeakPtr<GvrDelegate>& delegate) {
85 if (!vr_device_) 73 if (!vr_device_)
86 return; 74 return;
87 vr_device_->SetDelegate(delegate); 75 vr_device_->SetDelegate(delegate);
88 GamepadDataFetcherManager::GetInstance()->AddFactory( 76 GamepadDataFetcherManager::GetInstance()->AddFactory(
89 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id())); 77 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id()));
90 } 78 }
91 79
80 // VR presentation exit requested by the delegate (probably via UI).
92 void GvrDeviceProvider::OnGvrDelegateRemoved() { 81 void GvrDeviceProvider::OnGvrDelegateRemoved() {
93 ExitPresent(); 82 if (!vr_device_)
83 return;
84
85 SwitchToNonPresentingDelegate();
86 vr_device_->OnExitPresent();
94 } 87 }
95 88
96 void GvrDeviceProvider::OnDisplayBlur() { 89 void GvrDeviceProvider::OnDisplayBlur() {
97 if (!vr_device_) 90 if (!vr_device_)
98 return; 91 return;
99 vr_device_->OnDisplayBlur(); 92 vr_device_->OnDisplayBlur();
100 } 93 }
101 94
102 void GvrDeviceProvider::OnDisplayFocus() { 95 void GvrDeviceProvider::OnDisplayFocus() {
103 if (!vr_device_) 96 if (!vr_device_)
104 return; 97 return;
105 vr_device_->OnDisplayFocus(); 98 vr_device_->OnDisplayFocus();
106 } 99 }
107 100
101 void GvrDeviceProvider::SwitchToNonPresentingDelegate() {
102 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance();
103 if (!vr_device_ || !delegate_provider)
104 return;
105
106 vr_device_->SetDelegate(delegate_provider->GetNonPresentingDelegate());
107
108 // Remove GVR gamepad polling.
109 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
110 GAMEPAD_SOURCE_GVR);
111
112 // If we're presenting currently stop.
113 delegate_provider->ExitWebVRPresent();
114 }
115
108 } // namespace device 116 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698