| 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/textured_element.h" | |
| 11 #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" |
| 12 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 11 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| 12 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" |
| 13 #include "chrome/browser/android/vr_shell/ui_scene.h" | 13 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| 14 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" | 14 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" |
| 15 #include "chrome/browser/android/vr_shell/vr_shell.h" | 15 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 16 | 16 |
| 17 namespace vr_shell { | 17 namespace vr_shell { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 static constexpr int kWarningTimeoutSeconds = 30; | 21 static constexpr int kWarningTimeoutSeconds = 30; |
| 22 static constexpr float kWarningDistance = 0.7; | 22 static constexpr float kWarningDistance = 0.7; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 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 : browser_(browser), | 54 : browser_(browser), |
| 55 scene_(scene), | 55 scene_(scene), |
| 56 in_cct_(in_cct), | 56 in_cct_(in_cct), |
| 57 weak_ptr_factory_(this) { | 57 weak_ptr_factory_(this) { |
| 58 CreateBackground(); | 58 CreateBackground(); |
| 59 CreateContentQuad(); | 59 CreateContentQuad(); |
| 60 CreateSecurityWarnings(); | 60 CreateSecurityWarnings(); |
| 61 CreateUrlBar(); |
| 61 } | 62 } |
| 62 | 63 |
| 63 UiSceneManager::~UiSceneManager() {} | 64 UiSceneManager::~UiSceneManager() {} |
| 64 | 65 |
| 65 void UiSceneManager::CreateSecurityWarnings() { | 66 void UiSceneManager::CreateSecurityWarnings() { |
| 66 std::unique_ptr<UiElement> element; | 67 std::unique_ptr<UiElement> element; |
| 67 | 68 |
| 68 // TODO(mthiesse): Programatically compute the proper texture size for these | 69 // TODO(mthiesse): Programatically compute the proper texture size for these |
| 69 // textured UI elements. | 70 // textured UI elements. |
| 70 element = base::MakeUnique<PermanentSecurityWarning>(512); | 71 element = base::MakeUnique<PermanentSecurityWarning>(512); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 edge_color.a = 0.0; | 172 edge_color.a = 0.0; |
| 172 element->set_edge_color(edge_color); | 173 element->set_edge_color(edge_color); |
| 173 element->set_gridline_count(kFloorGridlineCount); | 174 element->set_gridline_count(kFloorGridlineCount); |
| 174 element->set_draw_phase(0); | 175 element->set_draw_phase(0); |
| 175 browser_ui_elements_.push_back(element.get()); | 176 browser_ui_elements_.push_back(element.get()); |
| 176 scene_->AddUiElement(std::move(element)); | 177 scene_->AddUiElement(std::move(element)); |
| 177 | 178 |
| 178 scene_->SetBackgroundColor(horizon); | 179 scene_->SetBackgroundColor(horizon); |
| 179 } | 180 } |
| 180 | 181 |
| 182 void UiSceneManager::CreateUrlBar() { |
| 183 // TODO(cjgrant): Incorporate final size and position. |
| 184 // TODO(cjgrant): Add the loading progress indicator element. |
| 185 auto element = base::MakeUnique<UrlBar>(512); |
| 186 element->set_id(AllocateId()); |
| 187 element->set_translation({0, -0.9, -1.8}); |
| 188 element->set_size({0.9, 0, 1}); |
| 189 url_bar_ = element.get(); |
| 190 browser_ui_elements_.push_back(element.get()); |
| 191 scene_->AddUiElement(std::move(element)); |
| 192 } |
| 193 |
| 181 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { | 194 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
| 182 return weak_ptr_factory_.GetWeakPtr(); | 195 return weak_ptr_factory_.GetWeakPtr(); |
| 183 } | 196 } |
| 184 | 197 |
| 185 void UiSceneManager::SetWebVRMode(bool web_vr) { | 198 void UiSceneManager::SetWebVRMode(bool web_vr) { |
| 186 web_vr_mode_ = web_vr; | 199 web_vr_mode_ = web_vr; |
| 187 | 200 |
| 188 // Make all VR scene UI elements visible if not in WebVR. | 201 // Make all VR scene UI elements visible if not in WebVR. |
| 189 for (UiElement* element : browser_ui_elements_) { | 202 for (UiElement* element : browser_ui_elements_) { |
| 190 element->set_visible(!web_vr_mode_); | 203 element->set_visible(!web_vr_mode_); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 216 &UiSceneManager::OnSecurityWarningTimer); | 229 &UiSceneManager::OnSecurityWarningTimer); |
| 217 } else { | 230 } else { |
| 218 security_warning_timer_.Stop(); | 231 security_warning_timer_.Stop(); |
| 219 } | 232 } |
| 220 } | 233 } |
| 221 | 234 |
| 222 void UiSceneManager::OnSecurityWarningTimer() { | 235 void UiSceneManager::OnSecurityWarningTimer() { |
| 223 transient_security_warning_->set_visible(false); | 236 transient_security_warning_->set_visible(false); |
| 224 } | 237 } |
| 225 | 238 |
| 239 void UiSceneManager::OnUrlChange(const GURL& gurl) { |
| 240 url_bar_->SetURL(gurl); |
| 241 } |
| 242 |
| 226 int UiSceneManager::AllocateId() { | 243 int UiSceneManager::AllocateId() { |
| 227 return next_available_id_++; | 244 return next_available_id_++; |
| 228 } | 245 } |
| 229 | 246 |
| 230 } // namespace vr_shell | 247 } // namespace vr_shell |
| OLD | NEW |