chromium/chromeos/crosapi/mojom/synced_session_client.mojom

// Copyright 2023 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 "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
import "ui/gfx/image/mojom/image.mojom";
import "url/mojom/url.mojom";

// Contains information regarding a Chrome tab for sync.
[Stable]
struct SyncedSessionTab {
  url.mojom.Url current_navigation_url@0;
  mojo_base.mojom.String16 current_navigation_title@1;
  mojo_base.mojom.Time last_modified_timestamp@2;
};

// Contains all tabs synced to a Chrome window.
[Stable]
struct SyncedSessionWindow {
  array<SyncedSessionTab> tabs@0;
};

// Contains all windows in a Chrome session.
[Stable]
struct SyncedSession {
  // |session_name| is a user-visible name that maps to session_name in
  // //components/sync_sessions/synced_session.h.
  string session_name@0;
  mojo_base.mojom.Time modified_time@1;
  array<SyncedSessionWindow> windows@2;
};

// Used by ash-chrome to request favicons for SyncedSessionTabs.
[Stable]
interface SyncedSessionClientFaviconDelegate {
  // Request a favicon for the given page URL. Responds with an empty image
  // if the favicon is not found.
  GetFaviconImageForPageURL@0(url.mojom.Url page_url)
      => (gfx.mojom.ImageSkia? image);
};

// Defines an API for updating synced foreign sessions.
[Stable]
interface SyncedSessionClient {
  // Notifies ash-chrome when any foreign phone session is updated.
  OnForeignSyncedPhoneSessionsUpdated@0(array<SyncedSession> sessions);

  // Called by Lacros when the user enables or disables tab sync.
  // Lacros will call this with an initial value when the connection
  // is established. Receivers should initialize this to "false" until
  // the first update is received.
  [MinVersion=1]
  OnSessionSyncEnabledChanged@1(bool enabled);

  // Called by Lacros to register a delegate which Ash can use to request
  // favicons.
  [MinVersion=2]
  SetFaviconDelegate@2(
      pending_remote<SyncedSessionClientFaviconDelegate> delegate);
};