1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246
|
// 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;
// True if the collection's preview image is valid (loads correctly).
bool image_verified;
};
// 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;
// True if the theme's preview image is valid (loads correctly).
bool image_verified;
};
// 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;
// The description associated with a module.
string? description;
// Whether the module is enabled or not.
bool enabled;
// Whether the module should be shown in Customize Chrome or not.
bool visible;
};
enum CustomizeChromeSection {
kAppearance,
kShortcuts,
kModules,
kWallpaperSearch,
kToolbar,
kFooter,
};
enum ChromeWebStoreCollection {
kWritingEssentials,
};
enum ChromeWebStoreCategory {
kWorkflowPlanning,
kShopping,
};
// Types of New Tabs that CustomizeChromePage can attach to.
enum NewTabPageType {
kFirstPartyWebUI,
kThirdPartyWebUI,
kThirdPartyRemote,
kExtension,
kIncognito,
kGuestMode,
kNone,
};
// 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 a valid collection preview image for |collection_id|.
GetReplacementCollectionPreviewImage(string collection_id)
=> (url.mojom.Url? preview_image_url);
// 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();
// Triggers a call to |CustomizeChromePage.SetThemeEditable()|.
UpdateThemeEditable(bool is_theme_editable);
// 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();
// If |visible| the NTP footer will be shown.
SetFooterVisible(bool visible);
// Triggers a call to |CustomizeChromePage.SetFooterSettings()|.
UpdateFooterSettings();
};
// 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 visibility and disabled state of the NTP Footer.
SetFooterSettings(bool visible, bool disable,
bool extension_attribution_enabled);
// Sets the current theme.
SetTheme(Theme theme);
// Sets whether edit theme should be enabled.
SetThemeEditable(bool is_theme_editable);
// 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(NewTabPageType ntp_type);
// Sets the name and description of the system that manages the new tab page,
// if there is one. If not, empty strings should be provided.
NtpManagedByNameUpdated(string name, string description);
};
|