| OLD | NEW |
| 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 "modules/vr/NavigatorVR.h" | 5 #include "modules/vr/NavigatorVR.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
| 9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
| 10 #include "core/dom/ExceptionCode.h" | 10 #include "core/dom/ExceptionCode.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return; | 147 return; |
| 148 focused_ = focused; | 148 focused_ = focused; |
| 149 if (controller_) { | 149 if (controller_) { |
| 150 controller_->SetListeningForActivate(listening_for_activate_ && focused); | 150 controller_->SetListeningForActivate(listening_for_activate_ && focused); |
| 151 controller_->FocusChanged(); | 151 controller_->FocusChanged(); |
| 152 } | 152 } |
| 153 } | 153 } |
| 154 | 154 |
| 155 void NavigatorVR::DidAddEventListener(LocalDOMWindow* window, | 155 void NavigatorVR::DidAddEventListener(LocalDOMWindow* window, |
| 156 const AtomicString& event_type) { | 156 const AtomicString& event_type) { |
| 157 // TODO(mthiesse): Remove fullscreen requirement for presentation. See | 157 if (event_type == EventTypeNames::vrdisplayactivate) { |
| 158 // crbug.com/687369 | |
| 159 if (event_type == EventTypeNames::vrdisplayactivate && | |
| 160 GetSupplementable()->GetFrame() && | |
| 161 GetSupplementable()->GetFrame()->GetDocument() && | |
| 162 Fullscreen::FullscreenEnabled( | |
| 163 *GetSupplementable()->GetFrame()->GetDocument())) { | |
| 164 listening_for_activate_ = true; | 158 listening_for_activate_ = true; |
| 165 Controller()->SetListeningForActivate(focused_); | 159 Controller()->SetListeningForActivate(focused_); |
| 166 } else if (event_type == EventTypeNames::vrdisplayconnect) { | 160 } else if (event_type == EventTypeNames::vrdisplayconnect) { |
| 167 // If the page is listening for connection events make sure we've created a | 161 // If the page is listening for connection events make sure we've created a |
| 168 // controller so that we'll be notified of new devices. | 162 // controller so that we'll be notified of new devices. |
| 169 Controller(); | 163 Controller(); |
| 170 } | 164 } |
| 171 } | 165 } |
| 172 | 166 |
| 173 void NavigatorVR::DidRemoveEventListener(LocalDOMWindow* window, | 167 void NavigatorVR::DidRemoveEventListener(LocalDOMWindow* window, |
| 174 const AtomicString& event_type) { | 168 const AtomicString& event_type) { |
| 175 if (event_type == EventTypeNames::vrdisplayactivate && | 169 if (event_type == EventTypeNames::vrdisplayactivate && |
| 176 !window->HasEventListeners(EventTypeNames::vrdisplayactivate)) { | 170 !window->HasEventListeners(EventTypeNames::vrdisplayactivate)) { |
| 177 listening_for_activate_ = false; | 171 listening_for_activate_ = false; |
| 178 Controller()->SetListeningForActivate(false); | 172 Controller()->SetListeningForActivate(false); |
| 179 } | 173 } |
| 180 } | 174 } |
| 181 | 175 |
| 182 void NavigatorVR::DidRemoveAllEventListeners(LocalDOMWindow* window) { | 176 void NavigatorVR::DidRemoveAllEventListeners(LocalDOMWindow* window) { |
| 183 if (!controller_) | 177 if (!controller_) |
| 184 return; | 178 return; |
| 185 | 179 |
| 186 controller_->SetListeningForActivate(false); | 180 controller_->SetListeningForActivate(false); |
| 187 listening_for_activate_ = false; | 181 listening_for_activate_ = false; |
| 188 } | 182 } |
| 189 | 183 |
| 190 } // namespace blink | 184 } // namespace blink |
| OLD | NEW |