toolkit/components/browser/nsIWebBrowserChrome3.idl
author Myk Melez <myk@mykzilla.org>
Tue, 10 Jan 2017 10:34:38 -0800
changeset 376493 58c050e010a596a5cbb419472714d2d68b8906c2
parent 374067 embedding/browser/nsIWebBrowserChrome3.idl@7362b109b0328879877b8c9e4f7c4ab9d3aa260b
child 377009 54f7bfe3ca1159493abdf19bb94e76e566cd021c
permissions -rw-r--r--
Bug 1309049 - move embedding/ files out of that directory, r=jst,mossop

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsIWebBrowserChrome2.idl"
#include "nsIURI.idl"
#include "nsIDOMNode.idl"

interface nsIDocShell;
interface nsIInputStream;
interface nsIRunnable;

/**
 * nsIWebBrowserChrome3 is an extension to nsIWebBrowserChrome2.
 */
[scriptable, uuid(542b6625-35a9-426a-8257-c12a345383b0)]
interface nsIWebBrowserChrome3 : nsIWebBrowserChrome2
{
  /**
   * Determines the appropriate target for a link.
   *
   * @param originalTarget
   *        The original link target.
   * @param linkURI
   *        Link destination URI.
   * @param aDOMNode
   *        Link DOM node.
   * @param isAppTab
   *        Whether or not the link is in an app tab.
   * @returns A new link target, if appropriate.
   *          Otherwise returns originalTarget.
   */
  AString onBeforeLinkTraversal(in AString originalTarget,
                                in nsIURI linkURI,
                                in nsIDOMNode linkNode,
                                in boolean isAppTab);

  /**
   * Determines whether a load should continue.
   *
   * @param aDocShell
   *        The docshell performing the load.
   * @param aURI
   *        The URI being loaded.
   * @param aReferrer
   *        The referrer of the load.
   */
  bool shouldLoadURI(in nsIDocShell    aDocShell,
                     in nsIURI         aURI,
                     in nsIURI         aReferrer);

  bool shouldLoadURIInThisProcess(in nsIURI aURI);

  /**
   * Attempts to load the currently loaded page into a fresh process to increase
   * available memory.
   *
   * @param aDocShell
   *        The docshell performing the load.
   */
  bool reloadInFreshProcess(in nsIDocShell aDocShell,
                            in nsIURI aURI,
                            in nsIURI aReferrer);

  /**
   * Tell the browser to start prerendering the given document. This prerendering
   * _must_ be for the toplevel document.
   *
   * @param aHref The URI to begin prerendering
   * @param aReferrer The URI of the document requesting the prerender.
   */
  void startPrerenderingDocument(in nsIURI aHref, in nsIURI aReferrer);

  /**
   * Check if there's a prerendered document which matches given URI /
   * referrer, and try to switch to the prerendered document immediately if
   * there is.
   *
   * @param aHref
   *        The URI which is being loaded.
   * @param aReferrer
   *        The referrer for the current load.
   * @param aSuccess
   *        (Optional) a runnable which will be run if the swap is successful.
   * @param aFailure
   *        (Optional) a runnable which will be run if the swap is not
   *        successful. Note it's not invoked if the function returns false.
   *
   * @return True if there is a matched prerendered document to swap with,
   *         false otherwise.
   */
  bool shouldSwitchToPrerenderedDocument(in nsIURI aHref,
                                         in nsIURI aReferrer,
                                         in nsIRunnable aSuccess,
                                         in nsIRunnable aFailure);
};