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.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * vim: set ts=4 sw=4 et tw=80: |
michael@0 | 3 | * |
michael@0 | 4 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 7 | |
michael@0 | 8 | #ifndef mozilla_jsipc_JavaScriptParent__ |
michael@0 | 9 | #define mozilla_jsipc_JavaScriptParent__ |
michael@0 | 10 | |
michael@0 | 11 | #include "JavaScriptShared.h" |
michael@0 | 12 | #include "mozilla/jsipc/PJavaScriptParent.h" |
michael@0 | 13 | #include "js/Class.h" |
michael@0 | 14 | |
michael@0 | 15 | #ifdef XP_WIN |
michael@0 | 16 | #undef GetClassName |
michael@0 | 17 | #undef GetClassInfo |
michael@0 | 18 | #endif |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | namespace jsipc { |
michael@0 | 22 | |
michael@0 | 23 | class JavaScriptParent |
michael@0 | 24 | : public PJavaScriptParent, |
michael@0 | 25 | public JavaScriptShared |
michael@0 | 26 | { |
michael@0 | 27 | public: |
michael@0 | 28 | JavaScriptParent(); |
michael@0 | 29 | |
michael@0 | 30 | bool init(); |
michael@0 | 31 | |
michael@0 | 32 | public: |
michael@0 | 33 | // Fundamental proxy traps. These are required. |
michael@0 | 34 | // (The traps should be in the same order like js/src/jsproxy.h) |
michael@0 | 35 | bool preventExtensions(JSContext *cx, JS::HandleObject proxy); |
michael@0 | 36 | bool getPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, |
michael@0 | 37 | JS::MutableHandle<JSPropertyDescriptor> desc); |
michael@0 | 38 | bool getOwnPropertyDescriptor(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, |
michael@0 | 39 | JS::MutableHandle<JSPropertyDescriptor> desc); |
michael@0 | 40 | bool defineProperty(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, |
michael@0 | 41 | JS::MutableHandle<JSPropertyDescriptor> desc); |
michael@0 | 42 | bool getOwnPropertyNames(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props); |
michael@0 | 43 | bool delete_(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); |
michael@0 | 44 | bool enumerate(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props); |
michael@0 | 45 | |
michael@0 | 46 | // Derived proxy traps. Implementing these is useful for perfomance. |
michael@0 | 47 | bool has(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); |
michael@0 | 48 | bool hasOwn(JSContext *cx, JS::HandleObject proxy, JS::HandleId id, bool *bp); |
michael@0 | 49 | bool get(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver, |
michael@0 | 50 | JS::HandleId id, JS::MutableHandleValue vp); |
michael@0 | 51 | bool set(JSContext *cx, JS::HandleObject proxy, JS::HandleObject receiver, |
michael@0 | 52 | JS::HandleId id, bool strict, JS::MutableHandleValue vp); |
michael@0 | 53 | bool keys(JSContext *cx, JS::HandleObject proxy, JS::AutoIdVector &props); |
michael@0 | 54 | // We use "iterate" provided by the base class here. |
michael@0 | 55 | |
michael@0 | 56 | // SpiderMonkey Extensions. |
michael@0 | 57 | bool isExtensible(JSContext *cx, JS::HandleObject proxy, bool *extensible); |
michael@0 | 58 | bool call(JSContext *cx, JS::HandleObject proxy, const JS::CallArgs &args); |
michael@0 | 59 | bool objectClassIs(JSContext *cx, JS::HandleObject obj, js::ESClassValue classValue); |
michael@0 | 60 | const char* className(JSContext *cx, JS::HandleObject proxy); |
michael@0 | 61 | |
michael@0 | 62 | virtual void ActorDestroy(ActorDestroyReason why); |
michael@0 | 63 | |
michael@0 | 64 | void decref(); |
michael@0 | 65 | void incref(); |
michael@0 | 66 | |
michael@0 | 67 | bool active() { return !inactive_; } |
michael@0 | 68 | |
michael@0 | 69 | void drop(JSObject *obj); |
michael@0 | 70 | |
michael@0 | 71 | static bool IsCPOW(JSObject *obj); |
michael@0 | 72 | |
michael@0 | 73 | static nsresult InstanceOf(JSObject *obj, const nsID *id, bool *bp); |
michael@0 | 74 | nsresult instanceOf(JSObject *obj, const nsID *id, bool *bp); |
michael@0 | 75 | |
michael@0 | 76 | /* |
michael@0 | 77 | * Check that |obj| is a DOM wrapper whose prototype chain contains |
michael@0 | 78 | * |prototypeID| at depth |depth|. |
michael@0 | 79 | */ |
michael@0 | 80 | static bool DOMInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp); |
michael@0 | 81 | bool domInstanceOf(JSContext *cx, JSObject *obj, int prototypeID, int depth, bool *bp); |
michael@0 | 82 | |
michael@0 | 83 | mozilla::ipc::IProtocol* |
michael@0 | 84 | CloneProtocol(Channel* aChannel, ProtocolCloneContext* aCtx) MOZ_OVERRIDE; |
michael@0 | 85 | |
michael@0 | 86 | protected: |
michael@0 | 87 | JSObject *unwrap(JSContext *cx, ObjectId objId); |
michael@0 | 88 | |
michael@0 | 89 | private: |
michael@0 | 90 | bool makeId(JSContext *cx, JSObject *obj, ObjectId *idp); |
michael@0 | 91 | bool getPropertyNames(JSContext *cx, JS::HandleObject proxy, uint32_t flags, |
michael@0 | 92 | JS::AutoIdVector &props); |
michael@0 | 93 | ObjectId idOf(JSObject *obj); |
michael@0 | 94 | |
michael@0 | 95 | // Catastrophic IPC failure. |
michael@0 | 96 | bool ipcfail(JSContext *cx); |
michael@0 | 97 | |
michael@0 | 98 | // Check whether a return status is okay, and if not, propagate its error. |
michael@0 | 99 | bool ok(JSContext *cx, const ReturnStatus &status); |
michael@0 | 100 | |
michael@0 | 101 | private: |
michael@0 | 102 | uintptr_t refcount_; |
michael@0 | 103 | bool inactive_; |
michael@0 | 104 | }; |
michael@0 | 105 | |
michael@0 | 106 | } // jsipc |
michael@0 | 107 | } // mozilla |
michael@0 | 108 | |
michael@0 | 109 | #endif // mozilla_jsipc_JavaScriptWrapper_h__ |
michael@0 | 110 |