Skip to content

Commit

Permalink
policy: Map managed screensaver user policies to Ash prefs
Browse files Browse the repository at this point in the history
This CL maps the policies that configure the managed screensaver as
simple prefs. The user policies will be used to set up the mapping, and
a follow up CL will use the LoginProfilePolicyProvider to pass the
device policies as user policies for the sign-in profile.

Bug: b/269576818
Doc: go/gb-screensaver-dd
Test: ./browser_tests --gtest_filter=*PolicyPrefsTest.PolicyToPrefsMapping*
Change-Id: I0dc33450048998c4881094a1ba4c7c04ffab11c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4324019
Reviewed-by: Xiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: Pavol Marko <pmarko@chromium.org>
Commit-Queue: Emmanuel Arias Soto <eariassoto@google.com>
Cr-Commit-Position: refs/heads/main@{#1116297}
  • Loading branch information
Emmanuel Arias Soto authored and Chromium LUCI CQ committed Mar 13, 2023
1 parent 680e063 commit de0a881
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 4 deletions.
11 changes: 11 additions & 0 deletions ash/ambient/ambient_controller.cc
Expand Up @@ -185,6 +185,17 @@ void AmbientController::RegisterProfilePrefs(PrefRegistrySimple* registry) {
registry->RegisterDoublePref(
ambient::prefs::kAmbientModeAnimationPlaybackSpeed,
kAnimationPlaybackSpeed);

registry->RegisterBooleanPref(
ash::ambient::prefs::kAmbientModeManagedScreensaverEnabled, false);

registry->RegisterIntegerPref(
ambient::prefs::kAmbientModeManagedScreensaverIdleTimeoutSeconds,
kManagedScreensaverInactivityTimeout.InSeconds());

registry->RegisterIntegerPref(
ambient::prefs::kAmbientModeManagedScreensaverImageDisplayIntervalSeconds,
kManagedScreensaverImageRefreshInterval.InSeconds());
}

AmbientController::AmbientController(
Expand Down
9 changes: 9 additions & 0 deletions ash/public/cpp/ambient/ambient_prefs.cc
Expand Up @@ -43,6 +43,15 @@ constexpr char kAmbientModeAnimationPlaybackSpeed[] =
constexpr char kAmbientModePhotoRefreshIntervalSeconds[] =
"ash.ambient.photo_refresh_interval";

constexpr char kAmbientModeManagedScreensaverEnabled[] =
"ash.ambient.managed_screensaver.enabled";

constexpr char kAmbientModeManagedScreensaverIdleTimeoutSeconds[] =
"ash.ambient.managed_screensaver.idle_timeout_seconds";

constexpr char kAmbientModeManagedScreensaverImageDisplayIntervalSeconds[] =
"ash.ambient.managed_screensaver.image_display_interval_seconds";

} // namespace prefs
} // namespace ambient
} // namespace ash
23 changes: 23 additions & 0 deletions ash/public/cpp/ambient/ambient_prefs.h
Expand Up @@ -58,6 +58,29 @@ ASH_PUBLIC_EXPORT extern const char kAmbientModeAnimationPlaybackSpeed[];
// the user in settings.
ASH_PUBLIC_EXPORT extern const char kAmbientModePhotoRefreshIntervalSeconds[];

// Boolean policy to pref mapping for whether the managed screensaver is
// enabled. This pref takes the value from the ScreensaverLockScreenEnabled
// policy for user profiles, and from the DeviceScreensaverLoginScreenEnabled
// policy for the sign-in profile.
ASH_PUBLIC_EXPORT extern const char kAmbientModeManagedScreensaverEnabled[];

// Integer policy to pref mapping for the time in seconds that the device will
// wait idle before showing the managed screensaver. This pref takes the value
// from the ScreensaverLockScreenIdleTimeoutSeconds policy for user profiles,
// and from the DeviceScreensaverLoginScreenIdleTimeoutSeconds policy for the
// sign-in profile.
ASH_PUBLIC_EXPORT extern const char
kAmbientModeManagedScreensaverIdleTimeoutSeconds[];

// Integer policy to pref mapping for the interval in seconds to display an
// image when the managed screensaver has multiple images to display. This pref
// takes the value from the ScreensaverLockScreenImageDisplayIntervalSeconds
// policy for user profiles, and from the
// DeviceScreensaverLoginScreenImageDisplayIntervalSeconds policy for the
// sign-in profile.
ASH_PUBLIC_EXPORT extern const char
kAmbientModeManagedScreensaverImageDisplayIntervalSeconds[];

} // namespace prefs
} // namespace ambient
} // namespace ash
Expand Down
13 changes: 13 additions & 0 deletions ash/public/cpp/ambient/ambient_ui_model.h
Expand Up @@ -43,6 +43,19 @@ constexpr base::TimeDelta kPhotoRefreshInterval = base::Seconds(60);
// The default animation playback speed. Not used in slideshow mode.
constexpr float kAnimationPlaybackSpeed = 1.f;

