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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 429 if (web_vr_mode_ == web_vr && web_vr_autopresented_ == auto_presented && | 429 if (web_vr_mode_ == web_vr && web_vr_autopresented_ == auto_presented && |
| 430 web_vr_show_toast_ == show_toast) { | 430 web_vr_show_toast_ == show_toast) { |
| 431 return; | 431 return; |
| 432 } | 432 } |
| 433 web_vr_mode_ = web_vr; | 433 web_vr_mode_ = web_vr; |
| 434 web_vr_autopresented_ = auto_presented; | 434 web_vr_autopresented_ = auto_presented; |
| 435 web_vr_show_toast_ = show_toast; | 435 web_vr_show_toast_ = show_toast; |
| 436 ConfigureScene(); | 436 ConfigureScene(); |
| 437 ConfigureSecurityWarnings(); | 437 ConfigureSecurityWarnings(); |
| 438 ConfigureTransientUrlBar(); | 438 ConfigureTransientUrlBar(); |
| 439 ConfigureIndicators(); | |
| 440 ConfigurePresentationToast(); | 439 ConfigurePresentationToast(); |
| 441 } | 440 } |
| 442 | 441 |
| 443 void UiSceneManager::ConfigureScene() { | 442 void UiSceneManager::ConfigureScene() { |
| 444 exit_warning_->SetEnabled(scene_->is_exiting()); | 443 exit_warning_->SetEnabled(scene_->is_exiting()); |
| 445 screen_dimmer_->SetEnabled(scene_->is_exiting()); | 444 screen_dimmer_->SetEnabled(scene_->is_exiting()); |
| 446 | 445 |
| 447 // Controls (URL bar, loading progress, etc). | 446 // Controls (URL bar, loading progress, etc). |
| 448 bool controls_visible = !web_vr_mode_ && !fullscreen_; | 447 bool controls_visible = !web_vr_mode_ && !fullscreen_; |
| 449 for (UiElement* element : control_elements_) { | 448 for (UiElement* element : control_elements_) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, | 490 gfx::Vector3dF(0, kContentVerticalOffset - (kContentHeight / 2) - 0.3, |
| 492 -kCloseButtonDistance)); | 491 -kCloseButtonDistance)); |
| 493 close_button_->set_size( | 492 close_button_->set_size( |
| 494 gfx::Vector3dF(kCloseButtonWidth, kCloseButtonHeight, 1)); | 493 gfx::Vector3dF(kCloseButtonWidth, kCloseButtonHeight, 1)); |
| 495 } | 494 } |
| 496 | 495 |
| 497 scene_->SetMode(mode()); | 496 scene_->SetMode(mode()); |
| 498 scene_->SetBackgroundDistance(main_content_->translation().z() * | 497 scene_->SetBackgroundDistance(main_content_->translation().z() * |
| 499 -kBackgroundDistanceMultiplier); | 498 -kBackgroundDistanceMultiplier); |
| 500 UpdateBackgroundColor(); | 499 UpdateBackgroundColor(); |
| 500 | |
| 501 ConfigureIndicators(); | |
|
amp
2017/06/23 18:36:59
Add a comment about why the indicators need to be
cjgrant
2017/06/23 19:38:26
I'll add the comment. At a high-level, I see Conf
| |
| 501 } | 502 } |
| 502 | 503 |
| 503 void UiSceneManager::UpdateBackgroundColor() { | 504 void UiSceneManager::UpdateBackgroundColor() { |
| 504 // TODO(vollick): it would be nice if ceiling, floor and the grid were | 505 // TODO(vollick): it would be nice if ceiling, floor and the grid were |
| 505 // UiElement subclasses and could respond to the OnSetMode signal. | 506 // UiElement subclasses and could respond to the OnSetMode signal. |
| 506 ceiling_->set_center_color(color_scheme().ceiling); | 507 ceiling_->set_center_color(color_scheme().ceiling); |
| 507 ceiling_->set_edge_color(color_scheme().world_background); | 508 ceiling_->set_edge_color(color_scheme().world_background); |
| 508 floor_->set_center_color(color_scheme().floor); | 509 floor_->set_center_color(color_scheme().floor); |
| 509 floor_->set_edge_color(color_scheme().world_background); | 510 floor_->set_edge_color(color_scheme().world_background); |
| 510 floor_->set_grid_color(color_scheme().floor_grid); | 511 floor_->set_grid_color(color_scheme().floor_grid); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 538 void UiSceneManager::SetIncognito(bool incognito) { | 539 void UiSceneManager::SetIncognito(bool incognito) { |
| 539 if (incognito == incognito_) | 540 if (incognito == incognito_) |
| 540 return; | 541 return; |
| 541 incognito_ = incognito; | 542 incognito_ = incognito; |
| 542 ConfigureScene(); | 543 ConfigureScene(); |
| 543 } | 544 } |
| 544 | 545 |
| 545 void UiSceneManager::OnGLInitialized() { | 546 void UiSceneManager::OnGLInitialized() { |
| 546 scene_->OnGLInitialized(); | 547 scene_->OnGLInitialized(); |
| 547 | 548 |
| 548 // Indicators don't know their position until they've rendered themselves. | 549 ConfigureScene(); |
| 549 ConfigureIndicators(); | |
| 550 } | 550 } |
| 551 | 551 |
| 552 void UiSceneManager::OnAppButtonClicked() { | 552 void UiSceneManager::OnAppButtonClicked() { |
| 553 // App button click exits the WebVR presentation and fullscreen. | 553 // App button click exits the WebVR presentation and fullscreen. |
| 554 browser_->ExitPresent(); | 554 browser_->ExitPresent(); |
| 555 browser_->ExitFullscreen(); | 555 browser_->ExitFullscreen(); |
| 556 } | 556 } |
| 557 | 557 |
| 558 void UiSceneManager::OnAppButtonGesturePerformed( | 558 void UiSceneManager::OnAppButtonGesturePerformed( |
| 559 UiInterface::Direction direction) {} | 559 UiInterface::Direction direction) {} |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 572 if (enabled) { | 572 if (enabled) { |
| 573 security_warning_timer_.Start( | 573 security_warning_timer_.Start( |
| 574 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, | 574 FROM_HERE, base::TimeDelta::FromSeconds(kWarningTimeoutSeconds), this, |
| 575 &UiSceneManager::OnSecurityWarningTimer); | 575 &UiSceneManager::OnSecurityWarningTimer); |
| 576 } else { | 576 } else { |
| 577 security_warning_timer_.Stop(); | 577 security_warning_timer_.Stop(); |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 | 580 |
| 581 void UiSceneManager::ConfigureIndicators() { | 581 void UiSceneManager::ConfigureIndicators() { |
| 582 audio_capture_indicator_->set_visible(!web_vr_mode_ && audio_capturing_); | 582 bool allowed = !web_vr_mode_ && !fullscreen_; |
| 583 video_capture_indicator_->set_visible(!web_vr_mode_ && video_capturing_); | 583 audio_capture_indicator_->set_visible(allowed && audio_capturing_); |
| 584 screen_capture_indicator_->set_visible(!web_vr_mode_ && screen_capturing_); | 584 video_capture_indicator_->set_visible(allowed && video_capturing_); |
| 585 location_access_indicator_->set_visible(!web_vr_mode_ && location_access_); | 585 screen_capture_indicator_->set_visible(allowed && screen_capturing_); |
| 586 location_access_indicator_->set_visible(allowed && location_access_); | |
| 587 | |
| 588 if (!allowed) | |
| 589 return; | |
| 586 | 590 |
| 587 // Position elements dynamically relative to each other, based on which | 591 // Position elements dynamically relative to each other, based on which |
| 588 // indicators are showing, and how big each one is. | 592 // indicators are showing, and how big each one is. |
| 589 float total_width = kIndicatorGap * (system_indicators_.size() - 1); | 593 float total_width = kIndicatorGap * (system_indicators_.size() - 1); |
| 590 for (const UiElement* indicator : system_indicators_) { | 594 for (const UiElement* indicator : system_indicators_) { |
| 591 if (indicator->visible()) | 595 if (indicator->visible()) |
| 592 total_width += indicator->size().x(); | 596 total_width += indicator->size().x(); |
| 593 } | 597 } |
| 594 float x_position = -total_width / 2; | 598 float x_position = -total_width / 2; |
| 595 for (UiElement* indicator : system_indicators_) { | 599 for (UiElement* indicator : system_indicators_) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 if (fullscreen_) | 734 if (fullscreen_) |
| 731 return ColorScheme::kModeFullscreen; | 735 return ColorScheme::kModeFullscreen; |
| 732 return ColorScheme::kModeNormal; | 736 return ColorScheme::kModeNormal; |
| 733 } | 737 } |
| 734 | 738 |
| 735 const ColorScheme& UiSceneManager::color_scheme() const { | 739 const ColorScheme& UiSceneManager::color_scheme() const { |
| 736 return ColorScheme::GetColorScheme(mode()); | 740 return ColorScheme::GetColorScheme(mode()); |
| 737 } | 741 } |
| 738 | 742 |
| 739 } // namespace vr_shell | 743 } // namespace vr_shell |
| OLD | NEW |