omnibox

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

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

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

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

omnibox.OnInputEnteredDisposition

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

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

関数

omnibox.setDefaultSuggestion()

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

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

omnibox.onInputChanged

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

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

omnibox.onInputCancelled

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

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
omnibox
OnInputEnteredDisposition
SuggestResult
SuggestResult.content
SuggestResult.deletable
SuggestResult.description
onDeleteSuggestion
onInputCancelled
onInputChanged
onInputEntered
onInputStarted
setDefaultSuggestion

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.

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.