chrome/browser/web_applications/docs/manifest_migration_process.md
The manifest migration process allows developers to transition users from an
older app (the "source") to a newer app (the "target") by specifying the
migrate_from field in the target app's manifest. This is used when an app's
identity or manifest properties change significantly enough.
A manifest migration happens in several phases:
Detection & Target Installation: The browser detects a migration based on the
manifest of an app, and whether it has the migrate_from and migrate_to
fields.
Metadata Resolution: The system establishes a link between the source app and the target app by updating the source app's metadata, following the 2-way handshake specified in the security section below.
UX Affordance: A notification is surfaced to the user in the source app window, indicating that a migration update is available.
Review Dialog: The user reviews the migration via a comparison dialog showing the "Before" (source) and "After" (target) states.
Finalization: If accepted, the target app is installed with the same OS integration states as the source app, and the source app is uninstalled.
kSuggest: The user is notified and must approve the migration.kForce: Unlike suggested migrations, the user cannot "Ignore" the migration
dialog, and the dialog is triggered immediately when the source app is
launched.To ensure a secure transition, the migration must be validated by both apps:
migrate_from
field.web-app-origin-association file.Manifest Parsing on page load:
Detection & Target Installation: The system can discover a migration requirement through two fields:
migrate_from field: Found in the target app's manifest. The
ManifestUpdateManager
triggers the
WebAppInstallFromMigrateFromFieldCommand,
which verifies if the source app is installed and uses the
MigrationTargetInstallJob to install the target app.migrate_to field: Found in the source app's manifest. This triggers
the
InstallMigrateToAppCommand,
which allows the target app to be installed (in a hidden state) without the
user having to visit the target app's URL. In both cases, the target app is
installed with the SUGGESTED_FROM_MIGRATION install state, keeping it
hidden from the user initially.Metadata Resolution: After a target app is installed (even in its hidden state), the system must establish the link between the apps in the database.
ResolveWebAppPendingMigrationInfoCommand
ensures that source apps point to their respective target apps if a pending
migration exists, or clears the pending migration metadata if the target
app is uninstalled.pending_migration_info (containing the
target's manifest ID and behavior) being set on the source app.WebAppRegistrar notifies observers of the change,
allowing UI components (such as the WebAppTabHelper) to surface the
migration affordance to the user.UX Affordance (Entry Point) Once an app has pending_migration_info, the
system surfaces a notification to the user.
WebAppBrowserController
is responsible for parsing the launched app and showing the migration
dialog if a pending migration exists.WebAppMenuModel)
displays an "App Update Available" label.WebAppBrowserController
triggers the migration dialog after the user clicks the label.The Review Dialog The user is presented with a comparison between the old and new app states.
ReadAppMigrationDataFromDisk
to fetch the "before" (source) and "after" (target) metadata.WebAppUpdateReviewDialog
is displayed, allowing the user to review icons, names, and other changes.Execution and Finalization If the user chooses to proceed, the system executes the final migration command.
WebAppBrowserController
initiates the final migration steps when the user clicks "Accept" in the
dialog.ApplyManifestMigrationCommand.Manifest migrations are synchronized across devices to ensure a seamless transition. If a user accepts a migration on one device (Device A), the state is synced to their other devices (Device B), where the target app is automatically installed and the source app is removed.
InstallFromSyncCommand
uses the
GatherMigrationSourceInfoJob
to locate the source app and retrieve its specific OS integration settings.FetchManifestAndUpdate)
to ensure the target app's metadata is fully synchronized and up-to-date with
its latest manifest.Integration Tests:
WebAppInstallFromMigrateFromFieldCommandBrowserTest:
Tests the initial detection and target installation.WebAppInstallMigrationBrowserTest:
End-to-end migration scenarios.ApplyManifestMigrationCommandBrowserTest:
Tests the full migration flow including OS integration and uninstallation.InstallMigrateToAppCommandBrowserTest:
Tests the installation of the target app when the migrate_to field is
present.InstallFromSyncCommandBrowserTest:
Tests migration propagation across synced devices.Unit Tests:
ResolveWebAppPendingMigrationInfoCommandTest:
Tests metadata establishment.WebAppInstallFromMigrateFromFieldCommandTest:
Tests detection and initial installation.InstallMigrateToAppCommandTest:
Tests the command logic for migrate_to installations.InstallFromSyncCommandTest:
Tests the retrieval of source app metadata during sync.UI Tests:
WebAppUpdateReviewDialogBrowserTests:
Tests the migration UX and dialog interactions.