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

import "chrome/browser/glic/host/glic_features.mojom";
import "chrome/common/actor_webui.mojom";
import "chrome/common/glic_enums.mojom";
import "components/content_settings/core/common/content_settings_types.mojom";
import "mojo/public/mojom/base/absl_status.mojom";
import "mojo/public/mojom/base/big_buffer.mojom";
import "mojo/public/mojom/base/byte_string.mojom";
import "mojo/public/mojom/base/proto_wrapper.mojom";
import "mojo/public/mojom/base/string16.mojom";
import "mojo/public/mojom/base/time.mojom";
import "mojo/public/mojom/base/unguessable_token.mojom";
import "mojo/public/mojom/base/values.mojom";
import "mojo/public/mojom/base/version.mojom";
import "skia/public/mojom/bitmap.mojom";
import "third_party/blink/public/mojom/content_extraction/ai_page_content_metadata.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
import "url/mojom/origin.mojom";
import "url/mojom/url.mojom";

// Warning: a script copies some enums from this file over to glic_api.ts.
// Run this script to update them, and read it for details.
// chrome/browser/resources/glic/glic_api_impl/generate.py

// @generate glic_api
// Settings for Gemini Enterprise.
struct GeminiEnterpriseSettings {
  string project_id;
  string app_id;
  string location;
};

enum GlicExperimentalTriggeringState {
  kUnavailable = 0,
  kNeedsOptIn = 1,
  kReady = 2,
};

// @generate glic_api
enum FileUploadPolicyState {
  kEnabled = 0,
  kDisabled = 1,
};

// Struct containing data about eligibility for GLIC.
struct ProfileEnablement {
  // Whether the GLIC feature is enabled.
  bool feature_enabled;

  // Whether the profile is regular (e.g. not incognito)
  bool is_regular_profile;

  // Whether Glic is rolled out to the profile. Rollout can be enabled by the
  // `GlicRollout` flag, or by the `GlicTieredRollout` flag and synced pref.
  bool is_rolled_out;

  // Whether a primary account exists and has the required Account Capabilities
  // to use Glic.
  bool primary_account_is_capable;

  // Whether the primary account exists and is fully signed in.
  bool primary_account_is_fully_signed_in;

  // Whether the profile is allowed to use Glic by chrome policy.
  bool allowed_by_chrome_policy;

  // Whether the profile is allowed to use Glic by remote admin.
  bool allowed_by_remote_admin;

  // Whether the profile is allowed to use Glic by remote for other reasons.
  bool allowed_by_remote_other;

  // Whether the user has consented with the FRE.
  bool fre_is_consented;

  // Whether Glic access is allowed by country filtering.
  bool allowed_by_country_filter;

  // Whether Glic access is allowed by UI locale filtering.
  bool allowed_by_locale_filter;

  // Whether the user has consented to actuation.
  bool actuation_is_consented;

  // Whether live (audio) functionality is allowed for this account type.
  bool live_allowed;

  // Whether 'Create Image with Gemini' functionality is allowed for this
  // account type.
  bool share_image_allowed;

  // Settings for Gemini Enterprise.
  GeminiEnterpriseSettings? gemini_enterprise_settings;

  // Summary of whether actuation is enabled, and if not, why not.
  ActuationEligibility actuation_eligibility;

  // Summary of whether Glic API actuation is enabled, and if not, why not.
  ActuationEligibility glic_api_actuation_eligibility;

  GlicExperimentalTriggeringState glic_experimental_triggering_state;
};

// Basic configuration information about Glic.
struct ConfigInfo {
  // The URL from which the guest web client is loaded from.
  url.mojom.Url guest_url;

  // User configured preset URLs for different environments of the guest web
  // client.
  url.mojom.Url autopush_guest_url;
  url.mojom.Url staging_guest_url;
  url.mojom.Url preprod_guest_url;
  url.mojom.Url prod_guest_url;

  // User configured preset URL for web continuity.
  url.mojom.Url web_continuity_originating_host_url;
};

// Whether actuation is enabled, and if not, why not.
enum ActuationEligibility {
  kEligible,
  kMissingAccountCapability,
  kMissingChromeBenefits,
  kDisabledByPolicy,
  kEnterpriseWithoutManagement,
  kPlatformUnsupported,
};

// @generate glic_api
// The type of user input reaction.
[Stable, Extensible]
enum MetricUserInputReactionType {
  // An unknown reaction type.
  [Default] kUnknown = 0,
  // A canned reaction which can be presented without communication with the
  // server.
  kCanned = 1,
  // A reaction which requires some generic modeling to produce.
  kModel = 2,
};

// Use ongoing conversation for the tab if it exists. Otherwise, fall back
// to the default behavior for opening the UI (typically a new conversation).
struct DefaultConversation {};

// Always invoke into a new conversation.
struct NewConversation {};

// Defines the conversation an invocation targets.
union InvokeConversationSelection {
  DefaultConversation default_conversation;
  NewConversation new_conversation;
  string conversation_id;
};

// Targets the default Glic surface (e.g., side panel).
struct DefaultSurfaceMojo {};

// Targets a new tab for the invocation.
struct NewTabMojo {
  bool open_in_foreground;
};

// Defines the surface an invocation targets.
union InvokeTargetSurface {
  DefaultSurfaceMojo default_surface;
  NewTabMojo new_tab;
};

// @generate glic_api
// Configuration to override the default ZSS behavior for the invocation,
// only having an impact if ZSS would be shown for the invocation.
struct ZssConfig {
  // Additional content to inject into the body of the ZSS message.
  string? additional_content;
};

// @generate glic_api
// Reason for failure while acting.
[Stable, Extensible]
enum PerformActionsErrorReason {
  [Default] kUnknown = 0,
  // The serialized actions proto failed to parse.
  [MinVersion=1] kInvalidProto = 1,

  // The actions proto did not set a task id.
  [MinVersion=2] kMissingTaskId = 2,
};

// @generate glic_api
// Reason for failure when creating an actor task.
[Stable, Extensible]
enum CreateTaskErrorReason {
  [Default] kUnknown = 0,

  // The host does not support the actor task system.
  kTaskSystemUnavailable = 1,

  // The host already has an existing task in progress. The client must stop it
  // before requesting a new task.
  [MinVersion=1] kExistingActiveTask = 2,

  // The user's browser policy or account settings prevent creating actor tasks.
  [MinVersion=2] kBlockedByPolicy = 3,

  // CreateTask was called on a Glic instance which does not have a registered
  // conversation.
  [MinVersion=3] kConversationNotRegistered = 4,
};

// @generate glic_api
// The state of an actor task.
[Stable, Extensible]
enum ActorTaskState {
  [Default] kUnknown = 0,
  // The actor task is idle and waiting for the next action instruction.
  kIdle = 1,
  // The actor task is performing an action.
  kActing = 2,
  // The actor task is paused and waiting to be resumed or stopped.
  kPaused = 3,
  // The actor task is stopped and going away.
  kStopped = 4,
};

// @generate glic_api
// The reason/source of why an actor task was paused.
[Stable, Extensible]
enum ActorTaskPauseReason {
  // Actor task was paused by the model.
  [Default] kPausedByModel = 0,
  // Actor task was puased by the user.
  kPausedByUser = 1,
};

// @generate glic_api
// Next version: 3
// The reason/source of why an actor task was stopped.
[Stable, Extensible]
enum ActorTaskStopReason {
  // Actor task is complete.
  [Default] kTaskComplete = 0,
  // Actor task was stopped by the user.
  kStoppedByUser = 1,
  // Actor task was stopped because the model reported a failure.
  [MinVersion=1] kModelError = 2,
  // Actor task was stopped by choosing a new conversation.
  [MinVersion=2] kUserStartedNewChat = 3,
  // Actor task was stopped by choosing a previous conversation.
  [MinVersion=2] kUserLoadedPreviousChat = 4,
};

// @generate glic_api
// The reason/source of why an actor task was interrupted.
[Stable, Extensible]
enum ActorTaskInterruptReason {
  // Actor task is interrupted for an unknown reason.
  [Default] kUnknownReason = 0,
  // Actor task is complete.
  kTaskComplete = 1,
  // Actor task was waiting for user input.
  kWaitingUserInput = 2,
  // Actor task was waiting for user to provide clarifications on the current
  // task.
  kWaitingUserClarification = 3,
  // Actor task was waiting for user to confirm an action.
  kWaitingUserConfirmation = 4,
  // Actor task was waiting for user to take over.
  kWaitingUserTakeOver = 5,
  // Actor task was waiting for irrelevant user input.
  kWaitingIrrelevantUserInput = 6,
  // Actor task was waiting for user to respond to unsafe counter-abuse verdict.
  [MinVersion=1] kWaitingUnsafeCounterAbuseVerdict = 7,
  // Actor task was waiting for user to consent on experimental triggering.
  [MinVersion=2] kWaitingForExperimentalTriggeringConsent = 8,
};

// @generate glic_api
// Reason why capturing desktop screenshot failed. NOTE: This may be extended in
// the future so avoid using complete switches on the currently used enum
// values.
[Stable, Extensible]
enum CaptureScreenshotErrorReason {
  // Screen capture or frame encoding failure.
  [Default] kUnknown = 0,
  // Screen capture requested but already in progress of serving another
  // request.
  kScreenCaptureRequestThrottled = 1,
  // User declined screen capture dialog before taking a screenshot.
  kUserCancelledScreenPickerDialog = 2,
};

union GetContextResult {
  string error_reason;
  TabContextResult tab_context;
};

struct GetContextResultWithActionResultCode {
  GetContextResult get_context_result;
  // Note that this is an enum ActionResultCode from chrome/common/actor.mojom.
  // It would be tedious to import the actual enum here and the renderer doesn't
  // need the type, so we just use an int here. It is expected that the client
  // has an equivalent enum definition. See http://shortn/_gLyPxrRm6p
  int32? action_result;
};

union CaptureScreenshotResult {
  CaptureScreenshotErrorReason error_reason;
  Screenshot screenshot;
};

// @generate glic_api
// Information from a signed-in Chrome user profile.
struct UserProfileInfo {
  // @glic_ignore
  skia.mojom.BitmapN32? avatar_icon;
  // The full name displayed for this profile.
  string display_name;
  // The given name for this profile.
  // @glic_optional
  string given_name;
  // The local profile name, which can be customized by the user.
  // @glic_optional
  string local_profile_name;
  // The profile email.
  string email;
  // Whether the profile's signed-in account is a managed account.
  /// See `policy::ManagementService::IsAccountManaged()`.
  // @glic_optional
  bool is_managed;
};

// @generate glic_api
// Safe Browsing Threat Type.
[Stable, Extensible]
enum SbThreatType {
  // Default value.
  [Default] kUnspecified = 0,
  kSocialEngineering = 1,
  kMalware = 2,
  kUnwantedSoftware = 3,
};

// @generate glic_api
// The result from checking a page with Safe Browsing.
struct SafeBrowsingVerdict {
  string url;
  SbThreatType threat_type;
  bool show_interstitial;
};

// @generate glic_api
// The type of counter abuse verdict that was received.
struct CounterAbuseVerdict {
  SafeBrowsingVerdict sb_verdict_result;
};

// @generate glic_api
// The platform glic is running on.
enum Platform {
  kUnknown = 0,
  kMacOS = 1,
  kWindows = 2,
  kLinux = 3,
  kChromeOS = 4,
  kAndroid = 5,
};

// @generate glic_api
// The form factor of the device glic is running on.
enum FormFactor {
  kUnknown = 0,
  kDesktop = 1,
  kPhone = 2,
  kTablet = 3,
};

