Back to Chromium

Gemini Model Layer

ios/chrome/browser/intelligence/bwg/model/README.md

150.0.7838.17.0 KB
Original Source

Gemini Model Layer

Last updated: May 2026

This directory contains the core business logic, data models, tab helpers, browser agents, and backend service bridges for the Gemini (BWG) feature integration on Chrome for iOS.

Due to the comprehensive integration of Gemini, the components are categorized into distinct logical subsystems:


Subsystems & Core Components

1. Core State & Scope Management

  • gemini_browser_agent.h & gemini_browser_agent.mm: A browser-scoped agent (BrowserUserData) managing the presentation of the Gemini UI overlay ("floaty"). It monitors scroll and keyboard events to temporarily hide/show the overlay, handles user preferences, and constructs the active session configuration.
  • gemini_tab_helper.h & gemini_tab_helper.mm: A tab-scoped agent (web::WebStateObserver & web::WebStateUserData) that governs the Gemini context for a single tab. It monitors navigation, page loading, title settings, and favicon changes, coordinates with PageContextWrapper to package page data, and implements the zero-state suggestion chips pipeline.
  • gemini_page_context.h & gemini_page_context.mm: An Objective-C data container wrapping C++ move-only optimization_guide::proto::PageContext objects. Implements custom getters with "consume-on-read" semantics, moving ownership of the proto context exactly once to the consumer.
  • gemini_configuration.h & gemini_configuration.mm: A configuration class encapsulating settings (client ID, server ID, animations, suggestions, image attachments) required to initialize or resume a Gemini overlay session.
  • gemini_startup_configuration.h & gemini_startup_configuration.mm: Data model representing entry-point configurations used during startup flows.

2. Session Management

3. Task Actuation (AI-Agent Automation)

  • gemini_actuation_handler.h & gemini_actuation_handler.mm: Implements the GeminiActuationDelegate protocol, bridging between the Gemini UI and the C++ actor::ActorService.
  • Capabilities:
    • Creates automated browser automation tasks.
    • Executes serialized action Protos (e.g., clicking, typing, navigating).
    • Captures page inner-text and screenshot context across multiple controlled tabs asynchronously via base::BarrierCallback.

4. Smart Suggestions & zero-state Chips

6. Page & View State Handlers

7. Services & Factories

8. Observers & Utilities


Test Suites

All components in this folder are covered by specialized unit test suites in the main ios_chrome_unittests target:

  • gemini_browser_agent_unittest.mm
  • gemini_tab_helper_unittest.mm
  • gemini_page_context_unittest.mm
  • gemini_session_handler_unittest.mm
  • gemini_actuation_handler_unittest.mm
  • gemini_camera_handler_unittest.mm
  • gemini_link_opening_handler_unittest.mm
  • gemini_page_state_change_handler_unittest.mm
  • gemini_suggestion_handler_unittest.mm
  • gemini_view_state_change_handler_unittest.mm
  • gemini_configuration_unittest.mm
  • gemini_service_factory_unittest.mm
  • gemini_service_impl_unittest.mm
  • bwg_snapshot_utils_unittest.mm