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.

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

mercurial