// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. module new_tab_page.mojom; import "components/ntp_tiles/tile_type.mojom"; import "chrome/browser/ui/webui/ntp_microsoft_auth/ntp_microsoft_auth_shared_ui.mojom"; import "skia/public/mojom/skcolor.mojom"; import "ui/webui/resources/cr_components/most_visited/most_visited.mojom"; import "url/mojom/url.mojom"; /** * New Tab Page image sources. This enum must match the numbering for * NTPBackgroundImageSource in enums.xml. These values are persisted to * logs. Entries should not be renumbered, removed or reused. */ enum NtpBackgroundImageSource { kNoImage, kFirstPartyThemeWithoutDailyRefresh, kFirstPartyThemeWithDailyRefresh, kThirdPartyTheme, kUploadedImage, kWallpaperSearch, kWallpaperSearchInspiration, }; // The background image URL and styling. struct BackgroundImage { // URL to the background image. Can point to untrusted content. url.mojom.Url url; // URL to a higher res background image. Can point to untrusted content. url.mojom.Url? url_2x; // URL to a logo of the theme. Has chrome:// scheme. url.mojom.Url? attribution_url; // CSS styling properties set on the background image. string? size; string? repeat_x; string? repeat_y; string? position_x; string? position_y; // Source of background image. NtpBackgroundImageSource image_source; }; // A generic theme. struct Theme { skia.mojom.SkColor text_color; skia.mojom.SkColor background_color; // True if user color mode is baseline. bool is_baseline; // True if theme is GM3 (uses user color pref). bool is_gm3; // True if the background is custom. bool is_custom_background; // True if daily refresh is enabled. bool daily_refresh_enabled; // True if the theme is dark (e.g. NTP background color is dark). bool is_dark; // Color of Google logo. If not set show the logo multi-colored. skia.mojom.SkColor? logo_color; // Collection id of the background image. string? background_image_collection_id; // The background image. BackgroundImage? background_image; // Human readable attributions of the background image. string? background_image_attribution_1; string? background_image_attribution_2; // URL associated with the background image. Used for href. url.mojom.Url? background_image_attribution_url; // Theme settings for the NTP MV tiles. most_visited.mojom.MostVisitedTheme most_visited; }; // Type of image of an image doodle. Used for metrics logging only. enum DoodleImageType { // Animation of an animated doodle. kAnimation, // Image of a static doodle. kStatic, }; // A simple or animated doodle in either dark or light mode. struct ImageDoodle { // Doodle image encoded as data URL. url.mojom.Url image_url; // URL pointing to animated content (e.g. gif). Only set for animated doodles. url.mojom.Url? animation_url; // Dimensions of the original image in pixels. uint32 width; uint32 height; // Color of the background the doodle was designed for. If the NTP background // differs from that color we show the doodle in a box of that color. skia.mojom.SkColor background_color; // URLs to be pinged when an image has been shown. url.mojom.Url image_impression_log_url; url.mojom.Url? animation_impression_log_url; }; // A simple or animated doodle in both dark and light mode. struct AllModeImageDoodle { // Doodles for respective modes. ImageDoodle light; ImageDoodle? dark; // URL opened in new tab when the doodle is clicked. url.mojom.Url? on_click_url; // URL displayed to users, which they can use to share the doodle. url.mojom.Url share_url; }; // A doodle. Retrieved from the Google doodle server. struct Doodle { // Set for simple and animated doodles. AllModeImageDoodle? image; // Localized description of the doodle. string description; }; // A channel through which a doodle can be shared. enum DoodleShareChannel { kFacebook, kTwitter, kEmail, kLinkCopy, }; struct PromoImagePart { url.mojom.Url image_url; url.mojom.Url target; }; struct PromoLinkPart { string text; url.mojom.Url url; }; struct PromoTextPart { string text; }; union PromoPart { PromoImagePart image; PromoLinkPart link; PromoTextPart text; }; // Homepage promo used to display a message with a link on the NTP. struct Promo { // A unique identifier for this promo. string? id; // URL to ping to log a promo impression. May be invalid. url.mojom.Url? log_url; // Middle slot promo data. array middle_slot_parts; }; // Used to determine available modules for the NTP. struct ModuleIdName { // A unique identifier associated with a module. string id; // The name associated with a module. string name; }; // Action the user performed while using the customize dialog. Used for metrics // logging only. Actions correspond to items in NTPLoggingEventType. enum CustomizeDialogAction { kCancelClicked, kDoneClicked, kOpenClicked, kBackgroundsBackClicked, kBackgroundsNoBackgroundSelected, kBackgroundsCollectionOpened, kBackgroundsRefreshToggleClicked, kBackgroundsImageSelected, kBackgroundsUploadFromDeviceClicked, kShortcutsCustomLinksClicked, kShortcutsMostVisitedClicked, kShortcutsVisibilityToggleClicked, }; // Opt in status. Used for metrics logging only. enum OptInStatus { kExplicitOptIn, kImplicitOptIn, kOptOut, }; // Used by the WebUI page to bootstrap bidirectional communication. interface PageHandlerFactory { // The WebUI page's |BrowserProxy| singleton calls this method when the page // is first initialized. CreatePageHandler(pending_remote page, pending_receiver handler); }; // Browser-side handler for requests from WebUI page. interface PageHandler { // Sets the visibility of NTP tiles and the shortcuts type. SetMostVisitedSettings(ntp_tiles.mojom.TileType shortcuts_type, bool shortcuts_visible); // Returns the visibility of NTP tiles and the shortcuts type. GetMostVisitedSettings() => (ntp_tiles.mojom.TileType shortcuts_type, bool shortcuts_visible); // Gets current doodle if there is one. GetDoodle() => (Doodle? doodle); // Updates middle slot promo data. Triggers a call to |SetPromo|. UpdatePromoData(); // Marks a promo as blocked. BlocklistPromo(string promo_id); // Unmarks a promo as blocked. UndoBlocklistPromo(string promo_id); // Called when a module the given id is dismissed. OnDismissModule(string module_id); // Called when a module the given id is restored. OnRestoreModule(string module_id); // If |visible| the modules will be shown. SetModulesVisible(bool visible); // Triggers a call to |SetDisabledModules|. UpdateDisabledModules(); // Called when at least one module has loaded with data. // `module_ids` is an array of module descriptor ids that identifies the // modules that loaded with data. OnModulesLoadedWithData(array module_ids); // Called when a user uses a module. May lead to a HaTS survey being // displayed or an in product help promo being closed. OnModuleUsed(string module_id); // Returns a list of available module id and name pairs. GetModulesIdNames() => (array data); // Returns a list of module ids that are eligible for auto removal. GetModulesEligibleForRemoval() => (array module_ids); // Sets the order of modules. SetModulesOrder(array module_ids); // Returns the order of modules or an empty array if the user has not // reordered them before. GetModulesOrder() => (array module_ids); // Triggers a call to |SetModulesLoadable|. UpdateModulesLoadable(); // Disables modules with IDs |module_ids| if |disabled|. Enables otherwise. // `is_user_action` is true if the action was triggered by a user action. SetModulesDisabled(array module_ids, bool disabled, bool is_user_action); // Updates the visibility of the action chips in the NTP on any pref changes. UpdateActionChipsVisibility(); // Triggers a call to |FooterVisibilityUpdated|. UpdateFooterVisibility(); // Increments count of times the compose button was shown. IncrementComposeButtonShownCount(); // Opens Customize Chrome if eligibility conditions are met. MaybeTriggerAutomaticCustomizeChromePromo(); // ======= METRICS ======= // Logs that the One Google Bar was added to the DOM / loaded in an iframe at // |time|. OnOneGoogleBarRendered(double time); // Logs that the promo iframe was loaded at |time| and pings |log_url| for // promo metrics logging. OnPromoRendered(double time, url.mojom.Url? log_url); // Logs an action performed in the customize dialog. OnCustomizeDialogAction(CustomizeDialogAction action); // Logs that the |type| image of an image doodle has been clicked. If set, the // |log_url| should be pinged for metrics logging. OnDoodleImageClicked(DoodleImageType type, url.mojom.Url? log_url); // Logs that the |type| image of an image doodle has been shown at |time|. // Returns additional params, which are fetched from |image_url|, we use to // perform more doodle logging later. We can't fetch the params in JS because // the NTP renderer process does not have network access. OnDoodleImageRendered(DoodleImageType type, double time, url.mojom.Url log_url) => (string? image_click_params, url.mojom.Url? interaction_log_url, string? share_id); // Logs that the doodle with |doodle_id| has been shared through |channel|. // |share_id| comes from a previous call to |OnDoodleImageRendered|. OnDoodleShared(DoodleShareChannel channel, string doodle_id, string? share_id); // Logs that a link on a promo has been clicked. OnPromoLinkClicked(); // Logs that the element's |ready| callback method was called. OnAppRendered(double time); // Queries whether the Realbox "+" context menu button animation should be shown. CanShowRealboxContextMenuAnimation() => (bool can_show); // Records that the Realbox "+" context menu button animation was shown or // blocked. RecordRealboxContextMenuAnimationImpression(bool shown); // Records that the user engaged with the contextual search IPH. OnContextualSearchIPHEngaged(); }; // WebUI-side handler for requests from the browser. interface Page { // Sets the current theme. SetTheme(Theme theme); // Disables the modules in |ids|. If |all|, disables all modules and passes an // empty list for |ids|. SetDisabledModules(bool all, array ids); // Allows modules to load on NTP when the UI has postponed module loading for // some reason. SetModulesLoadable(); // Sets the action chips visibility. SetActionChipsVisibility(bool visible); // Sets NTP homepage promo. SetPromo(Promo? promo); // Shows a toast with information about Chrome Webstore themes. ShowWebstoreToast(); // Sets wallpaper search button's visibility to |visible|. SetWallpaperSearchButtonVisibility(bool visible); // Called when the NTP footer is shown or hidden. FooterVisibilityUpdated(bool visible); // Called when the embedded chrome-untrusted:// document wants to bind Mojo // interfaces for communicating with the chrome:// document. ConnectToParentDocument(pending_remote child_untrusted_document_remote); };