// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module side_panel.mojom;
import "mojo/public/mojom/base/token.mojom";
import "skia/public/mojom/skcolor.mojom";
import "url/mojom/url.mojom";
// The background image URL and styling.
struct BackgroundImage {
// URL to the background image. Can point to untrusted content.
url.mojom.Url url;
// URL to snapshot of the background image. Can point to untrusted content.
url.mojom.Url snapshot_url;
// Whether the image is a local resource.
bool is_uploaded_image;
// Id for local resource. It is empty if it is an uploaded image and set if
// it is a local wallpaper search resource.
mojo_base.mojom.Token? local_background_id;
// Title of the background image.
string title;
// Collection id of the background image.
string collection_id;
// Whether daily refresh is enabled.
bool daily_refresh_enabled;
};
// Additional info for third-party themes.
struct ThirdPartyThemeInfo {
// ID in the Chrome Web Store.
string id;
// Human-readable theme name.
string name;
};
// A generic theme.
struct Theme {
// The background image.
BackgroundImage? background_image;
// User's third party theme info.
ThirdPartyThemeInfo? third_party_theme_info;
// The current theme background color.
skia.mojom.SkColor background_color;
// The current theme foreground color. If not set, we use the default theme.
skia.mojom.SkColor? foreground_color;
// True if the background is managed by a policy.
bool background_managed_by_policy;
// True if we are following the OS theme.
bool follow_device_theme;
};
// A collection of background images.
struct BackgroundCollection {
// Collection identifier.
string id;
// Localized string of the collection name.
string label;
// URL to a preview image for the collection. Can point to untrusted content.
url.mojom.Url preview_image_url;
};
// A background image in a collection.
struct CollectionImage {
// Human readable attributions of the background image.
string attribution_1;
string attribution_2;
// URL associated with the background image. Used for href.
url.mojom.Url attribution_url;
// URL of image. Can point to untrusted content.
url.mojom.Url image_url;
// URL to a preview of the image. Can point to untrusted content.
url.mojom.Url preview_image_url;
// Collection id of the image;
string collection_id;
};
// Settings associated with a given module.
struct ModuleSettings {
// A unique identifier associated with a module.
string id;
// The name associated with a module.
string name;
// Whether the module is enabled or not.
bool enabled;
};
enum CustomizeChromeSection {
kAppearance,
kShortcuts,
kModules,
kWallpaperSearch,
kToolbar,
};
enum ChromeWebStoreCollection {
kWritingEssentials,
};
enum ChromeWebStoreCategory {
kWorkflowPlanning,
kShopping,
};
// Used by the WebUI page to bootstrap bidirectional communication.
interface CustomizeChromePageHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreatePageHandler(pending_remote<CustomizeChromePage> page,
pending_receiver<CustomizeChromePageHandler> handler);
};
// Browser-side handler for requests from WebUI page.
interface CustomizeChromePageHandler {
// Sets the visibility of NTP tiles and whether custom links are enabled.
SetMostVisitedSettings(bool custom_links_enabled, bool shortcuts_visible);
// Triggers a call to |CustomizeChromePage.SetPageMostVisitedSettings|.
UpdateMostVisitedSettings();
// Returns the collections of background images.
GetBackgroundCollections() => (array<BackgroundCollection> collections);
// Returns the images of a collection identified by |collection_id|.
GetBackgroundImages(string collection_id) => (array<CollectionImage> images);
// Triggers a call to |CustomizeChromePage.SetModulesSettings|.
UpdateModulesSettings();
// Triggers a call to |CustomizeChromePage.SetTheme()|.
UpdateTheme();
// Sets Chrome's theme according to the default color.
SetDefaultColor();
// Set that the theme should follow the device's.
SetFollowDeviceTheme(bool follow);
// Removes background image.
RemoveBackgroundImage();
// Choose custom background from local file system.
ChooseLocalCustomBackground() => (bool success);
// Sets the background image and notifies all NTPs of the change.
SetBackgroundImage(string attribution_1, string attribution_2,
url.mojom.Url attribution_url, url.mojom.Url image_url,
url.mojom.Url thumbnail_url, string collection_id);
// Sets collection id for daily refresh. When |collection_id| is empty, the
// daily refresh is turned off.
SetDailyRefreshCollectionId(string collection_id);
// Open Chrome Web Store's theme page in a new tab.
OpenChromeWebStore();
// Open Chrome Web Store's home page in a new tab.
OpenChromeWebStoreHomePage();
// Opens link to Chrome Web Store theme in a new tab.
OpenThirdPartyThemePage(string theme_id);
// Opens link to Chrome Web Store category page in a new tab.
OpenChromeWebStoreCategoryPage(ChromeWebStoreCategory category);
// Opens link to Chrome Web Store collection page in a new tab.
OpenChromeWebStoreCollectionPage(ChromeWebStoreCollection collection);
// Opens a link to the system that manages the NTP, if its a DSE, it links
// to the settings page for search engines, if its an extension, then links
// to the extensions details page.
OpenNtpManagedByPage();
// If |visible| the modules will be shown.
SetModulesVisible(bool visible);
// Disables module with ID `module_id` if `disabled`. Enables otherwise.
SetModuleDisabled(string module_id, bool disabled);
// Triggers a call to |CustomizeChromePage.UpdateScrollToSection()|.
UpdateScrollToSection();
// Triggers a call to |CustomizeChromePage.AttachedTabStateUpdated()|.
UpdateAttachedTabState();
// Triggers a call to |CustomizeChromePage.NtpManagedByNameUpdated()|.
UpdateNtpManagedByName();
};
// WebUI-side handler for requests from the browser.
interface CustomizeChromePage {
// Sets available modules and their associated properties such as id, name,
// enabled status, visibility and managed state.
SetModulesSettings(array<ModuleSettings> modules_settings, bool managed,
bool visible);
// Sets the visibility of NTP tiles and whether custom links are enabled.
SetMostVisitedSettings(bool custom_links_enabled, bool visible);
// Sets the current theme.
SetTheme(Theme theme);
// Scrolls side panel to |section|. Possibly a response to a call to
// |CustomizeChromePageHandler.UpdateScrollToSection()|.
ScrollToSection(CustomizeChromeSection section);
// Sets Information about the tab that is attached to the CustomizeChromePage.
AttachedTabStateUpdated(bool is_source_tab_first_party_ntp);
// Sets the name of the system that manages the new tab page if there is one.
// If not, empty string should be provided.
NtpManagedByNameUpdated(string ntp_managed_by_name);
};