// Copyright 2026 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.mojom"; import "mojo/public/mojom/base/time.mojom"; import "ui/gfx/geometry/mojom/geometry.mojom"; import "url/mojom/url.mojom"; // LINT.IfChange(ProfileReadyState) // The ready state of the profile. enum ProfileReadyState { // The profile is not ready for Glic. kUnknownError, // The account state is paused, and requires sign in. kSignInRequired, // The profile is ready for Glic. kReady, // The profile is not eligible for Glic. kIneligible, // Similar to kIneligible, but the admin has explicitly disabled Glic. kDisabledByAdmin, // Potentially actionable state for travel or VPN region mismatch. kLocationMismatch, // Potentially actionable state for account capability/age restrictions. kIneligibleAccount, }; // LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:GlicProfileReadyState) // Directions for adjusting the zoom level of the WebUI page's hosted webview. enum ZoomAction { kZoomIn, kZoomOut, kReset, }; // A minimal interface for the initial handshake. interface PreloadPage { // The one and only method needed to unblock the frontend. SetProfileReadyState(ProfileReadyState ready_state); // Notifies the page when the guest frame starts a navigation. OnGuestNavigationStarted(); // Notifies the page when the guest frame commits a navigation. OnGuestNavigated(url.mojom.Url url, bool is_api_allowed, GuestPageType page_type, bool is_initial_commit); // Notifies the page when the guest process terminates unexpectedly. OnGuestProcessGone(); // Notifies the page when the web client state changes. WebClientStateChanged(WebClientState state); }; // State of the web client running inside the webview. enum WebClientState { kUninitialized, // The web client has been created, but not initialized. kWarmed, // The web client has finished initialization, with a glic instance, and is // currently responsive. kResponsive, // The web client is not currently responsive. kUnresponsive, // The web client has stopped working (e.g. permanently unresponsive), or // failed to load. kError, }; enum GuestPageType { kRegular = 0, kLogin = 1, kGuestError = 2, kLoadError = 3, kDisabledByAdmin = 4, }; // Functions provided by the WebUI page. interface Page { // Called before the page is shown. IntentToShow(); // TODO(crbug.com/454120908): Remove this method after WebContents warming is // rolled out. // Called any time the ready state of the profile changes. // `ready_state` = `GlicEnabling::GetProfileReadyState()`. SetProfileReadyState(ProfileReadyState ready_state); // Called to inform the page of the UI surface it is being rendered in. UpdatePageState(PanelStateKind panelStateKind); // Notifies the page when the web client ready state changes. ClientReadyStateChanged(bool ready); // Notifies the page to adjust the zoom level of its hosted webview. Zoom(ZoomAction action); }; // Page handler for pre-loading tasks. interface GlicPreloadHandler { // Prepare the webview for loading the client. Sync Google account sign-in // cookies to the webview, if necessary, so that it can sign-in automatically. // If this returns an error, the web client cannot be created. PrepareForClient() => (PrepareForClientResult result); }; // Factory for GlicPreloadHandler used in chrome://glic. interface GlicPreloadHandlerFactory { // Creates the GlicPreloadHandler for chrome://glic. CreatePreloadHandler(pending_receiver receiver, pending_remote page); }; // Factory for PageHandler used in chrome://glic. interface PageHandlerFactory { // Creates the PageHandler for chrome://glic. CreatePageHandler( pending_receiver receiver, pending_remote page) => (string instance_id); }; // It is used in the Glic.PanelWebUiState.FinishState histogram. // This must match enums.xml. // LINT.IfChange(WebUiState) enum WebUiState { // Glic app controller not started. kUninitialized = 0, // Web client begins loading; no visible UI. kBeginLoad = 1, // Loading panel is displayed. This state, combined with the `hold-loading` // state, will be held for `kMinHoldLoadingTimeMs` if entered. kShowLoading = 2, // Loading panel is still displayed, but the web client is ready. This // state will be held for the remainder of `kMinHoldLoadingTimeMs`. kHoldLoading = 3, // Loading panel is displayed until web client is ready, or until // `kMaxWaitTimeMs` timeout is reached. kFinishLoading = 4, // "Something went wrong" error panel is displayed. kError = 5, // Connection offline panel is displayed. kOffline = 6, // Glic is not available for profile; "Unavailable" panel is displayed. kUnavailable = 7, // Web view is displayed. kReady = 8, // Glic is unresponsive. Currently this will show the same UI as kError. kUnresponsive = 9, // Sign in panel is displayed. kSignIn = 10, // Web view is displayed, but it is an error page. kGuestError = 11, // Similar to kUnavailable, but the admin has explicitly disabled Glic. kDisabledByAdmin = 12, // Created for background warming, not yet displayed or fully initialized. kWarmed = 13, // Glic is unavailable due to country location mismatch. kLocationMismatch = 14, // Glic is unavailable due to account capabilities. kIneligibleAccount = 15, }; // LINT.ThenChange(//tools/metrics/histograms/metadata/glic/enums.xml:WebUiState) // The result of `PrepareForClient()`. enum PrepareForClientResult { // Ready to load the web client. kSuccess, // An unknown error occurred while resyncing cookies. kErrorResyncingCookies, // The account state is paused, and requires sign in. kRequiresSignIn, }; enum HelpCenterTopic { kLocationMismatch, kIneligibleAccount, }; // Page handler for the glic WebUI, implemented by the browser. interface PageHandler { // Creates a WebClientHandler, for use by a single web client instance. CreateWebClient(pending_receiver web_client_receiver); // TODO(crbug.com/454120908): Remove this method after WebContents warming is // rolled out. // Prepare the webview for loading the client. Sync Google account sign-in // cookies to the webview, if necessary, so that it can sign-in automatically. // If this returns an error, the web client cannot be created. PrepareForClient() => (PrepareForClientResult result); // Called whenever the webview mainframe commits. WebviewCommitted(url.mojom.Url url); // Notifies the host that the zoom level of the webview has changed. OnZoomLevelChange(double zoom_factor); // Closes the Glic panel. ClosePanel() => (); // Opens a help center topic and closes the Glic panel. OpenHelpCenterTopicAndClosePanel(HelpCenterTopic topic); // Opens the profile picker, and closes the Glic panel. OpenProfilePickerAndClosePanel(); // Opens the disabled by admin link, and closes the Glic panel. OpenDisabledByAdminLinkAndClosePanel(); // Opens the sign-in page, and closes the Glic panel. SignInAndClosePanel(); // Resize the widget hosting the WebUI to the given size. // If `duration` is 0 or less, instantly resize, otherwise run an animation. ResizeWidget(gfx.mojom.Size size, mojo_base.mojom.TimeDelta duration) => (); // Set whether the panel can be manually resized, or if the panel hasn't been // created yet, whether it should be resizable when created. EnableDragResize(bool enabled); // Notifies the PageHandler that the state of the WebUI has changed. OnWebUiStateChanged(WebUiState new_state); };