// The result of `WebClientCreated()`. Contains information that needs to be
// available before the web client is initialized.
struct WebClientInitialState {
  PanelState panel_state;
  // Initially focused tab data.
  FocusedTabData focused_tab_data;
  bool microphone_permission_enabled;
  bool location_permission_enabled;
  bool tab_context_permission_enabled;
  bool os_location_permission_enabled;
  double zoom_factor;

  string hotkey;
  mojo_base.mojom.Version chrome_version;
  Platform platform;
  FormFactor form_factor;
  // Whether the glic panel can currently be attached to a browser window.
  bool can_attach;
  // Whether the panel is active. See `NotifyPanelActiveChange`.
  bool panel_is_active;
  bool browser_is_open;
  bool instance_is_active;
  bool enable_zero_state_suggestions;
  bool enable_cached_get_user_profile_info;
  // Whether features::kGlicActor is enabled.
  bool enable_act_in_focused_tab;
  // Whether features::kGlicScrollTo is enabled.
  bool enable_scroll_to;
  // Whether features::kGlicDefaultTabContextSetting is enabled.
  bool enable_default_tab_context_setting_feature;
  // Whether the glic default tab context setting is enabled.
  bool default_tab_context_setting_enabled;
  // Whether the glic closed captioning setting is enabled.
  bool closed_captioning_setting_enabled;
  // Whether features::kGlicUserStatusCheck is enabled with
  // features::kGlicUserStatusRefreshApi true.
  bool enable_maybe_refresh_user_status;
  // Whether multi tab is enabled.
  bool enable_multi_tab;
  // Whether get context for actor from tab is enabled.
  bool enable_get_context_actor;
  // The list of capabilities of the host.
  array<HostCapability> host_capabilities;
  // Whether get page metadata is enabled.
  bool enable_get_page_metadata;
  // Whether capture region is enabled.
  bool enable_capture_region;
  // Whether kGlicWebActuationSetting is enabled.
  bool enable_web_actuation_setting_feature;
  // Whether the user enabled actuation setting is enabled.
  bool actuation_on_web_setting_enabled;
  // Whether the host has the capability to act on web.
  bool can_act_on_web;
  // Whether kGlicActivateTabApi is enabled.
  bool enable_activate_tab;
  // Whether kGlicGetTabByIdApi is enabled.
  bool enable_get_tab_by_id;
  // Whether kGlicOpenPasswordManagerSettingsPageApi is enabled.
  bool enable_open_password_manager_settings_page;
  // Whether kGlicTrustFirstOnboarding is enabled.
  bool enable_trust_first_onboarding;
  // Whether the user has completed the onboarding flow.
  bool onboarding_completed;
  // Whether the skills feature is enabled.
  bool enable_skills;
  // Whether glic API getTabFaviconById is enabled.
  bool enable_get_tab_favicon_by_id;
  // Whether the processCounterAbuseVerdict API is enabled.
  bool enable_process_counter_abuse_verdict;
  // Settings for Gemini Enterprise.
  GeminiEnterpriseSettings? gemini_enterprise_settings;
  // Whether features::kGlicActorAutofillOneTimePassword is enabled.
  bool enable_gmail_otp_opt_in;
  // Whether the Gmail OTP confirmation dialog is enabled.
  bool enable_gmail_otp_confirmation;
  // Whether file upload is allowed by the enterprise policy.
  FileUploadPolicyState file_upload_policy_state;
};

// @generate glic_api
// Enum to specify the image format of the screenshot.
[Stable, Extensible]
enum ScreenshotImageFormat {
  // JPEG screenshot format. This is the default format.
  [Default] kJpeg = 0,
  // PNG screenshot format.
  kPng = 1,
  // WEBP screenshot format.
  kWebp = 2,
};

// @generate glic_api
// Enum to specify the compression quality of the screenshot. Depending on
// screenshot format, the compression quality may not be respected or may mean
// something different.
[Stable, Extensible]
enum ScreenshotCompressionQuality {
  // No compression.
  [Default] kNone = 0,
  // Low compression quality.
  kLow = 1,
  // Medium compression quality.
  kMedium = 2,
  // High compression quality.
  kHigh = 3,
};

// @generate glic_api
// Options for screenshot collection.
struct ScreenshotCollectionOptions {
  // Screenshot will be scaled to fit the max width and height while
  // maintaining the aspect ratio.
  // If not set or set to 0, the screenshot will be captured without limiting
  // the width (so long as the height is not limited).
  // @glic_optional
  uint32 max_width;
  // Screenshot will be scaled to fit the max width and height while maintaining
  // the aspect ratio.
  // If not set or set to 0, the screenshot will be captured without limiting
  // the height (so long as the width is not limited).
  // @glic_optional
  uint32 max_height;
  // The format of the screenshot. If not set, the screenshot will be returned
  // as a jpeg image.
  // @glic_optional
  ScreenshotImageFormat screenshot_image_format;
  // The compression quality of the screenshot. If not set, the screenshot will
  // be returned with medium compression quality.
  // @glic_optional
  ScreenshotCompressionQuality screenshot_compression_quality;
};

// @generate glic_api
// Options for getting context from a tab.
struct TabContextOptions {
  // If true, an innerText representation of the page will be included in the
  // response.
  // @glic_optional
  bool inner_text;

  // Maximum size in UTF-8 bytes that the returned innerText data may contain.
  // If exceeded, the innerText will be truncated to the nearest character that
  // will leave the string less than or equal to the specified byte size.
  // Defaults to DEFAULT_INNER_TEXT_BYTES_LIMIT. If it is zero or negative,
  // the innerText will be empty.
  // @glic_optional
  uint32 inner_text_bytes_limit;

  // @deprecated Use `screenshotCollectionOptions` instead.
  //
  // If true, a screenshot of the user visible viewport will be included in the
  // response. If `screenshotCollectionOptions` is set, the screenshot will be
  // captured with the specified options regardless of this field.
  // @glic_optional
  bool viewport_screenshot;

  // If true, returns the serialized annotatedPageContent proto.
  // @glic_optional
  bool annotated_page_content;

  // Maximum number of meta tags (per Document/Frame) to include in the
  // response. Defaults to 0 if not provided.
  // @glic_optional
  uint32 max_meta_tags;

  // If true, and the focused tab contains a PDF as the top level document,
  // returns PdfDocumentData.
  // @glic_optional
  bool pdf_data;

  // Maximum size in bytes for returned PDF data. If this size is exceeded,
  // PdfDocumentData is still returned, but it will not contain PDF bytes.
  // Defaults to DEFAULT_PDF_SIZE_LIMIT. If it is zero or negative, PDF bytes
  // will never be returned.
  // @glic_optional
  uint32 pdf_size_limit;

  // The mode of the annotated page content if included in the response. This
  // maps directly to the AnnotatedPageContentMode enum in the proto.
  // @glic_optional
  uint32 annotated_page_content_mode = 0;

  // If set, the screenshot collection options will be used to capture the
  // screenshot. Otherwise, the screenshot will be captured with the default
  // options.
  // @glic_optional
  ScreenshotCollectionOptions screenshot_collection_options;
};

// @generate glic_api
// Used for customizing the list of pin candidates.
struct GetPinCandidatesOptions {
  // The maximum number of candidates to consider. Can return fewer.
  uint32 max_candidates;
  // An optional query string.
  string? query;
};

// @generate glic_api
// Params for scrollTo().
struct ScrollToParams {
  // Used to specify content to scroll to and highlight.
  ScrollToSelector selector;

  // Whether we should highlight the content selected. True by default if not
  // specified. If false, the content is scrolled to but not highlighted.
  // @glic_optional
  bool highlight;

  // Identifies the document we want to perform the scrollTo operation on. When
  // specified, we verify that the currently focused tab's document matches the
  // ID, and throw an error if doesn't. This is a required parameter for all
  // document types except PDF (see `url` below), and a NOT_SUPPORTED error will
  // be thrown if it is not specified.
  mojo_base.mojom.UnguessableToken? document_id;

  // Identifies the url of a document we want to perform the scrollTo
  // operation on. This is only required when scrolling PDF documents (and is
  // ignored otherwise; other document types require `documentId` to be
  // specified instead), and is used to verify that the currently focused tab
  // still points to a PDF with that URL. If not specified, and the currently
  // focused tab has a PDF loaded, a NOT_SUPPORTED error will be thrown.
  url.mojom.Url? url;
};

// @generate glic_api
// Used to select content to scroll to. Note that only one concrete selector
// type can be present.
// Additional selector types will be added to this API in the future.
union ScrollToSelector {
  ScrollToTextSelector exact_text;
  ScrollToTextFragmentSelector text_fragment;
  ScrollToNodeSelector node;
};

// @generate glic_api
// scrollTo() selector to select exact text in HTML and PDF documents within
// a given search range starting from the start node (specified with
// searchRangeStartNodeId) to the end of the document. If not specified, the
// search range will be the entire document.
// The documentId in ScrollToParams must be specified if a
// searchRangeStartNodeId is specified.
struct ScrollToTextSelector {
  // Exact text to select.
  string text;
  // See common_ancestor_dom_node_id in proto ContentAttributes
  // in components/optimization_guide/proto/features/common_quality_data.proto.
  int32? search_range_start_node_id;
};

// @generate glic_api
// scrollTo() selector to select a range of text in HTML and PDF documents
// within a given search range starting from the start node (specified with
// searchRangeStartNodeId) to the end of the document. If not specified, the
// search range will be the entire document.
// The documentId in ScrollToParams must be specified if a
// searchRangeStartNodeId is specified.
// Text selected will match textStart <anything in the middle> textEnd.
struct ScrollToTextFragmentSelector {
  // Start of text to select.
  string text_start;
  // End of text to select.
  string text_end;
  // See common_ancestor_dom_node_id in proto ContentAttributes
  // in components/optimization_guide/proto/features/common_quality_data.proto.
  int32? search_range_start_node_id;
};

// @generate glic_api
// scrollTo() selector to select all text inside a specific node (corresponding
// to the provided nodeId). documentId must also be specified in ScrollToParams
// when this selector is used.
struct ScrollToNodeSelector {
  // Value should be obtained from common_ancestor_dom_node_id in
  // ContentAttributes (see
  // components/optimization_guide/proto/features/common_quality_data.proto)
  int32 node_id;
};

// @generate glic_api
// Reason why scrollTo() failed.
// Next version: 8
// LINT.IfChange(ScrollToErrorReason)
[Stable, Extensible]
enum ScrollToErrorReason {
  // Invalid params were provided to scrollTo(), or the browser doesn't support
  // scrollTo() yet.
  [Default] kNotSupported = 0,

  // scrollTo() was called again before this call finished processing.
  [MinVersion=1] kNewerScrollToCall,

  // There is no tab currently in focus.
  [MinVersion=1] kNoFocusedTab,

  // The input selector did not match any content in the document or a given
  // range.
  [MinVersion=1] kNoMatchFound,

  // The currently focused tab changed or navigated while processing the
  // scrollTo() call.
  [MinVersion=1] kFocusedTabChangedOrNavigated,

  // The document_id or url provided doesn't match the active document in the
  // primary main frame of the currently focused tab. The document may have been
  // navigated away, may not currently be in focus, or may not be in a primary
  // main frame (we don't currently support iframes).
  [MinVersion=2] kNoMatchingDocument,

  // The search range starting from DOMNodeId did not result in a valid range.
  [MinVersion=5] kSearchRangeInvalid,

  // Page context access is disabled.
  [MinVersion=6] kTabContextPermissionDisabled,

