| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 scene_->SetBackgroundColor(horizon); | 187 scene_->SetBackgroundColor(horizon); |
| 188 } | 188 } |
| 189 | 189 |
| 190 void UiSceneManager::CreateUrlBar() { | 190 void UiSceneManager::CreateUrlBar() { |
| 191 // TODO(cjgrant): Incorporate final size and position. | 191 // TODO(cjgrant): Incorporate final size and position. |
| 192 // TODO(cjgrant): Add the loading progress indicator element. | 192 // TODO(cjgrant): Add the loading progress indicator element. |
| 193 auto element = base::MakeUnique<UrlBar>(512); | 193 auto element = base::MakeUnique<UrlBar>(512); |
| 194 element->set_id(AllocateId()); | 194 element->set_id(AllocateId()); |
| 195 element->set_translation({0, -0.9, -1.8}); | 195 element->set_translation({0, -0.9, -1.8}); |
| 196 element->set_size({0.9, 0, 1}); | 196 element->set_size({0.9, 0, 1}); |
| 197 element->SetBackButtonCallback( |
| 198 base::Bind(&UiSceneManager::OnBackButtonClicked, base::Unretained(this))); |
| 197 url_bar_ = element.get(); | 199 url_bar_ = element.get(); |
| 198 browser_ui_elements_.push_back(element.get()); | 200 browser_ui_elements_.push_back(element.get()); |
| 199 scene_->AddUiElement(std::move(element)); | 201 scene_->AddUiElement(std::move(element)); |
| 200 } | 202 } |
| 201 | 203 |
| 202 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { | 204 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
| 203 return weak_ptr_factory_.GetWeakPtr(); | 205 return weak_ptr_factory_.GetWeakPtr(); |
| 204 } | 206 } |
| 205 | 207 |
| 206 void UiSceneManager::SetWebVrMode(bool web_vr) { | 208 void UiSceneManager::SetWebVrMode(bool web_vr) { |
| 207 web_vr_mode_ = web_vr; | 209 web_vr_mode_ = web_vr; |
| 208 | 210 |
| 209 // Make all VR scene UI elements visible if not in WebVR. | 211 // Make all VR scene UI elements visible if not in WebVR. |
| 210 for (UiElement* element : browser_ui_elements_) { | 212 for (UiElement* element : browser_ui_elements_) { |
| 211 element->set_visible(!web_vr_mode_); | 213 element->set_visible(!web_vr_mode_); |
| 212 } | 214 } |
| 215 url_bar_->SetEnabled(!web_vr); |
| 213 | 216 |
| 214 ConfigureSecurityWarnings(); | 217 ConfigureSecurityWarnings(); |
| 215 } | 218 } |
| 216 | 219 |
| 217 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { | 220 void UiSceneManager::SetWebVrSecureOrigin(bool secure) { |
| 218 secure_origin_ = secure; | 221 secure_origin_ = secure; |
| 219 ConfigureSecurityWarnings(); | 222 ConfigureSecurityWarnings(); |
| 220 } | 223 } |
| 221 | 224 |
| 222 void UiSceneManager::OnAppButtonClicked() { | 225 void UiSceneManager::OnAppButtonClicked() { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 &UiSceneManager::OnSecurityWarningTimer); | 270 &UiSceneManager::OnSecurityWarningTimer); |
| 268 } else { | 271 } else { |
| 269 security_warning_timer_.Stop(); | 272 security_warning_timer_.Stop(); |
| 270 } | 273 } |
| 271 } | 274 } |
| 272 | 275 |
| 273 void UiSceneManager::OnSecurityWarningTimer() { | 276 void UiSceneManager::OnSecurityWarningTimer() { |
| 274 transient_security_warning_->set_visible(false); | 277 transient_security_warning_->set_visible(false); |
| 275 } | 278 } |
| 276 | 279 |
| 280 void UiSceneManager::OnBackButtonClicked() { |
| 281 browser_->NavigateBack(); |
| 282 } |
| 283 |
| 277 void UiSceneManager::SetURL(const GURL& gurl) { | 284 void UiSceneManager::SetURL(const GURL& gurl) { |
| 278 url_bar_->SetURL(gurl); | 285 url_bar_->SetURL(gurl); |
| 279 } | 286 } |
| 280 | 287 |
| 281 void UiSceneManager::SetSecurityLevel(int level) {} | 288 void UiSceneManager::SetSecurityLevel(int level) { |
| 289 url_bar_->SetSecurityLevel(level); |
| 290 } |
| 282 | 291 |
| 283 void UiSceneManager::SetLoading(bool loading) {} | 292 void UiSceneManager::SetLoading(bool loading) {} |
| 284 | 293 |
| 285 void UiSceneManager::SetLoadProgress(double progress) {} | 294 void UiSceneManager::SetLoadProgress(double progress) {} |
| 286 | 295 |
| 287 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 296 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
| 288 bool can_go_forward) {} | 297 bool can_go_forward) {} |
| 289 | 298 |
| 290 int UiSceneManager::AllocateId() { | 299 int UiSceneManager::AllocateId() { |
| 291 return next_available_id_++; | 300 return next_available_id_++; |
| 292 } | 301 } |
| 293 | 302 |
| 294 } // namespace vr_shell | 303 } // namespace vr_shell |
| OLD | NEW |