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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 /**
6 * Abstraction on top of the wifi support from libhardware_legacy that we
7 * use to talk to the wpa_supplicant.
8 */
10 #ifndef WifiUtils_h
11 #define WifiUtils_h
13 #include "nsString.h"
14 #include "nsAutoPtr.h"
15 #include "mozilla/dom/WifiOptionsBinding.h"
16 #include "mozilla/dom/network/NetUtils.h"
17 #include "nsCxPusher.h"
19 // Needed to add a copy constructor to WifiCommandOptions.
20 struct CommandOptions
21 {
22 public:
23 CommandOptions(const CommandOptions& aOther) {
24 mId = aOther.mId;
25 mCmd = aOther.mCmd;
26 mRequest = aOther.mRequest;
27 mIfname = aOther.mIfname;
28 mRoute = aOther.mRoute;
29 mIpaddr = aOther.mIpaddr;
30 mMask = aOther.mMask;
31 mGateway = aOther.mGateway;
32 mDns1 = aOther.mDns1;
33 mDns2 = aOther.mDns2;
34 mKey = aOther.mKey;
35 mValue = aOther.mValue;
36 mDefaultValue = aOther.mDefaultValue;
37 }
39 CommandOptions(const mozilla::dom::WifiCommandOptions& aOther) {
41 #define COPY_OPT_FIELD(prop, defaultValue) \
42 if (aOther.prop.WasPassed()) { \
43 prop = aOther.prop.Value(); \
44 } else { \
45 prop = defaultValue; \
46 }
48 #define COPY_FIELD(prop) prop = aOther.prop;
49 COPY_FIELD(mId)
50 COPY_FIELD(mCmd)
51 COPY_OPT_FIELD(mRequest, EmptyString())
52 COPY_OPT_FIELD(mIfname, EmptyString())
53 COPY_OPT_FIELD(mIpaddr, 0)
54 COPY_OPT_FIELD(mRoute, 0)
55 COPY_OPT_FIELD(mMask, 0)
56 COPY_OPT_FIELD(mGateway, 0)
57 COPY_OPT_FIELD(mDns1, 0)
58 COPY_OPT_FIELD(mDns2, 0)
59 COPY_OPT_FIELD(mKey, EmptyString())
60 COPY_OPT_FIELD(mValue, EmptyString())
61 COPY_OPT_FIELD(mDefaultValue, EmptyString())
63 #undef COPY_OPT_FIELD
64 #undef COPY_FIELD
65 }
67 // All the fields, not Optional<> anymore to get copy constructors.
68 nsString mCmd;
69 nsString mDefaultValue;
70 int32_t mDns1;
71 int32_t mDns2;
72 int32_t mGateway;
73 int32_t mId;
74 nsString mIfname;
75 int32_t mIpaddr;
76 nsString mKey;
77 int32_t mMask;
78 nsString mRequest;
79 int32_t mRoute;
80 nsString mValue;
81 };
83 // Abstract class that exposes libhardware_legacy functions we need for
84 // wifi management.
85 // We use the ICS signatures here since they are likely more future-proof.
86 class WpaSupplicantImpl
87 {
88 public:
89 // Suppress warning from nsAutoPtr
90 virtual ~WpaSupplicantImpl() {}
92 virtual int32_t
93 do_wifi_wait_for_event(const char *iface, char *buf, size_t len) = 0; // KK == ICS != JB
95 virtual int32_t
96 do_wifi_command(const char* iface, const char* cmd, char* buff, size_t* len) = 0; // KK == ICS != JB
98 virtual int32_t
99 do_wifi_load_driver() = 0;
101 virtual int32_t
102 do_wifi_unload_driver() = 0;
104 virtual int32_t
105 do_wifi_start_supplicant(int32_t) = 0; // ICS != JB == KK
107 virtual int32_t
108 do_wifi_stop_supplicant(int32_t) = 0; //ICS != JB == KK
110 virtual int32_t
111 do_wifi_connect_to_supplicant(const char* iface) = 0; // KK == ICS != JB
113 virtual void
114 do_wifi_close_supplicant_connection(const char* iface) = 0; // KK == ICS != JB
115 };
117 // Concrete class to use to access the wpa supplicant.
118 class WpaSupplicant MOZ_FINAL
119 {
120 public:
121 WpaSupplicant();
123 // Use nsCString as the type of aInterface to guarantee it's
124 // null-terminated so that we can pass it to c API without
125 // conversion
126 void WaitForEvent(nsAString& aEvent, const nsCString& aInterface);
127 bool ExecuteCommand(CommandOptions aOptions,
128 mozilla::dom::WifiResultOptions& result,
129 const nsCString& aInterface);
131 private:
132 nsAutoPtr<WpaSupplicantImpl> mImpl;
133 nsAutoPtr<NetUtils> mNetUtils;
135 protected:
136 void CheckBuffer(char* buffer, int32_t length, nsAString& aEvent);
137 uint32_t MakeMask(uint32_t len);
138 };
140 #endif // WifiUtils_h