  // The web client requested to drop the highlight via
  // `dropScrollToHighlight()`.
  [MinVersion=7] kDroppedByWebClient,
};

// LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:GlicScrollToErrorReason)

// @generate glic_api
// Zero-state suggestion for the current tab.
struct SuggestionContent {
  // The suggestion text. Always provided.
  string suggestion;
};

// @generate glic_api
// Next version: 3
// Enum to specify the source of the Skill.
// LINT.IfChange(SkillSource)
[Stable, Extensible]
enum SkillSource {
  [Default] kUnknown = 0,
  // Skill created by Google.
  kFirstParty = 1,
  // Skill created by an end-user.
  kUserCreated = 2,
  // Skill derived from a first party skill.
  [MinVersion=1] kDerivedFromFirstParty = 3,
  // Skill sourced from the EnterprisePublishedSkills enterprise policy.
  [MinVersion=2] kEnterprise = 4,
  // Skill derived from an enterprise skill.
  [MinVersion=2] kDerivedFromEnterprise = 5,
};

// LINT.ThenChange(//components/skills/public/skill.mojom:SkillSource,
// //components/sync/protocol/skill_specifics.proto:SkillSource)

// @generate glic_api
// LINT.IfChange(Skill)
// Represents a single skill preview.
struct SkillPreview {
  // A unique identifier for the skill.
  string id;
  // The user-facing name of the skill.
  string name;
  // The icon for the skill.
  string icon;
  // The source of the skill.
  SkillSource source;
  // The description of the skill.
  string description;
  // The name of the curator for this skill.
  string? curated_by;
  // The image URL to show when rendering this skill.
  url.mojom.Url? image_url;
  // The category of the skill.
  string? category;
  // The time when the skill was created.
  mojo_base.mojom.Time? creation_time;
};

// @generate glic_api
// A single skill.
struct Skill {
  // A preview of the skill.
  SkillPreview preview;
  // The underlying LLM prompt for the skill.
  string prompt;
  // The id of the source skill this skill is derived from. This is only
  // present if the SkillSource is DERIVED_FROM_FIRST_PARTY.
  string? source_skill_id;
};

// LINT.ThenChange(//components/skills/public/skill.mojom:Skill,
// //components/skills/public/skill.h:Skill)

// @generate glic_api
struct CreateSkillRequest {
  // A unique identifier for the skill. This is only available when the user is
  // trying to remix a 1P skill.
  // @glic_optional
  string id;
  // The user-facing name of the skill. Only available in 1P remix flow.
  // @glic_optional
  string name;
  // The icon for the skill. Only available in 1P remix flow.
  // @glic_optional
  string icon;
  // The source of the skill.
  // @glic_optional
  SkillSource source;
  // A prompt for the skill, which can be empty.
  string prompt;
  // The description of the skill. Only available in 1P remix flow.
  // @glic_optional
  string description;
};

// @generate glic_api
// Request to update a skill.
struct UpdateSkillRequest {
  // The unique identifier of the skill to be updated.
  string id;
};

// @generate glic_api
// Enum to specify the skills web client event for metrics recording.
// Includes both direct user interactions and WebClient state
// transitions to track feature funnels.
// LINT.IfChange(SkillsWebClientEvent)
[Stable, Extensible]
enum SkillsWebClientEvent {
  // Default value for unknown or uninitialized actions.
  [Default] kUnknown = 0,
  // User invoked a first-party skill.
  kUsedFirstPartySkill = 1,
  // User invoked a skill they created themselves.
  kUsedUserCreatedSkill = 2,
  // User invoked a skill that was remix/derived from a first-party skill.
  kUsedDerivedFirstPartySkill = 3,
  // User typed '/' or triggered the skills menu.
  kOpenedMenu = 4,
  // User clicked the 'Manage skills' button from the slash menu.
  kClickedManageFromMenu = 5,
  // User clicked the 'Add skill' button from the slash menu.
  kClickedAddFromMenu = 6,
  // User clicked the edit button on an existing skill preview.
  kClickedEditFromMenu = 7,
  // User clicked the generic '+' button on a 1P skill preview.
  kClickedAddOn1pSkill = 8,
  // User clicked the 'Save as Skill' chip that appears on hover.
  kClickedSaveAsSkillHoverChip = 9,
  // User clicked the 'Edit Skill' chip that appears on hover.
  [MinVersion=1] kClickedEditSkillHoverChip = 10,
  // User clicked the 'Browse skills' button from the plus menu.
  [MinVersion=2] kClickedBrowseSkillFromPlusMenu = 11,
  // User clicked a skill from the plus menu.
  [MinVersion=2] kClickedSkillFromPlusMenu = 12,
  // User clicked the 'Manage skills' button from the plus menu.
  [MinVersion=2] kClickedManageSkillFromPlusMenu = 13,
  // User clicked the 'More' button from the slash menu.
  [MinVersion=2] kClickedMoreFromMenu = 14,
  // User clicked the 'Manage skills' button from the slash skills submenu.
  // Deprecated. Use kClickedManageFromMenu instead.
  [MinVersion=2] kClickedManageSkillFromMenu = 15,
  // User clicked a skill from the slash menu.
  [MinVersion=2] kClickedSkillFromMenu = 16,
  // User clicked the 'Browse skills' button from the slash menu.
  [MinVersion=3] kClickedBrowseSkillsFromMenu = 17,
  // Skill Builder Step 1: User clicked the promo chip to start the flow.
  kSkillBuilderClickedPromoChip = 20,
  // Skill Builder Step 2: A draft skill was successfully generated by the AI.
  kSkillBuilderPromptGenerated = 21,
  // Skill Builder Step 3: User clicked save on the generated draft.
  kSkillBuilderClickedSaveAsSkill = 22,
};

// LINT.ThenChange(
//  //tools/metrics/histograms/metadata/glic/enums.xml:SkillsWebClientEvent
// )

// @generate glic_api
// Zero-state suggestions for the current tab.
struct ZeroStateSuggestions {
  // A collection of suggestions associated with the linked tab. This may be
  // empty.
  array<SuggestionContent> suggestions;
  // A unique ID to track the the associated tab.
  int32 tab_id;
  // The url of the associated tab.
  url.mojom.Url url;
};

// @generate glic_api
// Zero-state suggestions for the current tab context.
struct ZeroStateSuggestionsV2 {
  // A collection of suggestions associated with current tab context. This may
  // be empty.
  array<SuggestionContent> suggestions;
  // Whether there is a current outstanding request to generate suggestions for
  // the current tab context.
  // @glic_optional
  bool is_pending;
  // The host's invocation source.
  // @glic_optional
  InvocationSource invocation_source;
};

// @generate glic_api
// Options for ensuring chrome will create Zero State Suggestions for a
// specific webui context.
struct ZeroStateSuggestionsOptions {
  // If the suggestions will be used in a first run context.
  // @glic_optional
  bool is_first_run;
  // The list of tools that are currently supported.
  // @glic_optional
  array<string> supported_tools;
};

// @generate glic_api
// A candidate for pinning.
struct PinCandidate {
  // The tab that is a candidate for pinning.
  TabData tab_data;
};

// Observes changes to pin candidates.
interface PinCandidatesObserver {
  // Called when the list of pin candidates has changed.
  OnPinCandidatesChanged(array<PinCandidate> candidates);
};

// @generate glic_api
// Describes what triggered the pin.
[Stable, Extensible]
enum PinTrigger {
  // The pin occurred for unknown reasons. Specifies 'web client' to align with
  // `GlicPinTrigger` enum (which disambiguates from unknown triggers
  // originating elsewhere).
  [Default] kWebClientUnknown = 0,
  // The pin was triggered by the toggle UI for pin candidates.
  kCandidatesToggle = 1,
  // The pin was triggered by the inline '@' mention feature.
  kAtMention = 2,
  // The pin was triggered as part of actor/actuation behavior.
  kActuation = 3,
};

// @generate glic_api
// Options for pinning tabs.
struct PinTabsOptions {
  // @glic_optional
  PinTrigger pin_trigger;
};

// @generate glic_api
// Describes what triggered the unpin.
[Stable, Extensible]
enum UnpinTrigger {
  // The unpin occurred for unknown reasons. Specifies 'web client' to align
  // with `GlicUnpinTrigger` enum (which disambiguates from unknown triggers
  // originating elsewhere).
  [Default] kWebClientUnknown = 0,
  // The unpin was triggered by the toggle UI for pin candidates.
  kCandidatesToggle = 1,
  // The unpin was triggered by a chip.
  kChip = 2,
  // The unpin was triggered as part of actor/actuation behavior.
  kActuation = 3,
};

// @generate glic_api
// Options for unpinning tabs.
struct UnpinTabsOptions {
  // @glic_optional
  UnpinTrigger unpin_trigger;
};

// @generate glic_api
// Options for opening the pinned tab picker.
struct OpenPinnedTabPickerOptions {};

// Interface for actor-related callbacks to the web client.
interface ActorClient {
  // Requests the web client to show a dialog to the user to select a credential
  // for actor login. The web client should show the dialog and wait for the
  // user to interact with it.
  RequestToShowCredentialSelectionDialog(
      actor.webui.mojom.SelectCredentialDialogRequest request)
      => (actor.webui.mojom.SelectCredentialDialogResponse response);

  // Requests the web client to show a dialog to the user to select autofill
  // suggestions. The web client should show the dialog and wait for the user
  // to interact with it.
  //
  // Selections for multiple forms can be requested by populating multiple
  // FormFillingRequest objects.
  RequestToShowAutofillSuggestionsDialog(
      actor.webui.mojom.SelectAutofillSuggestionsDialogRequest request)
      => (actor.webui.mojom.SelectAutofillSuggestionsDialogResponse response);

  // Requests the web client to show a dialog for deterministic user
  // confirmation. This should occur when Chrome detects the actor
  // engaging in security-sensitive operations that require user permission.
  RequestToShowUserConfirmationDialog(
      actor.webui.mojom.UserConfirmationDialogRequest request)
      => (actor.webui.mojom.UserConfirmationDialogResponse response);

  // Requests the web client confirm navigation to a novel origin
  // that the model has not yet encountered, but is not sensitive
  // enough to require structured user confirmation.
  RequestToConfirmNavigation(
      actor.webui.mojom.NavigationConfirmationRequest request)
      => (actor.webui.mojom.NavigationConfirmationResponse response);

  // Notify that the actor task with the given id has changed to the indicated
  // state.
  NotifyActorTaskStateChanged(int32 task_id, ActorTaskState state);

  // Requests the web client to show the Gmail OTP opt-in dialog to the user.
  RequestToShowGmailOtpOptInDialog(
      actor.webui.mojom.GmailOtpOptInRequest request)
      => (actor.webui.mojom.GmailOtpOptInResult result);

  // Requests the web client to show the Gmail OTP confirmation dialog to the
  // user.
  RequestToShowGmailOtpConfirmationDialog(
      actor.webui.mojom.GmailOtpConfirmationRequest request)
      => (actor.webui.mojom.GmailOtpConfirmationResult result);
};

// @generate glic_api
// Holds optional parameters for `GlicBrowserHost#createActorTab`.
struct CreateActorTabOptions {
  // The tabId of the tab from which the conversation turn was initiated.
  int32? initiator_tab_id;

  // The windowId of the window which the conversation turn was initiated.
  // This may differ from the initiatorTabId's current window if the tab is
  // moved to a different window or closed.
  int32? initiator_window_id;

  // @glic_optional
  // Determines if the new tab should be created in the background or not. If
  // not provided, defaults to `false`.
  bool open_in_background;
};

