From 4e2c3da6af827cbf70e105635d87bdf5bb975924 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Wed, 28 Mar 2012 12:33:41 -0400 Subject: [PATCH] Bug 732708 - remove nsIDOMStorageList; r=honzab --- dom/base/nsDOMClassInfo.cpp | 18 -- dom/base/nsDOMClassInfo.h | 30 ---- dom/base/nsDOMClassInfoClasses.h | 1 - dom/base/nsGlobalWindow.cpp | 9 - dom/base/nsGlobalWindow.h | 1 - dom/interfaces/base/nsIDOMWindow.idl | 1 - dom/interfaces/storage/Makefile.in | 1 - dom/interfaces/storage/nsIDOMStorageList.idl | 60 ------- dom/src/storage/nsDOMStorage.cpp | 170 ------------------- dom/src/storage/nsDOMStorage.h | 57 ------- 10 files changed, 348 deletions(-) delete mode 100644 dom/interfaces/storage/nsIDOMStorageList.idl diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index f08a23e10957..1f18cbf6d82e 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -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(aNative); - - return storagelist->GetNamedItem(aName, aResult); -} - - // nsIDOMEventListener::HandleEvent() 'this' converter helper NS_INTERFACE_MAP_BEGIN(nsEventListenerThisTranslator) diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index 3dafff1ff6a7..0f06bd8cac94 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -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 diff --git a/dom/base/nsDOMClassInfoClasses.h b/dom/base/nsDOMClassInfoClasses.h index 619c8dc36dd0..dac5385a5002 100644 --- a/dom/base/nsDOMClassInfoClasses.h +++ b/dom/base/nsDOMClassInfoClasses.h @@ -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) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index af6cad814b75..d5cb2c0e2eeb 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -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); diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index c97973e5deff..4015d96bafc3 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -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" diff --git a/dom/interfaces/base/nsIDOMWindow.idl b/dom/interfaces/base/nsIDOMWindow.idl index 50162d3ee9d3..ab59d52ea518 100644 --- a/dom/interfaces/base/nsIDOMWindow.idl +++ b/dom/interfaces/base/nsIDOMWindow.idl @@ -49,7 +49,6 @@ interface nsIDOMMediaQueryList; interface nsIDOMOfflineResourceList; interface nsIDOMPerformance; interface nsIDOMStorage; -interface nsIDOMStorageList; interface nsIPrompt; interface nsISelection; interface nsIVariant; diff --git a/dom/interfaces/storage/Makefile.in b/dom/interfaces/storage/Makefile.in index 690d3ebfbfc8..7223c183b495 100644 --- a/dom/interfaces/storage/Makefile.in +++ b/dom/interfaces/storage/Makefile.in @@ -62,7 +62,6 @@ SDK_XPIDLSRCS = \ nsIDOMStorageEventObsolete.idl \ nsIDOMStorageItem.idl \ nsIDOMStorageIndexedDB.idl \ - nsIDOMStorageList.idl \ $(NULL) include $(topsrcdir)/config/rules.mk diff --git a/dom/interfaces/storage/nsIDOMStorageList.idl b/dom/interfaces/storage/nsIDOMStorageList.idl deleted file mode 100644 index 28acac7af1ee..000000000000 --- a/dom/interfaces/storage/nsIDOMStorageList.idl +++ /dev/null @@ -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 - * 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); -}; diff --git a/dom/src/storage/nsDOMStorage.cpp b/dom/src/storage/nsDOMStorage.cpp index d3e7ff85e8d3..09de92348d11 100644 --- a/dom/src/storage/nsDOMStorage.cpp +++ b/dom/src/storage/nsDOMStorage.cpp @@ -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 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 subjectPrincipal; - *aResult = ssm->GetSubjectPrincipal(getter_AddRefs(subjectPrincipal)); - NS_ENSURE_SUCCESS(*aResult, nsnull); - - nsCAutoString currentDomain; - if (subjectPrincipal) { - nsCOMPtr 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 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 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 *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 // diff --git a/dom/src/storage/nsDOMStorage.h b/dom/src/storage/nsDOMStorage.h index dafb48bed512..4ac4736672f6 100644 --- a/dom/src/storage/nsDOMStorage.h +++ b/dom/src/storage/nsDOMStorage.h @@ -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 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* aArray); - - nsInterfaceHashtable 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);