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/audio_input_indicator.h" | |
| 9 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning .h" | 10 #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" | 11 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning .h" |
| 11 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 12 #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_elements/url_bar.h" |
| 14 #include "chrome/browser/android/vr_shell/ui_elements/video_input_indicator.h" | |
| 13 #include "chrome/browser/android/vr_shell/ui_scene.h" | 15 #include "chrome/browser/android/vr_shell/ui_scene.h" |
| 14 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" | 16 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" |
| 15 #include "chrome/browser/android/vr_shell/vr_shell.h" | 17 #include "chrome/browser/android/vr_shell/vr_shell.h" |
| 16 | 18 |
| 17 namespace vr_shell { | 19 namespace vr_shell { |
| 18 | 20 |
| 19 namespace { | 21 namespace { |
| 20 | 22 |
| 21 static constexpr int kWarningTimeoutSeconds = 30; | 23 static constexpr int kWarningTimeoutSeconds = 30; |
| 22 static constexpr float kWarningDistance = 0.7; | 24 static constexpr float kWarningDistance = 0.7; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 bool in_cct, | 61 bool in_cct, |
| 60 bool in_web_vr) | 62 bool in_web_vr) |
| 61 : browser_(browser), | 63 : browser_(browser), |
| 62 scene_(scene), | 64 scene_(scene), |
| 63 in_cct_(in_cct), | 65 in_cct_(in_cct), |
| 64 web_vr_mode_(in_web_vr), | 66 web_vr_mode_(in_web_vr), |
| 65 weak_ptr_factory_(this) { | 67 weak_ptr_factory_(this) { |
| 66 CreateBackground(); | 68 CreateBackground(); |
| 67 CreateContentQuad(); | 69 CreateContentQuad(); |
| 68 CreateSecurityWarnings(); | 70 CreateSecurityWarnings(); |
| 71 CreateSystemIndicators(); | |
| 69 CreateUrlBar(); | 72 CreateUrlBar(); |
| 70 } | 73 } |
| 71 | 74 |
| 72 UiSceneManager::~UiSceneManager() {} | 75 UiSceneManager::~UiSceneManager() {} |
| 73 | 76 |
| 74 void UiSceneManager::CreateSecurityWarnings() { | 77 void UiSceneManager::CreateSecurityWarnings() { |
| 75 std::unique_ptr<UiElement> element; | 78 std::unique_ptr<UiElement> element; |
| 76 | 79 |
| 77 // TODO(mthiesse): Programatically compute the proper texture size for these | 80 // TODO(mthiesse): Programatically compute the proper texture size for these |
| 78 // textured UI elements. | 81 // textured UI elements. |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 97 element->set_size({kTransientWarningWidth, kTransientWarningHeight, 1}); | 100 element->set_size({kTransientWarningWidth, kTransientWarningHeight, 1}); |
| 98 element->set_scale({kWarningDistance, kWarningDistance, 1}); | 101 element->set_scale({kWarningDistance, kWarningDistance, 1}); |
| 99 element->set_translation({0, 0, -kWarningDistance}); | 102 element->set_translation({0, 0, -kWarningDistance}); |
| 100 element->set_visible(false); | 103 element->set_visible(false); |
| 101 element->set_hit_testable(false); | 104 element->set_hit_testable(false); |
| 102 element->set_lock_to_fov(true); | 105 element->set_lock_to_fov(true); |
| 103 transient_security_warning_ = element.get(); | 106 transient_security_warning_ = element.get(); |
| 104 scene_->AddUiElement(std::move(element)); | 107 scene_->AddUiElement(std::move(element)); |
| 105 } | 108 } |
| 106 | 109 |
| 110 void UiSceneManager::CreateSystemIndicators() { | |
| 111 std::unique_ptr<UiElement> element; | |
| 112 | |
| 113 // TODO(acondor): Make constants for sizes and positions once the UX for the | |
| 114 // indicators is defined. | |
| 115 element = base::MakeUnique<AudioInputIndicator>(256); | |
|
mthiesse
2017/05/12 19:44:50
Use 512 width like the permanent security warning?
acondor_
2017/05/12 20:09:51
These are smaller and look perfect as is.
| |
| 116 element->set_id(AllocateId()); | |
| 117 element->set_translation({-0.3, 0.8, -1.9}); | |
| 118 element->set_size({0.4, 0, 1}); | |
| 119 audio_input_indicator_ = element.get(); | |
| 120 browser_ui_elements_.push_back(element.get()); | |
| 121 scene_->AddUiElement(std::move(element)); | |
|
mthiesse
2017/05/12 19:44:50
Should hide these initially.
acondor_
2017/05/12 20:09:51
Done.
| |
| 122 | |
| 123 element = base::MakeUnique<VideoInputIndicator>(256); | |
| 124 element->set_id(AllocateId()); | |
| 125 element->set_translation({0.3, 0.8, -1.9}); | |
|
mthiesse
2017/05/12 19:44:50
Add TODO to not position them on top of each other
acondor_
2017/05/12 20:09:51
The TODO above should cover this. Currently, one g
| |
| 126 element->set_size({0.4, 0, 1}); | |
| 127 audio_input_indicator_ = element.get(); | |
| 128 browser_ui_elements_.push_back(element.get()); | |
| 129 scene_->AddUiElement(std::move(element)); | |
| 130 | |
| 131 // TODO(asimjour): Hook system updates to show/hide indicators. | |
| 132 } | |
| 133 | |
| 107 void UiSceneManager::CreateContentQuad() { | 134 void UiSceneManager::CreateContentQuad() { |
| 108 std::unique_ptr<UiElement> element; | 135 std::unique_ptr<UiElement> element; |
| 109 | 136 |
| 110 element = base::MakeUnique<UiElement>(); | 137 element = base::MakeUnique<UiElement>(); |
| 111 element->set_id(AllocateId()); | 138 element->set_id(AllocateId()); |
| 112 element->set_fill(vr_shell::Fill::CONTENT); | 139 element->set_fill(vr_shell::Fill::CONTENT); |
| 113 element->set_size({kContentWidth, kContentHeight, 1}); | 140 element->set_size({kContentWidth, kContentHeight, 1}); |
| 114 element->set_translation({0, kContentVerticalOffset, -kContentDistance}); | 141 element->set_translation({0, kContentVerticalOffset, -kContentDistance}); |
| 115 element->set_visible(false); | 142 element->set_visible(false); |
| 116 main_content_ = element.get(); | 143 main_content_ = element.get(); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 292 void UiSceneManager::SetLoadProgress(double progress) {} | 319 void UiSceneManager::SetLoadProgress(double progress) {} |
| 293 | 320 |
| 294 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 321 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
| 295 bool can_go_forward) {} | 322 bool can_go_forward) {} |
| 296 | 323 |
| 297 int UiSceneManager::AllocateId() { | 324 int UiSceneManager::AllocateId() { |
| 298 return next_available_id_++; | 325 return next_available_id_++; |
| 299 } | 326 } |
| 300 | 327 |
| 301 } // namespace vr_shell | 328 } // namespace vr_shell |
| OLD | NEW |