// Interface for actor-related functionality.
interface ActorHandler {
  // Called when a form is presented in the autofill selection dialog.
  AutofillSuggestionDialogOnFormPresented(
      int32 task_id,
      actor.webui.mojom.AutofillSuggestionDialogOnFormPresentedParams params);

  // Called when a suggestion preview is changed for a form in the autofill
  // selection dialog.
  AutofillSuggestionDialogOnFormPreviewChanged(
      int32 task_id,
      actor.webui.mojom.AutofillSuggestionDialogOnFormPreviewChangedParams
          params);

  // Called when a form is confirmed with a selected suggestion in the autofill
  // selection dialog.
  AutofillSuggestionDialogOnFormConfirmed(
      int32 task_id,
      actor.webui.mojom.AutofillSuggestionDialogOnFormConfirmedParams params);

  // Returns the context from the tab associated with `tab_id` for an actor.
  // This skips the focus check.
  [RuntimeFeature=glic.mojom.features.kGlicActorTabContext]
  GetContextForActorFromTab(int32 tab_id, TabContextOptions options)
      => (GetContextResult result);

  // Creates a new task in the actor framework and returns the new task's ID.
  // `task_options` contains information used to initialize the task. A
  // conversation must have been registered using RegisterConversation prior to
  // creating an actor task.
  CreateTask(actor.webui.mojom.TaskOptions? task_options)
      => result<int32, CreateTaskErrorReason>;

  // Executes the given actions. `action_proto` is a serialized proto of type
  // optimization_guide::proto::Actions. Returns the result of the actions as a
  // serialized proto of type optimization_guide::proto::ActionsResult.
  //
  // It is an error to act with a paused task.
  PerformActions(array<uint8> actions_proto)
      => result<mojo_base.mojom.ProtoWrapper, PerformActionsErrorReason>;

  // Cancel the actions for the specified actor task. Does not revert actions
  // already taken. Returns an error if the task is not found.
  CancelActions(int32 task_id) => (CancelActionsResult result);

  // Immediately stops the actor from taking any further actions associated with
  // the given id and exits acting mode. The stop_reason indicates the reason
  // for why the stop was initiated. Any in flight actions are canceled and
  // their callbacks will be (asynchronously) invoked. No-op if a task with the
  // given id does not exist.
  StopActorTask(int32 task_id, ActorTaskStopReason stop_reason);

  // Pauses the task associated with the given id. Any restrictions on the tab
  // which would prevent user interaction with it are lifted. The pause_reason
  // indicates the reason for why the pause was initiated. The optional tab_id
  // indicates the tab that belongs to this actor task. ResumeActorTask
  // restores these restrictions, and allows for further actions. Any in flight
  // actions are canceled and their callbacks will be (asynchronously) invoked.
  // No-op if a task with the given id does not exist.
  PauseActorTask(
      int32 task_id, ActorTaskPauseReason pause_reason, int32? tab_id);

  // Resumes a paused task associated with the given id, allowing for further
  // actions. Any restrictions on the tab lifted by PauseActorTask are
  // reimposed. After resumption, computes the context of the tab associated
  // with the task according to the given `context_options` and returns the
  // result. Returns an error if the task doesn't exist or is not paused.
  ResumeActorTask(int32 task_id, TabContextOptions context_options)
      => (GetContextResultWithActionResultCode result);

  // Interrupts the task associated with the given id. This is
  // different than pausing a task since this still prevents user
  // interaction. The interrupt_reason indicates the reason for why the
  // interrupt was initiated.
  // No-op if a task with the given id does not exist.
  // No-op if the state of the task not in the reflecting state.
  InterruptActorTask(
      int32 task_id, ActorTaskInterruptReason? interrupt_reason);

  // Indicates the task associated with the given id is no longer waiting
  // on user input.
  // No-op if a task with the given id does not exist.
  // No-op if the task is not in the interrupted state.
  UninterruptActorTask(int32 task_id);

  // Updates the progress of a step for an actor task with the given ID.
  UpdateActorTaskStepProgress(int32 task_id, string step_progress);

  // Creates a new tab for an actor task to act in. The initiator tab and window
  // are used to place the new tab in the window the task was started from,
  // regardless of whether context from that initial tab was shared or not.
  // Note: task_id is used primarily for the journal, the new tab isn't
  // associated with the task in any way until acted on. Returns the TabData
  // for the newly created tab or undefined if tab creation failed.
  CreateActorTab(int32 task_id, CreateActorTabOptions options)
      => (TabData? tab_data);

  // Log a begin event in the journal.
  LogBeginAsyncEvent(
      uint64 event_async_id, int32 task_id, string event, string details);

  // Log an end event in the journal.
  LogEndAsyncEvent(uint64 event_async_id, string details);

  // Log an instant event in the journal.
  LogInstantEvent(int32 task_id, string event, string details);

  // Clear the journal.
  JournalClear();

  // Serialize the current journal collection to a encoded
  // perfetto protobuf encoding.
  JournalSnapshot(bool clear_journal) => (Journal journal);

  // Start journal collection.
  JournalStart(uint64 max_bytes, bool capture_screenshots);

  // Stop journal collection.
  JournalStop();

  // Record the journal in a listnr feedback. The reason will be sent to listnr
  // as the feedback description exactly as is without being parsed or processed
  // in the browser process.
  JournalRecordFeedback(bool positive, string reason);
};

// @generate glic_api
// Result of CancelActions().
[Stable, Extensible]
enum CancelActionsResult {
  // Do not manually use this value. Fail safe when an old client receives an
  // extended new enum.
  [Default] kUnknown = 0,
  // Actions were successfully cancelled.
  kSuccess = 1,
  // The task was not found.
  kTaskNotFound = 2,
  // Could not cancel the actions for other reasons (e.g., the task is already
  // completed).
  kFailed = 3,
};

// @generate glic_api
// Options used to customize region capture.
struct CaptureRegionParams {
  // @glic_type string
  int32 tab_id;
  TabContextOptions options;
};

// Interface for annotation-related functionality, used by the web client.
interface AnnotationHandler {
  // Scrolls to and (optionally) highlights content specified by `params`. Only
  // one highlight is active at a time. Returns an error reason if the scroll
  // fails, or null otherwise.
  ScrollTo(ScrollToParams params) => (ScrollToErrorReason? error_reason);

  // Drops the content highlight from scrollTo(). No effects if no contents are
  // highlighted.
  DropScrollToHighlight();
};

// @generate glic_api
// Holds optional parameters for GlicBrowserHost#activateTabWithUrl.
struct ActivateTabOptions {
  // Wildcard pattern (using '*' and '?') matched against tab URLs. If empty or
  // undefined, wildcard matching is not performed.
  // @glic_type string?
  string pattern = "";
  // The windowId of the window where the tab should be created if no matching
  // tab is found.
  int32? fallback_window_id;
};

// Interface for skills-related functionality, used by the web client.
interface SkillsHandler {
  // Initiates the creation of a skill by opening a modal dialog. It returns a
  // boolean indicating whether the modal dialog was opened successfully.
  CreateSkill(CreateSkillRequest request) => (bool modal_opened);

  // Initiates the update of a skill by opening a modal dialog. It returns a
  // boolean indicating whether the modal dialog was opened successfully.
  UpdateSkill(UpdateSkillRequest request) => (bool modal_opened);

  // Requests that the browser show skill management UI.
  ShowManageSkillsUi();

  // Requests that the browser show skill browsing UI.
  ShowBrowseSkillsUi();

  // Gets a skill by its id. Returns null if the skill does not exist.
  GetSkill(string id) => (Skill? skill);

  // Logs metrics for web client specific skill events.
  RecordSkillsWebClientEvent(SkillsWebClientEvent event);
};

// Interface for skills-related callbacks to the web client.
interface SkillsClient {
  // Notify that the skills previews have changed.
  NotifySkillPreviewsChanged(array<SkillPreview> skill_previews);

  // Notify that the contextual skills previews have changed.
  NotifyContextualSkillPreviewsChanged(array<SkillPreview> skill_previews);

  // Notify that a skill preview has changed.
  NotifySkillPreviewChanged(SkillPreview skill_preview);

  // Notify that a skill has been deleted.
  NotifySkillDeleted(string skill_id);

  // The skills enablement state has changed at runtime.
  NotifySkillsEnabledChanged(bool enabled);
};

// @generate glic_api
// Holds optional parameters for `GlicBrowserHost#createTab`.
struct CreateTabOptions {
  // Determines if the new tab should be created in the background or not.
  // @glic_optional
  bool open_in_background;
  // The windowId of the window where the new tab should be created at.
  int32? window_id;
};

// Access to the browser from the web client by proxy through the WebUI.
// A single WebClientHandler will provide access to the browser for only
// a single web client. If the webview navigates or refreshes, a new
// WebClientHandler is created.
interface WebClientHandler {
  // Called just before the web client initialize() call. Provides the initial
  // state of any values that can be queried.
  WebClientCreated(pending_remote<WebClient> web_client)
      => (WebClientInitialState initial_state);

  // Called when the web client loads and successfully returns from
  // initialize(), indicating that it will support Chrome. `web_client` may
  // be used to communicate with the client.
  WebClientInitialized();

  // Called when the web client loads, but throws an exception in initialize().
  WebClientInitializeFailed();

  // Creates the actor handler.
  CreateActorHandler(pending_receiver<ActorHandler> receiver,
                     pending_remote<ActorClient> client);

  // Sets the experimental triggering client.
  CreateExperimentalTriggeringClient(
      pending_remote<ExperimentalTriggeringClient> client);

  // Creates the annotation handler.
  CreateAnnotationHandler(pending_receiver<AnnotationHandler> receiver);

  // Creates the skills handler.
  CreateSkillsHandler(pending_receiver<SkillsHandler> receiver,
                      pending_remote<SkillsClient> client);

  // Creates the zero state suggestions handler.
  CreateZeroStateSuggestionsHandler(
      pending_receiver<ZeroStateSuggestionsHandler> receiver);

  // Creates a new tab. `url` must have a http or https protocol.
  // `tab_data` is null if the tab could not be created, which may happen if the
  // url or window_id is invalid.
  CreateTab(url.mojom.Url url, CreateTabOptions create_options)
      => (TabData? tab_data);

  // Activates an existing tab matching `exact_url` or the wildcard pattern in
  // `options` (if provided), falling back to creating a new tab navigated to
  // `exact_url`.
  ActivateTabWithUrl(url.mojom.Url exact_url, ActivateTabOptions? options)
      => (TabData? tab_data);

  // Creates a new popup window.
  OpenLinkInPopup(url.mojom.Url url, int32 popup_width, int32 popup_height);

  // Opens the glic settings page.
  OpenGlicSettingsPage(OpenSettingsOptions options);

  // Opens the password manager settings page.
  OpenPasswordManagerSettingsPage();

  // Set whether the panel can be manually resized.
  EnableDragResize(bool enabled);

  // Closes the Glic panel.
  ClosePanel();

  // Shuts down the Glic panel.
  ClosePanelAndShutdown();

  // Requests that the web client's panel be attached to a browser
  // window.
  AttachPanel();

  // Requests that the web client's panel be detached from a browser
  // window (floats free).
  DetachPanel();

  // Notifies the browser that the web client has switched modes.
  OnModeChange(WebClientMode new_mode);

  // Called when the microphone status changes in the web client.
  OnMicrophoneStatusChange(MicrophoneStatus status);

  // Triggers the change profile flow, which allows the user to switch which
  // profile is used. If a new profile is chosen, this WebUI will be closed in
  // favor of a new one.
  ShowProfilePicker();

