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/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" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 77 : browser_(browser), | 77 : browser_(browser), |
| 78 scene_(scene), | 78 scene_(scene), |
| 79 in_cct_(in_cct), | 79 in_cct_(in_cct), |
| 80 web_vr_mode_(in_web_vr), | 80 web_vr_mode_(in_web_vr), |
| 81 weak_ptr_factory_(this) { | 81 weak_ptr_factory_(this) { |
| 82 CreateBackground(); | 82 CreateBackground(); |
| 83 CreateContentQuad(); | 83 CreateContentQuad(); |
| 84 CreateSecurityWarnings(); | 84 CreateSecurityWarnings(); |
| 85 CreateSystemIndicators(); | 85 CreateSystemIndicators(); |
| 86 CreateUrlBar(); | 86 CreateUrlBar(); |
| 87 if (in_cct_) | 87 CreateCloseButton(); |
| 88 CreateCloseButton(); | |
| 89 CreateScreenDimmer(); | 88 CreateScreenDimmer(); |
| 90 | 89 |
| 91 ConfigureScene(); | 90 ConfigureScene(); |
| 92 ConfigureSecurityWarnings(); | 91 ConfigureSecurityWarnings(); |
| 93 } | 92 } |
| 94 | 93 |
| 95 UiSceneManager::~UiSceneManager() {} | 94 UiSceneManager::~UiSceneManager() {} |
| 96 | 95 |
| 97 void UiSceneManager::CreateScreenDimmer() { | 96 void UiSceneManager::CreateScreenDimmer() { |
| 98 std::unique_ptr<UiElement> element; | 97 std::unique_ptr<UiElement> element; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 std::unique_ptr<Button> element = base::MakeUnique<Button>( | 296 std::unique_ptr<Button> element = base::MakeUnique<Button>( |
| 298 base::Bind(&UiSceneManager::OnCloseButtonClicked, base::Unretained(this)), | 297 base::Bind(&UiSceneManager::OnCloseButtonClicked, base::Unretained(this)), |
| 299 base::MakeUnique<CloseButtonTexture>()); | 298 base::MakeUnique<CloseButtonTexture>()); |
| 300 element->set_debug_id(kCloseButton); | 299 element->set_debug_id(kCloseButton); |
| 301 element->set_id(AllocateId()); | 300 element->set_id(AllocateId()); |
| 302 element->set_fill(vr_shell::Fill::NONE); | 301 element->set_fill(vr_shell::Fill::NONE); |
| 303 element->set_translation( | 302 element->set_translation( |
| 304 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, | 303 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, |
| 305 -kContentDistance + 0.4)); | 304 -kContentDistance + 0.4)); |
| 306 element->set_size(gfx::Vector3dF(0.2, 0.2, 1)); | 305 element->set_size(gfx::Vector3dF(0.2, 0.2, 1)); |
| 307 control_elements_.push_back(element.get()); | 306 close_button_ = element.get(); |
| 307 control_elements_.push_back(close_button_); | |
| 308 scene_->AddUiElement(std::move(element)); | 308 scene_->AddUiElement(std::move(element)); |
| 309 } | 309 } |
| 310 | 310 |
| 311 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { | 311 base::WeakPtr<UiSceneManager> UiSceneManager::GetWeakPtr() { |
| 312 return weak_ptr_factory_.GetWeakPtr(); | 312 return weak_ptr_factory_.GetWeakPtr(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 void UiSceneManager::SetWebVrMode(bool web_vr) { | 315 void UiSceneManager::SetWebVrMode(bool web_vr) { |
| 316 if (web_vr_mode_ == web_vr) | 316 if (web_vr_mode_ == web_vr) |
| 317 return; | 317 return; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 331 bool controls_visible = !web_vr_mode_ && !fullscreen_; | 331 bool controls_visible = !web_vr_mode_ && !fullscreen_; |
| 332 for (UiElement* element : control_elements_) { | 332 for (UiElement* element : control_elements_) { |
| 333 element->SetEnabled(controls_visible); | 333 element->SetEnabled(controls_visible); |
| 334 } | 334 } |
| 335 | 335 |
| 336 // Content elements. | 336 // Content elements. |
| 337 for (UiElement* element : content_elements_) { | 337 for (UiElement* element : content_elements_) { |
| 338 element->SetEnabled(!web_vr_mode_); | 338 element->SetEnabled(!web_vr_mode_); |
| 339 } | 339 } |
| 340 | 340 |
| 341 close_button_->SetEnabled(fullscreen_); | |
|
cjgrant
2017/05/31 15:39:28
Does this break the button for CCT mode, by hiding
amp
2017/06/02 01:08:35
It looks like it probably does. I don't think we
cjgrant
2017/06/02 12:51:47
We do have a CctButtonVisibleInCct test, which cov
amp
2017/06/02 21:40:24
Updated. I changed the test to be about the butto
| |
| 342 | |
| 341 // Update content quad parameters depending on fullscreen. | 343 // Update content quad parameters depending on fullscreen. |
| 342 // TODO(http://crbug.com/642937): Animate fullscreen transitions. | 344 // TODO(http://crbug.com/642937): Animate fullscreen transitions. |
| 343 if (fullscreen_) { | 345 if (fullscreen_) { |
| 344 main_content_->set_translation( | 346 main_content_->set_translation( |
| 345 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); | 347 {0, kFullscreenVerticalOffset, -kFullscreenDistance}); |
| 346 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); | 348 main_content_->set_size({kFullscreenWidth, kFullscreenHeight, 1}); |
| 349 | |
| 350 close_button_->set_translation(gfx::Vector3dF( | |
| 351 0, kFullscreenVerticalOffset - (kFullscreenHeight / 2) - 0.1, | |
| 352 -kFullscreenDistance + 0.4)); | |
| 347 } else { | 353 } else { |
| 348 // Note that main_content_ is already visible in this case. | 354 // Note that main_content_ is already visible in this case. |
| 349 main_content_->set_translation( | 355 main_content_->set_translation( |
| 350 {0, kContentVerticalOffset, -kContentDistance}); | 356 {0, kContentVerticalOffset, -kContentDistance}); |
| 351 main_content_->set_size({kContentWidth, kContentHeight, 1}); | 357 main_content_->set_size({kContentWidth, kContentHeight, 1}); |
| 358 | |
| 359 close_button_->set_translation( | |
| 360 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, | |
| 361 -kContentDistance + 0.4)); | |
| 352 } | 362 } |
| 353 | 363 |
| 354 scene_->SetMode(mode()); | 364 scene_->SetMode(mode()); |
| 355 scene_->SetBackgroundDistance(main_content_->translation().z() * | 365 scene_->SetBackgroundDistance(main_content_->translation().z() * |
| 356 -kBackgroundDistanceMultiplier); | 366 -kBackgroundDistanceMultiplier); |
| 357 UpdateBackgroundColor(); | 367 UpdateBackgroundColor(); |
| 358 } | 368 } |
| 359 | 369 |
| 360 void UiSceneManager::UpdateBackgroundColor() { | 370 void UiSceneManager::UpdateBackgroundColor() { |
| 361 // TODO(vollick): it would be nice if ceiling, floor and the grid were | 371 // TODO(vollick): it would be nice if ceiling, floor and the grid were |
| 362 // UiElement subclasses and could respond to the OnSetMode signal. | 372 // UiElement subclasses and could respond to the OnSetMode signal. |
| 363 ceiling_->set_center_color(color_scheme().ceiling); | 373 ceiling_->set_center_color(color_scheme().ceiling); |
| 364 ceiling_->set_edge_color(color_scheme().horizon); | 374 ceiling_->set_edge_color(color_scheme().world_background); |
| 365 floor_->set_center_color(color_scheme().floor); | 375 floor_->set_center_color(color_scheme().floor); |
| 366 floor_->set_edge_color(color_scheme().horizon); | 376 floor_->set_edge_color(color_scheme().world_background); |
| 367 floor_grid_->set_center_color(color_scheme().floor_grid); | 377 floor_grid_->set_center_color(color_scheme().floor_grid); |
| 368 SkColor floor_grid_edge_color = SkColorSetA(color_scheme().floor_grid, 0); | 378 SkColor floor_grid_edge_color = SkColorSetA(color_scheme().floor_grid, 0); |
| 369 floor_grid_->set_edge_color(floor_grid_edge_color); | 379 floor_grid_->set_edge_color(floor_grid_edge_color); |
| 370 } | 380 } |
| 371 | 381 |
| 372 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { | 382 void UiSceneManager::SetAudioCapturingIndicator(bool enabled) { |
| 373 audio_capturing_ = enabled; | 383 audio_capturing_ = enabled; |
| 374 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); | 384 audio_capture_indicator_->set_visible(enabled && !web_vr_mode_); |
| 375 } | 385 } |
| 376 | 386 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 455 scene_->set_is_exiting(); | 465 scene_->set_is_exiting(); |
| 456 ConfigureScene(); | 466 ConfigureScene(); |
| 457 } | 467 } |
| 458 | 468 |
| 459 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, | 469 void UiSceneManager::SetHistoryButtonsEnabled(bool can_go_back, |
| 460 bool can_go_forward) { | 470 bool can_go_forward) { |
| 461 url_bar_->SetHistoryButtonsEnabled(can_go_back); | 471 url_bar_->SetHistoryButtonsEnabled(can_go_back); |
| 462 } | 472 } |
| 463 | 473 |
| 464 void UiSceneManager::OnCloseButtonClicked() { | 474 void UiSceneManager::OnCloseButtonClicked() { |
| 465 browser_->ExitCct(); | 475 if (fullscreen_) { |
| 476 browser_->ExitFullscreen(); | |
| 477 } | |
| 478 if (in_cct_) { | |
| 479 browser_->ExitCct(); | |
| 480 } | |
| 466 } | 481 } |
| 467 | 482 |
| 468 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { | 483 void UiSceneManager::OnUnsupportedMode(UiUnsupportedMode mode) { |
| 469 browser_->OnUnsupportedMode(mode); | 484 browser_->OnUnsupportedMode(mode); |
| 470 } | 485 } |
| 471 | 486 |
| 472 int UiSceneManager::AllocateId() { | 487 int UiSceneManager::AllocateId() { |
| 473 return next_available_id_++; | 488 return next_available_id_++; |
| 474 } | 489 } |
| 475 | 490 |
| 476 ColorScheme::Mode UiSceneManager::mode() const { | 491 ColorScheme::Mode UiSceneManager::mode() const { |
| 477 if (incognito_) | 492 if (incognito_) |
| 478 return ColorScheme::kModeIncognito; | 493 return ColorScheme::kModeIncognito; |
| 479 if (fullscreen_) | 494 if (fullscreen_) |
| 480 return ColorScheme::kModeFullscreen; | 495 return ColorScheme::kModeFullscreen; |
| 481 return ColorScheme::kModeNormal; | 496 return ColorScheme::kModeNormal; |
| 482 } | 497 } |
| 483 | 498 |
| 484 const ColorScheme& UiSceneManager::color_scheme() const { | 499 const ColorScheme& UiSceneManager::color_scheme() const { |
| 485 return ColorScheme::GetColorScheme(mode()); | 500 return ColorScheme::GetColorScheme(mode()); |
| 486 } | 501 } |
| 487 | 502 |
| 488 } // namespace vr_shell | 503 } // namespace vr_shell |
| OLD | NEW |