diff --git a/mozilla/extensions/cookie/Makefile.in b/mozilla/extensions/cookie/Makefile.in index 295c798c085..8dd061249c0 100644 --- a/mozilla/extensions/cookie/Makefile.in +++ b/mozilla/extensions/cookie/Makefile.in @@ -83,7 +83,6 @@ XPIDLSRCS = \ EXPORTS = \ nsCookieHTTPNotify.h \ - nsCCookie.h \ nsCCookieManager.h \ $(NULL) diff --git a/mozilla/extensions/cookie/nsCCookie.h b/mozilla/extensions/cookie/nsCCookie.h deleted file mode 100644 index 61568b8bf0e..00000000000 --- a/mozilla/extensions/cookie/nsCCookie.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; 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 is mozilla.org code. - * - * The Initial Developer of the Original Code is Netscape Communications Corporation. - * Portions created by Netscape Communications Corporation are - * Copyright (C) 2002 Netscape Communications Corporation. - * 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 LGPL or the GPL. 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 ----- */ - -/* - * This is a "service" and not just an ordinary component. A consumer must talk - * to the service manager, not the component manager. - */ - -#ifndef NSCCOOKIE_H -#define NSCCOOKIE_H - -#include "nsICookie.h" -#define NS_COOKIE_CONTRACTID "@mozilla.org/cookie;1" - -#endif diff --git a/mozilla/extensions/cookie/nsCookie.cpp b/mozilla/extensions/cookie/nsCookie.cpp index 3cf4f0f8e45..38256653312 100644 --- a/mozilla/extensions/cookie/nsCookie.cpp +++ b/mozilla/extensions/cookie/nsCookie.cpp @@ -60,21 +60,22 @@ StrBlockCopy(const nsACString &aSource1, // find the required buffer size, adding 4 for the terminating nulls const PRUint32 totalLength = aSource1.Length() + aSource2.Length() + aSource3.Length() + aSource4.Length() + 4; - char *result = NS_STATIC_CAST(char*, nsMemory::Alloc(totalLength * sizeof(char))); - NS_ASSERTION(result, "out of memory allocating for nsCookie!"); - - nsACString::const_iterator fromBegin, fromEnd; - char *toBegin = result; + char *toBegin = NS_STATIC_CAST(char*, nsMemory::Alloc(totalLength * sizeof(char))); + NS_ASSERTION(toBegin, "out of memory allocating for nsCookie!"); aDest1 = toBegin; - *copy_string(aSource1.BeginReading(fromBegin), aSource1.EndReading(fromEnd), toBegin) = char(0); - aDest2 = ++toBegin; - *copy_string(aSource2.BeginReading(fromBegin), aSource2.EndReading(fromEnd), toBegin) = char(0); - aDest3 = ++toBegin; - *copy_string(aSource3.BeginReading(fromBegin), aSource3.EndReading(fromEnd), toBegin) = char(0); - aDest4 = ++toBegin; - *copy_string(aSource4.BeginReading(fromBegin), aSource4.EndReading(fromEnd), toBegin) = char(0); - aDestEnd = toBegin; + if (toBegin) { + nsACString::const_iterator fromBegin, fromEnd; + + *copy_string(aSource1.BeginReading(fromBegin), aSource1.EndReading(fromEnd), toBegin) = char(0); + aDest2 = ++toBegin; + *copy_string(aSource2.BeginReading(fromBegin), aSource2.EndReading(fromEnd), toBegin) = char(0); + aDest3 = ++toBegin; + *copy_string(aSource3.BeginReading(fromBegin), aSource3.EndReading(fromEnd), toBegin) = char(0); + aDest4 = ++toBegin; + *copy_string(aSource4.BeginReading(fromBegin), aSource4.EndReading(fromEnd), toBegin) = char(0); + aDestEnd = toBegin; + } } /****************************************************************************** diff --git a/mozilla/extensions/cookie/nsCookie.h b/mozilla/extensions/cookie/nsCookie.h index a1678a10043..fb382ecd2a7 100644 --- a/mozilla/extensions/cookie/nsCookie.h +++ b/mozilla/extensions/cookie/nsCookie.h @@ -69,15 +69,6 @@ class nsCookie : public nsICookie2 NS_DECL_NSICOOKIE NS_DECL_NSICOOKIE2 - // XXX the default ctor is required by nsModuleFactory.cpp, - // because it registers nsCookie as a module with a constructor. - // this probably shouldn't be happening. same for nsPermission. - nsCookie() - : mName(nsnull) - , mRefCnt(0) - { - } - nsCookie(const nsACString &aName, const nsACString &aValue, const nsACString &aHost, @@ -111,6 +102,8 @@ class nsCookie : public nsICookie2 inline void SetLastAccessed(nsInt64 aLastAccessed) { mLastAccessed = aLastAccessed; } protected: + nsCookie(); // not to be implemented (required for nsDerivedSafe) + // member variables // we use char* ptrs to store the strings in a contiguous block, // so we save on the overhead of using nsCStrings. However, we @@ -133,7 +126,4 @@ class nsCookie : public nsICookie2 PRUint32 mPolicy : 3; }; -#define NS_COOKIE_CID {0xe9fcb9a4,0xd376,0x458f,{0xb7,0x20,0xe6,0x5e,0x7d,0xf5,0x93,0xbc}} -#define NS_COOKIE2_CID {0xd3493503,0x7854,0x46ed,{0x82,0x84,0x8a,0xf5,0x4a,0x84,0x7e,0xfb}} - #endif // nsCookie_h__ diff --git a/mozilla/extensions/cookie/nsIPermission.idl b/mozilla/extensions/cookie/nsIPermission.idl index 8ebf10e3b71..4f9f1d538c6 100644 --- a/mozilla/extensions/cookie/nsIPermission.idl +++ b/mozilla/extensions/cookie/nsIPermission.idl @@ -47,7 +47,3 @@ interface nsIPermission : nsISupports */ readonly attribute PRUint32 capability; }; - -%{ C++ -#define NS_PERMISSION_CONTRACTID "@mozilla.org/permission;1" -%} diff --git a/mozilla/extensions/cookie/nsModuleFactory.cpp b/mozilla/extensions/cookie/nsModuleFactory.cpp index 31a636483b8..3702d2a3a72 100644 --- a/mozilla/extensions/cookie/nsModuleFactory.cpp +++ b/mozilla/extensions/cookie/nsModuleFactory.cpp @@ -40,9 +40,6 @@ #include "nsIModule.h" #include "nsIGenericFactory.h" #include "nsIServiceManager.h" -#include "nsCookie.h" -#include "nsCCookie.h" -#include "nsPermission.h" #include "nsCCookieManager.h" #include "nsCookieService.h" #include "nsImgManager.h" @@ -50,20 +47,18 @@ #include "nsPopupWindowManager.h" #include "nsCookieHTTPNotify.h" #include "nsICategoryManager.h" -#include "nsXPIDLString.h" #include "nsCookiePromptService.h" #include "nsCookiePermission.h" +#include "nsXPIDLString.h" // Define the constructor function for the objects -NS_GENERIC_FACTORY_CONSTRUCTOR(nsCookie) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsPermission) NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsCookieService, nsCookieService::GetSingleton) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsImgManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPermissionManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPopupWindowManager, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCookieHTTPNotify, Init) -NS_GENERIC_FACTORY_CONSTRUCTOR(nsCookiePromptService) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsCookiePermission, Init) +NS_GENERIC_FACTORY_CONSTRUCTOR(nsCookiePromptService) static NS_METHOD RegisterContentPolicy(nsIComponentManager *aCompMgr, nsIFile *aPath, @@ -99,16 +94,6 @@ UnregisterContentPolicy(nsIComponentManager *aCompMgr, nsIFile *aPath, // The list of components we register static const nsModuleComponentInfo components[] = { - { "Cookie", - NS_COOKIE_CID, - NS_COOKIE_CONTRACTID, - nsCookieConstructor - }, - { "Permission", - NS_PERMISSION_CID, - NS_PERMISSION_CONTRACTID, - nsPermissionConstructor - }, { "CookieManager", NS_COOKIEMANAGER_CID, NS_COOKIEMANAGER_CONTRACTID, diff --git a/mozilla/extensions/cookie/nsPermission.cpp b/mozilla/extensions/cookie/nsPermission.cpp index 64af9ec1ba7..546876a5893 100644 --- a/mozilla/extensions/cookie/nsPermission.cpp +++ b/mozilla/extensions/cookie/nsPermission.cpp @@ -37,41 +37,41 @@ * ***** END LICENSE BLOCK ***** */ #include "nsPermission.h" -#include "nsCRT.h" -#include "prmem.h" // nsPermission Implementation -NS_IMPL_ISUPPORTS2(nsPermission, nsIPermission, nsISupportsWeakReference); +NS_IMPL_ISUPPORTS1(nsPermission, nsIPermission) -nsPermission::nsPermission() +nsPermission::nsPermission(const nsACString &aHost, + PRUint32 aType, + PRUint32 aCapability) + : mHost(aHost) + , mType(aType) + , mCapability(aCapability) { } -nsPermission::nsPermission - (const nsACString &aHost, - PRUint32 aType, - PRUint32 aCapability) -: mHost(aHost), - mType(aType), - mCapability(aCapability) +nsPermission::~nsPermission() { } -nsPermission::~nsPermission() { -} - -NS_IMETHODIMP nsPermission::GetHost(nsACString& aHost) { +NS_IMETHODIMP +nsPermission::GetHost(nsACString &aHost) +{ aHost = mHost; return NS_OK; } -NS_IMETHODIMP nsPermission::GetType(PRUint32 *aType) { +NS_IMETHODIMP +nsPermission::GetType(PRUint32 *aType) +{ *aType = mType; return NS_OK; } -NS_IMETHODIMP nsPermission::GetCapability(PRUint32 *aCapability) { +NS_IMETHODIMP +nsPermission::GetCapability(PRUint32 *aCapability) +{ *aCapability = mCapability; return NS_OK; } diff --git a/mozilla/extensions/cookie/nsPermission.h b/mozilla/extensions/cookie/nsPermission.h index a2dcd579059..cfc87bec237 100644 --- a/mozilla/extensions/cookie/nsPermission.h +++ b/mozilla/extensions/cookie/nsPermission.h @@ -40,13 +40,11 @@ #define nsPermission_h__ #include "nsIPermission.h" -#include "nsWeakReference.h" #include "nsString.h" //////////////////////////////////////////////////////////////////////////////// -class nsPermission : public nsIPermission, - public nsSupportsWeakReference +class nsPermission : public nsIPermission { public: // nsISupports @@ -54,17 +52,14 @@ public: NS_DECL_NSIPERMISSION nsPermission(const nsACString &aHost, PRUint32 aType, PRUint32 aCapability); - nsPermission(); virtual ~nsPermission(); protected: + nsPermission(); // not to be implemented (required for nsDerivedSafe) + nsCString mHost; PRUint32 mType; PRUint32 mCapability; }; -// {28F16D80-157B-11d5-A542-0010A401EB10} -#define NS_PERMISSION_CID \ -{ 0x28f16d80, 0x157b, 0x11d5, { 0xa5, 0x42, 0x0, 0x10, 0xa4, 0x1, 0xeb, 0x10 } } - -#endif /* nsPermission_h__ */ +#endif // nsPermission_h__