dom/quota/OriginCollection.h

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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=2 et sw=2 tw=80: */
     3 /* This Source Code Form is subject to the terms of the Mozilla Public
     4  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_quota_origincollection_h__
     8 #define mozilla_dom_quota_origincollection_h__
    10 #include "mozilla/dom/quota/QuotaCommon.h"
    12 #include "nsHashKeys.h"
    13 #include "nsTHashtable.h"
    15 #include "Utilities.h"
    17 BEGIN_QUOTA_NAMESPACE
    19 class OriginCollection
    20 {
    21 public:
    22   bool
    23   ContainsPattern(const nsACString& aPattern)
    24   {
    25     return mPatterns.Contains(aPattern);
    26   }
    28   void
    29   AddPattern(const nsACString& aPattern)
    30   {
    31     MOZ_ASSERT(!mOrigins.Count());
    32     MOZ_ASSERT(!ContainsPattern(aPattern));
    33     mPatterns.AppendElement(aPattern);
    34   }
    36   bool
    37   ContainsOrigin(const nsACString& aOrigin)
    38   {
    39     for (uint32_t index = 0; index < mPatterns.Length(); index++) {
    40       if (PatternMatchesOrigin(mPatterns[index], aOrigin)) {
    41         return true;
    42       }
    43     }
    45     return mOrigins.GetEntry(aOrigin);
    46   }
    48   void
    49   AddOrigin(const nsACString& aOrigin)
    50   {
    51     MOZ_ASSERT(!ContainsOrigin(aOrigin));
    52     mOrigins.PutEntry(aOrigin);
    53   }
    55 private:
    56   nsTArray<nsCString> mPatterns;
    57   nsTHashtable<nsCStringHashKey> mOrigins;
    58 };
    60 END_QUOTA_NAMESPACE
    62 #endif // mozilla_dom_quota_origincollection_h__

mercurial