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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 et :
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
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef dom_plugins_PluginScriptableObjectParent_h
8 #define dom_plugins_PluginScriptableObjectParent_h 1
10 #include "mozilla/plugins/PPluginScriptableObjectParent.h"
11 #include "mozilla/plugins/PluginMessageUtils.h"
13 #include "npfunctions.h"
14 #include "npruntime.h"
16 namespace mozilla {
17 namespace plugins {
19 class PluginInstanceParent;
20 class PluginScriptableObjectParent;
21 class PPluginIdentifierParent;
23 struct ParentNPObject : NPObject
24 {
25 ParentNPObject()
26 : NPObject(), parent(nullptr), invalidated(false) { }
28 // |parent| is always valid as long as the actor is alive. Once the actor is
29 // destroyed this will be set to null.
30 PluginScriptableObjectParent* parent;
31 bool invalidated;
32 };
34 class PluginScriptableObjectParent : public PPluginScriptableObjectParent
35 {
36 friend class PluginInstanceParent;
38 public:
39 PluginScriptableObjectParent(ScriptableObjectType aType);
40 virtual ~PluginScriptableObjectParent();
42 void
43 InitializeProxy();
45 void
46 InitializeLocal(NPObject* aObject);
48 virtual bool
49 AnswerHasMethod(PPluginIdentifierParent* aId,
50 bool* aHasMethod) MOZ_OVERRIDE;
52 virtual bool
53 AnswerInvoke(PPluginIdentifierParent* aId,
54 const InfallibleTArray<Variant>& aArgs,
55 Variant* aResult,
56 bool* aSuccess) MOZ_OVERRIDE;
58 virtual bool
59 AnswerInvokeDefault(const InfallibleTArray<Variant>& aArgs,
60 Variant* aResult,
61 bool* aSuccess) MOZ_OVERRIDE;
63 virtual bool
64 AnswerHasProperty(PPluginIdentifierParent* aId,
65 bool* aHasProperty) MOZ_OVERRIDE;
67 virtual bool
68 AnswerGetParentProperty(PPluginIdentifierParent* aId,
69 Variant* aResult,
70 bool* aSuccess) MOZ_OVERRIDE;
72 virtual bool
73 AnswerSetProperty(PPluginIdentifierParent* aId,
74 const Variant& aValue,
75 bool* aSuccess) MOZ_OVERRIDE;
77 virtual bool
78 AnswerRemoveProperty(PPluginIdentifierParent* aId,
79 bool* aSuccess) MOZ_OVERRIDE;
81 virtual bool
82 AnswerEnumerate(InfallibleTArray<PPluginIdentifierParent*>* aProperties,
83 bool* aSuccess) MOZ_OVERRIDE;
85 virtual bool
86 AnswerConstruct(const InfallibleTArray<Variant>& aArgs,
87 Variant* aResult,
88 bool* aSuccess) MOZ_OVERRIDE;
90 virtual bool
91 AnswerNPN_Evaluate(const nsCString& aScript,
92 Variant* aResult,
93 bool* aSuccess) MOZ_OVERRIDE;
95 virtual bool
96 RecvProtect() MOZ_OVERRIDE;
98 virtual bool
99 RecvUnprotect() MOZ_OVERRIDE;
101 static const NPClass*
102 GetClass()
103 {
104 return &sNPClass;
105 }
107 PluginInstanceParent*
108 GetInstance() const
109 {
110 return mInstance;
111 }
113 NPObject*
114 GetObject(bool aCanResurrect);
116 // Protect only affects LocalObject actors. It is called by the
117 // ProtectedVariant/Actor helper classes before the actor is used as an
118 // argument to an IPC call and when the child process resurrects a
119 // proxy object to the NPObject associated with this actor.
120 void Protect();
122 // Unprotect only affects LocalObject actors. It is called by the
123 // ProtectedVariant/Actor helper classes after the actor is used as an
124 // argument to an IPC call and when the child process is no longer using this
125 // actor.
126 void Unprotect();
128 // DropNPObject is only used for Proxy actors and is called when the parent
129 // process is no longer using the NPObject associated with this actor. The
130 // child process may subsequently use this actor again in which case a new
131 // NPObject will be created and associated with this actor (see
132 // ResurrectProxyObject).
133 void DropNPObject();
135 ScriptableObjectType
136 Type() const {
137 return mType;
138 }
140 bool GetPropertyHelper(NPIdentifier aName,
141 bool* aHasProperty,
142 bool* aHasMethod,
143 NPVariant* aResult);
145 private:
146 static NPObject*
147 ScriptableAllocate(NPP aInstance,
148 NPClass* aClass);
150 static void
151 ScriptableInvalidate(NPObject* aObject);
153 static void
154 ScriptableDeallocate(NPObject* aObject);
156 static bool
157 ScriptableHasMethod(NPObject* aObject,
158 NPIdentifier aName);
160 static bool
161 ScriptableInvoke(NPObject* aObject,
162 NPIdentifier aName,
163 const NPVariant* aArgs,
164 uint32_t aArgCount,
165 NPVariant* aResult);
167 static bool
168 ScriptableInvokeDefault(NPObject* aObject,
169 const NPVariant* aArgs,
170 uint32_t aArgCount,
171 NPVariant* aResult);
173 static bool
174 ScriptableHasProperty(NPObject* aObject,
175 NPIdentifier aName);
177 static bool
178 ScriptableGetProperty(NPObject* aObject,
179 NPIdentifier aName,
180 NPVariant* aResult);
182 static bool
183 ScriptableSetProperty(NPObject* aObject,
184 NPIdentifier aName,
185 const NPVariant* aValue);
187 static bool
188 ScriptableRemoveProperty(NPObject* aObject,
189 NPIdentifier aName);
191 static bool
192 ScriptableEnumerate(NPObject* aObject,
193 NPIdentifier** aIdentifiers,
194 uint32_t* aCount);
196 static bool
197 ScriptableConstruct(NPObject* aObject,
198 const NPVariant* aArgs,
199 uint32_t aArgCount,
200 NPVariant* aResult);
202 NPObject*
203 CreateProxyObject();
205 // ResurrectProxyObject is only used with Proxy actors. It is called when the
206 // child process uses an actor whose NPObject was deleted by the parent
207 // process.
208 bool ResurrectProxyObject();
210 private:
211 PluginInstanceParent* mInstance;
213 // This may be a ParentNPObject or some other kind depending on who created
214 // it. Have to check its class to find out.
215 NPObject* mObject;
216 int mProtectCount;
218 ScriptableObjectType mType;
220 static const NPClass sNPClass;
221 };
223 } /* namespace plugins */
224 } /* namespace mozilla */
226 #endif /* dom_plugins_PluginScriptableObjectParent_h */