  // Returns the current model quality client id.
  [RuntimeFeature=glic.mojom.features.kGlicAppendModelQualityClientId]
  GetModelQualityClientId() => (string model_quality_client_id);

  // Returns the context from the currently active tab.
  // `tab_context_result` is null if tab content could not be captured.
  // This may fail if the tab is navigated while collecting data, or closed
  // before data is collected.
  GetContextFromFocusedTab(TabContextOptions options)
      => (GetContextResult result);

  // Returns the context from the tab associated with `tab_id`.
  // `tab_context_result` is null if tab content could not be captured.
  // This may fail if the tab is navigated while collecting data, or closed
  // before data is collected.
  GetContextFromTab(int32 tab_id, TabContextOptions options)
      => (GetContextResult result);

  // Returns raw image bytes and MIME type for an image node from the tab
  // associated with `tab_id`.
  GetImageBytesFromTab(int32 tab_id, string document_id, int32 dom_node_id)
      => (GetImageBytesResult result);

  // Sets the maximum number of supported pinned tabs. Negative means that the
  // client has no limit. Since the browser may only support so many, the
  // effective limit is returned. The returned number may also differ from the
  // requested number if the current number of pinned tabs exceeds the requested
  // amount.
  SetMaximumNumberOfPinnedTabs(uint32 requested_max)
      => (uint32 effective_max);

  // Pins the given tabs. Can fail if the tabs cannot be found, if the number of
  // pinned tabs exceeds the allowed limit or if the tabs are already pinned.
  // Returns true if all the given tabs were pinned.
  PinTabs(array<int32> tab_ids, PinTabsOptions? options) => (bool pinned_all);

  // Unpins the given tabs. Can fail if the tabs cannot be found, or if some of
  // the given tabs aren't pinned.
  UnpinTabs(array<int32> tab_ids, UnpinTabsOptions? options)
      => (bool unpinned_all);

  // Unpins all currently pinned tabs.
  UnpinAllTabs(UnpinTabsOptions? options);

  // Subscribes to receive updates on pin candidates.
  SubscribeToPinCandidates(GetPinCandidatesOptions options,
                           pending_remote<PinCandidatesObserver> observer);

  // Opens the browser's native pinned tab picker UI on mobile platforms
  // (Android phone and tablet). On desktop and other non-mobile form factors,
  // this is a no-op that resolves immediately.
  OpenPinnedTabPicker(OpenPinnedTabPickerOptions? options) => ();

  // Foregrounds the given tab.
  // No-op if the tab doesn't exist or is already in the foreground.
  [RuntimeFeature=glic.mojom.features.kGlicActivateTabApi]
  ActivateTab(int32 task_id);

  // Resize the widget hosting the WebUI to the given size.
  // If `duration` is 0 or less, instantly resize, otherwise run an animation.
  // If the widget doesn't exist yet, `size` will be used as its initial size
  // when it's created later.
  ResizeWidget(gfx.mojom.Size size, mojo_base.mojom.TimeDelta duration) => ();

  // Returns the screenshot result or error reason. 'screenshot' is null when an
  // error occurs during capture. This can also fail if the user cancels the
  // screen picker dialog.
  CaptureScreenshot() => (CaptureScreenshotResult result);

  // Starts a user-interactive process to select content from a tab. Multiple
  // regions can be captured. Results for each region, and errors, are sent
  // via the observer.
  //
  // The `observer` remote is disconnected when the capture operation is
  // terminated by either the browser (e.g., on user cancellation) or the
  // client.
  //
  // The optional `params` can be used to specify a target tab or request
  // specific capture behavior.
  //
  // If another capture is already in progress, the previous capture session
  // will be terminated and a new one will begin.
  CaptureRegion(pending_remote<CaptureRegionObserver> observer,
                CaptureRegionParams? params);

  // Deletes a captured region.
  DeleteCapturedRegion(int32 tab_id, mojo_base.mojom.UnguessableToken id);

  // Requests that audio ducking be enabled or disabled.
  // If enabled, audio from other sources will be attenuated.
  // If disabled, normal audio playout resumes.
  // Returns `true` if the ducking state was actually changed. On some
  // platforms this will also duck other applications besides Chrome. On these
  // platforms, we will return `true` if other Chrome tabs were successfully
  // ducked, even if ducking other applications has failed.
  SetAudioDucking(bool enable) => (bool result);

  // Sets the minimum possible size that a user can manually resize to for the
  // widget hosting the WebUI.
  SetMinimumPanelSize(gfx.mojom.Size size);

  // Set the state of the Microphone permission pref:
  // prefs::kGlicMicrophoneEnabled. Returns when the browser has stored the new
  // pref value.
  SetMicrophonePermissionState(bool enabled) => ();

  // Set the state of the Location permission pref:
  // prefs::kGlicGeolocationEnabled. Returns when the browser has stored the new
  // pref value.
  SetLocationPermissionState(bool enabled) => ();

  // Set the state of the TabContextResult permission pref:
  // prefs::kGlicTabContextEnabled. Returns when the browser has stored the new
  // pref value.
  SetTabContextPermissionState(bool enabled) => ();

  // Set the state of the closed captioning glic setting pref:
  // prefs::kGlicClosedCaptioningEnabled. Returns when the browser has stored
  // the new pref value.
  SetClosedCaptioningSetting(bool enabled) => ();

  // Set the state of the user enabled web actuation glic setting pref:
  // prefs::kGlicUserEnabledActuationOnWeb. Returns when the browser has stored
  // the new pref value.
  SetActuationOnWebSetting(bool enabled) => ();

  // Returns whether a media permission request from the guest should be granted
  // or denied.
  ShouldAllowMediaPermissionRequest() => (bool is_allowed);

  // Returns whether a geolocation permission request from the guest should be
  // granted or denied.
  ShouldAllowGeolocationPermissionRequest() => (bool is_allowed);

  // Set the state of the context access indicator UI effect on the focused tab.
  SetContextAccessIndicator(bool enabled);

  // Returns the user profile information. This should only return null if
  // the profile associated with this webui is invalid, which should only
  // possibly happen during teardown.
  GetUserProfileInfo() => (UserProfileInfo? profile_info);

  // Sync signin cookies to webview. This is the same as
  // `PageHandler.SyncWebviewCookies()`, except this call originates from the
  // webview.
  SyncCookies() => (bool success);

  // Notifies the browser that the client error dialog state has changed.
  // `shown_dialog_type` is null when no dialog is shown (e.g., it was closed).
  ClientErrorDialogStateChanged(ClientErrorDialogType? shown_dialog_type);

  // Reports that the web client encountered a transient error. These errors may
  // be presented to the user, but may not prevent further use of Glic.
  ReportClientTransientError(mojo_base.mojom.AbslStatusCode status_code);

  // Processes the counter-abuse verdict from the server.
  ProcessCounterAbuseVerdict(int32 tab_id, CounterAbuseVerdict? verdict);

  // Called when the opt-in CTA is shown.
  OnOptinImpression();

  // Called when the user submits input.
  OnUserInputSubmitted(
      WebClientMode mode, [MinVersion=1] PromptType prompt_type);

  // Called when starting to upload context to the server.
  OnContextUploadStarted();

  // Called when finished uploading context to the server.
  OnContextUploadCompleted();

  // Called after user input is submitted, but before a response starts,
  // when the UI shows a message that explains the progress of the request.
  OnReaction(MetricUserInputReactionType reactionType);

  // Called when the web client starts to respond.
  OnResponseStarted();

  // Called when the web client stops responding.
  OnResponseStopped(OnResponseStoppedDetails details);

  // Called when the session is terminated.
  OnSessionTerminated();

  // Called when the web client completes a turn.
  OnTurnCompleted(WebClientModel model, mojo_base.mojom.TimeDelta duration);

  // Called when the user rates a response.
  OnResponseRated(bool positive);

  // Called when the user receives a response with closed captions showing.
  OnClosedCaptionsShown();

  // Called when the web client sends a browser actuation result over the
  // network.
  OnActionSubmitted(bool is_retry);

  // Enrolls Chrome in the synthetic experiment group specified by
  // trial_name.group_name. Enrollment will start when the API is called and end
  // when Chrome closes.
  SetSyntheticExperimentState(string trial_name, string group_name);

  // Attempts to open the OS permission settings page.  No return value.
  OpenOsPermissionSettingsMenu(
      content_settings.mojom.ContentSettingsType type);

  // Get the status of the OS Microphone permission currently granted to Chrome.
  GetOsMicrophonePermissionStatus() => (bool enabled);

  // Returns zero-state suggestions from the currently active tab.
  GetZeroStateSuggestionsForFocusedTab(bool? is_first_run)
      => (ZeroStateSuggestions? suggestions);

  // Called when the client believes that the user's status may have changed.
  // For example, an RPC may have been rejected due to the the service being
  // disabled.
  MaybeRefreshUserStatus();

  // Returns whether the debugger is attached to the webview.
  // This is useful for debugging the webview without having the responsiveness
  // check get in the way.
  IsDebuggerAttached() => (bool is_attached_to_webview);

  // Subscribe to be notified when meta tags change. Sends the current state on
  // first call, and then notifies when the state changes. Call with an empty
  // names array to stop receiving notifications.
  SubscribeToPageMetadata(int32 tab_id, array<string> names)
      => (bool success);

  // Switches the active conversation in the web client.
  SwitchConversation(ConversationInfo info)
      => (SwitchConversationErrorReason? error_reason);

  // Registers a conversation in the web client.
  RegisterConversation(ConversationInfo info)
      => (RegisterConversationErrorReason? error_reason);

  // Called when the user has completed the onboarding flow.
  SetOnboardingCompleted();

  // Request updates from a tab. The receiver is closed when the tab is closed,
  // or if the tab is not found.
  SubscribeToTabData(int32 tab_id, pending_remote<TabDataHandler> receiver);

  // Request favicon updates from a tab. The receiver is closed when the tab is
  // closed, or if the tab is not found.
  SubscribeToTabFavicon(
      int32 tab_id, pending_remote<TabFaviconHandler> receiver);
};

// Accesses zero state suggestions from the web client.
interface ZeroStateSuggestionsHandler {
  // If client is not null, this will return the zero state suggestions for the
  // currently shared content. Suggestions will continue to emit via
  // NotifyZeroStateSuggestionsChanged until this is called with a null client.
  GetZeroStateSuggestionsAndSubscribe(
      pending_remote<ZeroStateSuggestionsClient>? client,
      ZeroStateSuggestionsOptions options)
      => (ZeroStateSuggestionsV2? zero_state_suggestions);
};

// Notifies the web client of changes to the zero state suggestions.
interface ZeroStateSuggestionsClient {
  // The zero state suggestions have changed.
  NotifyZeroStateSuggestionsChanged(ZeroStateSuggestionsV2 suggestions,
                                    ZeroStateSuggestionsOptions options);
};

// Receives updates for a specific tab.
interface TabDataHandler {
  // Tab data has changed for this tab.
  OnTabDataChanged(TabData tab_data);
};

// Receives favicon updates for a specific tab.
interface TabFaviconHandler {
  // Tab favicon has changed for this tab.
  OnTabFaviconChanged(skia.mojom.BitmapN32? favicon);
};

// @generate glic_api
// Information about a conversation.
struct ConversationInfo {
  // The unique ID of the conversation. This will be stored.
  string conversation_id;
  // The title of the conversation. This will be stored. It is expected that
  // titles don't change.
  string conversation_title;
  // Optional client-specific data. This data is not used by Chrome and Chrome
  // will never attempt to deserialize it. It can hold a key for client-side
  // lookup or opaque serialized data.
  mojo_base.mojom.ByteString? client_data;
  // Optional turn ID to open this conversation at.
  string? turn_id;
};

