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