// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Do not edit this file manually. See README.chromium for details on
// how to edit this file.

syntax = 'proto3';

option optimize_for = LITE_RUNTIME;
option java_package = 'org.chromium.components.omnibox';
option java_outer_classname = 'AimEligibilityResponseProto';

package omnibox;

import "model_mode.proto";
import "searchbox_config.proto";

// GWS serves this proto from a publicly accessible endpoint.
// DO NOT include any sensitive data in this proto.

// Configuration for AIM eligibility response.
// Next ID: 14
message AimEligibilityResponse {
  // True if the user is eligible for AIM. This is false for users in any AIM
  // holdback.
  optional bool is_eligible = 1;
  optional bool is_pdf_upload_eligible = 2;
  optional bool is_deep_search_eligible = 3;
  optional bool is_canvas_eligible = 4;
  optional bool is_image_generation_eligible = 6;

  // Primitives enablement and compatibility config. Used only by xGA for Capy
  // eligibility for now. Not ready to be consumed by other clients.
  // TODO(wilsonssun): Flesh out values in this config and deprecate the
  // primitive-specific fields above.
  optional SearchboxConfig searchbox_config = 7;

  // The session index of the user.
  optional int32 session_index = 5;

  message QueryParam {
    optional string key = 1;
    optional string value = 2;
  }

  message AimDetectionUrlRule {
    // A set of key-value pairs that must all be present in a URL's
    // query parameters for it to be considered a valid AIM URL.
    repeated QueryParam required_params = 1;

    // The type of AIM experience the user is being led to.
    optional ModelMode type = 2;
  }

  // A list of rules to DETECT potential AIM URLs. Every URL load in the
  // client is inspected against these rules.
  // If a URL matches any rule in this list:
  //   1. A background request is ALWAYS sent to the AIM Eligibility Service
  //   (AES)
  //      to synchronize and update the client's eligibility status.
  //   2. The URL is INTERCEPTED (i.e., prevented from normal navigation and
  //      instead embedded within the AIM Co-Browse experience) ONLY IF
  //      `is_cobrowse_eligible` is true.
  // If no rules exist, or if no rule matches the URL, the client will neither
  // intercept the URL nor send a request to AES.
  repeated AimDetectionUrlRule aim_detection_url_rule = 8;

  // Controls whether a DETECTED AIM URL should be INTERCEPTED and embedded
  // in the Co-Browse experience. This field works in tandem with
  // `aim_detection_url_rule`.
  // When a URL matches a rule in `aim_detection_url_rule`:
  //   - If true: The client INTERCEPTS the URL (for Co-Browse embedding)
  //     AND sends a background request to AES.
  //   - If false: The client does NOT INTERCEPT the URL, but STILL sends
  //     a background request to AES to update client state.
  // This setup allows the Co-Browse feature to be dynamically enabled/disabled
  // via AES response, with the state update affecting subsequent AIM
  // interactions, while ensuring the eligibility status is kept fresh even if
  // interception is off.
  optional bool is_cobrowse_eligible = 9;

  // Controls whether the user is eligible for Chrome Fusebox features.
  // This flag will be controlled by GWS Mendel and used to signal Chrome
  // clients whether to enable or disable Chrome Fusebox and dependent features.
  // The primary use case is to support server-side Mendel holdback studies for
  // Fusebox, ensuring users in a holdback group do not see the Fusebox.
  optional bool is_fusebox_eligible = 10;

  // The explicit list of hosts allowed for Co-Browse URL interception.
  repeated string interception_allowed_hosts = 11;

  // The explicit list of URL paths allowed for Co-Browse URL interception.
  repeated string interception_allowed_paths = 12;

  // Query parameters that, if present in the URL, will prevent the browser
  // from entering Co-Browse mode (bypassing interception).
  repeated QueryParam no_cobrowse_params = 13;
}
