chromium/chromeos/crosapi/mojom/digital_goods.mojom

// 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 crosapi.mojom;

import "components/digital_goods/mojom/digital_goods.mojom";
import "url/mojom/url.mojom";

// Implemented in ash-chrome. Allows lacros-chrome to perform Digital Goods
// operations (forwarded to ARC).
[Stable, Uuid="6f2fbc9e-2ff1-47bd-a15d-08e12c226f61"]
interface DigitalGoods {
  // Queries the associated backend for information about one or more items.
  GetDetails@0(string web_app_id, url.mojom.Url scope, array<string> item_ids)
      => (payments.mojom.BillingResponseCode code,
          array<payments.mojom.ItemDetails> item_details_list);

  // Queries the associated backend for information on all items that are
  // currently owned by the user. May include unconfirmed purchases.
  ListPurchases@1(string web_app_id, url.mojom.Url scope)
      => (payments.mojom.BillingResponseCode code,
          array<payments.mojom.PurchaseReference> purchase_reference_list);

  // Queries the associated backend for information on the latest purchase for
  // each item type ever purchased by the user. May include expired or consumed
  // purchases.
  ListPurchaseHistory@2(string web_app_id, url.mojom.Url scope)
      => (payments.mojom.BillingResponseCode code,
          array<payments.mojom.PurchaseReference> purchase_reference_list);

  // Informs the associated backend that the purchase identified by
  // |purchase_token| was used up.
  Consume@3(string web_app_id, url.mojom.Url scope, string purchase_token)
      => (payments.mojom.BillingResponseCode code);
};

// Implemented in ash-chrome. Allows lacros-chrome to create a |DigitalGoods|
// instance.
[Stable, Uuid="1197d2ad-0f33-49e4-b6d6-370e255a9896"]
interface DigitalGoodsFactory {
  // Creates a DigitalGoods instance. The |digital_goods| is non-null iff
  // |code| == kOk.
  CreateDigitalGoods@0(string payment_method, string web_app_id)
    => (payments.mojom.CreateDigitalGoodsResponseCode code,
        pending_remote<DigitalGoods>? digital_goods);
};