browser/components/sessionstore/nsISessionStore.idl

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #include "nsISupports.idl"
     7 interface nsIDOMWindow;
     8 interface nsIDOMNode;
    10 /**
    11  * nsISessionStore keeps track of the current browsing state - i.e.
    12  * tab history, cookies, scroll state, form data, and window features
    13  * - and allows to restore everything into one browser window.
    14  *
    15  * The nsISessionStore API operates mostly on browser windows and the tabbrowser
    16  * tabs contained in them:
    17  *
    18  * * "Browser windows" are those DOM windows having loaded
    19  * chrome://browser/content/browser.xul . From overlays you can just pass the
    20  * global |window| object to the API, though (or |top| from a sidebar).
    21  * From elsewhere you can get browser windows through the nsIWindowMediator
    22  * by looking for "navigator:browser" windows.
    23  *
    24  * * "Tabbrowser tabs" are all the child nodes of a browser window's
    25  * |gBrowser.tabContainer| such as e.g. |gBrowser.selectedTab|.
    26  */
    28 [scriptable, uuid(0c99811f-6c5f-4a78-9c31-2d266d714175)]
    29 interface nsISessionStore : nsISupports
    30 {
    31   /**
    32    * Is it possible to restore the previous session. Will always be false when
    33    * in Private Browsing mode.
    34    */
    35   attribute boolean canRestoreLastSession;
    37   /**
    38    * Restore the previous session if possible. This will not overwrite the
    39    * current session. Instead the previous session will be merged into the
    40    * current session. Current windows will be reused if they were windows that
    41    * pinned tabs were previously restored into. New windows will be opened as
    42    * needed.
    43    *
    44    * Note: This will throw if there is no previous state to restore. Check with
    45    * canRestoreLastSession first to avoid thrown errors.
    46    */
    47   void restoreLastSession();
    49   /**
    50    * Get the current browsing state.
    51    * @returns a JSON string representing the session state.
    52    */
    53   AString getBrowserState();
    55   /**
    56    * Set the browsing state.
    57    * This will immediately restore the state of the whole application to the state
    58    * passed in, *replacing* the current session.
    59    *
    60    * @param aState is a JSON string representing the session state.
    61    */
    62   void setBrowserState(in AString aState);
    64   /**
    65    * @param aWindow is the browser window whose state is to be returned.
    66    *
    67    * @returns a JSON string representing a session state with only one window.
    68    */
    69   AString getWindowState(in nsIDOMWindow aWindow);
    71   /**
    72    * @param aWindow    is the browser window whose state is to be set.
    73    * @param aState     is a JSON string representing a session state.
    74    * @param aOverwrite boolean overwrite existing tabs
    75    */
    76   void setWindowState(in nsIDOMWindow aWindow, in AString aState, in boolean aOverwrite);
    78   /**
    79    * @param aTab is the tabbrowser tab whose state is to be returned.
    80    *
    81    * @returns a JSON string representing the state of the tab
    82    *         (note: doesn't contain cookies - if you need them, use getWindowState instead).
    83    */
    84   AString getTabState(in nsIDOMNode aTab);
    86   /**
    87    * @param aTab   is the tabbrowser tab whose state is to be set.
    88    * @param aState is a JSON string representing a session state.
    89    */
    90   void setTabState(in nsIDOMNode aTab, in AString aState);
    92   /**
    93    * Duplicates a given tab as thoroughly as possible.
    94    *
    95    * @param aWindow is the browser window into which the tab will be duplicated.
    96    * @param aTab    is the tabbrowser tab to duplicate (can be from a different window).
    97    * @param aDelta  is the offset to the history entry to load in the duplicated tab.
    98    * @returns a reference to the newly created tab.
    99    */
   100   nsIDOMNode duplicateTab(in nsIDOMWindow aWindow, in nsIDOMNode aTab,
   101                           [optional] in long aDelta);
   103   /**
   104    * Get the number of restore-able tabs for a browser window
   105    */
   106   unsigned long getClosedTabCount(in nsIDOMWindow aWindow);
   108   /**
   109    * Get closed tab data
   110    *
   111    * @param aWindow is the browser window for which to get closed tab data
   112    * @returns a JSON string representing the list of closed tabs.
   113    */
   114   AString getClosedTabData(in nsIDOMWindow aWindow);
   116   /**
   117    * @param aWindow is the browser window to reopen a closed tab in.
   118    * @param aIndex  is the index of the tab to be restored (FIFO ordered).
   119    * @returns a reference to the reopened tab.
   120    */
   121   nsIDOMNode undoCloseTab(in nsIDOMWindow aWindow, in unsigned long aIndex);
   123   /**
   124    * @param aWindow is the browser window associated with the closed tab.
   125    * @param aIndex  is the index of the closed tab to be removed (FIFO ordered).
   126    */
   127   nsIDOMNode forgetClosedTab(in nsIDOMWindow aWindow, in unsigned long aIndex);
   129   /**
   130    * Get the number of restore-able windows
   131    */
   132   unsigned long getClosedWindowCount();
   134   /**
   135    * Get closed windows data
   136    *
   137    * @returns a JSON string representing the list of closed windows.
   138    */
   139   AString getClosedWindowData();
   141   /**
   142    * @param aIndex is the index of the windows to be restored (FIFO ordered).
   143    * @returns the nsIDOMWindow object of the reopened window
   144    */
   145   nsIDOMWindow undoCloseWindow(in unsigned long aIndex);
   147   /**
   148    * @param aIndex  is the index of the closed window to be removed (FIFO ordered).
   149    *
   150    * @throws NS_ERROR_INVALID_ARG
   151    *   when aIndex does not map to a closed window
   152    */
   153   nsIDOMNode forgetClosedWindow(in unsigned long aIndex);
   155   /**
   156    * @param aWindow is the window to get the value for.
   157    * @param aKey    is the value's name.
   158    *
   159    * @returns A string value or an empty string if none is set.
   160    */
   161   AString getWindowValue(in nsIDOMWindow aWindow, in AString aKey);
   163   /**
   164    * @param aWindow      is the browser window to set the value for.
   165    * @param aKey         is the value's name.
   166    * @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects).
   167    */
   168   void setWindowValue(in nsIDOMWindow aWindow, in AString aKey, in AString aStringValue);
   170   /**
   171    * @param aWindow is the browser window to get the value for.
   172    * @param aKey    is the value's name.
   173    */
   174   void deleteWindowValue(in nsIDOMWindow aWindow, in AString aKey);
   176   /**
   177    * @param aTab is the tabbrowser tab to get the value for.
   178    * @param aKey is the value's name.
   179    *
   180    * @returns A string value or an empty string if none is set.
   181    */
   182   AString getTabValue(in nsIDOMNode aTab, in AString aKey);
   184   /**
   185    * @param aTab         is the tabbrowser tab to set the value for.
   186    * @param aKey         is the value's name.
   187    * @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects).
   188    */
   189   void setTabValue(in nsIDOMNode aTab, in AString aKey, in AString aStringValue);
   191   /**
   192    * @param aTab is the tabbrowser tab to get the value for.
   193    * @param aKey is the value's name.
   194    */
   195   void deleteTabValue(in nsIDOMNode aTab, in AString aKey);
   197    /**
   198    * @param aKey is the value's name.
   199    *
   200    * @returns A string value or an empty string if none is set.
   201    */
   202   AString getGlobalValue(in AString aKey);
   204   /**
   205    * @param aKey         is the value's name.
   206    * @param aStringValue is the value itself (use JSON.stringify/parse before setting JS objects).
   207    */
   208   void setGlobalValue(in AString aKey, in AString aStringValue);
   210   /**
   211    * @param aTab is the browser tab to get the value for.
   212    * @param aKey is the value's name.
   213    */
   214   void deleteGlobalValue(in AString aKey);
   216   /**
   217    * @param aName is the name of the attribute to save/restore for all tabbrowser tabs.
   218    */
   219   void persistTabAttribute(in AString aName);
   220 };

mercurial