chrome.omnibox (original) (raw)

Description

The omnibox API allows you to register a keyword with Google Chrome's address bar, which is also known as the omnibox.

A screenshot showing suggestions related to the keyword 'Chromium Search'

When the user enters your extension's keyword, the user starts interacting solely with your extension. Each keystroke is sent to your extension, and you can provide suggestions in response.

The suggestions can be richly formatted in a variety of ways. When the user accepts a suggestion, your extension is notified and can take action.

Manifest

The following keys must be declared in the manifest to use this API.

"omnibox"

You must include an "omnibox.keyword" field in the manifest to use the omnibox API. You should also specify a 16 by 16-pixel icon, which will be displayed in the address bar when suggesting that users enter keyword mode.

For example:

{
  "name": "Aaron's omnibox extension",
  "version": "1.0",
  "omnibox": { "keyword" : "aaron" },
  "icons": {
    "16": "16-full-color.png"
  },
  "background": {
    "persistent": false,
    "scripts": ["background.js"]
  }
}

Examples

To try this API, install the omnibox API example from the chrome-extension-samplesrepository.

Types

DefaultSuggestResult

A suggest result.

Properties

DescriptionStyleType

The style type.

Enum

OnInputEnteredDisposition

The window disposition for the omnibox query. This is the recommended context to display results. For example, if the omnibox command is to navigate to a certain URL, a disposition of 'newForegroundTab' means the navigation should take place in a new selected tab.

Enum

"currentTab"

"newForegroundTab"

"newBackgroundTab"

SuggestResult

A suggest result.

Properties

Methods

setDefaultSuggestion()

chrome.omnibox.setDefaultSuggestion(
  suggestion: DefaultSuggestResult,
): Promise

Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar.

Parameters

Returns

Events

onDeleteSuggestion

chrome.omnibox.onDeleteSuggestion.addListener(
  callback: function,
)

User has deleted a suggested result.

Parameters

onInputCancelled

chrome.omnibox.onInputCancelled.addListener(
  callback: function,
)

User has ended the keyword input session without accepting the input.

Parameters

onInputChanged

chrome.omnibox.onInputChanged.addListener(
  callback: function,
)

User has changed what is typed into the omnibox.

Parameters

onInputEntered

chrome.omnibox.onInputEntered.addListener(
  callback: function,
)

User has accepted what is typed into the omnibox.

Parameters

onInputStarted

chrome.omnibox.onInputStarted.addListener(
  callback: function,
)

User has started a keyword input session by typing the extension's keyword. This is guaranteed to be sent exactly once per input session, and before any onInputChanged events.

Parameters