0

[VC] disable vc background for enterprise.

Set the Image button to be visable-but-disabled state and let the enterprise to enable it.

TEST='test on dut'

Change-Id: Ie78a1060f5a1f13565084339bfb337075a3909c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5584567
Reviewed-by: CJ Huang <chenjih@google.com>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Charles Zhao <charleszhao@chromium.org>
Reviewed-by: Andre Le <leandre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1311703}
This commit is contained in:
Guoxing Zhao
2024-06-07 02:06:40 +00:00
committed by Chromium LUCI CQ
parent 3e6c6c588e
commit d7731769a8
14 changed files with 65 additions and 21 deletions

@ -1776,6 +1776,9 @@ You can also use the keyboard shortcut. First, highlight text, then press <ph na
<message name="IDS_ASH_VIDEO_CONFERENCE_BUBBLE_BACKGROUND_BLUR_IMAGE" desc="Text for background blur 'Image' setting, in the VC bubble.">
Image
</message>
<message name="IDS_ASH_VIDEO_CONFERENCE_BUBBLE_BACKGROUND_DISABLED_TOOLTIP" desc="The tooltip text when the Image button is disabled.">
Managed by your administrator
</message>
<message name="IDS_ASH_VIDEO_CONFERENCE_BUBBLE_BACKGROUND_BLUR_IMAGE_LIST_ITEM_DESCRIPTION" desc="Text for description of background image buttons in the VC bubble. Only for accessibility purpose.">
Background
</message>

@ -0,0 +1 @@
3d0ef527a740b33abd2303b6140c170e9d9aaa39

