Interface WebExtension.TabDelegate

Enclosing class:
WebExtension

public static interface WebExtension.TabDelegate
This delegate is invoked whenever an extension uses the `tabs` WebExtension API and the request is not specific to an existing tab, e.g. when creating a new tab. See also WebExtensions/API/tabs.
  • Method Details

    • onNewTab

      @UiThread @Nullable default GeckoResult<GeckoSession> onNewTab(@NonNull WebExtension source, @NonNull WebExtension.CreateTabDetails createDetails)
      Called when tabs.create is invoked, this method returns a *newly-created* session that GeckoView will use to load the requested page on. If the returned value is null the page will not be opened.
      Parameters:
      source - An instance of WebExtension
      createDetails - Information about this tab.
      Returns:
      A GeckoResult which holds the returned GeckoSession. May be null, in which case the request for a new tab by the extension will fail. The implementation of onNewTab is responsible for maintaining a reference to the returned object, to prevent it from being garbage collected.
    • onOpenOptionsPage

      @UiThread default void onOpenOptionsPage(@NonNull WebExtension source)
      Called when runtime.openOptionsPage is invoked with options_ui.open_in_tab = false. In this case, GeckoView delegates options page handling to the app. With options_ui.open_in_tab = true, onNewTab(org.mozilla.geckoview.WebExtension, org.mozilla.geckoview.WebExtension.CreateTabDetails) is called instead.
      Parameters:
      source - An instance of WebExtension.