// @generate glic_api
// Reason for failure when switching a conversation.
[Stable, Extensible]
enum SwitchConversationErrorReason {
  [Default] kUnknown = 0,
};

// @generate glic_api
// Reason for failure when registering a conversation.
[Stable, Extensible]
enum RegisterConversationErrorReason {
  [Default] kUnknown = 0,
  // The instance already has a conversation ID.
  kInstanceAlreadyHasConversationId = 1,
};

// @generate glic_api
// Data structure sent from the browser to the web client with panel opening
// information.
struct PanelOpeningData {
  // The state of the panel as it's being opened.
  // @glic_optional
  PanelState panel_state;
  // Indicates the entry point used to trigger the opening of the panel.
  // In the event the web client's page is reloaded, the new web client will
  // receive a notifyPanelWillOpen call with the same invocation source as
  // before, even though the user did not, for example, click a button again.
  // @glic_optional
  InvocationSource invocation_source;

  // If set, the textbox for user input will be populated with the given string
  // before the panel opens.
  string? prompt_suggestion;
  // If true and prompt_suggestion is set, the prompt will be automatically
  // submitted after the panel opens.
  // @glic_optional
  bool auto_send;
  // An optional Skill. If provided, the Gemini app should auto-run it.
  Skill? skill_to_invoke;
  // Up to 3 most recently active conversations, ordered by most recently active
  // first.
  array<ConversationInfo>? recently_active_conversations;
  // Information about the conversation being opened.
  //
  // - The web client will load the requested `conversationInfo.conversationId`.
  // - If `conversationInfo.conversationId` is empty, it indicates a new
  //   conversation is being started.
  // - The object may contain `clientData` if it was provided in the
  //   `registerConversation` or `switchConversation` calls.
  //
  // @glic_optional
  ConversationInfo conversation_info;

  // Overrides the First Run Experience. If set, the panel will act as if the
  // user was or wasn't in a specific FRE state.
  // @glic_optional
  FreOverride fre_override = kUnspecified;
};

// @generate glic_api
// The panel can be in one of these three states.
enum PanelStateKind {
  // The panel is hidden.
  kHidden = 0,
  // The panel is a floating window, detached from any browser window.
  kDetached = 1,
  // The panel is a side panel, attached to a browser window.
  kAttached = 2,
};

// @generate glic_api
// Information of how the panel is being presented/configured.
struct PanelState {
  // The panel's presentation kind/state.
  PanelStateKind kind;
  // Present only when attached to a window, indicating which window it is
  // attached to.
  int32? window_id;
};

// @generate glic_api
// Represents an override of the First Run Experience (FRE).
[Stable, Extensible]
enum FreOverride {
  [Default] kUnspecified = 0,
  // Deprecated: No longer used.
  // Variation that requires text input from the user to unlock full client.
  kTrustFirstText = 1,
  // Variation that requires mouse click from the user to unlock full client.
  kTrustFirstClick = 2,
  // Variation that starts with full client unlocked and shows inline consent.
  kTrustFirstInline = 3,
};

// @generate glic_api
// Entry points that can trigger the opening of the panel.
// LINT.IfChange(InvocationSource)
[Stable, Extensible]
enum InvocationSource {
  // Button in the OS.
  kOsButton = 0,
  // Menu from button in the OS.
  kOsButtonMenu = 1,
  // OS-level hotkey.
  kOsHotkey = 2,
  // Button in top-chrome.
  kTopChromeButton = 3,
  // First run experience.
  kFre = 4,
  // From the profile picker.
  kProfilePicker = 5,
  // From tab strip nudge.
  kNudge = 6,
  // From 3-dot menu.
  kThreeDotsMenu = 7,
  // An unsupported/unknown source.
  /// The default is set to a valid value because this enum is only sent to the
  /// web client, so Mojo will never handle an unknown value.
  [Default] kUnsupported = 8,
  // From the What's New page.
  [MinVersion=1] kWhatsNew = 9,
  // User clicked the sign-in button and signed in.
  [MinVersion=2] kAfterSignIn = 10,
  // User shared a tab via the tab context menu.
  [MinVersion=3] kSharedTab = 11,
  // From the actor task icon.
  [MinVersion=4] kActorTaskIcon = 12,
  // User shared an image via the context menu.
  [MinVersion=5] kSharedImage = 13,
  // From the handoff button.
  [MinVersion=6] kHandoffButton = 14,
  // From invoking skills.
  [MinVersion=7] kSkills = 15,
  // Automatically opened from contextual cueing.
  [MinVersion=8] kAutoOpenedByContextualCue = 16,
  // User clicked the summarize button in the PDF viewer.
  [MinVersion=9] kPdfSummarizeButton = 17,
  // From a navigation capture.
  [MinVersion=10] kNavigationCapture = 18,
  // Automatically opened for a PDF.
  [MinVersion=11] kAutoOpenedForPdf = 19,
  // Selection hotkey.
  [MinVersion=12] kCaptureRegionHotkey = 20,
  // From the in-product-help (IPH) entrypoint.
  [MinVersion=13] kIph = 21,
  // User clicked an anchored contextual cue chip.
  [MinVersion=14] kAnchoredContextualCue = 22,
  // From the context menu.
  [MinVersion=15] kWebContentsContextMenu = 23,
  // User clicked on text selection nudge.
  [MinVersion=16] kTextSelectionNudge = 24,
  // User clicked on text selection widget.
  [MinVersion=16] kTextSelectionWidget = 25,
  // Automatic summarization upon opening.
  // Deprecated.
  [MinVersion=17] kZeroStateAutoSummarize = 26,
  // From the universal cart.
  [MinVersion=18] kUniversalCart = 27,
  // Used exclusively for invocations originating from the
  // GlicExperimentalTriggeringMessageHandler.
  [MinVersion=19] kExperimentalTriggering = 28,
  // Actuation triggered by the password change feature.
  [MinVersion=20] kPasswordChange = 29,
  // From an Autofill action.
  [MinVersion=21] kAutofill = 30,
  // Button in the toolbar.
  [MinVersion=22] kToolbarButton = 31,
  // User clicked on an Indigo page action.
  [MinVersion=23] kIndigoPageAction = 32,
  // User dropped a file/image onto the GLIC panel.
  [MinVersion=24] kWebDragDrop = 33,
  // From the promotion page.
  [MinVersion=25] kPromotionPage = 34,
  // Side panel remained open on a new tab.
  [MinVersion=26] kDaisyChainOnNewTab = 35,
  // Side panel remained open on a follow-link.
  [MinVersion=26] kDaisyChainOnFollowLink = 36,
  // User switched conversation.
  [MinVersion=26] kConversationSwitch = 37,
  // User detached or attached the panel.
  [MinVersion=26] kDetachAttachButton = 38,
  // Restarted from a restored tab.
  [MinVersion=26] kTabRestore = 39,
  // Implicitly focused or revealed, e.g., on tab switch or re-focus.
  [MinVersion=26] kReshowInactive = 40,
  // From the tab context menu.
  [MinVersion=27] kTabContextMenu = 41,
  // From Web Continuity.
  [MinVersion=28] kWebContinuity = 42,
};

// LINT.ThenChange(
//  //tools/metrics/histograms/metadata/glic/enums.xml:GlicInvocationSource,
// //tools/metrics/histograms/metadata/glic/histograms.xml:GlicInvocationSource,
//  //chrome/browser/glic/service/metrics/metrics_types.h:ResponseSegmentation
// )

// @generate glic_api
// Target for actuation.
[Stable, Extensible]
enum ActuationTarget {
  // Will default to the agent if the target is unknown.
  [Default] kUnknown = 0,
  // Agent infers the best location based on the prompt.
  kAgentDecides = 1,
  // Forces actuation on the initiating tab.
  kCurrentTab = 2,
  // Forces actuation in a new tab.
  kNewTab = 3,
  // Forces actuation on the target surface, if the surface is a valid tab.
  // Note: kTargetSurface can be different than kCurrentTab if the target
  // surface is not the foregrounded tab. This option has no effect if the
  // surface does not resolve to a valid tab.
  [MinVersion=1] kTargetSurface = 4,
};

// @generate glic_api
// Payload for invoking a skill.
struct SkillsPayload {
  // Skill ID to trigger.
  string skill_id;

  // Skill name to show in the Glic client. Empty string is the null state.
  string skill_name;

  // Skill icon (emoji) to show in the Glic client.
  // Empty string is the null state.
  string skill_icon;
};

// @generate glic_api
// Payload for Universal Cart invocation.
struct UniversalCartPayload {
  // This metadata is received from the same Google endpoint we receive the
  // actual invocation prompt from. Opaque to the browser.
  // @glic_type ArrayBuffer
  array<uint8> serialized_metadata;
};

union InvocationPayload {
  UniversalCartPayload universal_cart;

  [MinVersion=3]
  SkillsPayload skills_payload;
};

// @generate glic_api
// Options for invoking Glic.
struct InvokeOptions {
  // Source that triggered this invocation.
  InvocationSource invocation_source;

  // Prompts to pre-populate or suggest.
  array<string>? prompts;

  // Additional context to attach.
  AdditionalContext? context;

  // Whether to automatically submit the prompt.
  bool auto_submit;

  // Feature mode to switch to.
  FeatureMode feature_mode;

  // Target for actuation.
  // @glic_optional
  ActuationTarget actuation_target;

  // Whether to suppress Zero State Suggestions.
  bool disable_zero_state_suggestions;

  // Skill ID to trigger.
  // Deprecated: Use payload.skills_payload.skill_id instead.
  string? skill_id;

  // Configuration to override the default ZSS behavior for the invocation.
  ZssConfig? zss_config;

  // Source-specific payload for the invocation.
  InvocationPayload? payload;

  // The ID of the tab to actuate on, if actuationTarget is kTargetSurface.
  [MinVersion=1]
  int32? actuation_tab_id;
};

// @generate glic_api
// Web client's operation modes.
// LINT.IfChange(WebClientMode)
[Stable, Extensible]
enum WebClientMode {
  [Default] kUnknown = 2,
  // Text operation mode.
  kText = 0,
  // Audio operation mode.
  kAudio = 1,
};

// LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:WebClientMode)

// @generate glic_api
// Prompt submission type.
// LINT.IfChange(PromptType)
[Stable, Extensible]
enum PromptType {
  // Default value when prompt type is unspecified or unknown.
  [Default] kUnspecified = 0,
  // User typed text in the prompt input field.
  kTypedText = 1,
  // User selected a Zero State Suggestion (ZSS).
  kZeroStateSuggestions = 2,
  // Auto-submitted prompt (e.g. contextual cueing auto-submit).
  kAutoPrompt = 3,
  // Audio input prompt.
  kAudio = 4,
};

// LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:GlicPromptType)

// @generate glic_api
// Microphone status.
[Stable, Extensible]
enum MicrophoneStatus {
  kNotListening = 0,
  kListening = 1,
  [Default] kUnknown = 2,
};

// @generate glic_api
// Web client's operation model.
[Stable, Extensible]
enum WebClientModel {
  // Default model.
  [Default] kDefault = 0,
  // Actor operation mode.
  kActor = 1,
};

