Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: chrome/browser/android/vr_shell/ui_scene_manager.cc

Issue 2877133002: VR: Add a loading indicator to the scene. (Closed)
Patch Set: Add units to timeout constant. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/loading_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"
13 #include "chrome/browser/android/vr_shell/ui_scene.h" 14 #include "chrome/browser/android/vr_shell/ui_scene.h"
14 #include "chrome/browser/android/vr_shell/vr_browser_interface.h" 15 #include "chrome/browser/android/vr_shell/vr_browser_interface.h"
15 #include "chrome/browser/android/vr_shell/vr_shell.h" 16 #include "chrome/browser/android/vr_shell/vr_shell.h"
16 17
17 namespace vr_shell { 18 namespace vr_shell {
18 19
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool in_web_vr) 61 bool in_web_vr)
61 : browser_(browser), 62 : browser_(browser),
62 scene_(scene), 63 scene_(scene),
63 in_cct_(in_cct), 64 in_cct_(in_cct),
64 web_vr_mode_(in_web_vr), 65 web_vr_mode_(in_web_vr),
65 weak_ptr_factory_(this) { 66 weak_ptr_factory_(this) {
66 CreateBackground(); 67 CreateBackground();
67 CreateContentQuad(); 68 CreateContentQuad();
68 CreateSecurityWarnings(); 69 CreateSecurityWarnings();
69 CreateUrlBar(); 70 CreateUrlBar();
71
72 ConfigureScene();
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.
79 element = base::MakeUnique<PermanentSecurityWarning>(512); 82 element = base::MakeUnique<PermanentSecurityWarning>(512);
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 element->set_gridline_count(kFloorGridlineCount); 185 element->set_gridline_count(kFloorGridlineCount);
183 element->set_draw_phase(0); 186 element->set_draw_phase(0);
184 browser_ui_elements_.push_back(element.get()); 187 browser_ui_elements_.push_back(element.get());
185 scene_->AddUiElement(std::move(element)); 188 scene_->AddUiElement(std::move(element));
186 189
187 scene_->SetBackgroundColor(horizon); 190 scene_->SetBackgroundColor(horizon);
188 } 191 }
189 192
190 void UiSceneManager::CreateUrlBar() { 193 void UiSceneManager::CreateUrlBar() {
191 // TODO(cjgrant): Incorporate final size and position. 194 // TODO(cjgrant): Incorporate final size and position.
192 // TODO(cjgrant): Add the loading progress indicator element. 195 auto url_bar = base::MakeUnique<UrlBar>(512);
193 auto element = base::MakeUnique<UrlBar>(512); 196 url_bar->set_id(AllocateId());
194 element->set_id(AllocateId()); 197 url_bar->set_translation({0, -0.9, -1.8});
195 element->set_translation({0, -0.9, -1.8}); 198 url_bar->set_size({0.9, 0, 1});
196 element->set_size({0.9, 0, 1}); 199 url_bar->SetBackButtonCallback(
197 element->SetBackButtonCallback(
198 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); 200 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this)));
199 url_bar_ = element.get(); 201 url_bar_ = url_bar.get();
200 browser_ui_elements_.push_back(element.get()); 202 scene_->AddUiElement(std::move(url_bar));
201 scene_->AddUiElement(std::move(element)); 203
204 auto indicator = base::MakeUnique<LoadingIndicator>(256);
205 indicator->set_id(AllocateId());
206 indicator->set_translation({0, -0.8, -1.8});
207 indicator->set_size({0.4, 0, 1});
208 loading_indicator_ = indicator.get();
209 scene_->AddUiElement(std::move(indicator));
202 } 210 }
203 211
204 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { 212 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() {
205 return weak_ptr_factory_.GetWeakPtr(); 213 return weak_ptr_factory_.GetWeakPtr();
206 } 214 }
207 215
208 void UiSceneManager::SetWebVrMode(bool web_vr) { 216 void UiSceneManager::SetWebVrMode(bool web_vr) {
209 web_vr_mode_ = web_vr; 217 web_vr_mode_ = web_vr;
210 218
211 // Make all VR scene UI elements visible if not in WebVR. 219 ConfigureScene();
220 }
221
222 void UiSceneManager::ConfigureScene() {
amp 2017/05/12 18:46:44 Should we have the fullscreen changes go through h
cjgrant 2017/05/12 18:52:12 We could do that. It'd look more like the origina
cjgrant 2017/05/12 21:03:06 Done. I refactored as suggested and retested. PT
223 // Make all simple browser UI elements visible if not in WebVR.
212 for (UiElement* element : browser_ui_elements_) { 224 for (UiElement* element : browser_ui_elements_) {
213 element->set_visible(!web_vr_mode_); 225 element->set_visible(!web_vr_mode_);
214 } 226 }
215 url_bar_->SetEnabled(!web_vr);
216 227
217 ConfigureSecurityWarnings(); 228 url_bar_->SetEnabled(!web_vr_mode_);
229 loading_indicator_->SetEnabled(!web_vr_mode_);
218 } 230 }
219 231
220 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { 232 void UiSceneManager::SetWebVrSecureOrigin(bool secure) {
221 secure_origin_ = secure; 233 secure_origin_ = secure;
222 ConfigureSecurityWarnings(); 234 ConfigureSecurityWarnings();
223 } 235 }
224 236
225 void UiSceneManager::OnAppButtonClicked() { 237 void UiSceneManager::OnAppButtonClicked() {
226 // Pressing the app button currenly pauses content rendering. Note: its still 238 // Pressing the app button currenly pauses content rendering. Note: its still
227 // unclear what we want to do here and this will most likely change. 239 // unclear what we want to do here and this will most likely change.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 } 294 }
283 295
284 void UiSceneManager::SetURL(const GURL& gurl) { 296 void UiSceneManager::SetURL(const GURL& gurl) {
285 url_bar_->SetURL(gurl); 297 url_bar_->SetURL(gurl);
286 } 298 }
287 299
288 void UiSceneManager::SetSecurityLevel(int level) { 300 void UiSceneManager::SetSecurityLevel(int level) {
289 url_bar_->SetSecurityLevel(level); 301 url_bar_->SetSecurityLevel(level);
290 } 302 }
291 303
292 void UiSceneManager::SetLoading(bool loading) {} 304 void UiSceneManager::SetLoading(bool loading) {
305 loading_indicator_->SetLoading(loading);
306 }
293 307
294 void UiSceneManager::SetLoadProgress(double progress) {} 308 void UiSceneManager::SetLoadProgress(float progress) {
309 loading_indicator_->SetLoadProgress(progress);
310 }
295 311
296 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, 312 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back,
297 bool can_go_forward) {} 313 bool can_go_forward) {}
298 314
299 int UiSceneManager::AllocateId() { 315 int UiSceneManager::AllocateId() {
300 return next_available_id_++; 316 return next_available_id_++;
301 } 317 }
302 318
303 } // namespace vr_shell 319 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/ui_scene_manager.h ('k') | chrome/browser/android/vr_shell/vr_gl_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698