// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
module data_sharing.mojom;
import "url/mojom/url.mojom";
import "components/data_sharing/public/protocol/group_data.mojom";
// Factory ensures that the Page and PageHandler interfaces are always created
// together without requiring an initialization call from the WebUI to the
// handler.
interface PageHandlerFactory {
// The WebUI calls this method when the page is first initialized.
CreatePageHandler(pending_remote<Page> page,
pending_receiver<PageHandler> handler);
};
// Browser-side handler for requests from WebUI page.
interface PageHandler {
// Ask the browser to show the UI. Called when the page is loaded and ready to
// show.
ShowUI();
// Called when the api page is fully initialized and authenticated.
// All other APIs on the Page such as ReadGroups should only be invoked
// after ApiInitComplete.
ApiInitComplete();
// `group_id` connects the shared tab group with people group. `access_token`
// is used to check link validity. Chrome stitches them together with a host
// and generates an invite link. Owner can share the link to the public.
GetShareLink(string group_id, string access_token) => (url.mojom.Url url);
// `tab_group_id` is the local id of the group in tab strip that gets shared.
// `group_id` is the id that connects the people with the shared tab group.
AssociateTabGroupWithGroupId(string tab_group_id, string group_id);
};
// WebUI-side handler for requests from the browser.
interface Page {
// Called when the access token of the primary account is fetched.
// The token is used by data sharing SDK to authenticate the current user.
OnAccessTokenFetched(string access_token);
// Read groups given group_ids.
ReadGroups(array<string> group_ids) => (array<GroupData> groups);
};