blob: 1bdcf0e64b6f7331c0b9bfedb7ee9ea30661c396 [file] [log] [blame]
// Copyright 2016 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.
module ash.mojom;
import "ash/public/interfaces/user_info.mojom";
import "components/signin/public/interfaces/account_id.mojom";
import "mojo/common/file_path.mojom";
import "mojo/common/time.mojom";
import "skia/public/interfaces/bitmap.mojom";
import "url/mojo/url.mojom";
// These values match wallpaper::WallpaperLayout.
enum WallpaperLayout {
// These values match wallpaper::WallpaperType.
enum WallpaperType {
// TODO( Remove this after WallpaperManager is removed.
// WallpaperInfo will be an internal concept within WallpaperController.
// This corresponds to wallpaper::WallpaperInfo.
struct WallpaperInfo {
string location;
WallpaperLayout layout;
WallpaperType type;
mojo.common.mojom.Time date;
// User info needed to set wallpapers. Clients must specify the user because
// it's not always the same with the active user, e.g., when showing wallpapers
// for different user pods at login screen, or setting wallpapers selectively
// for primary user and active user during a multi-profile session.
struct WallpaperUserInfo {
// The user's account id.
signin.mojom.AccountId account_id;
// The user type. Matches user_manager::UserType.
UserType type;
// True if the user's non-cryptohome data (wallpaper, avatar etc.) is
// ephemeral. See |UserManager::IsCurrentUserNonCryptohomeDataEphemeral| for
// more details.
bool is_ephemeral;
// True if the user has gaia account.
bool has_gaia_account;
// Used by Chrome to set the wallpaper displayed by ash.
interface WallpaperController {
// Do the initialization: Sets the client interface, the paths of wallpaper
// directories and the device wallpaper policy enforcement flag. The paths
// must be sent over IPC because chrome owns the concept of user data
// directory.
// |client|: The client interface.
// |user_data_path|: Directory where user data can be written.
// |chromeos_wallpapers_path|: Directory where downloaded chromeos wallpapers
// reside.
// |chromeos_custom_wallpapers_path|: Directory where custom wallpapers
// reside.
// |is_device_wallpaper_policy_enforced|: Whether the device wallpaper policy
// is enforced on the device.
Init(WallpaperControllerClient client,
mojo.common.mojom.FilePath user_data_path,
mojo.common.mojom.FilePath chromeos_wallpapers_path,
mojo.common.mojom.FilePath chromeos_custom_wallpapers_path,
bool is_device_wallpaper_policy_enforced);
// Sets wallpaper from policy or from a local file. Saves the custom wallpaper
// to file, posts task to generate thumbnail and updates local state.
// |user_info|: The user's information related to wallpaper.
// |wallpaper_files_id|: The file id for user_info.account_id.
// |file_name|: The name of the wallpaper file.
// |layout|: The layout of the wallpaper, used for wallpaper resizing.
// |type|: The type of the wallpaper, e.g., default, policy etc.
// |image|: The wallpaper image.
// |show_wallpaper|: If false, don't show the new wallpaper now but only
// update cache.
SetCustomWallpaper(WallpaperUserInfo user_info,
string wallpaper_files_id,
string file_name,
WallpaperLayout layout,
WallpaperType type,
skia.mojom.Bitmap image,
bool show_wallpaper);
// Sets wallpaper from the wallpaper picker selection, i.e., the wallpaper
// type is ONLINE.
// |user_info|: The user's information related to wallpaper.
// |image|: The wallpaper image.
// |url|: The url corresponding to this wallpaper. Used as a placeholder for
// the location in WallpaperInfo.
// |layout|: The layout of the wallpaper, used for wallpaper resizing.
// |show_wallpaper|: If false, don't show the new wallpaper now but only
// update cache.
SetOnlineWallpaper(WallpaperUserInfo user_info,
skia.mojom.Bitmap image,
string url,
WallpaperLayout layout,
bool show_wallpaper);
// Sets the user's wallpaper to be the default wallpaper. Note: different user
// types may have different default wallpapers.
// |wallpaper_files_id|: The file id for user_info.account_id.
// |show_wallpaper|: If false, don't show the new wallpaper now but only
// update cache.
SetDefaultWallpaper(WallpaperUserInfo user_info,
string wallpaper_files_id,
bool show_wallpaper);
// Sets a customized default wallpaper to be used wherever a default wallpaper
// is needed. Note: it doesn't change the default wallpaper for guest and
// child accounts.
// |wallpaper_url|: The url corresponding to this wallpaper.
// |file_path|: The path of the wallpaper file.
// |resized_directory|: The directory where resized versions are stored. Must
// be writable.
SetCustomizedDefaultWallpaper(url.mojom.Url wallpaper_url,
mojo.common.mojom.FilePath file_path,
mojo.common.mojom.FilePath resized_directory);
// Sets whether device wallpaper policy is enforced on this device. Updates/
// clears the device policy controlled wallpaper if applicable.
SetDeviceWallpaperPolicyEnforced(bool enforced);
// Updates the layout for the user's custom wallpaper and reloads the
// wallpaper with the new layout.
// |user_info|: The user's information related to wallpaper.
// |layout|: The new layout of the wallpaper.
UpdateCustomWallpaperLayout(WallpaperUserInfo user_info,
WallpaperLayout layout);
// Shows the user's wallpaper, which is determined in the following order:
// 1) Use device policy wallpaper if it exists AND we are at the login screen.
// 2) Use user policy wallpaper if it exists.
// 3) Use the wallpaper set by the user (either by |SetOnlineWallpaper| or
// |SetCustomWallpaper|), if any.
// 4) Use the default wallpaper of this user.
ShowUserWallpaper(WallpaperUserInfo user_info);
// Used by the gaia-signin UI. Signin wallpaper is considered either as the
// device policy wallpaper or the default wallpaper.
// Removes all of the user's saved wallpapers and related info.
// |wallpaper_files_id|: The file id for user_info.account_id.
RemoveUserWallpaper(WallpaperUserInfo user_info, string wallpaper_files_id);
// TODO( This is only used by WallpaperManager. Remove this
// after WallpaperManager is removed.
// Set the wallpaper bitmap and info used for the ash desktop background.
// A null or empty |wallpaper| bitmap is treated as a no-op.
// TODO( Optimize ash wallpaper transport; avoid sending
// large bitmaps over Mojo; use shared memory like BitmapUploader, etc.
SetWallpaper(skia.mojom.Bitmap? wallpaper, WallpaperInfo info);
// Calling this method triggers an initial notification of the wallpaper
// state. Observers are automatically removed as their connections are closed.
AddObserver(associated WallpaperObserver observer);
// Runs to get wallpaper prominent colors.
GetWallpaperColors() => (array<uint32> prominent_colors);
// Used by ash to control a Chrome client.
interface WallpaperControllerClient {
// Opens the wallpaper picker window.
// Used to listen for wallpaper state changed.
interface WallpaperObserver {
// Called when the colors extracted from the current wallpaper change. May
// be called as a side effect of changing the wallpaper on the
// WallpaperController, e.g. WallpaperController::SetWallpaperImage().
// Colors are ordered and are referenced in wallpaper::ColorProfileType.
OnWallpaperColorsChanged(array<uint32> prominent_colors);