mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 669603 - Part 2 - Add sessionStorage helpers to nsIDocShell; r=smaug,mayhemer
This commit is contained in:
parent
ff25e344eb
commit
7d954a7579
@ -2584,6 +2584,37 @@ nsDocShell::AddSessionStorage(nsIPrincipal* aPrincipal,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static PLDHashOperator
|
||||
CloneSessionStorages(nsCStringHashKey::KeyType aKey, nsIDOMStorage* aStorage,
|
||||
void* aUserArg)
|
||||
{
|
||||
nsIDocShell *docShell = static_cast<nsIDocShell*>(aUserArg);
|
||||
nsCOMPtr<nsPIDOMStorage> pistorage = do_QueryInterface(aStorage);
|
||||
|
||||
if (pistorage) {
|
||||
nsCOMPtr<nsIDOMStorage> storage = pistorage->Clone();
|
||||
docShell->AddSessionStorage(pistorage->Principal(), storage);
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::CloneSessionStoragesTo(nsIDocShell* aDocShell)
|
||||
{
|
||||
aDocShell->ClearSessionStorages();
|
||||
mStorages.EnumerateRead(CloneSessionStorages, aDocShell);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::ClearSessionStorages()
|
||||
{
|
||||
mStorages.Clear();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetCurrentDocumentChannel(nsIChannel** aResult)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ interface nsIWebBrowserPrint;
|
||||
interface nsIVariant;
|
||||
interface nsIPrivacyTransitionObserver;
|
||||
|
||||
[scriptable, uuid(6f60ac96-fa2c-41a5-92b4-29aaadbd7a7b)]
|
||||
[scriptable, builtinclass, uuid(89ea9f32-18ec-413b-9e2c-ce9a4c851b1c)]
|
||||
interface nsIDocShell : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -434,6 +434,19 @@ interface nsIDocShell : nsISupports
|
||||
*/
|
||||
void addSessionStorage(in nsIPrincipal principal, in nsIDOMStorage storage);
|
||||
|
||||
/**
|
||||
* Clones all session storage objects and attaches them to the given docshell.
|
||||
* Useful when duplicating tabs and their states.
|
||||
*
|
||||
* @param docShell the docshell to clone the sessionstorage objects to
|
||||
*/
|
||||
void cloneSessionStoragesTo(in nsIDocShell docShell);
|
||||
|
||||
/**
|
||||
* Removes all WebApps session storage objects attached to the docshell.
|
||||
*/
|
||||
void clearSessionStorages();
|
||||
|
||||
/**
|
||||
* Gets the channel for the currently loaded document, if any.
|
||||
* For a new document load, this will be the channel of the previous document
|
||||
|
Loading…
Reference in New Issue
Block a user