Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/android/vr_shell/ui_scene_manager.h" | 5 #include "chrome/browser/android/vr_shell/ui_scene_manager.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 8 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
| 9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" | 9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" |
| 10 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" | 10 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 static constexpr vr::Colorf kCctBackgroundHorizonColor = {0.2, 0.6, 0.2, 1.0}; | 43 static constexpr vr::Colorf kCctBackgroundHorizonColor = {0.2, 0.6, 0.2, 1.0}; |
| 44 static constexpr vr::Colorf kCctBackgroundCenterColor = {0.13, 0.52, 0.13, 1.0}; | 44 static constexpr vr::Colorf kCctBackgroundCenterColor = {0.13, 0.52, 0.13, 1.0}; |
| 45 | 45 |
| 46 // Tiny distance to offset textures that should appear in the same plane. | 46 // Tiny distance to offset textures that should appear in the same plane. |
| 47 static constexpr float kTextureOffset = 0.01; | 47 static constexpr float kTextureOffset = 0.01; |
| 48 | 48 |
| 49 } // namespace | 49 } // namespace |
| 50 | 50 |
| 51 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, | 51 UiSceneManager::UiSceneManager(VrBrowserInterface* browser, |
| 52 UiScene* scene, | 52 UiScene* scene, |
| 53 bool in_cct) | 53 bool in_cct, |
| 54 bool in_web_vr) | |
| 54 : browser_(browser), | 55 : browser_(browser), |
| 55 scene_(scene), | 56 scene_(scene), |
| 56 in_cct_(in_cct), | 57 in_cct_(in_cct), |
| 58 web_vr_mode_(in_web_vr), | |
| 57 weak_ptr_factory_(this) { | 59 weak_ptr_factory_(this) { |
| 58 CreateBackground(); | 60 CreateBackground(); |
| 59 CreateContentQuad(); | 61 CreateContentQuad(); |
| 60 CreateSecurityWarnings(); | 62 CreateSecurityWarnings(); |
| 61 CreateUrlBar(); | 63 CreateUrlBar(); |
| 62 } | 64 } |
| 63 | 65 |
| 64 UiSceneManager::~UiSceneManager() {} | 66 UiSceneManager::~UiSceneManager() {} |
| 65 | 67 |
| 66 void UiSceneManager::CreateSecurityWarnings() { | 68 void UiSceneManager::CreateSecurityWarnings() { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 element->set_size({0.9, 0, 1}); | 190 element->set_size({0.9, 0, 1}); |
| 189 url_bar_ = element.get(); | 191 url_bar_ = element.get(); |
| 190 browser_ui_elements_.push_back(element.get()); | 192 browser_ui_elements_.push_back(element.get()); |
| 191 scene_->AddUiElement(std::move(element)); | 193 scene_->AddUiElement(std::move(element)); |
| 192 } | 194 } |
| 193 | 195 |
| 194 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { | 196 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
| 195 return weak_ptr_factory_.GetWeakPtr(); | 197 return weak_ptr_factory_.GetWeakPtr(); |
| 196 } | 198 } |
| 197 | 199 |
| 198 void UiSceneManager::SetWebVRMode(bool web_vr) { | 200 void UiSceneManager::SetWebVrMode(bool web_vr) { |
| 199 web_vr_mode_ = web_vr; | 201 web_vr_mode_ = web_vr; |
| 200 | 202 |
| 201 // Make all VR scene UI elements visible if not in WebVR. | 203 // Make all VR scene UI elements visible if not in WebVR. |
| 202 for (UiElement* element : browser_ui_elements_) { | 204 for (UiElement* element : browser_ui_elements_) { |
| 203 element->set_visible(!web_vr_mode_); | 205 element->set_visible(!web_vr_mode_); |
| 204 } | 206 } |
| 205 | 207 |
| 206 ConfigureSecurityWarnings(); | 208 ConfigureSecurityWarnings(); |
| 207 } | 209 } |
| 208 | 210 |
| 209 void UiSceneManager::SetWebVRSecureOrigin(bool secure) { | 211 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { |
| 210 secure_origin_ = secure; | 212 secure_origin_ = secure; |
| 211 ConfigureSecurityWarnings(); | 213 ConfigureSecurityWarnings(); |
| 212 } | 214 } |
| 213 | 215 |
| 214 void UiSceneManager::OnAppButtonClicked() { | 216 void UiSceneManager::OnAppButtonClicked() { |
| 215 // Pressing the app button currenly pauses content rendering. Note: its still | 217 // Pressing the app button currenly pauses content rendering. Note: its still |
| 216 // unclear what we want to do here and this will most likely change. | 218 // unclear what we want to do here and this will most likely change. |
| 217 content_rendering_enabled_ = !content_rendering_enabled_; | 219 content_rendering_enabled_ = !content_rendering_enabled_; |
| 218 scene_->SetWebVrRenderingEnabled(content_rendering_enabled_); | 220 scene_->SetWebVrRenderingEnabled(content_rendering_enabled_); |
| 219 browser_->OnContentPaused(!content_rendering_enabled_); | 221 browser_->OnContentPaused(!content_rendering_enabled_); |
| 220 } | 222 } |
| 221 | 223 |
| 224 void UiSceneManager::OnAppButtonGesturePerformed( | |
| 225 UiInterface::Direction direction) {} | |
| 226 | |
| 222 void UiSceneManager::ConfigureSecurityWarnings() { | 227 void UiSceneManager::ConfigureSecurityWarnings() { |
| 223 bool enabled = web_vr_mode_ && !secure_origin_; | 228 bool enabled = web_vr_mode_ && !secure_origin_; |
| 224 permanent_security_warning_->set_visible(enabled); | 229 permanent_security_warning_->set_visible(enabled); |
| 225 transient_security_warning_->set_visible(enabled); | 230 transient_security_warning_->set_visible(enabled); |
| 226 if (enabled) { | 231 if (enabled) { |
| 227 security_warning_timer_.Start( | 232 security_warning_timer_.Start( |
| 228 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, | 233 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, |
| 229 &UiSceneManager::OnSecurityWarningTimer); | 234 &UiSceneManager::OnSecurityWarningTimer); |
| 230 } else { | 235 } else { |
| 231 security_warning_timer_.Stop(); | 236 security_warning_timer_.Stop(); |
| 232 } | 237 } |
| 233 } | 238 } |
| 234 | 239 |
| 235 void UiSceneManager::OnSecurityWarningTimer() { | 240 void UiSceneManager::OnSecurityWarningTimer() { |
| 236 transient_security_warning_->set_visible(false); | 241 transient_security_warning_->set_visible(false); |
| 237 } | 242 } |
| 238 | 243 |
| 239 void UiSceneManager::OnUrlChange(const GURL& gurl) { | 244 void UiSceneManager::SetURL(const GURL& gurl) { |
| 240 url_bar_->SetURL(gurl); | 245 url_bar_->SetURL(gurl); |
| 241 } | 246 } |
| 242 | 247 |
| 248 void UiSceneManager::SetFullscreen(bool enabled) {} | |
|
amp
2017/05/08 20:30:06
I went with OnFullscreenChanged in my change since
| |
| 249 | |
| 250 void UiSceneManager::SetSecurityLevel(int level) {} | |
| 251 | |
| 252 void UiSceneManager::SetLoading(bool loading) {} | |
| 253 | |
| 254 void UiSceneManager::SetLoadProgress(double progress) {} | |
| 255 | |
| 256 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | |
| 257 bool can_go_forward) {} | |
| 258 | |
| 243 int UiSceneManager::AllocateId() { | 259 int UiSceneManager::AllocateId() { |
| 244 return next_available_id_++; | 260 return next_available_id_++; |
| 245 } | 261 } |
| 246 | 262 |
| 247 } // namespace vr_shell | 263 } // namespace vr_shell |
| OLD | NEW |