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

Side by Side Diff: device/vr/vr_device.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/vr_device.h ('k') | device/vr/vr_display_impl.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/vr_device.h" 5 #include "device/vr/vr_device.h"
6 #include "device/vr/vr_device_provider.h" 6 #include "device/vr/vr_device_provider.h"
7 #include "device/vr/vr_service_impl.h" 7 #include "device/vr/vr_service_impl.h"
8 8
9 namespace device { 9 namespace device {
10 10
11 unsigned int VRDevice::next_id_ = 1; 11 unsigned int VRDevice::next_id_ = 1;
12 12
13 VRDevice::VRDevice() : presenting_service_(nullptr), id_(next_id_) { 13 VRDevice::VRDevice() : presenting_service_(nullptr), id_(next_id_) {
14 // Prevent wraparound. Devices with this ID will be treated as invalid. 14 // Prevent wraparound. Devices with this ID will be treated as invalid.
15 if (next_id_ != VR_DEVICE_LAST_ID) 15 if (next_id_ != VR_DEVICE_LAST_ID)
16 next_id_++; 16 next_id_++;
17 } 17 }
18 18
19 VRDevice::~VRDevice() {} 19 VRDevice::~VRDevice() {}
20 20
21 bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) { 21 bool VRDevice::RequestPresent(bool secure_origin) {
22 return true; 22 return true;
23 }; 23 };
24 24
25 void VRDevice::AddService(VRServiceImpl* service) { 25 void VRDevice::AddService(VRServiceImpl* service) {
26 // Create a VRDisplayImpl for this service/device pair 26 // Create a VRDisplayImpl for this service/device pair
27 VRDisplayImpl* display_impl = service->GetVRDisplayImpl(this); 27 VRDisplayImpl* display_impl = service->GetVRDisplayImpl(this);
28 displays_.insert(std::make_pair(service, display_impl)); 28 displays_.insert(std::make_pair(service, display_impl));
29 } 29 }
30 30
31 void VRDevice::RemoveService(VRServiceImpl* service) { 31 void VRDevice::RemoveService(VRServiceImpl* service) {
32 ExitPresent(service); 32 if (IsPresentingService(service))
33 ExitPresent();
33 displays_.erase(service); 34 displays_.erase(service);
34 } 35 }
35 36
36 bool VRDevice::IsAccessAllowed(VRServiceImpl* service) { 37 bool VRDevice::IsAccessAllowed(VRServiceImpl* service) {
37 return (!presenting_service_ || presenting_service_ == service); 38 return (!presenting_service_ || presenting_service_ == service);
38 } 39 }
39 40
40 bool VRDevice::IsPresentingService(VRServiceImpl* service) { 41 bool VRDevice::IsPresentingService(VRServiceImpl* service) {
41 return (presenting_service_ && presenting_service_ == service); 42 return (presenting_service_ && presenting_service_ == service);
42 } 43 }
43 44
44 void VRDevice::OnDisplayChanged() { 45 void VRDevice::OnDisplayChanged() {
45 mojom::VRDisplayInfoPtr vr_device_info = GetVRDevice(); 46 mojom::VRDisplayInfoPtr vr_device_info = GetVRDevice();
46 if (vr_device_info.is_null()) 47 if (vr_device_info.is_null())
47 return; 48 return;
48 49
49 for (const auto& display : displays_) 50 for (const auto& display : displays_)
50 display.second->client()->OnDisplayChanged(vr_device_info.Clone()); 51 display.second->client()->OnDisplayChanged(vr_device_info.Clone());
51 } 52 }
52 53
53 void VRDevice::OnExitPresent(VRServiceImpl* service) { 54 void VRDevice::OnExitPresent() {
54 DisplayClientMap::iterator it = displays_.find(service); 55 DisplayClientMap::iterator it = displays_.find(presenting_service_);
55 if (it != displays_.end()) 56 if (it != displays_.end())
56 it->second->client()->OnExitPresent(); 57 it->second->client()->OnExitPresent();
58
59 SetPresentingService(nullptr);
57 } 60 }
58 61
59 void VRDevice::OnDisplayBlur() { 62 void VRDevice::OnDisplayBlur() {
60 for (const auto& display : displays_) 63 for (const auto& display : displays_)
61 display.second->client()->OnDisplayBlur(); 64 display.second->client()->OnDisplayBlur();
62 } 65 }
63 66
64 void VRDevice::OnDisplayFocus() { 67 void VRDevice::OnDisplayFocus() {
65 for (const auto& display : displays_) 68 for (const auto& display : displays_)
66 display.second->client()->OnDisplayFocus(); 69 display.second->client()->OnDisplayFocus();
67 } 70 }
68 71
72 void VRDevice::SetPresentingService(VRServiceImpl* service) {
73 presenting_service_ = service;
74 }
75
69 } // namespace device 76 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/vr_device.h ('k') | device/vr/vr_display_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698