blob: 1fee2173531406a361bc0e445ead7d4fd3df917b [file] [log] [blame]
// Copyright 2017 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 blink.mojom;
import "mojo/public/mojom/base/string16.mojom";
import "skia/public/interfaces/bitmap.mojom";
import "url/mojom/url.mojom";
// Directionality options that can be indicated for notifications.
enum NotificationDirection {
LEFT_TO_RIGHT,
RIGHT_TO_LEFT,
AUTO,
};
// The different types of actions that can be added to a Notification.
enum NotificationActionType {
BUTTON,
TEXT
};
// Structure representing an action button associated with a Notification.
struct NotificationAction {
// Type of action this structure represents.
NotificationActionType type;
// Action name that the author can use to distinguish them.
string action;
// Title of the action button.
mojo_base.mojom.String16 title;
// URL of the icon for the button. May be empty if no url was specified.
url.mojom.Url icon;
// Placeholder to display for text-based actions in absence of user input.
mojo_base.mojom.String16? placeholder;
};
// Structure representing the information associated with a Web Notification.
struct NotificationData {
// The maximum size of developer-provided data to be stored in the |data|
// property of this structure, in bytes.
const uint64 kMaximumDeveloperDataSize = 1048576; // 1024 * 1024 (= 1 MB)
// Title to be displayed with the Web Notification.
mojo_base.mojom.String16 title;
// Hint to determine the directionality of the displayed notification.
NotificationDirection direction = LEFT_TO_RIGHT;
// BCP 47 language tag describing the notification's contents. Optional.
string? lang;
// Contents of the notification.
mojo_base.mojom.String16 body;
// Tag of the notification. Notifications sharing both their origin and their
// tag will replace the first displayed notification.
string tag;
// URL of the image contents of the notification. May be empty if no url was
// specified.
url.mojom.Url image;
// URL of the icon which is to be displayed with the notification.
url.mojom.Url icon;
// URL of the badge representing the website displaying the notification.
url.mojom.Url badge;
// Vibration pattern for the notification. Each element in the array
// represents a number of milliseconds to vibrate (even indices), or wait
// (odd indices). This follows the syntax of the Vibration API - see
// https://w3c.github.io/vibration/
//
// TODO(https://crbug.com/797306): Make this an array of base::TimeDeltas.
array<int32>? vibration_pattern;
// The time at which the event the notification represents took place,
// in milliseconds since the Unix epoch.
// TODO(https://crbug.com/797306): Use base::TimeTicks instead of a double.
double timestamp = 0;
// Whether default notification indicators (sound, vibration, light) should
// be played again if the notification is replacing an older notification.
bool renotify = false;
// Whether default notification indicators (sound, vibration, light) should
// be suppressed.
bool silent = false;
// Whether the notification should remain onscreen indefinitely, rather than
// being auto-minimized to the notification center (if allowed by platform).
bool require_interaction = false;
// Developer-provided data associated with the notification, in the form of
// a serialized string. Must not exceed the number of bytes specified by
// |kMaximumDeveloperDataSize|.
array<uint8>? data;
// Actions that should be shown as buttons on the notification.
array<NotificationAction>? actions;
};
// Structure representing the resources associated with a Web Notification.
struct NotificationResources {
// Image contents of the notification. May be empty if no image was specified.
skia.mojom.Bitmap? image;
// Icon to be displayed with the notification.
skia.mojom.Bitmap? icon;
// Badge representing the website displaying the notification.
skia.mojom.Bitmap? badge;
// Icons for the actions. The size of |action_icons| must match the size
// of |actions| in the corresponding NotificationData.
array<skia.mojom.Bitmap?>? action_icons;
};