// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module blink.mojom;
import "mojo/public/mojom/base/string16.mojom";
import "services/device/public/mojom/screen_orientation_lock_types.mojom";
import "third_party/blink/public/mojom/manifest/capture_links.mojom";
import "third_party/blink/public/mojom/manifest/display_mode.mojom";
import "third_party/blink/public/mojom/manifest/manifest_launch_handler.mojom";
import "third_party/blink/public/mojom/permissions_policy/permissions_policy.mojom";
import "third_party/blink/public/mojom/safe_url_pattern.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";
// The Manifest structure is an internal representation of the Manifest file
// described in the "Manifest for Web Application" document:
// http://w3c.github.io/manifest/
// All fields will be their default constructed values (optional types nullopt)
// if the manifest failed to parse.
[JavaClassName="WebManifest"]
struct Manifest {
// The URL this manifest was loaded from. This can be an empty URL if this is
// an automatically generated "default" manifest.
url.mojom.Url manifest_url;
mojo_base.mojom.String16? name;
mojo_base.mojom.String16? short_name;
mojo_base.mojom.String16? description;
// This is empty or invalid iff the start_url is empty or invalid.
url.mojom.Url id;
// Set to true if the json specified a specific value for the id.
bool has_custom_id;
// This defaults to the document_url. See `has_valid_specified_start_url` to know if
// this was specified by the manifest json itself.
url.mojom.Url start_url;
// True if the json specified a start_url.
bool has_valid_specified_start_url;
DisplayMode display;
array<DisplayMode> display_override;
device.mojom.ScreenOrientationLockType orientation;
array<ManifestImageResource> icons;
array<ManifestScreenshot> screenshots;
array<ManifestShortcutItem> shortcuts;
ManifestShareTarget? share_target;
// TODO(crbug.com/829689): This field is non-standard and part of a Chrome
// experiment. See:
// https://github.com/WICG/file-handling/blob/main/explainer.md
// As such, this field should not be exposed by default.
array<ManifestFileHandler> file_handlers;
// The URLProtocolHandler explainer can be found here:
// https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/URLProtocolHandler/explainer.md
array<ManifestProtocolHandler> protocol_handlers;
// TODO(crbug.com/1072058): This field is non-standard and part of an
// experiment. See:
// https://github.com/WICG/pwa-url-handler/blob/main/explainer.md
array<ManifestUrlHandler> url_handlers;
// TODO(crbug.com/1250011): This field is non-standard and part of an
// experiment. See:
// https://github.com/WICG/manifest-incubations/blob/gh-pages/scope_extensions-explainer.md
array<ManifestScopeExtension> scope_extensions;
// TODO(crbug.com/1006642): This field is non-standard and part of an
// experiment. See:
// https://github.com/WICG/lock-screen/
ManifestLockScreen? lock_screen;
// TODO(crbug.com/1185678): This field is non-standard and part of a manifest
// incubation. See:
// https://wicg.github.io/manifest-incubations/index.html#dfn-note_taking
ManifestNoteTaking? note_taking;
array<ManifestRelatedApplication> related_applications;
// A boolean that is used as a hint for the user agent to say that related
// applications should be preferred over the web application. False if missing
// or there is a parsing failure.
bool prefer_related_applications;
// TODO(https://crbug.com/657632): Numeric types are not nullable. =(
bool has_theme_color;
uint32 theme_color;
// TODO(https://crbug.com/657632): Numeric types are not nullable. =(
bool has_background_color;
uint32 background_color;
mojo_base.mojom.String16? gcm_sender_id;
// Defaults to the start URL (or document URL if start URL isn't present) with
// filename, query, and fragment removed if not present.
url.mojom.Url scope;
// TODO(crbug.com/1163398): This field is non-standard and part of a Chrome
// experiment. See:
// https://github.com/WICG/web-app-launch/blob/main/declarative_link_capturing.md#proposal
// As such, this field should not be exposed by default.
CaptureLinks capture_links;
array<ParsedPermissionsPolicyDeclaration> permissions_policy;
// TODO(crbug.com/1231886): This field is non-standard and part of a Chrome
// experiment. See:
// https://github.com/WICG/web-app-launch/blob/main/launch_handler.md
ManifestLaunchHandler? launch_handler;
// TODO(crbug.com/1259777): This field is non-standard and part of a Chrome
// experiment. See:
// https://github.com/WICG/manifest-incubations/blob/gh-pages/translations-explainer.md
// A mapping of locales to their translations.
map<mojo_base.mojom.String16, ManifestTranslationItem> translations;
// TODO(b:340126786): Remove these obsolete fields.
// TODO(crbug.com/1318305): This field is non-standard and part of a Chrome
// experiment. See: https://github.com/w3c/manifest/issues/1045
bool has_dark_theme_color;
uint32 dark_theme_color;
bool has_dark_background_color;
uint32 dark_background_color;
// TODO(crbug.com/897314): This field is non-standard and part of a Chrome
// experiment. See:
// https://github.com/WICG/manifest-incubations/blob/gh-pages/tabbed-mode-explainer.md
ManifestTabStrip? tab_strip;
// TODO(crbug.com/1444407): This field is non-standard and part of an
// experiment. See: https://github.com/WICG/isolated-web-apps
mojo_base.mojom.String16? version;
};
// Structure representing a Shortcut Item per the Manifest specification, see:
// https://w3c.github.io/manifest/#shortcutitem-and-its-members
struct ManifestShortcutItem {
// name is required
mojo_base.mojom.String16 name;
mojo_base.mojom.String16? short_name;
mojo_base.mojom.String16? description;
// URL at which the shortcut can be found.
// MUST be a valid url. If a shortcut doesn't have a valid URL, it will not be
// successfully parsed, thus will not be represented in the Manifest.
url.mojom.Url url;
array<ManifestImageResource> icons;
};
// Structure representing an icon as per the Manifest specification, see:
// https://w3c.github.io/manifest/#dom-imageresource
struct ManifestImageResource {
enum Purpose {
ANY = 0,
MONOCHROME,
MASKABLE,
};
// MUST be a valid url. If an icon doesn't have a valid URL, it will not be
// successfully parsed, thus will not be represented in the Manifest.
url.mojom.Url src;
// The type can be any string and doesn't have to be a valid image MIME type
// at this point. It is up to the consumer of the object to check if the type
// matches a supported type.
mojo_base.mojom.String16? type;
// The special value "any" is represented by gfx::Size(0, 0).
array<gfx.mojom.Size> sizes;
// Never empty. Defaults to a vector with a single value, IconPurpose::ANY,
// if not explicitly specified in the manifest.
array<Purpose> purpose;
};
// Structure representing a screenshot as per the Manifest specification, see:
// https://www.w3.org/TR/manifest-app-info/#screenshots-member. This includes
// a ImageResource with some additional members.
struct ManifestScreenshot {
enum FormFactor {
kUnknown = 0,
kWide,
kNarrow,
};
ManifestImageResource image;
// The form factor for which a given screenshot applies.
FormFactor form_factor;
// This serves as the accessible name of the screenshot.
mojo_base.mojom.String16? label;
};
// Structure representing a share target file.
struct ManifestFileFilter {
mojo_base.mojom.String16? name;
// A sequence of accepted MIME types.
array<mojo_base.mojom.String16> accept;
};
// Structure representing a URL protocol handler.
struct ManifestProtocolHandler {
mojo_base.mojom.String16 protocol;
url.mojom.Url url;
};
struct ManifestUrlHandler {
url.mojom.Origin origin;
// A boolean that is used to show if a wildcard is present for the origin.
// If true, the application indicates that it wants to handle all subdomains
// of |origin|. If false, the application only wants to handle |origin|.
bool has_origin_wildcard;
};
struct ManifestScopeExtension {
url.mojom.Origin origin;
// A boolean that is used to show if a wildcard is present for the origin.
// If true, the application indicates that it wants to extend its scope to all
// subdomains of |origin|. If false, the application only wants to extend its
// scope to |origin|.
bool has_origin_wildcard;
};
// Structure representing lock screen capabilities.
struct ManifestLockScreen {
// A URL for launching a special instance of the web application on the lock
// screen of a device. If valid, this web application is declaring itself
// capable of being used on the lock screen.
url.mojom.Url start_url;
};
// Structure representing note-taking application capabilities.
struct ManifestNoteTaking {
// A URL for taking a new note in the web application. If valid, this web
// application is a note-taking application.
url.mojom.Url new_note_url;
};
// Structure representing a related application.
struct ManifestRelatedApplication {
// The platform on which the application can be found. This can be any
// string, and is interpreted by the consumer of the object.
mojo_base.mojom.String16? platform;
// URL at which the application can be found. One of |url| or |id| must be
// present.
url.mojom.Url? url;
// An id which is used to represent the application on the platform. One of
// |url| or |id| must be present.
mojo_base.mojom.String16? id;
};
// Structure representing how a Web Share target fills query parameters of an
// incoming share. These fields contain the names of the query parameters that
// will hold the value of the corresponding share data.
struct ManifestShareTargetParams {
mojo_base.mojom.String16? title;
mojo_base.mojom.String16? text;
mojo_base.mojom.String16? url;
// An array of share target files, which is represented by two members:
// name and accept.
array<ManifestFileFilter>? files;
};
// Structure representing how a Web Share target handles an incoming share.
struct ManifestShareTarget {
// This enum corresponds to HTTP methods, where kGet corresponds to GET
// and kPost corresponds to POST.
enum Method {
kGet,
kPost,
};
// This enum corresponds to HTTP enctype, where kApplication corresponds
// to application/x-www-url-encoded and kMultipart corresponds to
// multipart/form-data.
enum Enctype {
kFormUrlEncoded,
kMultipartFormData,
};
// The URL that will be opened when the share target is invoked.
url.mojom.Url action;
// The method that specifies the HTTP request method for web share target.
Method method;
// The enctype that specifies how share data is encoded in a POST request.
// It is ignored when method is "GET".
Enctype enctype;
ManifestShareTargetParams params;
};
struct ManifestFileHandler {
// The URL that will be opened when the file handler is invoked.
url.mojom.Url action;
// Human-readable name for the file handler. May be displayed in file manager.
mojo_base.mojom.String16 name;
// Icon representing the file handler. May be displayed in file manager.
array<ManifestImageResource> icons;
// A mapping of a MIME types to a corresponding list of file extensions.
map<mojo_base.mojom.String16, array<mojo_base.mojom.String16>> accept;
// How the app should be launched when there are multiple files being opened.
// For `kSingleClient`, they'll all be passed in a single launch. For
// `kMultipleClients`, multiple launched app instances will each get a single
// file.
enum LaunchType {
kSingleClient,
kMultipleClients,
};
LaunchType launch_type;
};
// Structure representing the translated manifest fields. Each field corresponds
// to a translatable field in the Web App Manifest and contains a translation of
// that field. Each field is optional as there is no mandatory field which must
// be translated in any locale.
struct ManifestTranslationItem {
mojo_base.mojom.String16? name;
mojo_base.mojom.String16? short_name;
mojo_base.mojom.String16? description;
};
// Structure representing customizations to the tab strip.
struct ManifestTabStrip {
HomeTabUnion home_tab;
NewTabButtonParams new_tab_button;
};
// Represents whether a particular tab strip customization is present or not.
// If kAuto, the platform can decide what the behaviour should be.
enum TabStripMemberVisibility {
kAuto,
kAbsent,
};
union HomeTabUnion {
TabStripMemberVisibility visibility;
HomeTabParams params;
};
// Structure representing the home tab customization to the tab strip.
struct HomeTabParams {
// If the array is empty, the platform can choose what icon to use. This is
// the same as setting 'auto' on the icons field.
array<ManifestImageResource> icons;
// TODO(crbug.com/1381374): Use URLPatternList once available.
array<SafeUrlPattern> scope_patterns;
};
// Structure representing the new tab button customization to the tab strip.
struct NewTabButtonParams {
// If url is not present, the platform can choose what to do. This is the
// same as setting 'auto' on the url field.
url.mojom.Url? url;
};
// Debug information for a parsed manifest.
struct ManifestDebugInfo {
array<ManifestError> errors;
string raw_manifest;
};
// An individual manifest parsing error.
struct ManifestError {
string message;
bool critical;
uint32 line;
uint32 column;
};
// Possible results of requesting the manifest for a document.
enum ManifestRequestResult {
// Something unexpectedly went wrong, no default manifest will be returned
// with this response.
kUnexpectedFailure,
// This page isn't allowed to have a manifest, for example because it has a
// unique origin. No default manifest will be returned, but the manifest url
// (if any) specified in the page is still returned.
kNoManifestAllowed,
// The page does not specify a manifest, a default manifest is returned
// instead.
kNoManifestSpecified,
// The manifest failed to fetch or failed to parse. A default manifest will
// be returned in addition to the manifest URL the page specified.
kManifestFailedToFetch,
kManifestFailedToParse,
// Success, the manifest was loaded from the URL specified by the page.
kSuccess
};