Commit 0375ab86 authored by Ian Vollick's avatar Ian Vollick Committed by Commit Bot

[vr] Wire up the system indicators via databinding

With these CL the permission indicators have their colors and visibility
determined by bindings to model properties.

Bug: 768512
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I4aff56e1a5e986ad11cb157f47b5e86a800c5084
Reviewed-on: https://chromium-review.googlesource.com/779240Reviewed-by: default avatarAmirhossein Simjour <asimjour@chromium.org>
Commit-Queue: Ian Vollick <vollick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517893}
parent 0731f15c
...@@ -224,41 +224,39 @@ void VrGLThread::SetWebVrMode(bool enabled, bool show_toast) { ...@@ -224,41 +224,39 @@ void VrGLThread::SetWebVrMode(bool enabled, bool show_toast) {
enabled, show_toast)); enabled, show_toast));
} }
void VrGLThread::SetAudioCapturingIndicator(bool enabled) { void VrGLThread::SetAudioCaptureEnabled(bool enabled) {
DCHECK(OnMainThread()); DCHECK(OnMainThread());
task_runner()->PostTask( task_runner()->PostTask(
FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetAudioCapturingIndicator, FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetAudioCaptureEnabled,
browser_ui_, enabled)); browser_ui_, enabled));
} }
void VrGLThread::SetLocationAccessIndicator(bool enabled) { void VrGLThread::SetLocationAccess(bool enabled) {
DCHECK(OnMainThread()); DCHECK(OnMainThread());
task_runner()->PostTask( task_runner()->PostTask(FROM_HERE,
FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetLocationAccessIndicator, base::Bind(&vr::BrowserUiInterface::SetLocationAccess,
browser_ui_, enabled)); browser_ui_, enabled));
} }
void VrGLThread::SetVideoCapturingIndicator(bool enabled) { void VrGLThread::SetVideoCaptureEnabled(bool enabled) {
DCHECK(OnMainThread()); DCHECK(OnMainThread());
task_runner()->PostTask( task_runner()->PostTask(
FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetVideoCapturingIndicator, FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetVideoCaptureEnabled,
browser_ui_, enabled)); browser_ui_, enabled));
} }
void VrGLThread::SetScreenCapturingIndicator(bool enabled) { void VrGLThread::SetScreenCaptureEnabled(bool enabled) {
DCHECK(OnMainThread()); DCHECK(OnMainThread());
task_runner()->PostTask( task_runner()->PostTask(
FROM_HERE, FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetScreenCaptureEnabled,
base::Bind(&vr::BrowserUiInterface::SetScreenCapturingIndicator, browser_ui_, enabled));
browser_ui_, enabled));
} }
void VrGLThread::SetBluetoothConnectedIndicator(bool enabled) { void VrGLThread::SetBluetoothConnected(bool enabled) {
DCHECK(OnMainThread()); DCHECK(OnMainThread());
task_runner()->PostTask( task_runner()->PostTask(
FROM_HERE, FROM_HERE, base::Bind(&vr::BrowserUiInterface::SetBluetoothConnected,
base::Bind(&vr::BrowserUiInterface::SetBluetoothConnectedIndicator, browser_ui_, enabled));
browser_ui_, enabled));
} }
void VrGLThread::SetIsExiting() { void VrGLThread::SetIsExiting() {
......
...@@ -76,11 +76,11 @@ class VrGLThread : public base::android::JavaHandlerThread, ...@@ -76,11 +76,11 @@ class VrGLThread : public base::android::JavaHandlerThread,
void SetLoadProgress(float progress) override; void SetLoadProgress(float progress) override;
void SetIsExiting() override; void SetIsExiting() override;
void SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward) override; void SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward) override;
void SetVideoCapturingIndicator(bool enabled) override; void SetVideoCaptureEnabled(bool enabled) override;
void SetScreenCapturingIndicator(bool enabled) override; void SetScreenCaptureEnabled(bool enabled) override;
void SetAudioCapturingIndicator(bool enabled) override; void SetAudioCaptureEnabled(bool enabled) override;
void SetBluetoothConnectedIndicator(bool enabled) override; void SetBluetoothConnected(bool enabled) override;
void SetLocationAccessIndicator(bool enabled) override; void SetLocationAccess(bool enabled) override;
void SetExitVrPromptEnabled(bool enabled, void SetExitVrPromptEnabled(bool enabled,
vr::UiUnsupportedMode reason) override; vr::UiUnsupportedMode reason) override;
void SetSpeechRecognitionEnabled(bool enabled) override; void SetSpeechRecognitionEnabled(bool enabled) override;
......
...@@ -820,19 +820,19 @@ void VrShell::PollMediaAccessFlag() { ...@@ -820,19 +820,19 @@ void VrShell::PollMediaAccessFlag() {
bool is_capturing_screen = num_tabs_capturing_screen > 0; bool is_capturing_screen = num_tabs_capturing_screen > 0;
bool is_bluetooth_connected = num_tabs_bluetooth_connected > 0; bool is_bluetooth_connected = num_tabs_bluetooth_connected > 0;
if (is_capturing_audio != is_capturing_audio_) { if (is_capturing_audio != is_capturing_audio_) {
ui_->SetAudioCapturingIndicator(is_capturing_audio); ui_->SetAudioCaptureEnabled(is_capturing_audio);
is_capturing_audio_ = is_capturing_audio; is_capturing_audio_ = is_capturing_audio;
} }
if (is_capturing_video != is_capturing_video_) { if (is_capturing_video != is_capturing_video_) {
ui_->SetVideoCapturingIndicator(is_capturing_video); ui_->SetVideoCaptureEnabled(is_capturing_video);
is_capturing_video_ = is_capturing_video; is_capturing_video_ = is_capturing_video;
} }
if (is_capturing_screen != is_capturing_screen_) { if (is_capturing_screen != is_capturing_screen_) {
ui_->SetScreenCapturingIndicator(is_capturing_screen); ui_->SetScreenCaptureEnabled(is_capturing_screen);
is_capturing_screen_ = is_capturing_screen; is_capturing_screen_ = is_capturing_screen;
} }
if (is_bluetooth_connected != is_bluetooth_connected_) { if (is_bluetooth_connected != is_bluetooth_connected_) {
ui_->SetBluetoothConnectedIndicator(is_bluetooth_connected); ui_->SetBluetoothConnected(is_bluetooth_connected);
is_bluetooth_connected_ = is_bluetooth_connected; is_bluetooth_connected_ = is_bluetooth_connected;
} }
} }
...@@ -840,7 +840,7 @@ void VrShell::PollMediaAccessFlag() { ...@@ -840,7 +840,7 @@ void VrShell::PollMediaAccessFlag() {
void VrShell::SetHighAccuracyLocation(bool high_accuracy_location) { void VrShell::SetHighAccuracyLocation(bool high_accuracy_location) {
if (high_accuracy_location == high_accuracy_location_) if (high_accuracy_location == high_accuracy_location_)
return; return;
ui_->SetLocationAccessIndicator(high_accuracy_location); ui_->SetLocationAccess(high_accuracy_location);
high_accuracy_location_ = high_accuracy_location; high_accuracy_location_ = high_accuracy_location;
} }
......
...@@ -122,6 +122,7 @@ static_library("vr_common") { ...@@ -122,6 +122,7 @@ static_library("vr_common") {
"model/model.h", "model/model.h",
"model/omnibox_suggestions.cc", "model/omnibox_suggestions.cc",
"model/omnibox_suggestions.h", "model/omnibox_suggestions.h",
"model/permissions_model.h",
"model/reticle_model.h", "model/reticle_model.h",
"model/speech_recognition_model.h", "model/speech_recognition_model.h",
"model/toolbar_state.cc", "model/toolbar_state.cc",
......
...@@ -27,11 +27,11 @@ class BrowserUiInterface { ...@@ -27,11 +27,11 @@ class BrowserUiInterface {
virtual void SetIsExiting() = 0; virtual void SetIsExiting() = 0;
virtual void SetHistoryButtonsEnabled(bool can_go_back, virtual void SetHistoryButtonsEnabled(bool can_go_back,
bool can_go_forward) = 0; bool can_go_forward) = 0;
virtual void SetVideoCapturingIndicator(bool enabled) = 0; virtual void SetVideoCaptureEnabled(bool enabled) = 0;
virtual void SetScreenCapturingIndicator(bool enabled) = 0; virtual void SetScreenCaptureEnabled(bool enabled) = 0;
virtual void SetAudioCapturingIndicator(bool enabled) = 0; virtual void SetAudioCaptureEnabled(bool enabled) = 0;
virtual void SetBluetoothConnectedIndicator(bool enabled) = 0; virtual void SetBluetoothConnected(bool enabled) = 0;
virtual void SetLocationAccessIndicator(bool enabled) = 0; virtual void SetLocationAccess(bool enabled) = 0;
virtual void SetExitVrPromptEnabled(bool enabled, virtual void SetExitVrPromptEnabled(bool enabled,
UiUnsupportedMode reason) = 0; UiUnsupportedMode reason) = 0;
virtual void SetSpeechRecognitionEnabled(bool enabled) = 0; virtual void SetSpeechRecognitionEnabled(bool enabled) = 0;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "chrome/browser/vr/model/controller_model.h" #include "chrome/browser/vr/model/controller_model.h"
#include "chrome/browser/vr/model/modal_prompt_type.h" #include "chrome/browser/vr/model/modal_prompt_type.h"
#include "chrome/browser/vr/model/omnibox_suggestions.h" #include "chrome/browser/vr/model/omnibox_suggestions.h"
#include "chrome/browser/vr/model/permissions_model.h"
#include "chrome/browser/vr/model/reticle_model.h" #include "chrome/browser/vr/model/reticle_model.h"
#include "chrome/browser/vr/model/speech_recognition_model.h" #include "chrome/browser/vr/model/speech_recognition_model.h"
#include "chrome/browser/vr/model/toolbar_state.h" #include "chrome/browser/vr/model/toolbar_state.h"
...@@ -34,6 +35,8 @@ struct Model { ...@@ -34,6 +35,8 @@ struct Model {
ModalPromptType active_modal_prompt_type = kModalPromptTypeNone; ModalPromptType active_modal_prompt_type = kModalPromptTypeNone;
PermissionsModel permissions;
ToolbarState toolbar_state; ToolbarState toolbar_state;
std::vector<OmniboxSuggestion> omnibox_suggestions; std::vector<OmniboxSuggestion> omnibox_suggestions;
}; };
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_VR_MODEL_PERMISSIONS_MODEL_H_
#define CHROME_BROWSER_VR_MODEL_PERMISSIONS_MODEL_H_
namespace vr {
struct PermissionsModel {
bool audio_capture_enabled = false;
bool video_capture_enabled = false;
bool screen_capture_enabled = false;
bool location_access = false;
bool bluetooth_connected = false;
};
} // namespace vr
#endif // CHROME_BROWSER_VR_MODEL_PERMISSIONS_MODEL_H_
...@@ -65,6 +65,7 @@ VrTestContext::VrTestContext() : view_scale_factor_(kDefaultViewScaleFactor) { ...@@ -65,6 +65,7 @@ VrTestContext::VrTestContext() : view_scale_factor_(kDefaultViewScaleFactor) {
base::i18n::InitializeICU(); base::i18n::InitializeICU();
ui_ = base::MakeUnique<Ui>(this, nullptr, UiInitialState()); ui_ = base::MakeUnique<Ui>(this, nullptr, UiInitialState());
model_ = ui_->model_for_test();
GURL gurl("https://dangerous.com/dir/file.html"); GURL gurl("https://dangerous.com/dir/file.html");
ToolbarState state(gurl, security_state::SecurityLevel::DANGEROUS, ToolbarState state(gurl, security_state::SecurityLevel::DANGEROUS,
...@@ -74,11 +75,11 @@ VrTestContext::VrTestContext() : view_scale_factor_(kDefaultViewScaleFactor) { ...@@ -74,11 +75,11 @@ VrTestContext::VrTestContext() : view_scale_factor_(kDefaultViewScaleFactor) {
ui_->SetHistoryButtonsEnabled(true, true); ui_->SetHistoryButtonsEnabled(true, true);
ui_->SetLoading(true); ui_->SetLoading(true);
ui_->SetLoadProgress(0.4); ui_->SetLoadProgress(0.4);
ui_->SetVideoCapturingIndicator(true); ui_->SetVideoCaptureEnabled(true);
ui_->SetScreenCapturingIndicator(true); ui_->SetScreenCaptureEnabled(true);
ui_->SetAudioCapturingIndicator(true); ui_->SetAudioCaptureEnabled(true);
ui_->SetBluetoothConnectedIndicator(true); ui_->SetBluetoothConnected(true);
ui_->SetLocationAccessIndicator(true); ui_->SetLocationAccess(true);
} }
VrTestContext::~VrTestContext() = default; VrTestContext::~VrTestContext() = default;
...@@ -127,6 +128,10 @@ void VrTestContext::HandleInput(ui::Event* event) { ...@@ -127,6 +128,10 @@ void VrTestContext::HandleInput(ui::Event* event) {
case ui::DomCode::US_S: { case ui::DomCode::US_S: {
CreateFakeOmniboxSuggestions(); CreateFakeOmniboxSuggestions();
break; break;
case ui::DomCode::US_V:
ui_->SetVideoCaptureEnabled(
!model_->permissions.video_capture_enabled);
break;
} }
default: default:
break; break;
......
...@@ -21,6 +21,7 @@ class Event; ...@@ -21,6 +21,7 @@ class Event;
namespace vr { namespace vr {
class Ui; class Ui;
struct Model;
// This class provides a home for the VR UI in a testapp context, and // This class provides a home for the VR UI in a testapp context, and
// manipulates the UI according to user input. // manipulates the UI according to user input.
...@@ -67,6 +68,9 @@ class VrTestContext : public vr::UiBrowserInterface { ...@@ -67,6 +68,9 @@ class VrTestContext : public vr::UiBrowserInterface {
float view_scale_factor_ = 1.f; float view_scale_factor_ = 1.f;
// This avoids storing a duplicate of the model state here.
Model* model_;
bool fullscreen_ = false; bool fullscreen_ = false;
bool incognito_ = false; bool incognito_ = false;
......
...@@ -86,24 +86,24 @@ void Ui::SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward) { ...@@ -86,24 +86,24 @@ void Ui::SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward) {
scene_manager_->SetHistoryButtonsEnabled(can_go_back, can_go_forward); scene_manager_->SetHistoryButtonsEnabled(can_go_back, can_go_forward);
} }
void Ui::SetVideoCapturingIndicator(bool enabled) { void Ui::SetVideoCaptureEnabled(bool enabled) {
scene_manager_->SetVideoCapturingIndicator(enabled); model_->permissions.video_capture_enabled = enabled;
} }
void Ui::SetScreenCapturingIndicator(bool enabled) { void Ui::SetScreenCaptureEnabled(bool enabled) {
scene_manager_->SetScreenCapturingIndicator(enabled); model_->permissions.screen_capture_enabled = enabled;
} }
void Ui::SetAudioCapturingIndicator(bool enabled) { void Ui::SetAudioCaptureEnabled(bool enabled) {
scene_manager_->SetAudioCapturingIndicator(enabled); model_->permissions.audio_capture_enabled = enabled;
} }
void Ui::SetBluetoothConnectedIndicator(bool enabled) { void Ui::SetBluetoothConnected(bool enabled) {
scene_manager_->SetBluetoothConnectedIndicator(enabled); model_->permissions.bluetooth_connected = enabled;
} }
void Ui::SetLocationAccessIndicator(bool enabled) { void Ui::SetLocationAccess(bool enabled) {
scene_manager_->SetLocationAccessIndicator(enabled); model_->permissions.location_access = enabled;
} }
void Ui::SetExitVrPromptEnabled(bool enabled, UiUnsupportedMode reason) { void Ui::SetExitVrPromptEnabled(bool enabled, UiUnsupportedMode reason) {
......
...@@ -64,11 +64,11 @@ class Ui : public BrowserUiInterface { ...@@ -64,11 +64,11 @@ class Ui : public BrowserUiInterface {
void SetLoadProgress(float progress) override; void SetLoadProgress(float progress) override;
void SetIsExiting() override; void SetIsExiting() override;
void SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward) override; void SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward) override;
void SetVideoCapturingIndicator(bool enabled) override; void SetVideoCaptureEnabled(bool enabled) override;
void SetScreenCapturingIndicator(bool enabled) override; void SetScreenCaptureEnabled(bool enabled) override;
void SetAudioCapturingIndicator(bool enabled) override; void SetAudioCaptureEnabled(bool enabled) override;
void SetBluetoothConnectedIndicator(bool enabled) override; void SetBluetoothConnected(bool enabled) override;
void SetLocationAccessIndicator(bool enabled) override; void SetLocationAccess(bool enabled) override;
void SetExitVrPromptEnabled(bool enabled, UiUnsupportedMode reason) override; void SetExitVrPromptEnabled(bool enabled, UiUnsupportedMode reason) override;
void SetSpeechRecognitionEnabled(bool enabled) override; void SetSpeechRecognitionEnabled(bool enabled) override;
void SetRecognitionResult(const base::string16& result) override; void SetRecognitionResult(const base::string16& result) override;
...@@ -94,6 +94,8 @@ class Ui : public BrowserUiInterface { ...@@ -94,6 +94,8 @@ class Ui : public BrowserUiInterface {
void OnContentBoundsChanged(int width, int height); void OnContentBoundsChanged(int width, int height);
void OnPlatformControllerInitialized(PlatformController* controller); void OnPlatformControllerInitialized(PlatformController* controller);
Model* model_for_test() { return model_.get(); }
private: private:
UiBrowserInterface* browser_; UiBrowserInterface* browser_;
......
...@@ -167,7 +167,7 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser, ...@@ -167,7 +167,7 @@ UiSceneManager::UiSceneManager(UiBrowserInterface* browser,
CreateExitPrompt(model); CreateExitPrompt(model);
CreateAudioPermissionPrompt(model); CreateAudioPermissionPrompt(model);
CreateWebVRExitWarning(); CreateWebVRExitWarning();
CreateSystemIndicators(); CreateSystemIndicators(model);
CreateUrlBar(model); CreateUrlBar(model);
CreateSuggestionList(model); CreateSuggestionList(model);
CreateWebVrUrlToast(model); CreateWebVrUrlToast(model);
...@@ -275,26 +275,29 @@ void UiSceneManager::CreateWebVRExitWarning() { ...@@ -275,26 +275,29 @@ void UiSceneManager::CreateWebVRExitWarning() {
scene_->AddUiElement(k2dBrowsingViewportAwareRoot, std::move(element)); scene_->AddUiElement(k2dBrowsingViewportAwareRoot, std::move(element));
} }
void UiSceneManager::CreateSystemIndicators() { void UiSceneManager::CreateSystemIndicators(Model* model) {
std::unique_ptr<UiElement> element; std::unique_ptr<UiElement> element;
struct Indicator { struct Indicator {
UiElement** element;
UiElementName name; UiElementName name;
const gfx::VectorIcon& icon; const gfx::VectorIcon& icon;
int resource_string; int resource_string;
bool PermissionsModel::*signal;
}; };
const std::vector<Indicator> indicators = { const std::vector<Indicator> indicators = {
{&audio_capture_indicator_, kAudioCaptureIndicator, {kAudioCaptureIndicator, vector_icons::kMicrophoneIcon,
vector_icons::kMicrophoneIcon, IDS_AUDIO_CALL_NOTIFICATION_TEXT_2}, IDS_AUDIO_CALL_NOTIFICATION_TEXT_2,
{&video_capture_indicator_, kVideoCaptureIndicator, &PermissionsModel::audio_capture_enabled},
vector_icons::kVideocamIcon, IDS_VIDEO_CALL_NOTIFICATION_TEXT_2}, {kVideoCaptureIndicator, vector_icons::kVideocamIcon,
{&screen_capture_indicator_, kScreenCaptureIndicator, IDS_VIDEO_CALL_NOTIFICATION_TEXT_2,
vector_icons::kScreenShareIcon, IDS_SCREEN_CAPTURE_NOTIFICATION_TEXT_2}, &PermissionsModel::video_capture_enabled},
{&bluetooth_connected_indicator_, kBluetoothConnectedIndicator, {kScreenCaptureIndicator, vector_icons::kScreenShareIcon,
vector_icons::kBluetoothConnectedIcon, 0}, IDS_SCREEN_CAPTURE_NOTIFICATION_TEXT_2,
{&location_access_indicator_, kLocationAccessIndicator, &PermissionsModel::screen_capture_enabled},
vector_icons::kLocationOnIcon, 0}, {kBluetoothConnectedIndicator, vector_icons::kBluetoothConnectedIcon, 0,
&PermissionsModel::bluetooth_connected},
{kLocationAccessIndicator, vector_icons::kLocationOnIcon, 0,
&PermissionsModel::location_access},
}; };
std::unique_ptr<LinearLayout> indicator_layout = std::unique_ptr<LinearLayout> indicator_layout =
...@@ -305,6 +308,9 @@ void UiSceneManager::CreateSystemIndicators() { ...@@ -305,6 +308,9 @@ void UiSceneManager::CreateSystemIndicators() {
indicator_layout->SetTranslate(0, kIndicatorVerticalOffset, indicator_layout->SetTranslate(0, kIndicatorVerticalOffset,
kIndicatorDistanceOffset); kIndicatorDistanceOffset);
indicator_layout->set_margin(kIndicatorGap); indicator_layout->set_margin(kIndicatorGap);
indicator_layout->AddBinding(
VR_BIND_FUNC(bool, UiSceneManager, this, fullscreen() == false, UiElement,
indicator_layout.get(), SetVisible));
scene_->AddUiElement(k2dBrowsingContentGroup, std::move(indicator_layout)); scene_->AddUiElement(k2dBrowsingContentGroup, std::move(indicator_layout));
for (const auto& indicator : indicators) { for (const auto& indicator : indicators) {
...@@ -312,9 +318,20 @@ void UiSceneManager::CreateSystemIndicators() { ...@@ -312,9 +318,20 @@ void UiSceneManager::CreateSystemIndicators() {
512, kIndicatorHeight, indicator.icon, indicator.resource_string); 512, kIndicatorHeight, indicator.icon, indicator.resource_string);
element->set_name(indicator.name); element->set_name(indicator.name);
element->set_draw_phase(kPhaseForeground); element->set_draw_phase(kPhaseForeground);
element->set_requires_layout(false);
element->SetVisible(false); element->SetVisible(false);
*(indicator.element) = element.get(); element->AddBinding(base::MakeUnique<Binding<bool>>(
system_indicators_.push_back(element.get()); base::Bind(
[](Model* m, bool PermissionsModel::*permission) {
return m->permissions.*permission;
},
base::Unretained(model), indicator.signal),
base::Bind(
[](UiElement* e, const bool& v) {
e->SetVisible(v);
e->set_requires_layout(v);
},
base::Unretained(element.get()))));
scene_->AddUiElement(kIndicatorLayout, std::move(element)); scene_->AddUiElement(kIndicatorLayout, std::move(element));
} }
} }
...@@ -1283,28 +1300,10 @@ void UiSceneManager::ConfigureScene() { ...@@ -1283,28 +1300,10 @@ void UiSceneManager::ConfigureScene() {
scene_->set_reticle_rendering_enabled( scene_->set_reticle_rendering_enabled(
!(web_vr_mode_ || exiting_ || showing_web_vr_splash_screen_)); !(web_vr_mode_ || exiting_ || showing_web_vr_splash_screen_));
ConfigureIndicators();
ConfigureBackgroundColor(); ConfigureBackgroundColor();
scene_->set_dirty(); scene_->set_dirty();
} }
void UiSceneManager::ConfigureIndicators() {
DCHECK(configuring_scene_);
bool allowed = !web_vr_mode_ && !fullscreen_;
audio_capture_indicator_->SetVisible(allowed && audio_capturing_);
video_capture_indicator_->SetVisible(allowed && video_capturing_);
screen_capture_indicator_->SetVisible(allowed && screen_capturing_);
location_access_indicator_->SetVisible(allowed && location_access_);
bluetooth_connected_indicator_->SetVisible(allowed && bluetooth_connected_);
audio_capture_indicator_->set_requires_layout(allowed && audio_capturing_);
video_capture_indicator_->set_requires_layout(allowed && video_capturing_);
screen_capture_indicator_->set_requires_layout(allowed && screen_capturing_);
location_access_indicator_->set_requires_layout(allowed && location_access_);
bluetooth_connected_indicator_->set_requires_layout(allowed &&
bluetooth_connected_);
}
void UiSceneManager::ConfigureBackgroundColor() { void UiSceneManager::ConfigureBackgroundColor() {
DCHECK(configuring_scene_); DCHECK(configuring_scene_);
for (Rect* panel : background_panels_) { for (Rect* panel : background_panels_) {
...@@ -1317,31 +1316,6 @@ void UiSceneManager::ConfigureBackgroundColor() { ...@@ -1317,31 +1316,6 @@ void UiSceneManager::ConfigureBackgroundColor() {
floor_->SetGridColor(color_scheme().floor_grid); floor_->SetGridColor(color_scheme().floor_grid);
} }
void UiSceneManager::SetAudioCapturingIndicator(bool enabled) {
audio_capturing_ = enabled;
ConfigureScene();
}
void UiSceneManager::SetVideoCapturingIndicator(bool enabled) {
video_capturing_ = enabled;
ConfigureScene();
}
void UiSceneManager::SetScreenCapturingIndicator(bool enabled) {
screen_capturing_ = enabled;
ConfigureScene();
}
void UiSceneManager::SetLocationAccessIndicator(bool enabled) {
location_access_ = enabled;
ConfigureScene();
}
void UiSceneManager::SetBluetoothConnectedIndicator(bool enabled) {
bluetooth_connected_ = enabled;
ConfigureScene();
}
void UiSceneManager::SetIncognito(bool incognito) { void UiSceneManager::SetIncognito(bool incognito) {
if (incognito == incognito_) if (incognito == incognito_)
return; return;
......
...@@ -126,11 +126,6 @@ class UiSceneManager { ...@@ -126,11 +126,6 @@ class UiSceneManager {
void SetIncognito(bool incognito); void SetIncognito(bool incognito);
void SetWebVrMode(bool web_vr, bool show_toast); void SetWebVrMode(bool web_vr, bool show_toast);
void SetIsExiting(); void SetIsExiting();
void SetVideoCapturingIndicator(bool enabled);
void SetScreenCapturingIndicator(bool enabled);
void SetAudioCapturingIndicator(bool enabled);
void SetLocationAccessIndicator(bool enabled);
void SetBluetoothConnectedIndicator(bool enabled);
void SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward); void SetHistoryButtonsEnabled(bool can_go_back, bool can_go_forward);
bool ShouldRenderWebVr(); bool ShouldRenderWebVr();
...@@ -165,7 +160,7 @@ class UiSceneManager { ...@@ -165,7 +160,7 @@ class UiSceneManager {
void CreateWebVrRoot(); void CreateWebVrRoot();
void CreateScreenDimmer(); void CreateScreenDimmer();
void CreateWebVRExitWarning(); void CreateWebVRExitWarning();
void CreateSystemIndicators(); void CreateSystemIndicators(Model* model);
void CreateContentQuad(ContentInputDelegate* delegate); void CreateContentQuad(ContentInputDelegate* delegate);
void CreateSplashScreen(Model* model); void CreateSplashScreen(Model* model);
void CreateUnderDevelopmentNotice(); void CreateUnderDevelopmentNotice();
...@@ -182,7 +177,6 @@ class UiSceneManager { ...@@ -182,7 +177,6 @@ class UiSceneManager {
void CreateController(Model* model); void CreateController(Model* model);
void ConfigureScene(); void ConfigureScene();
void ConfigureIndicators();
void ConfigureBackgroundColor(); void ConfigureBackgroundColor();
void OnBackButtonClicked(); void OnBackButtonClicked();
void OnSecurityIconClicked(); void OnSecurityIconClicked();
...@@ -209,11 +203,6 @@ class UiSceneManager { ...@@ -209,11 +203,6 @@ class UiSceneManager {
ShowUntilSignalTransientElement* splash_screen_transient_parent_ = nullptr; ShowUntilSignalTransientElement* splash_screen_transient_parent_ = nullptr;
UiElement* exit_warning_ = nullptr; UiElement* exit_warning_ = nullptr;
ContentElement* main_content_ = nullptr; ContentElement* main_content_ = nullptr;
UiElement* audio_capture_indicator_ = nullptr;
UiElement* bluetooth_connected_indicator_ = nullptr;
UiElement* video_capture_indicator_ = nullptr;
UiElement* screen_capture_indicator_ = nullptr;
UiElement* location_access_indicator_ = nullptr;
UiElement* screen_dimmer_ = nullptr; UiElement* screen_dimmer_ = nullptr;
Rect* ceiling_ = nullptr; Rect* ceiling_ = nullptr;
Grid* floor_ = nullptr; Grid* floor_ = nullptr;
...@@ -222,8 +211,6 @@ class UiSceneManager { ...@@ -222,8 +211,6 @@ class UiSceneManager {
TransientElement* webvr_url_toast_transient_parent_ = nullptr; TransientElement* webvr_url_toast_transient_parent_ = nullptr;
WebVrUrlToast* webvr_url_toast_ = nullptr; WebVrUrlToast* webvr_url_toast_ = nullptr;
std::vector<UiElement*> system_indicators_;
bool in_cct_; bool in_cct_;
bool web_vr_mode_; bool web_vr_mode_;
bool web_vr_show_toast_ = false; bool web_vr_show_toast_ = false;
...@@ -238,11 +225,6 @@ class UiSceneManager { ...@@ -238,11 +225,6 @@ class UiSceneManager {
bool fullscreen_ = false; bool fullscreen_ = false;
bool incognito_ = false; bool incognito_ = false;
bool audio_capturing_ = false;
bool video_capturing_ = false;
bool screen_capturing_ = false;
bool location_access_ = false;
bool bluetooth_connected_ = false;
std::vector<Rect*> background_panels_; std::vector<Rect*> background_panels_;
......
...@@ -460,11 +460,11 @@ TEST_F(UiSceneManagerTest, SecondaryButtonClickTriggersOnExitPrompt) { ...@@ -460,11 +460,11 @@ TEST_F(UiSceneManagerTest, SecondaryButtonClickTriggersOnExitPrompt) {
TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) { TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) {
MakeManager(kNotInCct, kInWebVr); MakeManager(kNotInCct, kInWebVr);
manager_->SetAudioCapturingIndicator(true); model_->permissions.audio_capture_enabled = true;
manager_->SetVideoCapturingIndicator(true); model_->permissions.video_capture_enabled = true;
manager_->SetScreenCapturingIndicator(true); model_->permissions.screen_capture_enabled = true;
manager_->SetLocationAccessIndicator(true); model_->permissions.location_access = true;
manager_->SetBluetoothConnectedIndicator(true); model_->permissions.bluetooth_connected = true;
auto* web_vr_root = scene_->GetUiElementByName(kWebVrRoot); auto* web_vr_root = scene_->GetUiElementByName(kWebVrRoot);
for (auto& element : *web_vr_root) { for (auto& element : *web_vr_root) {
...@@ -480,11 +480,11 @@ TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) { ...@@ -480,11 +480,11 @@ TEST_F(UiSceneManagerTest, UiUpdatesForWebVR) {
TEST_F(UiSceneManagerTest, UiUpdateTransitionToWebVR) { TEST_F(UiSceneManagerTest, UiUpdateTransitionToWebVR) {
MakeManager(kNotInCct, kNotInWebVr); MakeManager(kNotInCct, kNotInWebVr);
manager_->SetAudioCapturingIndicator(true); model_->permissions.audio_capture_enabled = true;
manager_->SetVideoCapturingIndicator(true); model_->permissions.video_capture_enabled = true;
manager_->SetScreenCapturingIndicator(true); model_->permissions.screen_capture_enabled = true;
manager_->SetLocationAccessIndicator(true); model_->permissions.location_access = true;
manager_->SetBluetoothConnectedIndicator(true); model_->permissions.bluetooth_connected = true;
// Transition to WebVR mode // Transition to WebVR mode
manager_->SetWebVrMode(true, false); manager_->SetWebVrMode(true, false);
...@@ -504,22 +504,20 @@ TEST_F(UiSceneManagerTest, CaptureIndicatorsVisibility) { ...@@ -504,22 +504,20 @@ TEST_F(UiSceneManagerTest, CaptureIndicatorsVisibility) {
EXPECT_TRUE(VerifyVisibility(indicators, false)); EXPECT_TRUE(VerifyVisibility(indicators, false));
EXPECT_TRUE(VerifyRequiresLayout(indicators, false)); EXPECT_TRUE(VerifyRequiresLayout(indicators, false));
manager_->SetAudioCapturingIndicator(true); model_->permissions.audio_capture_enabled = true;
manager_->SetVideoCapturingIndicator(true); model_->permissions.video_capture_enabled = true;
manager_->SetScreenCapturingIndicator(true); model_->permissions.screen_capture_enabled = true;
manager_->SetLocationAccessIndicator(true); model_->permissions.location_access = true;
manager_->SetBluetoothConnectedIndicator(true); model_->permissions.bluetooth_connected = true;
EXPECT_TRUE(VerifyVisibility(indicators, true)); EXPECT_TRUE(VerifyVisibility(indicators, true));
EXPECT_TRUE(VerifyRequiresLayout(indicators, true)); EXPECT_TRUE(VerifyRequiresLayout(indicators, true));
// Go into non-browser modes and make sure all indicators are hidden. // Go into non-browser modes and make sure all indicators are hidden.
manager_->SetWebVrMode(true, false); manager_->SetWebVrMode(true, false);
EXPECT_TRUE(VerifyVisibility(indicators, false)); EXPECT_TRUE(VerifyVisibility(indicators, false));
EXPECT_TRUE(VerifyRequiresLayout(indicators, false));
manager_->SetWebVrMode(false, false); manager_->SetWebVrMode(false, false);
manager_->SetFullscreen(true); manager_->SetFullscreen(true);
EXPECT_TRUE(VerifyVisibility(indicators, false)); EXPECT_TRUE(VerifyVisibility(indicators, false));
EXPECT_TRUE(VerifyRequiresLayout(indicators, false));
manager_->SetFullscreen(false); manager_->SetFullscreen(false);
// Back to browser, make sure the indicators reappear. // Back to browser, make sure the indicators reappear.
...@@ -528,12 +526,11 @@ TEST_F(UiSceneManagerTest, CaptureIndicatorsVisibility) { ...@@ -528,12 +526,11 @@ TEST_F(UiSceneManagerTest, CaptureIndicatorsVisibility) {
EXPECT_TRUE(VerifyRequiresLayout(indicators, true)); EXPECT_TRUE(VerifyRequiresLayout(indicators, true));
// Ensure they can be turned off. // Ensure they can be turned off.
manager_->SetAudioCapturingIndicator(false); model_->permissions.audio_capture_enabled = false;
manager_->SetVideoCapturingIndicator(false); model_->permissions.video_capture_enabled = false;
manager_->SetScreenCapturingIndicator(false); model_->permissions.screen_capture_enabled = false;
manager_->SetLocationAccessIndicator(false); model_->permissions.location_access = false;
manager_->SetBluetoothConnectedIndicator(false); model_->permissions.bluetooth_connected = false;
EXPECT_TRUE(VerifyVisibility(indicators, false));
EXPECT_TRUE(VerifyRequiresLayout(indicators, false)); EXPECT_TRUE(VerifyRequiresLayout(indicators, false));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment