Bug 732708 - remove nsIDOMStorageList; r=honzab

This commit is contained in:
Nathan Froyd 2012-03-28 12:33:41 -04:00
parent 553dd5ca61
commit 4e2c3da6af
10 changed files with 0 additions and 348 deletions

View File

@ -1356,8 +1356,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
nsIXPCScriptable::WANT_DELPROPERTY |
nsIXPCScriptable::DONT_ENUM_STATIC_PROPS |
nsIXPCScriptable::WANT_NEWENUMERATE)
NS_DEFINE_CLASSINFO_DATA(StorageList, nsStorageListSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(StorageItem, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(StorageEvent, nsDOMGenericSH,
@ -3921,10 +3919,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorage)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(StorageList, nsIDOMStorageList)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageList)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(StorageItem, nsIDOMStorageItem)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageItem)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMToString)
@ -10630,18 +10624,6 @@ nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
return NS_OK;
}
// StorageList scriptable helper
nsISupports*
nsStorageListSH::GetNamedItem(nsISupports *aNative, const nsAString& aName,
nsWrapperCache **aCache, nsresult *aResult)
{
nsDOMStorageList* storagelist = static_cast<nsDOMStorageList*>(aNative);
return storagelist->GetNamedItem(aName, aResult);
}
// nsIDOMEventListener::HandleEvent() 'this' converter helper
NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator)

View File

@ -1427,36 +1427,6 @@ public:
}
};
class nsStorageListSH : public nsNamedArraySH
{
protected:
nsStorageListSH(nsDOMClassInfoData* aData) : nsNamedArraySH(aData)
{
}
virtual ~nsStorageListSH()
{
}
virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex,
nsWrapperCache **aCache, nsresult *aResult)
{
return nsnull;
}
// Override nsNamedArraySH::GetNamedItem()
virtual nsISupports* GetNamedItem(nsISupports *aNative,
const nsAString& aName,
nsWrapperCache **cache,
nsresult *aResult);
public:
static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
{
return new nsStorageListSH(aData);
}
};
// Event handler 'this' translator class, this is called by XPConnect
// when a "function interface" (nsIDOMEventListener) is called, this
// class extracts 'this' fomr the first argument to the called

View File

@ -374,7 +374,6 @@ DOMCI_CLASS(XPathResult)
// WhatWG WebApps Objects
DOMCI_CLASS(StorageObsolete)
DOMCI_CLASS(Storage)
DOMCI_CLASS(StorageList)
DOMCI_CLASS(StorageItem)
DOMCI_CLASS(StorageEvent)
DOMCI_CLASS(StorageEventObsolete)

View File

@ -8453,15 +8453,6 @@ nsGlobalWindow::Observe(nsISupports* aSubject, const char* aTopic,
if (NS_FAILED(rv)) {
return NS_OK;
}
if (!nsDOMStorageList::CanAccessDomain(NS_ConvertUTF16toUTF8(aData),
currentDomain)) {
// This window can't reach the global storage object for the
// domain for which the change happened, so don't fire any
// events in this window.
return NS_OK;
}
}
nsAutoString domain(aData);

View File

@ -88,7 +88,6 @@
#include "mozFlushType.h"
#include "prclist.h"
#include "nsIDOMStorageObsolete.h"
#include "nsIDOMStorageList.h"
#include "nsIDOMStorageEvent.h"
#include "nsIDOMStorageIndexedDB.h"
#include "nsIDOMOfflineResourceList.h"

View File

@ -49,7 +49,6 @@ interface nsIDOMMediaQueryList;
interface nsIDOMOfflineResourceList;
interface nsIDOMPerformance;
interface nsIDOMStorage;
interface nsIDOMStorageList;
interface nsIPrompt;
interface nsISelection;
interface nsIVariant;

View File

@ -62,7 +62,6 @@ SDK_XPIDLSRCS = \
nsIDOMStorageEventObsolete.idl \
nsIDOMStorageItem.idl \
nsIDOMStorageIndexedDB.idl \
nsIDOMStorageList.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,60 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Neil Deakin <enndeakin@sympatico.ca>
* Portions created by the Initial Developer are Copyright (C) 2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
/**
* Interface for a client side storage. See
* http://www.whatwg.org/specs/web-apps/current-work/#scs-client-side
* for more information.
*
* Allows access to contextual storage areas by domain.
*/
interface nsIDOMStorageObsolete;
[scriptable, uuid(A4E9B257-5CCF-4b17-8721-23AC45C83128)]
interface nsIDOMStorageList : nsISupports
{
/**
* Returns a storage object for a particular domain.
*
* @param domain domain to retrieve
* @returns a storage area for the given domain
*/
nsIDOMStorageObsolete namedItem(in DOMString domain);
};

View File

@ -1985,176 +1985,6 @@ nsDOMStorage2::Clear()
return mStorage->Clear();
}
//
// nsDOMStorageList
//
DOMCI_DATA(StorageList, nsDOMStorageList)
NS_INTERFACE_MAP_BEGIN(nsDOMStorageList)
NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_ENTRY(nsIDOMStorageList)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(StorageList)
NS_INTERFACE_MAP_END
NS_IMPL_ADDREF(nsDOMStorageList)
NS_IMPL_RELEASE(nsDOMStorageList)
nsIDOMStorageObsolete*
nsDOMStorageList::GetNamedItem(const nsAString& aDomain, nsresult* aResult)
{
nsCAutoString requestedDomain;
// Normalize the requested domain
nsCOMPtr<nsIIDNService> idn = do_GetService(NS_IDNSERVICE_CONTRACTID);
if (idn) {
*aResult = idn->ConvertUTF8toACE(NS_ConvertUTF16toUTF8(aDomain),
requestedDomain);
NS_ENSURE_SUCCESS(*aResult, nsnull);
} else {
// Don't have the IDN service, best we can do is URL escape.
NS_EscapeURL(NS_ConvertUTF16toUTF8(aDomain),
esc_OnlyNonASCII | esc_AlwaysCopy,
requestedDomain);
}
ToLowerCase(requestedDomain);
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
if (!ssm) {
*aResult = NS_ERROR_FAILURE;
return nsnull;
}
nsCOMPtr<nsIPrincipal> subjectPrincipal;
*aResult = ssm->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal));
NS_ENSURE_SUCCESS(*aResult, nsnull);
nsCAutoString currentDomain;
if (subjectPrincipal) {
nsCOMPtr<nsIURI> unused;
*aResult = GetPrincipalURIAndHost(subjectPrincipal, getter_AddRefs(unused),
currentDomain);
NS_ENSURE_SUCCESS(*aResult, nsnull);
bool sessionOnly;
if (!nsDOMStorage::CanUseStorage(&sessionOnly)) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
}
bool isSystem = nsContentUtils::IsCallerTrustedForRead();
if (currentDomain.IsEmpty() && !isSystem) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
return GetStorageForDomain(requestedDomain,
currentDomain, isSystem, aResult);
}
NS_IMETHODIMP
nsDOMStorageList::NamedItem(const nsAString& aDomain,
nsIDOMStorageObsolete** aStorage)
{
nsresult rv;
NS_IF_ADDREF(*aStorage = GetNamedItem(aDomain, &rv));
return rv;
}
// static
bool
nsDOMStorageList::CanAccessDomain(const nsACString& aRequestedDomain,
const nsACString& aCurrentDomain)
{
return aRequestedDomain.Equals(aCurrentDomain);
}
nsIDOMStorageObsolete*
nsDOMStorageList::GetStorageForDomain(const nsACString& aRequestedDomain,
const nsACString& aCurrentDomain,
bool aNoCurrentDomainCheck,
nsresult* aResult)
{
nsTArray<nsCString> requestedDomainArray;
if ((!aNoCurrentDomainCheck &&
!CanAccessDomain(aRequestedDomain, aCurrentDomain)) ||
!ConvertDomainToArray(aRequestedDomain, &requestedDomainArray)) {
*aResult = NS_ERROR_DOM_SECURITY_ERR;
return nsnull;
}
// now rebuild a string for the domain.
nsCAutoString usedDomain;
PRUint32 requestedPos = 0;
for (requestedPos = 0; requestedPos < requestedDomainArray.Length();
requestedPos++) {
if (!usedDomain.IsEmpty())
usedDomain.Append('.');
usedDomain.Append(requestedDomainArray[requestedPos]);
}
*aResult = NS_OK;
// now have a valid domain, so look it up in the storage table
nsIDOMStorageObsolete* storage = mStorages.GetWeak(usedDomain);
if (!storage) {
nsRefPtr<nsDOMStorage> newstorage;
newstorage = new nsDOMStorage();
if (newstorage && mStorages.Put(usedDomain, newstorage)) {
storage = newstorage;
}
else {
*aResult = NS_ERROR_OUT_OF_MEMORY;
}
}
return storage;
}
// static
bool
nsDOMStorageList::ConvertDomainToArray(const nsACString& aDomain,
nsTArray<nsCString> *aArray)
{
PRInt32 length = aDomain.Length();
PRInt32 n = 0;
while (n < length) {
PRInt32 dotpos = aDomain.FindChar('.', n);
nsCAutoString domain;
if (dotpos == -1) // no more dots
domain.Assign(Substring(aDomain, n));
else if (dotpos - n == 0) // no point continuing in this case
return false;
else if (dotpos >= 0)
domain.Assign(Substring(aDomain, n, dotpos - n));
ToLowerCase(domain);
aArray->AppendElement(domain);
if (dotpos == -1)
break;
n = dotpos + 1;
}
// if n equals the length, there is a dot at the end, so treat it as invalid
return (n != length);
}
nsresult
NS_NewDOMStorageList(nsIDOMStorageList** aResult)
{
*aResult = new nsDOMStorageList();
if (!*aResult)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aResult);
return NS_OK;
}
//
// nsDOMStorageItem
//

View File

@ -45,7 +45,6 @@
#include "nsAutoPtr.h"
#include "nsIDOMStorageObsolete.h"
#include "nsIDOMStorage.h"
#include "nsIDOMStorageList.h"
#include "nsIDOMStorageItem.h"
#include "nsIPermissionManager.h"
#include "nsInterfaceHashtable.h"
@ -465,59 +464,6 @@ private:
nsRefPtr<nsDOMStorage> mStorage;
};
class nsDOMStorageList : public nsIDOMStorageList
{
public:
nsDOMStorageList()
{
mStorages.Init();
}
virtual ~nsDOMStorageList() {}
// nsISupports
NS_DECL_ISUPPORTS
// nsIDOMStorageList
NS_DECL_NSIDOMSTORAGELIST
nsIDOMStorageObsolete* GetNamedItem(const nsAString& aDomain, nsresult* aResult);
/**
* Check whether aCurrentDomain has access to aRequestedDomain
*/
static bool
CanAccessDomain(const nsACString& aRequestedDomain,
const nsACString& aCurrentDomain);
protected:
/**
* Return the global nsIDOMStorageObsolete for a particular domain.
* aNoCurrentDomainCheck may be true to skip the domain comparison;
* this is used for chrome code so that it may retrieve data from
* any domain.
*
* @param aRequestedDomain domain to return
* @param aCurrentDomain domain of current caller
* @param aNoCurrentDomainCheck true to skip domain comparison
*/
nsIDOMStorageObsolete*
GetStorageForDomain(const nsACString& aRequestedDomain,
const nsACString& aCurrentDomain,
bool aNoCurrentDomainCheck,
nsresult* aResult);
/**
* Convert the domain into an array of its component parts.
*/
static bool
ConvertDomainToArray(const nsACString& aDomain,
nsTArray<nsCString>* aArray);
nsInterfaceHashtable<nsCStringHashKey, nsIDOMStorageObsolete> mStorages;
};
class nsDOMStorageItem : public nsIDOMStorageItem,
public nsIDOMToString
{
@ -637,9 +583,6 @@ NS_NewDOMStorage(nsISupports* aOuter, REFNSIID aIID, void** aResult);
nsresult
NS_NewDOMStorage2(nsISupports* aOuter, REFNSIID aIID, void** aResult);
nsresult
NS_NewDOMStorageList(nsIDOMStorageList** aResult);
PRUint32
GetOfflinePermission(const nsACString &aDomain);