xpcom/glue/GenericModule.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #include "mozilla/ModuleUtils.h"
michael@0 7 #include "mozilla/GenericFactory.h"
michael@0 8
michael@0 9 #include "nsICategoryManager.h"
michael@0 10 #include "nsIComponentManager.h"
michael@0 11 #include "nsIComponentRegistrar.h"
michael@0 12 #include "nsServiceManagerUtils.h"
michael@0 13 #include "nsXPCOMCID.h"
michael@0 14 #include "nsStringAPI.h"
michael@0 15
michael@0 16 namespace mozilla {
michael@0 17
michael@0 18 NS_IMPL_ISUPPORTS(GenericModule, nsIModule)
michael@0 19
michael@0 20 NS_IMETHODIMP
michael@0 21 GenericModule::GetClassObject(nsIComponentManager* aCompMgr,
michael@0 22 const nsCID& aCID,
michael@0 23 const nsIID& aIID,
michael@0 24 void** aResult)
michael@0 25 {
michael@0 26 for (const Module::CIDEntry* e = mData->mCIDs; e->cid; ++e) {
michael@0 27 if (e->cid->Equals(aCID)) {
michael@0 28 nsCOMPtr<nsIFactory> f;
michael@0 29 if (e->getFactoryProc) {
michael@0 30 f = e->getFactoryProc(*mData, *e);
michael@0 31 }
michael@0 32 else {
michael@0 33 NS_ASSERTION(e->constructorProc, "No constructor proc?");
michael@0 34 f = new GenericFactory(e->constructorProc);
michael@0 35 }
michael@0 36 if (!f)
michael@0 37 return NS_ERROR_FAILURE;
michael@0 38
michael@0 39 return f->QueryInterface(aIID, aResult);
michael@0 40 }
michael@0 41 }
michael@0 42 NS_ERROR("Asking a module for a CID it doesn't implement.");
michael@0 43 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 44 }
michael@0 45
michael@0 46 NS_IMETHODIMP
michael@0 47 GenericModule::RegisterSelf(nsIComponentManager* aCompMgr,
michael@0 48 nsIFile* aLocation,
michael@0 49 const char* aLoaderStr,
michael@0 50 const char* aType)
michael@0 51 {
michael@0 52 nsCOMPtr<nsIComponentRegistrar> r = do_QueryInterface(aCompMgr);
michael@0 53 for (const Module::CIDEntry* e = mData->mCIDs; e->cid; ++e)
michael@0 54 r->RegisterFactoryLocation(*e->cid, "", nullptr, aLocation, aLoaderStr, aType);
michael@0 55
michael@0 56 for (const Module::ContractIDEntry* e = mData->mContractIDs;
michael@0 57 e && e->contractid;
michael@0 58 ++e)
michael@0 59 r->RegisterFactoryLocation(*e->cid, "", e->contractid, aLocation, aLoaderStr, aType);
michael@0 60
michael@0 61 nsCOMPtr<nsICategoryManager> catman;
michael@0 62 for (const Module::CategoryEntry* e = mData->mCategoryEntries;
michael@0 63 e && e->category;
michael@0 64 ++e) {
michael@0 65 if (!catman)
michael@0 66 catman = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
michael@0 67
michael@0 68 nsAutoCString r;
michael@0 69 catman->AddCategoryEntry(e->category, e->entry, e->value, true, true,
michael@0 70 getter_Copies(r));
michael@0 71 }
michael@0 72 return NS_OK;
michael@0 73 }
michael@0 74
michael@0 75 NS_IMETHODIMP
michael@0 76 GenericModule::UnregisterSelf(nsIComponentManager* aCompMgr,
michael@0 77 nsIFile* aFile,
michael@0 78 const char* aLoaderStr)
michael@0 79 {
michael@0 80 NS_ERROR("Nobody should ever call UnregisterSelf!");
michael@0 81 return NS_ERROR_NOT_IMPLEMENTED;
michael@0 82 }
michael@0 83
michael@0 84 NS_IMETHODIMP
michael@0 85 GenericModule::CanUnload(nsIComponentManager* aCompMgr, bool* aResult)
michael@0 86 {
michael@0 87 NS_ERROR("Nobody should ever call CanUnload!");
michael@0 88 *aResult = false;
michael@0 89 return NS_OK;
michael@0 90 }
michael@0 91
michael@0 92 } // namespace mozilla

mercurial