@ -56,11 +56,13 @@ class ASH_PUBLIC_EXPORT SessionControllerClient {
// Returns the profile path for `account_id` or empty if one does not exist.
virtual base::FilePath GetProfilePath(const AccountId& account_id) = 0;
// Returns whether `account_id` is eligible for SeaPen features.
// Returns a tuple of whether
// <IsVcBackgroundSupported, IsVcBackgroundAllowedByEnterprise>.
// TODO(b/333767964): this is only a temporary solution. Having a function
// here for each project does not sound ideal; this should be replaced with
// more general approach.
virtual bool IsEligibleForSeaPen(const AccountId& account_id) = 0;
virtual std::tuple<bool, bool> IsEligibleForSeaPen(
const AccountId& account_id) = 0;
// Return the number of users that have previously logged in on the device.
// Returns nullopt in the event where we cannot query the number of existing

@ -321,9 +321,10 @@ base::FilePath SessionControllerImpl::GetProfilePath(
return client_ ? client_->GetProfilePath(account_id) : base::FilePath();
}
bool SessionControllerImpl::IsEligibleForSeaPen(
std::tuple<bool, bool> SessionControllerImpl::IsEligibleForSeaPen(
const AccountId& account_id) const {
return client_ ? client_->IsEligibleForSeaPen(account_id) : false;
return client_ ? client_->IsEligibleForSeaPen(account_id)
: std::make_tuple(false, false);
}
PrefService* SessionControllerImpl::GetPrimaryUserPrefService() const {

@ -187,8 +187,9 @@ class ASH_EXPORT SessionControllerImpl : public SessionController {
// Returns the profile path for `account_id` or empty if one does not exist.
base::FilePath GetProfilePath(const AccountId& account_id) const;
// Returns whether `account_id` is eligible for SeaPen features.
bool IsEligibleForSeaPen(const AccountId& account_id) const;
// Returns a tuple of whether
// <IsVcBackgroundSupported, IsVcBackgroundAllowedByEnterprise>.
std::tuple<bool, bool> IsEligibleForSeaPen(const AccountId& account_id) const;
// Returns the PrefService for the primary user or null if no user is signed
// in or the PrefService connection hasn't been established.

@ -328,7 +328,7 @@ base::FilePath TestSessionControllerClient::GetProfilePath(
return base::FilePath("/profile/path").Append(account_id.GetUserEmail());
}
bool TestSessionControllerClient::IsEligibleForSeaPen(
std::tuple<bool, bool> TestSessionControllerClient::IsEligibleForSeaPen(
const AccountId& account_id) {
return is_eligible_for_background_replace_;
}

@ -147,7 +147,8 @@ class TestSessionControllerClient : public SessionControllerClient {
PrefService* GetSigninScreenPrefService() override;
PrefService* GetUserPrefService(const AccountId& account_id) override;
base::FilePath GetProfilePath(const AccountId& account_id) override;
bool IsEligibleForSeaPen(const AccountId& account_id) override;
std::tuple<bool, bool> IsEligibleForSeaPen(
const AccountId& account_id) override;
std::optional<int> GetExistingUsersCount() const override;
// By default `LockScreen()` only changes the session state but no UI views
@ -158,7 +159,7 @@ class TestSessionControllerClient : public SessionControllerClient {
}
void set_is_eligible_for_background_replace(
bool is_eligible_for_background_replace) {
const std::tuple<bool, bool>& is_eligible_for_background_replace) {
is_eligible_for_background_replace_ = is_eligible_for_background_replace;
}
@ -185,7 +186,7 @@ class TestSessionControllerClient : public SessionControllerClient {
bool is_enterprise_managed_ = false;
bool is_eligible_for_background_replace_ = true;
std::tuple<bool, bool> is_eligible_for_background_replace_ = {true, true};
int existing_users_count_ = 0;

@ -570,7 +570,8 @@ void CameraEffectsController::OnActiveUserSessionChanged(
const AccountId& account_id) {
is_eligible_for_background_replace_ =
features::IsVcBackgroundReplaceEnabled() &&
Shell::Get()->session_controller()->IsEligibleForSeaPen(account_id);
std::get<0>(
Shell::Get()->session_controller()->IsEligibleForSeaPen(account_id));
const base::FilePath profile_path =
Shell::Get()->session_controller()->GetProfilePath(account_id);

@ -861,7 +861,8 @@ TEST_F(CameraEffectsControllerTest, GetBackgroundImageInfo) {
TEST_F(CameraEffectsControllerTest, NotEligibleForSeaPen) {
// Set is_eligible_for_background_replace to false so that the image button
// will not be constructed.
GetSessionControllerClient()->set_is_eligible_for_background_replace(false);
GetSessionControllerClient()->set_is_eligible_for_background_replace(
{false, false});
SimulateUserLogin(kTestAccount);
// Update media status to make the video conference tray visible.

@ -179,8 +179,6 @@ void BubbleView::AddedToWidget() {
if (GetCameraEffectsController()->is_eligible_for_background_replace()) {
set_camera_background_view_ = scroll_contents_view->AddChildView(
std::make_unique<SetCameraBackgroundView>(this, controller_.get()));
set_camera_background_view_->SetVisible(
GetCameraEffectsController()->GetCameraEffects()->replace_enabled);
}
}

@ -95,6 +95,12 @@ CameraEffectsController* GetCameraEffectsController() {
return Shell::Get()->camera_effects_controller();
}
bool IsVcBackgroundAllowedByEnterprise() {
auto* controller = Shell::Get()->session_controller();
return std::get<1>(
controller->IsEligibleForSeaPen(controller->GetActiveAccountId()));
}
// Returns a gradient lottie animation defined in the resource file for the
// `Create with AI` button.
std::unique_ptr<lottie::Animation> GetGradientAnimation(
@ -449,7 +455,9 @@ SetCameraBackgroundView::SetCameraBackgroundView(
VideoConferenceTrayController* controller)
: controller_(controller) {
SetID(BubbleViewID::kSetCameraBackgroundView);
SetVisible(false);
SetVisible(
GetCameraEffectsController()->GetCameraEffects()->replace_enabled &&
IsVcBackgroundAllowedByEnterprise());
// `SetCameraBackgroundView` has 2+ children, we want to stack them
// vertically.

@ -6,6 +6,8 @@
#include "ash/bubble/bubble_utils.h"
#include "ash/constants/ash_features.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "ash/style/tab_slider.h"
#include "ash/style/tab_slider_button.h"
#include "ash/style/typography.h"
@ -16,8 +18,10 @@
#include "ash/system/video_conference/resources/grit/vc_resources.h"
#include "ash/system/video_conference/video_conference_tray_controller.h"
#include "ash/system/video_conference/video_conference_utils.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/compositor/layer.h"
#include "ui/views/controls/animated_image_view.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
@ -31,6 +35,13 @@ namespace ash::video_conference {
namespace {
constexpr int kIconSize = 20;
constexpr float kVcDisabledButtonOpacity = 0.38f;
bool IsVcBackgroundAllowedByEnterprise() {
auto* controller = Shell::Get()->session_controller();
return std::get<1>(
controller->IsEligibleForSeaPen(controller->GetActiveAccountId()));
}
// Returns a gradient lottie animation defined in the resource file for the
// `Image` button.
@ -244,9 +255,12 @@ SetValueEffectSlider::SetValueEffectSlider(
const VcEffectState* state = effect->GetState(/*index=*/i);
DCHECK(state->state_value());
const bool is_image_button =
state->view_id() ==
video_conference::BubbleViewID::kBackgroundBlurImageButton;
TabSliderButton* slider_button;
if (state->state_value() ==
CameraEffectsController::BackgroundBlurPrefValue::kImage) {
if (is_image_button && IsVcBackgroundAllowedByEnterprise()) {
slider_button = tab_slider->AddButton(
std::make_unique<AnimatedImageButton>(controller, effect, state));
} else {
@ -265,6 +279,16 @@ SetValueEffectSlider::SetValueEffectSlider(
state->icon(), state->label_text()));
}
if (is_image_button && !IsVcBackgroundAllowedByEnterprise()) {
// Disable button.
slider_button->SetState(views::Button::ButtonState::STATE_DISABLED);
// Add tooltip to indicate why it is disabled.
slider_button->SetTooltipText(l10n_util::GetStringUTF16(
IDS_ASH_VIDEO_CONFERENCE_BUBBLE_BACKGROUND_DISABLED_TOOLTIP));
// Set opacity.
slider_button->layer()->SetOpacity(kVcDisabledButtonOpacity);
}
slider_button->SetSelected(state->state_value().value() == current_state);
if (state->view_id() != -1) {

@ -348,15 +348,17 @@ base::FilePath SessionControllerClientImpl::GetProfilePath(
return user_profile->GetPath();
}
bool SessionControllerClientImpl::IsEligibleForSeaPen(
std::tuple<bool, bool> SessionControllerClientImpl::IsEligibleForSeaPen(
const AccountId& account_id) {
Profile* const user_profile =
multi_user_util::GetProfileFromAccountId(account_id);
if (!user_profile) {
return false;
return {false, false};
}
return ash::personalization_app::IsEligibleForSeaPen(user_profile);
return {ash::personalization_app::IsEligibleForSeaPen(user_profile),
ash::personalization_app::IsManagedSeaPenVcBackgroundEnabled(
user_profile)};
}
std::optional<int> SessionControllerClientImpl::GetExistingUsersCount() const {

@ -92,7 +92,8 @@ class SessionControllerClientImpl
PrefService* GetSigninScreenPrefService() override;
PrefService* GetUserPrefService(const AccountId& account_id) override;
base::FilePath GetProfilePath(const AccountId& account_id) override;
bool IsEligibleForSeaPen(const AccountId& account_id) override;
std::tuple<bool, bool> IsEligibleForSeaPen(
const AccountId& account_id) override;
std::optional<int> GetExistingUsersCount() const override;
// Returns true if a multi-profile user can be added to the session or if