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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" | 9 #include "chrome/browser/android/vr_shell/textures/close_button_texture.h" |
10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" | 10 #include "chrome/browser/android/vr_shell/textures/ui_texture.h" |
11 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" | 11 #include "chrome/browser/android/vr_shell/ui_elements/audio_capture_indicator.h" |
12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" | 12 #include "chrome/browser/android/vr_shell/ui_elements/button.h" |
13 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" | 13 #include "chrome/browser/android/vr_shell/ui_elements/loading_indicator.h" |
14 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning
.h" | 14 #include "chrome/browser/android/vr_shell/ui_elements/permanent_security_warning
.h" |
15 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning
.h" | 15 #include "chrome/browser/android/vr_shell/ui_elements/transient_security_warning
.h" |
16 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" | 16 #include "chrome/browser/android/vr_shell/ui_elements/ui_element.h" |
| 17 #include "chrome/browser/android/vr_shell/ui_elements/ui_element_identifiers.h" |
17 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" | 18 #include "chrome/browser/android/vr_shell/ui_elements/url_bar.h" |
18 #include "chrome/browser/android/vr_shell/ui_elements/video_capture_indicator.h" | 19 #include "chrome/browser/android/vr_shell/ui_elements/video_capture_indicator.h" |
19 #include "chrome/browser/android/vr_shell/ui_scene.h" | 20 #include "chrome/browser/android/vr_shell/ui_scene.h" |
20 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" | 21 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" |
21 #include "chrome/browser/android/vr_shell/vr_shell.h" | 22 #include "chrome/browser/android/vr_shell/vr_shell.h" |
22 | 23 |
23 namespace vr_shell { | 24 namespace vr_shell { |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 weak_ptr_factory_(this) { | 78 weak_ptr_factory_(this) { |
78 CreateBackground(); | 79 CreateBackground(); |
79 CreateContentQuad(); | 80 CreateContentQuad(); |
80 CreateSecurityWarnings(); | 81 CreateSecurityWarnings(); |
81 CreateSystemIndicators(); | 82 CreateSystemIndicators(); |
82 CreateUrlBar(); | 83 CreateUrlBar(); |
83 if (in_cct_) | 84 if (in_cct_) |
84 CreateCloseButton(); | 85 CreateCloseButton(); |
85 | 86 |
86 ConfigureScene(); | 87 ConfigureScene(); |
| 88 ConfigureSecurityWarnings(); |
87 } | 89 } |
88 | 90 |
89 UiSceneManager::~UiSceneManager() {} | 91 UiSceneManager::~UiSceneManager() {} |
90 | 92 |
91 void UiSceneManager::CreateSecurityWarnings() { | 93 void UiSceneManager::CreateSecurityWarnings() { |
92 std::unique_ptr<UiElement> element; | 94 std::unique_ptr<UiElement> element; |
93 | 95 |
94 // TODO(mthiesse): Programatically compute the proper texture size for these | 96 // TODO(mthiesse): Programatically compute the proper texture size for these |
95 // textured UI elements. | 97 // textured UI elements. |
96 element = base::MakeUnique<PermanentSecurityWarning>(512); | 98 element = base::MakeUnique<PermanentSecurityWarning>(512); |
| 99 element->set_identifier(kWebVrPermanentHttpSecurityWarning); |
97 element->set_id(AllocateId()); | 100 element->set_id(AllocateId()); |
98 element->set_fill(vr_shell::Fill::NONE); | 101 element->set_fill(vr_shell::Fill::NONE); |
99 element->set_size({kPermanentWarningWidth, kPermanentWarningHeight, 1}); | 102 element->set_size({kPermanentWarningWidth, kPermanentWarningHeight, 1}); |
100 element->set_scale({kWarningDistance, kWarningDistance, 1}); | 103 element->set_scale({kWarningDistance, kWarningDistance, 1}); |
101 element->set_translation( | 104 element->set_translation( |
102 gfx::Vector3dF(0, kWarningDistance * sin(kWarningAngleRadians), | 105 gfx::Vector3dF(0, kWarningDistance * sin(kWarningAngleRadians), |
103 -kWarningDistance * cos(kWarningAngleRadians))); | 106 -kWarningDistance * cos(kWarningAngleRadians))); |
104 element->set_rotation({1.0f, 0, 0, kWarningAngleRadians}); | 107 element->set_rotation({1.0f, 0, 0, kWarningAngleRadians}); |
105 element->set_visible(false); | 108 element->set_visible(false); |
106 element->set_hit_testable(false); | 109 element->set_hit_testable(false); |
107 element->set_lock_to_fov(true); | 110 element->set_lock_to_fov(true); |
108 permanent_security_warning_ = element.get(); | 111 permanent_security_warning_ = element.get(); |
109 scene_->AddUiElement(std::move(element)); | 112 scene_->AddUiElement(std::move(element)); |
110 | 113 |
111 element = base::MakeUnique<TransientSecurityWarning>(1024); | 114 element = base::MakeUnique<TransientSecurityWarning>(1024); |
| 115 element->set_identifier(kWebVrTransientHttpSecurityWarning); |
112 element->set_id(AllocateId()); | 116 element->set_id(AllocateId()); |
113 element->set_fill(vr_shell::Fill::NONE); | 117 element->set_fill(vr_shell::Fill::NONE); |
114 element->set_size({kTransientWarningWidth, kTransientWarningHeight, 1}); | 118 element->set_size({kTransientWarningWidth, kTransientWarningHeight, 1}); |
115 element->set_scale({kWarningDistance, kWarningDistance, 1}); | 119 element->set_scale({kWarningDistance, kWarningDistance, 1}); |
116 element->set_translation({0, 0, -kWarningDistance}); | 120 element->set_translation({0, 0, -kWarningDistance}); |
117 element->set_visible(false); | 121 element->set_visible(false); |
118 element->set_hit_testable(false); | 122 element->set_hit_testable(false); |
119 element->set_lock_to_fov(true); | 123 element->set_lock_to_fov(true); |
120 transient_security_warning_ = element.get(); | 124 transient_security_warning_ = element.get(); |
121 scene_->AddUiElement(std::move(element)); | 125 scene_->AddUiElement(std::move(element)); |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 indicator->set_y_anchoring(YAnchoring::YTOP); | 246 indicator->set_y_anchoring(YAnchoring::YTOP); |
243 loading_indicator_ = indicator.get(); | 247 loading_indicator_ = indicator.get(); |
244 control_elements_.push_back(indicator.get()); | 248 control_elements_.push_back(indicator.get()); |
245 scene_->AddUiElement(std::move(indicator)); | 249 scene_->AddUiElement(std::move(indicator)); |
246 } | 250 } |
247 | 251 |
248 void UiSceneManager::CreateCloseButton() { | 252 void UiSceneManager::CreateCloseButton() { |
249 std::unique_ptr<Button> element = base::MakeUnique<Button>( | 253 std::unique_ptr<Button> element = base::MakeUnique<Button>( |
250 base::Bind(&UiSceneManager::OnCloseButtonClicked, base::Unretained(this)), | 254 base::Bind(&UiSceneManager::OnCloseButtonClicked, base::Unretained(this)), |
251 base::MakeUnique<CloseButtonTexture>()); | 255 base::MakeUnique<CloseButtonTexture>()); |
| 256 element->set_identifier(kCloseButton); |
252 element->set_id(AllocateId()); | 257 element->set_id(AllocateId()); |
253 element->set_fill(vr_shell::Fill::NONE); | 258 element->set_fill(vr_shell::Fill::NONE); |
254 element->set_translation( | 259 element->set_translation( |
255 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, | 260 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, |
256 -kContentDistance + 0.4)); | 261 -kContentDistance + 0.4)); |
257 element->set_size(gfx::Vector3dF(0.2, 0.2, 1)); | 262 element->set_size(gfx::Vector3dF(0.2, 0.2, 1)); |
258 control_elements_.push_back(element.get()); | 263 control_elements_.push_back(element.get()); |
259 scene_->AddUiElement(std::move(element)); | 264 scene_->AddUiElement(std::move(element)); |
260 } | 265 } |
261 | 266 |
262 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { | 267 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
263 return weak_ptr_factory_.GetWeakPtr(); | 268 return weak_ptr_factory_.GetWeakPtr(); |
264 } | 269 } |
265 | 270 |
266 void UiSceneManager::SetWebVrMode(bool web_vr) { | 271 void UiSceneManager::SetWebVrMode(bool web_vr) { |
267 if (web_vr_mode_ == web_vr) | 272 if (web_vr_mode_ == web_vr) |
268 return; | 273 return; |
269 web_vr_mode_ = web_vr; | 274 web_vr_mode_ = web_vr; |
270 ConfigureScene(); | 275 ConfigureScene(); |
| 276 ConfigureSecurityWarnings(); |
271 } | 277 } |
272 | 278 |
273 void UiSceneManager::ConfigureScene() { | 279 void UiSceneManager::ConfigureScene() { |
274 // Controls (URL bar, loading progress, etc). | 280 // Controls (URL bar, loading progress, etc). |
275 bool controls_visible = !web_vr_mode_ && !fullscreen_; | 281 bool controls_visible = !web_vr_mode_ && !fullscreen_; |
276 for (UiElement* element : control_elements_) { | 282 for (UiElement* element : control_elements_) { |
277 element->SetEnabled(controls_visible); | 283 element->SetEnabled(controls_visible); |
278 } | 284 } |
279 | 285 |
280 // Content elements. | 286 // Content elements. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 380 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
375 bool can_go_forward) {} | 381 bool can_go_forward) {} |
376 | 382 |
377 void UiSceneManager::OnCloseButtonClicked() {} | 383 void UiSceneManager::OnCloseButtonClicked() {} |
378 | 384 |
379 int UiSceneManager::AllocateId() { | 385 int UiSceneManager::AllocateId() { |
380 return next_available_id_++; | 386 return next_available_id_++; |
381 } | 387 } |
382 | 388 |
383 } // namespace vr_shell | 389 } // namespace vr_shell |
OLD | NEW |