// The default time before starting the managed screensaver. Must match with the
// default value declared in the DeviceScreensaverLoginScreenIdleTimeoutSeconds
// and ScreensaverLockScreenIdleTimeoutSeconds policies.
constexpr base::TimeDelta kManagedScreensaverInactivityTimeout =
base::Seconds(7);

// The default interval to refresh images in the managed screensaver. Must match
// with the default value declared in the
// DeviceScreensaverImageDisplayIntervalSeconds and
// ScreensaverImageDisplayIntervalSeconds policies.
constexpr base::TimeDelta kManagedScreensaverImageRefreshInterval =
base::Seconds(60);

// A checked observer which receives notification of changes to the Ambient Mode
// UI model.
class ASH_PUBLIC_EXPORT AmbientUiModelObserver : public base::CheckedObserver {
Expand Down
Expand Up @@ -151,6 +151,7 @@
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/arc_prefs.h"
#include "ash/constants/ash_pref_names.h"
#include "ash/public/cpp/ambient/ambient_prefs.h"
#include "chrome/browser/apps/app_service/webapk/webapk_prefs.h"
#include "chrome/browser/ash/accessibility/magnifier_type.h"
#include "chrome/browser/ash/app_restore/full_restore_prefs.h"
Expand Down Expand Up @@ -1411,7 +1412,15 @@ const PolicyToPreferenceMapEntry kSimplePolicyMap[] = {
{ key::kWallpaperGooglePhotosIntegrationEnabled,
wallpaper_handlers::prefs::kWallpaperGooglePhotosIntegrationEnabled,
base::Value::Type::BOOLEAN },

{ key::kScreensaverLockScreenEnabled,
ash::ambient::prefs::kAmbientModeManagedScreensaverEnabled,
base::Value::Type::BOOLEAN },
{ key::kScreensaverLockScreenIdleTimeoutSeconds,
ash::ambient::prefs::kAmbientModeManagedScreensaverIdleTimeoutSeconds,
base::Value::Type::INTEGER },
{ key::kScreensaverLockScreenImageDisplayIntervalSeconds,
ash::ambient::prefs::kAmbientModeManagedScreensaverImageDisplayIntervalSeconds,
base::Value::Type::INTEGER },
#endif // BUILDFLAG(IS_CHROMEOS_ASH)

#if BUILDFLAG(IS_LINUX)
Expand Down
92 changes: 89 additions & 3 deletions components/policy/test/data/policy_test_cases.json
Expand Up @@ -22307,13 +22307,99 @@
]
},
"ScreensaverLockScreenEnabled" : {
"reason_for_missing_test": "TODO(b/175142676): Feature not yet implemented"
"os": [
"chromeos_ash"
],
"can_be_recommended": false,
"policy_pref_mapping_tests": [
{
"policies": {},
"prefs": {
"ash.ambient.managed_screensaver.enabled": {
"location": "user_profile",
"default_value": false
}
}
},
{
"policies": {
"ScreensaverLockScreenEnabled": true
},
"prefs": {
"ash.ambient.managed_screensaver.enabled": {
"location": "user_profile",
"value": true
}
}
},
{
"policies": {
"ScreensaverLockScreenEnabled": false
},
"prefs": {
"ash.ambient.managed_screensaver.enabled": {
"location": "user_profile",
"value": false
}
}
}
]
},
"ScreensaverLockScreenIdleTimeoutSeconds" : {
"reason_for_missing_test": "TODO(b/175142676): Feature not yet implemented"
"os": [
"chromeos_ash"
],
"can_be_recommended": false,
"policy_pref_mapping_tests": [
{
"policies": {},
"prefs": {
"ash.ambient.managed_screensaver.idle_timeout_seconds": {
"location": "user_profile",
"default_value": 7
}
}
},
{
"policies": {
"ScreensaverLockScreenIdleTimeoutSeconds": 42
},
"prefs": {
"ash.ambient.managed_screensaver.idle_timeout_seconds": {
"location": "user_profile",
"value": 42
}
}
}
]
},
"ScreensaverLockScreenImageDisplayIntervalSeconds" : {
"reason_for_missing_test": "TODO(b/175142676): Feature not yet implemented"
"os": [
"chromeos_ash"
],
"can_be_recommended": false,
"policy_pref_mapping_tests": [
{
"policies": {},
"prefs": {
"ash.ambient.managed_screensaver.image_display_interval_seconds": {
"location": "user_profile",
"default_value": 60
}
}
},
{
"policies": {
"ScreensaverLockScreenImageDisplayIntervalSeconds": 128
},
"prefs": {
"ash.ambient.managed_screensaver.image_display_interval_seconds": {
"location": "user_profile",
"value": 128
}
}
}
]
},
"ScreensaverLockScreenImages" : {
"reason_for_missing_test": "TODO(b/175142676): Feature not yet implemented"
Expand Down

0 comments on commit de0a881

Please sign in to comment.