omnibox

拡張機能に、ユーザーがアドレスバーに入力した時のカスタマイズされた振る舞いを有効にします。

ユーザーがブラウザーのアドレスバーにフォーカスした時、ブラウザーは、タイプした内容に応じたサジェストページを含んだドロップダウンリストを表示します。これはユーザーにとって、例えば履歴やブックマークからのページにすぐにアクセスできる方法を与えます。

omnibox API は、ユーザーが拡張機能で定義されたキーワードを入力した時に、ドロップダウンに表示されるサジェストを拡張機能がカスタマイズする方法を提供します。これは下記のように動作します:

  1. まず、拡張機能は manifest.json ファイルに "omnibox" キーを入れないといけません、ここでキーワードを定義します。
  2. ユーザーがアドレスバーにフォーカスしてキーワードに続いてスペースをタイプした時、拡張機能は omnibox.onInputStarted (en-US) イベントを受け取ります。
  3. オプションとして、拡張機能は omnibox.setDefaultSuggestion() (en-US) を呼んでアドレスバーのドロップダウンに最初に表示されるサジェストを定義します。
  4. ユーザーがこの後にも文字をタイプし続けると、拡張機能は omnibox.onInputChanged (en-US) イベントを受け取ります。イベントリスナーはユーザーがタイプした現在の値を受けて、アドレスバーのドロップダウンにサジェストを生成できます。拡張機能が omnibox.setDefaultSuggestion() (en-US) を使ったデフォルトのサジェストをセットした場合、これがドロップダウンの最初に出てきます。
  5. ユーザーがサジェストを受け入れたら、拡張機能は omnibox.onInputEntered (en-US) イベントを受け取ります。イベントリスナーは受け入れられたサジェストを受け取ります。
  6. ユーザーがドロップダウンを止めたら、拡張機能は omnibox.onInputCancelled (en-US) イベントを受け取ります。

omnibox.OnInputEnteredDisposition (en-US)

Describes the recommended method to handle the selected suggestion: open in the current tab, open in a new foreground tab, or open in a new background tab.

omnibox.SuggestResult (en-US)

Object representing a suggestion to add to the address bar drop-down.

関数

omnibox.setDefaultSuggestion() (en-US)

Defines the first suggestion that appears in the drop-down when the user enters the keyword for your extension, followed by a space.

イベント

omnibox.onInputStarted (en-US)

Fired when a the user focuses the address bar and types your extension's omnibox keyword, followed by a space.

omnibox.onInputChanged (en-US)

Fired whenever the user's input changes, after they have focused the address bar and typed your extension's omnibox keyword, followed by a space.

omnibox.onInputEntered (en-US)

Fired when the user accepts one of your extension's suggestions.

omnibox.onInputCancelled (en-US)

Fired when the user dismisses the address bar drop-down, after they have focused the address bar and typed your extension's omnibox keyword.

ブラウザーの互換性

BCD tables only load in the browser

Example extensions

メモ: This API is based on Chromium's chrome.omnibox API.Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.