Sat, 03 Jan 2015 20:18:00 +0100
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 "nsIServiceManager.h"
7 #include "nsRDFCID.h"
8 #include "nsIRDFService.h"
9 #include "nsString.h"
10 #include "nsXULTemplateResultStorage.h"
12 NS_IMPL_ISUPPORTS(nsXULTemplateResultStorage, nsIXULTemplateResult)
14 nsXULTemplateResultStorage::nsXULTemplateResultStorage(nsXULTemplateResultSetStorage* aResultSet)
15 {
16 static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
17 nsCOMPtr<nsIRDFService> rdfService = do_GetService(kRDFServiceCID);
18 rdfService->GetAnonymousResource(getter_AddRefs(mNode));
19 mResultSet = aResultSet;
20 if (aResultSet) {
21 mResultSet->FillColumnValues(mValues);
22 }
23 }
25 NS_IMETHODIMP
26 nsXULTemplateResultStorage::GetIsContainer(bool* aIsContainer)
27 {
28 *aIsContainer = false;
29 return NS_OK;
30 }
32 NS_IMETHODIMP
33 nsXULTemplateResultStorage::GetIsEmpty(bool* aIsEmpty)
34 {
35 *aIsEmpty = true;
36 return NS_OK;
37 }
39 NS_IMETHODIMP
40 nsXULTemplateResultStorage::GetMayProcessChildren(bool* aMayProcessChildren)
41 {
42 *aMayProcessChildren = false;
43 return NS_OK;
44 }
46 NS_IMETHODIMP
47 nsXULTemplateResultStorage::GetId(nsAString& aId)
48 {
49 const char* uri = nullptr;
50 mNode->GetValueConst(&uri);
52 aId.Assign(NS_ConvertUTF8toUTF16(uri));
54 return NS_OK;
55 }
57 NS_IMETHODIMP
58 nsXULTemplateResultStorage::GetResource(nsIRDFResource** aResource)
59 {
60 *aResource = mNode;
61 NS_IF_ADDREF(*aResource);
62 return NS_OK;
63 }
65 NS_IMETHODIMP
66 nsXULTemplateResultStorage::GetType(nsAString& aType)
67 {
68 aType.Truncate();
69 return NS_OK;
70 }
73 NS_IMETHODIMP
74 nsXULTemplateResultStorage::GetBindingFor(nsIAtom* aVar, nsAString& aValue)
75 {
76 NS_ENSURE_ARG_POINTER(aVar);
78 aValue.Truncate();
79 if (!mResultSet) {
80 return NS_OK;
81 }
83 int32_t idx = mResultSet->GetColumnIndex(aVar);
84 if (idx < 0) {
85 return NS_OK;
86 }
88 nsIVariant * value = mValues[idx];
89 if (value) {
90 value->GetAsAString(aValue);
91 }
92 return NS_OK;
93 }
95 NS_IMETHODIMP
96 nsXULTemplateResultStorage::GetBindingObjectFor(nsIAtom* aVar, nsISupports** aValue)
97 {
98 NS_ENSURE_ARG_POINTER(aVar);
100 if (mResultSet) {
101 int32_t idx = mResultSet->GetColumnIndex(aVar);
102 if (idx >= 0) {
103 *aValue = mValues[idx];
104 NS_IF_ADDREF(*aValue);
105 return NS_OK;
106 }
107 }
108 *aValue = nullptr;
109 return NS_OK;
110 }
112 NS_IMETHODIMP
113 nsXULTemplateResultStorage::RuleMatched(nsISupports* aQuery, nsIDOMNode* aRuleNode)
114 {
115 return NS_OK;
116 }
118 NS_IMETHODIMP
119 nsXULTemplateResultStorage::HasBeenRemoved()
120 {
121 return NS_OK;
122 }