// @generate glic_api
// Web client's user counter.
// LINT.IfChange(WebUseCounter)
[Stable, Extensible]
enum WebUseCounter {
  // Default counter. Never used.
  [Default] kDefault = 0,
  kSubmitPromptWithAutoMode = 1,
  kTaskInterruptedForUserConfirmation = 2,
  kTaskInterruptedForUserClarification = 3,
  kSelectionToggledViaSharedMenu = 4,
  kSelectionToggledViaHotKey = 5,
  kSubmitPromptWithTextSelectionCue = 6,
};

// LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:GlicWebUseCounter)

// @generate glic_api
// Client error dialog types.
// LINT.IfChange(ClientErrorDialogType)
[Stable, Extensible]
enum ClientErrorDialogType {
  [Default] kUnknown = 0,
  kDisabledByOrganization = 1,
  kGenericAvailability = 2,
  kIneligibleAccount = 3,
  kSignout = 4,
  kUnsupportedLocation = 5,
};

// LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:GlicClientErrorDialogType)
[Stable, Extensible]
enum ResponseStopCause {
  [Default] kUnknown = 0,
  kUser = 1,
  kOther = 2,
};

// @generate glic_api
// Details for metrics recording purposes.
struct OnResponseStoppedDetails {
  // @glic_optional
  ResponseStopCause cause;
};

// Carries back to the browser information on how to configure the panel being
// opened.
struct OpenPanelInfo {
  // Informs Chrome of the current web client mode, which may be kUnknown for
  // clients that do not support it.
  WebClientMode web_client_mode;
  // The size of the panel upon opening. Temporarily, it may not be provided by
  // the web client.
  gfx.mojom.Size? panelSize;
  // Resize animation duration.
  mojo_base.mojom.TimeDelta resizeDuration;
  // Whether the panel should start out user-resizable.
  bool can_user_resize;
};

// Data for AdditionalContext.
struct ContextData {
  // The MIME type of the context data.
  string mime_type;
  // The context data.
  mojo_base.mojom.BigBuffer data;
  // The filename of the data, if available.
  string? filename;
};

// @generate glic_api
// Metadata of the parent conversation. Some, all, or none, of this information
// may be available, depending on what context information was available from
// the server when the parent conversation was initiated.
struct ParentConversationMetadata {
  string? conversation_id;
  string? conversation_title;
};

// Part of an additional context object.
union AdditionalContextPart {
  ContextData data;
  // The four items below can be contained by TabContextResult and are
  // deprecated.
  Screenshot screenshot;
  WebPageData web_page_data;
  AnnotatedPageData annotated_page_data;
  PdfDocumentData pdf_document_data;
  TabContextResult tab_context;
  CapturedRegion region;
  PendingCapturedRegion pending_region;
  ParentConversationMetadata parent_conversation_metadata;
};

// @generate glic_api
[Stable, Extensible]
enum AdditionalContextSource {
  [Default] kUnknown = 2,
  kShareContextMenu = 0,
  kRegionSelection = 1,
  kTextSelection = 3,
  [MinVersion=1] kWebDragDrop = 4,
  [MinVersion=2] kExperimentalTriggering = 5,
};

// @generate glic_api
// Additional context object.
struct AdditionalContext {
  // Where the additional context came from.
  // @glic_optional
  AdditionalContextSource source;
  // User facing name of the context. Eg. the filename, or full url.
  string? name;
  // Tab id, if associated with a tab.
  // Callers may use this to associate context but should not assume this
  // relationship persists as tab contents change.
  // @glic_type string
  int32? tab_id;
  // Origin of the frame where the data came from (if it came from a frame).
  url.mojom.Origin? origin;
  // url of the frame where the data came from (if it came from a frame).
  url.mojom.Url? frameUrl;
  // The parts of the context.
  array<AdditionalContextPart> parts;
};

// @generate glic_api
// Types of updates that may be relayed back by the web client.
[Stable, Extensible]
enum ExperimentalTriggeringUpdateType {
  // An unknown, non-terminal update type.
  [Default] kUnknown = 0,
  // A log entry describing internal steps or "thought" process.
  kWorklog = 1,
  // The interaction was paused.
  kPaused = 2,
  // A final status update or metadata about the completed task.
  kTerminalCompletion = 3,
  // The interaction was stopped or cancelled.
  kTerminalStopped = 4,
  // The interaction failed.
  kTerminalFailed = 5,
  // The interaction yielded to the user.
  [MinVersion=1] kYieldToUser = 6,
  // The interaction has resumed after a pause or wait state.
  [MinVersion=2] kResumed = 7,
};

// Types of subscriber observations that may be observed.
[Stable, Extensible]
enum SubscriberObservationType {
  // An update was observed.
  [Default] kUpdate = 0,
  // Completed all observations.
  kComplete = 1,
  // An unexpected error was observed.
  kError = 2,
};

// @generate glic_api
// An update event sent to the browser by the web client.
struct ExperimentalTriggeringUpdate {
  // The type of this update.
  ExperimentalTriggeringUpdateType type;
  // The human-readable text associated with the update, such as response text
  // or status message.
  string data;
  // Optional structured metadata associated with the update (e.g., choice
  // options for interactive yields).
  map<string, string>? metadata;
};

// Interface for receiving updates during web client interactions.
// Implemented by the caller to receive streaming updates from the web client.
interface ExperimentalTriggeringUpdatesHandler {
  // Called when a new update is available.
  OnUpdate(ExperimentalTriggeringUpdate? update,
           SubscriberObservationType observation);
};

// Interface for experimental triggering messages sent from browser to web
// client.
interface ExperimentalTriggeringClient {
  // Requests the web client to upload a screenshot of the target tab's
  // web contents to remote storage.
  UploadEncryptedScreenshot(Screenshot screenshot) => (string? file_token);

  // Register a handler to observe Glic updates.
  GetExperimentalTriggeringUpdates(
      pending_remote<ExperimentalTriggeringUpdatesHandler> handler)
      => (bool success);
};

// Access from the browser to the Glic web client by proxy of the WebUI page.
interface WebClient {
  // Lightweight check sent by C++ browser process to verify guest JS event-loop
  // responsiveness.
  CheckResponsive() => ();

  // Informs the web client that the panel will open. Chrome will wait to open
  // the panel until after this returns, and will use the data in the returned
  // `OpenPanelInfo` to setup the opening panel.
  NotifyPanelWillOpen(PanelOpeningData panel_opening_data)
      => (OpenPanelInfo openPanelInfo);

  // Informs the web client that the panel was closed. Chrome will try to keep
  // the web client alive until this function returns.
  NotifyPanelWasClosed() => ();

  // Informs the client that the state of the glic panel has changed.
  NotifyPanelStateChange(PanelState panel_state);

  // Informs the client that the panel active state has changed. The panel is
  // inactive if it's attached to a browser window, and that browser window is
  // not the active window.
  NotifyPanelActiveChange(bool panel_active);

  // Informs the client that whether the panel can be attached right now.
  NotifyPanelCanAttachChange(bool can_attach);

  // The Microphone permission has changed either by action within the web
  // client or by user action in the glic settings.
  NotifyMicrophonePermissionStateChanged(bool enabled);

  // Informs the web client that the enterprise policy for file upload has
  // changed.
  NotifyFileUploadStateChanged(FileUploadPolicyState state);

  // Requests the web client to stop microphone recording.
  StopMicrophone() => ();

  // The Location permission has changed either by action within the web client
  // or by user action in the glic settings.
  NotifyLocationPermissionStateChanged(bool enabled);

  // The Tab Context permission has changed either by action within the web
  // client or by user action in the glic settings.
  NotifyTabContextPermissionStateChanged(bool enabled);

  // The OS Location permission granted to Chrome has changed by user action in
  // the OS settings menu.
  NotifyOsLocationPermissionStateChanged(bool enabled);

  // The focused tab has changed.
  NotifyFocusedTabChanged(FocusedTabData focused_tab_data);

  // The user started or stopped manually resizing the window.
  NotifyManualResizeChanged(bool resizing);

  // The OS Hotkey has changed.
  NotifyOsHotkeyStateChanged(string hotkey);

  // True if the browser has at least one open window.
  NotifyBrowserIsOpenChanged(bool browser_is_open);

  // Informs the client that the zoom level has changed.
  NotifyZoomLevelChanged(double zoom_factor);

  // The window holding the glic panel has become active or inactive (in the
  // sense of visibility and focus). Some activity, such as responsiveness
  // checks, may be paused or resumed accordingly.
  NotifyInstanceActivationChanged(bool instance_active);

  // Notify that the closed captioning setting has changed.
  NotifyClosedCaptioningSettingChanged(bool enabled);

  // Notify that the collection of shared tabs has changed.
  NotifyPinnedTabsChanged(array<TabData> tab_data);

  // Notify that the TabData for a pinned tab has changed.
  NotifyPinnedTabDataChanged(TabData tab_data);

  // Informs the client that the metadata tags have changed.
  // Contents from meta tags are passed unsanitized from the renderer.
  NotifyPageMetadataChanged(
      int32 tab_id, blink.mojom.PageMetadata? metadata);

  // Informs the client when the default state for tab context sharing for new
  // sessions changes.
  NotifyDefaultTabContextPermissionStateChanged(bool enabled);

  // Informs the client that additional context is available.
  NotifyAdditionalContext(AdditionalContext context);

  // Notify that the user enabled web actuation setting has changed.
  NotifyActuationOnWebSettingChanged(bool enabled);

  // Informs the client that the capability to act on web pages has changed.
  NotifyActOnWebCapabilityChanged(bool can_act_on_web);

  // The onboarding completed state has changed.
  NotifyOnboardingCompletedChanged(bool completed);

  // Informs the client that the Gemini Enterprise settings have changed.
  NotifyGeminiEnterpriseSettingsChanged(GeminiEnterpriseSettings? settings);

  // Notifies the client that the user has clicked on a row in the actor task
  // list bubble.
  NotifyActorTaskListRowClicked(int32 task_id);

  // Invokes Glic with specific options. Expects a return to signal completion.
  Invoke(InvokeOptions options) => ();
};

// @generate glic_api
// Information extracted from a tab.
struct TabContextResult {
  // Metadata about the tab that holds the page. Always provided.
  TabData tab_data;
  // Web page data, if requested.
  WebPageData? web_page_data;
  // A screenshot of the user-visible portion of the tab. Provided only if
  // requested.
  Screenshot? viewport_screenshot;
  // @glic_type ReadableStream<Uint8Array>
  // Proto for ScreenshotInfo.
  // See components/optimization_guide/proto/features/common_quality_data.proto.
  // Provided if include_viewport_screenshot was requested in
  // GetTabContextOptions and layout metadata is available.
  mojo_base.mojom.ProtoWrapper? screenshot_info;
  // Information about a PDF document. Provided if the document is a PDF or
  // contains a PDF, and PDF data was requested. Note that it is possible for
  // a document to contain multiple PDFs using iframes. Only the first PDF
  // document found while traversing the frame tree will be provided here.
  PdfDocumentData? pdf_document_data;
  // Information about the annotated page content. Provided if the document is
  // a web page and annotated page content was requested.
  AnnotatedPageData? annotated_page_data;
};

// @generate glic_api
// Information about a web page being rendered in a tab.
struct WebPageData {
  // Main document of the page.
  DocumentData main_document;
};

// @generate glic_api
// Text information about a web document.
struct DocumentData {
  // Origin of the document.
  url.mojom.Origin origin;
  // The innerText of the document at its current state.
  // Currently includes embedded same-origin iframes.
  // @glic_optional
  string inner_text;
  // Whether `innerText` was truncated due to `innerTextBytesLimit`.
  // @glic_optional
  bool inner_text_truncated;
};

