Native dialogs

Show browser-native alerts, confirmations, and non-modal notifications through chrovia.ui.

Entitlement: nativeDialog. API: chrovia.ui. No EP section is required. Use a Provision Service Worker; page use additionally requires unrestrictedApi.

Show a dialog

Invoke this from your plugin's command handler while a browser window is available:

async function askToContinue() {
  const ui = globalThis.chrovia?.ui;
  if (!ui) {
    throw new Error('nativeDialog is required');
  }
  const accepted = await ui.confirm('SDK Example', 'Continue with this operation?');
  if (!accepted) {
    return false;
  }
  await ui.alert('SDK Example', 'The operation was confirmed.');
  return true;
}

Methods and behavior

MethodResult
alert(title, message)Promise resolving to undefined when the dialog completes
confirm(title, message)Promise resolving to true on accept, false otherwise
notify(title, message)Shows a non-modal notification; resolves to undefined when acknowledged or dismissed, not immediately on display

Title and message are strings, not HTML. Alerts and confirmations use Chromium native message-box UI associated with a browser window. Notifications are non-modal; they do not return the user's approval. There are no custom button, checkbox, or HTML options in this interface.

Handle failures

Await or catch Promises in event handlers; a call can reject if the dialog service is unavailable. With no suitable browser window, alert() can resolve without displaying anything and confirm() resolves to false. Provision Service Worker calls use the last active normal browser window. Do not depend on an alert being seen during headless or pre-window startup phases. For a request decision, keep network interception's timeout and fail-open behavior in mind: leaving a confirmation open past the request timeout does not keep the request blocked.

This API is separate from window.alert and extension notifications. If chrovia.ui is missing, verify nativeDialog and the execution context. Test alerts, accepted and cancelled confirmations, and notification behavior independently.