chromium/third_party/blink/public/mojom/subapps/sub_apps_service.mojom

// Copyright 2021 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;

enum SubAppsServiceResultCode {
  kSuccess,
  kFailure,
};

// `manifest_id_path` is the sub app id generated according to
// https://www.w3.org/TR/appmanifest/#dfn-identity, but only the path component
// of the full url.
// `install_url_path` is a path to a page hosting or containing a link to the
// app's manifest.
// Name of this struct can't be "SubAppsServiceAddParams" because it causes a
// collision in the Android mojo bindings (interface name "SubAppsService" plus
// method name "Add" plus suffix "Params" create the colliding name).
struct SubAppsServiceAddParameters {
  string manifest_id_path;
  string install_url_path;
};

struct SubAppsServiceAddResult {
  string manifest_id_path;
  SubAppsServiceResultCode result_code;
};

struct SubAppsServiceListResult {
  SubAppsServiceResultCode result_code;
  array<SubAppsServiceListResultEntry> sub_apps_list;
};

struct SubAppsServiceListResultEntry {
  string manifest_id_path;
  string app_name;
};

struct SubAppsServiceRemoveResult {
  string manifest_id_path;
  SubAppsServiceResultCode result_code;
};

// Sub Apps APIs allow installed PWAs to install shortcuts to their various
// sub-parts by means of installing the sub-component.  Example: main app hosted
// at https://office.org/ which provides a full set of office productivity tools
// creates a new shortcut to itself with `spreadsheet` as the install_path
// effectively adding the Spreadsheet app to the launcher surface.
// NOTE: This Mojo interface is per-frame, there is one logical instance per
// frame, and it's main-frame only. It is only valid for already-installed apps,
// and has an origin associated with it.
interface SubAppsService {
  // Installs one or more sub-apps of an already-installed app corresponding to
  // this instance of SubAppsService.
  Add(array<SubAppsServiceAddParameters> sub_apps_to_add) => (array<SubAppsServiceAddResult> result);

  // List all sub-apps installed by the app making the API call.
  List() => (SubAppsServiceListResult result);

  // Uninstalls the sub-apps represented by the given argument previously
  // installed via the `Add` method by the same app making the current API call.
  Remove(array<string> manifest_id_paths) => (array<SubAppsServiceRemoveResult> result);
};