// @generate glic_api
// Information about a PDF document.
struct PdfDocumentData {
  // Origin of the PDF document. This may not match the origin of the tab.
  url.mojom.Origin origin;
  // Raw PDF bytes.
  // @glic_type ReadableStream<Uint8Array>
  array<uint8>? pdf_data;
  // Whether the the PDF size exceeds the requested limit. If true, pdf data is
  // not returned.
  bool pdf_size_limit_exceeded;
};

// @generate glic_api
// Lightweight page features detected on the page.
[Stable, Extensible]
enum LightweightPageFeature {
  [Default] kUnknown = 0,
  // The YouTube "Ask" button is visible.
  kYtAskButtonPresent = 1,
};

// @generate glic_api
// Various bits of data about a browser tab. Optional fields may not be
// available while the page is being loaded or if not provided by the page
// itself.
struct TabData {
  // Unique ID of the tab that owns the page. These values are unique across
  // all tabs from all windows, and will not change even if the user moves the
  // tab to a different window.
  int32 tab_id;
  // Unique ID of the browser window holding the tab. This value may change if
  // the tab is moved to a different window.
  int32 window_id;
  // URL of the page. For a given tab, this value will change if the tab is
  // navigated to a different URL.
  url.mojom.Url url;
  // The title of the loaded page. Returned only if the page is loaded enough
  // for it to be available. It may be empty if the page did not specify a
  // title.
  string? title;
  // The favicon for the tab. Null when not available. This will be removed
  // once usages are migrated to `favicon_url`.
  // @glic_ignore
  skia.mojom.BitmapN32? favicon;
  // The favicon URL. Only available if the page is loaded enough and it
  // specifies a favicon.
  //
  // @deprecated Should no longer be used, will be removed in the future.
  url.mojom.Url? favicon_url;
  // MIME type of the main document. Returned only if the page is loaded enough
  // for it to be available.
  // @glic_optional
  string document_mime_type;
  // Whether the tab is audible or visible. Specifically this is the visibility
  // of the WebContents as returned by: `WebContents::GetVisibility`. If the
  // visibility is either VISIBLE or OCCLUDED, we consider the web contents to
  // be visible. @todo: This field is being added as a temporary solution.
  // b/433995475
  bool? is_observable;
  // Whether the tab has active audio or video playing, used for showing tab UI.
  // This is a best effort signal, and may not be accurate/stale due to not
  // observing media events directly. @todo: This field is being added as a
  // temporary solution. b/433995475
  bool? is_media_active;
  // Whether the tab content is being captured by another functionality (e.g.,
  // screen share in video chat). This is a best effort signal, and may not be
  // accurate/stale due to not observing tab content capture events
  // directly. @todo: This field is being added as a temporary solution.
  // b/433995475
  bool? is_tab_content_captured;
  // Whether the tab is the active tab in its browser window. Note that this
  // does not consider the state of the window.
  bool? is_active_in_window;
  // Whether the tab's browser window is active. Note that this does not
  // consider whether the tab is active in the window.
  // WARNING: This is not implemented on Android, and is always true.
  bool? is_window_active;
  // Lightweight page features detected on the page.
  array<LightweightPageFeature>? lightweight_page_features;
};

// Data about the focused tab state.
union FocusedTabData {
  // Stores the focused tab data if one exists.
  TabData focused_tab;
  // Information about why there is no focused tab.
  NoFocusedTabData no_focused_tab_data;
};

// Data about the why there is no focused tab.
struct NoFocusedTabData {
  // Data about the active tab that could not be focused, if one exists.
  TabData? active_tab_data;
  // A human-readable debug message explaining why there is no focused tab.
  string no_focus_reason;
};

// @generate glic_api
// Information about the annotated page content.
struct AnnotatedPageData {
  // Proto for AnnotatedPageContent.
  // See components/optimization_guide/proto/features/common_quality_data.proto
  // Provided only if requested.
  // @glic_type ReadableStream<Uint8Array>
  mojo_base.mojom.ProtoWrapper? annotated_page_content;

  // Metadata about the page content.
  blink.mojom.PageMetadata? metadata;
};

// Annotates an image, providing security relevant information about the origins
// from which image is composed.
// TODO(crbug.com/380495633): Finalize and implement image annotations.
struct ImageOriginAnnotations {};

// An encoded journal. This is an encoded perfetto protobuf.
// See `chrome/browser/actor/aggregated_journal_serializer.h`
struct Journal {
  // Encoded journal data.
  array<uint8> data;
};

// @generate glic_api
// A region captured by the user from a document in a tab.
//
// This is a union of different possible region shapes. Currently only
// rectangular regions are supported, but this may be expanded with other region
// types like polygons in the future.
union CapturedRegion {
  // A rectangular region captured from a document in a tab.
  //
  // The coordinate system is relative to the top-left corner of the document.
  // The units are in pixels and match screenshot pixel dimensions.
  //
  // - **Position (`x`, `y`):** Coordinates of the top-left corner of the
  //   rectangle, relative to the document's origin (0,0). Can be negative if
  //   content is scrolled out of view.
  // - **Size (`width`, `height`):** Dimensions of the rectangle, expected to be
  //   non-negative.
  //
  // The rectangle can represent an area outside the currently visible viewport
  // if the page is scrolled. It is not guaranteed to be contained within the
  // document's bounds.
  gfx.mojom.Rect rect;

  // A polyline captured from a document in a tab.
  //
  // The coordinate system is relative to the top-left corner of the document.
  // The units are in pixels and match screenshot pixel dimensions.
  //
  // The polyline is represented by an ordered array of points. The line formed
  // by these points is not required to be closed, and it represents a shape
  // (path), not necessarily a region.
  array<gfx.mojom.Point> polyline;
};

// @generate glic_api
// The captured region with an ID.
struct PendingCapturedRegion {
  // The ID of the captured region.
  mojo_base.mojom.UnguessableToken id;
  // The captured region.
  CapturedRegion region;
};

// @generate glic_api
// The result of a successful region capture.
/// This result is deprecated, results for region capture are now
/// pushed via NotifyAdditionalContext with the source being kRegionSelection.
struct CaptureRegionResult {
  // @glic_optional
  // The ID of the tab from which the region was captured.
  int32 tab_id;
  // @glic_optional
  // The captured region. This can be expanded with other region types like
  // polygons in the future.
  CapturedRegion region;
};

// @generate glic_api
// Reason for `captureRegion` error.
// LINT.IfChange(CaptureRegionErrorReason)
[Stable, Extensible]
enum CaptureRegionErrorReason {
  [Default] kUnknown = 0,
  // There is no focused tab that can be used for region capture.
  kNoFocusableTab = 1,
};

// LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:CaptureRegionErrorReason)

// Observer for the capture region process.
interface CaptureRegionObserver {
  // Called for each region the user successfully selects, or when an
  // error occurs. Exactly one of `result` or `reason` will be non-null.
  OnUpdate(CaptureRegionResult? result, CaptureRegionErrorReason? reason);
};

// @generate glic_api
// Specifies the encryption scheme used for the screenshot data.
[Stable, Extensible]
enum ScreenshotEncryptionScheme {
  // Unknown or unrecognized scheme across version boundaries.
  [Default] kUnknown = 0,
  // Unencrypted screenshot data.
  kNone = 1,
  // Encrypted according to RFC 8291 (Web Push message encryption), combining an
  // ephemeral ECDH P-256 public key share header with RFC 8188 record
  // encryption.
  kRfc8291 = 2,
};

// @generate glic_api
// An encoded screenshot image and associated metadata.
struct Screenshot {
  // Width and height of the image in pixels.
  uint32 width_pixels;
  uint32 height_pixels;
  // Encoded image data. If `encryption_scheme` is not `kNone`, this contains
  // the encrypted ciphertext payload. ArrayBuffer is transferable, so it should
  // be copied more efficiently over postMessage.
  // @glic_type ArrayBuffer
  array<uint8> data;
  // The unencrypted source image format represented as a MIME type (e.g.,
  // "image/jpeg").
  string mime_type;
  // Image annotations for this screenshot.
  ImageOriginAnnotations origin_annotations;
  // The encryption scheme applied to the image data in `data`.
  // @glic_optional
  ScreenshotEncryptionScheme encryption_scheme;
};

// @generate glic_api
// Metadata about an image on the page.
struct ImageInfo {
  // Caption of the image if available.
  string? caption;
  // Security origin of the image resource.
  url.mojom.Origin? source_origin;
  // Source URL of the image.
  url.mojom.Url url;
  // The image encoding format represented as a MIME type (e.g., image/jpeg).
  string? mime_type;
};

// @generate glic_api
// Result of retrieving image bytes.
struct ImageBytesResult {
  // Raw encoded image bytes.
  // @glic_type ArrayBuffer
  mojo_base.mojom.BigBuffer bytes;
  // Metadata about the image.
  ImageInfo image_info;
};

// Result of retrieving image bytes or failure reason.
union GetImageBytesResult {
  ImageBytesResult image_bytes;
  string error_reason;
};

// @generate glic_api
// Fields of interest from the Glic settings page.
// Next version: 2
[Stable, Extensible]
enum SettingsPageField {
  [Default] kNone = 0,
  // The OS hotkey configuration field.
  kOsHotkey,
  // The OS entrypoint enabling field.
  kOsEntrypointToggle,
  // The location permission field.
  [MinVersion=1] kLocationPermission,
};

// @generate glic_api
// Optional parameters for the openGlicSettingsPage function.
struct OpenSettingsOptions {
  // Optionally select a field to be highlighted while opening the Glic settings
  // page.
  // @glic_optional
  SettingsPageField highlightField;
};

// @generate glic_api
// Describes the capability of the glic host.
enum HostCapability {
  // Glic host supports scrollTo() with PDF documents.
  kScrollToPdf = 0,
  // Glic host will reset panel size and location on open.
  kResetSizeAndLocationOnOpen = 1,
  // The glic host's getModelQualityClientId() is enabled and can be called
  // safely.
  kGetModelQualityClientId = 2,
  // Glic is in multi-instance mode.
  kMultiInstance = 3,
  // Enables the experimental "Trust First" (Arm 1 - "Start Chat") onboarding
  // UI flow, bypassing the standard FRE flow.
  kTrustFirstOnboardingArm1 = 4,
  // Enables the experimental "Trust First" (Arm 2 - "Welcome Screen")
  // onboarding UI flow, bypassing the standard FRE flow.
  kTrustFirstOnboardingArm2 = 5,
  // Glic host supports sharing additional image context.
  kShareAdditionalImageContext = 6,
  // Enables the PDF Zero State Web UI.
  kPdfZeroState = 7,
  // Indicates that the host supports the invoke mechanism.
  kInvoke = 8,
  // Indicates that the host does not support Live Mode.
  kNoLiveMode = 9,
  // Indicates that the host supports auto browse attempting login using Sign in
  // with Google.
  kAutoLoginSignInWithGoogle = 10,
  // Indicates that the host supports sharing images via the invoke mechanism.
  kShareImageViaInvoke = 11,
  // Indicates that the host supports image drag and drop from the web
  kImgWebDragDrop = 12,
  // Indicates that the host does not show the WebUi preloader.
  kNoWebUiLoader = 13,
  // Indicates that the host enforces paste eligibility checks.
  kEnforcesPasteEligibility = 14,
  // Indicates that the host supports autofilling OTPs.
  kAttemptOtpFilling = 15,
};

// @generate glic_api
// Lists capabilities that the glic web client may support.
enum ClientCapabilities {
  // The glic web client does not use favicons in TabData, so they can
  // be omitted from TabData.
  kIgnoresTabDataFavicons = 0,
};
