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

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

Issue 2501793002: Prevent the browser from crashing when exiting pages that use WebVR. (Closed)
Patch Set: Rebase 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 | « chrome/browser/android/vr_shell/vr_shell_delegate.cc ('k') | device/vr/vr_display_impl.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"
11 #include "base/android/jni_utils.h" 11 #include "base/android/jni_utils.h"
12 #include "base/android/scoped_java_ref.h" 12 #include "base/android/scoped_java_ref.h"
13 #include "device/vr/android/gvr/gvr_delegate.h" 13 #include "device/vr/android/gvr/gvr_delegate.h"
14 #include "device/vr/android/gvr/gvr_device.h" 14 #include "device/vr/android/gvr/gvr_device.h"
15 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h" 15 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
16 #include "device/vr/vr_device_manager.h" 16 #include "device/vr/vr_device_manager.h"
17 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h" 17 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr.h"
18 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_co ntroller.h" 18 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_co ntroller.h"
19 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_ty pes.h" 19 #include "third_party/gvr-android-sdk/src/ndk/include/vr/gvr/capi/include/gvr_ty pes.h"
20 20
21 using base::android::AttachCurrentThread; 21 using base::android::AttachCurrentThread;
22 using base::android::GetApplicationContext; 22 using base::android::GetApplicationContext;
23 23
24 namespace device { 24 namespace device {
25 25
26 GvrDeviceProvider::GvrDeviceProvider() : weak_ptr_factory_(this) {} 26 GvrDeviceProvider::GvrDeviceProvider() : weak_ptr_factory_(this) {}
27 27
28 GvrDeviceProvider::~GvrDeviceProvider() { 28 GvrDeviceProvider::~GvrDeviceProvider() {
29 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
30 GAMEPAD_SOURCE_GVR);
31
29 device::GvrDelegateProvider* delegate_provider = 32 device::GvrDelegateProvider* delegate_provider =
30 device::GvrDelegateProvider::GetInstance(); 33 device::GvrDelegateProvider::GetInstance();
31 if (delegate_provider) 34 if (delegate_provider) {
35 delegate_provider->ExitWebVRPresent();
32 delegate_provider->DestroyNonPresentingDelegate(); 36 delegate_provider->DestroyNonPresentingDelegate();
33 37 }
34 ExitPresent();
35 } 38 }
36 39
37 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { 40 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) {
38 Initialize(); 41 Initialize();
39 42
40 if (vr_device_) 43 if (vr_device_)
41 devices->push_back(vr_device_.get()); 44 devices->push_back(vr_device_.get());
42 } 45 }
43 46
44 void GvrDeviceProvider::Initialize() { 47 void GvrDeviceProvider::Initialize() {
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 110
108 // Remove GVR gamepad polling. 111 // Remove GVR gamepad polling.
109 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( 112 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
110 GAMEPAD_SOURCE_GVR); 113 GAMEPAD_SOURCE_GVR);
111 114
112 // If we're presenting currently stop. 115 // If we're presenting currently stop.
113 delegate_provider->ExitWebVRPresent(); 116 delegate_provider->ExitWebVRPresent();
114 } 117 }
115 118
116 } // namespace device 119 } // namespace device
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_delegate.cc ('k') | device/vr/vr_display_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698