dom/base/Navigator.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.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 sw=2 et tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_Navigator_h
michael@0 8 #define mozilla_dom_Navigator_h
michael@0 9
michael@0 10 #include "mozilla/MemoryReporting.h"
michael@0 11 #include "mozilla/dom/Nullable.h"
michael@0 12 #include "mozilla/ErrorResult.h"
michael@0 13 #include "nsIDOMNavigator.h"
michael@0 14 #include "nsIMozNavigatorNetwork.h"
michael@0 15 #include "nsAutoPtr.h"
michael@0 16 #include "nsWrapperCache.h"
michael@0 17 #include "nsHashKeys.h"
michael@0 18 #include "nsInterfaceHashtable.h"
michael@0 19 #include "nsString.h"
michael@0 20 #include "nsTArray.h"
michael@0 21
michael@0 22 class nsPluginArray;
michael@0 23 class nsMimeTypeArray;
michael@0 24 class nsPIDOMWindow;
michael@0 25 class nsIDOMMozMobileMessageManager;
michael@0 26 class nsIDOMNavigatorSystemMessages;
michael@0 27 class nsDOMCameraManager;
michael@0 28 class nsDOMDeviceStorage;
michael@0 29 class nsIDOMBlob;
michael@0 30
michael@0 31 namespace mozilla {
michael@0 32 namespace dom {
michael@0 33 class Geolocation;
michael@0 34 class systemMessageCallback;
michael@0 35 class MediaStreamConstraints;
michael@0 36 class WakeLock;
michael@0 37 class ArrayBufferViewOrBlobOrStringOrFormData;
michael@0 38 }
michael@0 39 }
michael@0 40
michael@0 41 #ifdef MOZ_B2G_RIL
michael@0 42 class nsIDOMMozIccManager;
michael@0 43 #endif // MOZ_B2G_RIL
michael@0 44
michael@0 45 //*****************************************************************************
michael@0 46 // Navigator: Script "navigator" object
michael@0 47 //*****************************************************************************
michael@0 48
michael@0 49 namespace mozilla {
michael@0 50 namespace dom {
michael@0 51
michael@0 52 namespace battery {
michael@0 53 class BatteryManager;
michael@0 54 } // namespace battery
michael@0 55
michael@0 56 #ifdef MOZ_B2G_FM
michael@0 57 class FMRadio;
michael@0 58 #endif
michael@0 59
michael@0 60 class Promise;
michael@0 61
michael@0 62 class DesktopNotificationCenter;
michael@0 63 class MobileMessageManager;
michael@0 64 class MozIdleObserver;
michael@0 65 #ifdef MOZ_GAMEPAD
michael@0 66 class Gamepad;
michael@0 67 #endif // MOZ_GAMEPAD
michael@0 68 #ifdef MOZ_MEDIA_NAVIGATOR
michael@0 69 class NavigatorUserMediaSuccessCallback;
michael@0 70 class NavigatorUserMediaErrorCallback;
michael@0 71 class MozGetUserMediaDevicesSuccessCallback;
michael@0 72 #endif // MOZ_MEDIA_NAVIGATOR
michael@0 73
michael@0 74 namespace network {
michael@0 75 class Connection;
michael@0 76 } // namespace Connection;
michael@0 77
michael@0 78 #ifdef MOZ_B2G_BT
michael@0 79 namespace bluetooth {
michael@0 80 class BluetoothManager;
michael@0 81 } // namespace bluetooth
michael@0 82 #endif // MOZ_B2G_BT
michael@0 83
michael@0 84 #ifdef MOZ_B2G_RIL
michael@0 85 class CellBroadcast;
michael@0 86 class IccManager;
michael@0 87 class MobileConnectionArray;
michael@0 88 class Voicemail;
michael@0 89 #endif
michael@0 90
michael@0 91 class PowerManager;
michael@0 92 class Telephony;
michael@0 93
michael@0 94 namespace time {
michael@0 95 class TimeManager;
michael@0 96 } // namespace time
michael@0 97
michael@0 98 namespace system {
michael@0 99 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
michael@0 100 class AudioChannelManager;
michael@0 101 #endif
michael@0 102 } // namespace system
michael@0 103
michael@0 104 class Navigator : public nsIDOMNavigator
michael@0 105 , public nsIMozNavigatorNetwork
michael@0 106 , public nsWrapperCache
michael@0 107 {
michael@0 108 public:
michael@0 109 Navigator(nsPIDOMWindow *aInnerWindow);
michael@0 110 virtual ~Navigator();
michael@0 111
michael@0 112 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
michael@0 113 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Navigator,
michael@0 114 nsIDOMNavigator)
michael@0 115 NS_DECL_NSIDOMNAVIGATOR
michael@0 116 NS_DECL_NSIMOZNAVIGATORNETWORK
michael@0 117
michael@0 118 static void Init();
michael@0 119
michael@0 120 void Invalidate();
michael@0 121 nsPIDOMWindow *GetWindow() const
michael@0 122 {
michael@0 123 return mWindow;
michael@0 124 }
michael@0 125
michael@0 126 void RefreshMIMEArray();
michael@0 127
michael@0 128 static bool HasDesktopNotificationSupport();
michael@0 129
michael@0 130 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
michael@0 131
michael@0 132 /**
michael@0 133 * For use during document.write where our inner window changes.
michael@0 134 */
michael@0 135 void SetWindow(nsPIDOMWindow *aInnerWindow);
michael@0 136
michael@0 137 /**
michael@0 138 * Called when the inner window navigates to a new page.
michael@0 139 */
michael@0 140 void OnNavigation();
michael@0 141
michael@0 142 // Helper to initialize mMessagesManager.
michael@0 143 nsresult EnsureMessagesManager();
michael@0 144
michael@0 145 // The XPCOM GetProduct is OK
michael@0 146 // The XPCOM GetLanguage is OK
michael@0 147 bool OnLine();
michael@0 148 void RegisterProtocolHandler(const nsAString& aScheme, const nsAString& aURL,
michael@0 149 const nsAString& aTitle, ErrorResult& aRv);
michael@0 150 void RegisterContentHandler(const nsAString& aMIMEType, const nsAString& aURL,
michael@0 151 const nsAString& aTitle, ErrorResult& aRv);
michael@0 152 nsMimeTypeArray* GetMimeTypes(ErrorResult& aRv);
michael@0 153 nsPluginArray* GetPlugins(ErrorResult& aRv);
michael@0 154 // The XPCOM GetDoNotTrack is ok
michael@0 155 Geolocation* GetGeolocation(ErrorResult& aRv);
michael@0 156 battery::BatteryManager* GetBattery(ErrorResult& aRv);
michael@0 157
michael@0 158 static void AppName(nsAString& aAppName, bool aUsePrefOverriddenValue);
michael@0 159
michael@0 160 static nsresult GetPlatform(nsAString& aPlatform,
michael@0 161 bool aUsePrefOverriddenValue);
michael@0 162
michael@0 163 static nsresult GetAppVersion(nsAString& aAppVersion,
michael@0 164 bool aUsePrefOverriddenValue);
michael@0 165
michael@0 166 already_AddRefed<Promise> GetDataStores(const nsAString &aName,
michael@0 167 ErrorResult& aRv);
michael@0 168 bool Vibrate(uint32_t aDuration);
michael@0 169 bool Vibrate(const nsTArray<uint32_t>& aDuration);
michael@0 170 uint32_t MaxTouchPoints();
michael@0 171 void GetAppCodeName(nsString& aAppCodeName, ErrorResult& aRv)
michael@0 172 {
michael@0 173 aRv = GetAppCodeName(aAppCodeName);
michael@0 174 }
michael@0 175 void GetOscpu(nsString& aOscpu, ErrorResult& aRv)
michael@0 176 {
michael@0 177 aRv = GetOscpu(aOscpu);
michael@0 178 }
michael@0 179 // The XPCOM GetVendor is OK
michael@0 180 // The XPCOM GetVendorSub is OK
michael@0 181 // The XPCOM GetProductSub is OK
michael@0 182 bool CookieEnabled();
michael@0 183 void GetBuildID(nsString& aBuildID, ErrorResult& aRv)
michael@0 184 {
michael@0 185 aRv = GetBuildID(aBuildID);
michael@0 186 }
michael@0 187 PowerManager* GetMozPower(ErrorResult& aRv);
michael@0 188 bool JavaEnabled(ErrorResult& aRv);
michael@0 189 bool TaintEnabled()
michael@0 190 {
michael@0 191 return false;
michael@0 192 }
michael@0 193 void AddIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
michael@0 194 void RemoveIdleObserver(MozIdleObserver& aObserver, ErrorResult& aRv);
michael@0 195 already_AddRefed<WakeLock> RequestWakeLock(const nsAString &aTopic,
michael@0 196 ErrorResult& aRv);
michael@0 197 nsDOMDeviceStorage* GetDeviceStorage(const nsAString& aType,
michael@0 198 ErrorResult& aRv);
michael@0 199 void GetDeviceStorages(const nsAString& aType,
michael@0 200 nsTArray<nsRefPtr<nsDOMDeviceStorage> >& aStores,
michael@0 201 ErrorResult& aRv);
michael@0 202 DesktopNotificationCenter* GetMozNotification(ErrorResult& aRv);
michael@0 203 bool MozIsLocallyAvailable(const nsAString& aURI, bool aWhenOffline,
michael@0 204 ErrorResult& aRv);
michael@0 205 nsIDOMMozMobileMessageManager* GetMozMobileMessage();
michael@0 206 Telephony* GetMozTelephony(ErrorResult& aRv);
michael@0 207 network::Connection* GetConnection(ErrorResult& aRv);
michael@0 208 nsDOMCameraManager* GetMozCameras(ErrorResult& aRv);
michael@0 209 void MozSetMessageHandler(const nsAString& aType,
michael@0 210 systemMessageCallback* aCallback,
michael@0 211 ErrorResult& aRv);
michael@0 212 bool MozHasPendingMessage(const nsAString& aType, ErrorResult& aRv);
michael@0 213 #ifdef MOZ_B2G_RIL
michael@0 214 MobileConnectionArray* GetMozMobileConnections(ErrorResult& aRv);
michael@0 215 CellBroadcast* GetMozCellBroadcast(ErrorResult& aRv);
michael@0 216 Voicemail* GetMozVoicemail(ErrorResult& aRv);
michael@0 217 IccManager* GetMozIccManager(ErrorResult& aRv);
michael@0 218 #endif // MOZ_B2G_RIL
michael@0 219 #ifdef MOZ_GAMEPAD
michael@0 220 void GetGamepads(nsTArray<nsRefPtr<Gamepad> >& aGamepads, ErrorResult& aRv);
michael@0 221 #endif // MOZ_GAMEPAD
michael@0 222 #ifdef MOZ_B2G_FM
michael@0 223 FMRadio* GetMozFMRadio(ErrorResult& aRv);
michael@0 224 #endif
michael@0 225 #ifdef MOZ_B2G_BT
michael@0 226 bluetooth::BluetoothManager* GetMozBluetooth(ErrorResult& aRv);
michael@0 227 #endif // MOZ_B2G_BT
michael@0 228 #ifdef MOZ_TIME_MANAGER
michael@0 229 time::TimeManager* GetMozTime(ErrorResult& aRv);
michael@0 230 #endif // MOZ_TIME_MANAGER
michael@0 231 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
michael@0 232 system::AudioChannelManager* GetMozAudioChannelManager(ErrorResult& aRv);
michael@0 233 #endif // MOZ_AUDIO_CHANNEL_MANAGER
michael@0 234
michael@0 235 bool SendBeacon(const nsAString& aUrl,
michael@0 236 const Nullable<ArrayBufferViewOrBlobOrStringOrFormData>& aData,
michael@0 237 ErrorResult& aRv);
michael@0 238
michael@0 239 #ifdef MOZ_MEDIA_NAVIGATOR
michael@0 240 void MozGetUserMedia(const MediaStreamConstraints& aConstraints,
michael@0 241 NavigatorUserMediaSuccessCallback& aOnSuccess,
michael@0 242 NavigatorUserMediaErrorCallback& aOnError,
michael@0 243 ErrorResult& aRv);
michael@0 244 void MozGetUserMediaDevices(const MediaStreamConstraints& aConstraints,
michael@0 245 MozGetUserMediaDevicesSuccessCallback& aOnSuccess,
michael@0 246 NavigatorUserMediaErrorCallback& aOnError,
michael@0 247 uint64_t aInnerWindowID,
michael@0 248 ErrorResult& aRv);
michael@0 249 #endif // MOZ_MEDIA_NAVIGATOR
michael@0 250 bool DoNewResolve(JSContext* aCx, JS::Handle<JSObject*> aObject,
michael@0 251 JS::Handle<jsid> aId,
michael@0 252 JS::MutableHandle<JSPropertyDescriptor> aDesc);
michael@0 253 void GetOwnPropertyNames(JSContext* aCx, nsTArray<nsString>& aNames,
michael@0 254 ErrorResult& aRv);
michael@0 255
michael@0 256 // WebIDL helper methods
michael@0 257 static bool HasBatterySupport(JSContext* /* unused*/, JSObject* /*unused */);
michael@0 258 static bool HasPowerSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 259 static bool HasPhoneNumberSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 260 static bool HasIdleSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 261 static bool HasWakeLockSupport(JSContext* /* unused*/, JSObject* /*unused */);
michael@0 262 static bool HasDesktopNotificationSupport(JSContext* /* unused*/,
michael@0 263 JSObject* /*unused */)
michael@0 264 {
michael@0 265 return HasDesktopNotificationSupport();
michael@0 266 }
michael@0 267 static bool HasMobileMessageSupport(JSContext* /* unused */,
michael@0 268 JSObject* aGlobal);
michael@0 269 static bool HasTelephonySupport(JSContext* cx,
michael@0 270 JSObject* aGlobal);
michael@0 271 static bool HasCameraSupport(JSContext* /* unused */,
michael@0 272 JSObject* aGlobal);
michael@0 273 #ifdef MOZ_B2G_RIL
michael@0 274 static bool HasMobileConnectionSupport(JSContext* /* unused */,
michael@0 275 JSObject* aGlobal);
michael@0 276 static bool HasCellBroadcastSupport(JSContext* /* unused */,
michael@0 277 JSObject* aGlobal);
michael@0 278 static bool HasVoicemailSupport(JSContext* /* unused */,
michael@0 279 JSObject* aGlobal);
michael@0 280 static bool HasIccManagerSupport(JSContext* /* unused */,
michael@0 281 JSObject* aGlobal);
michael@0 282 #endif // MOZ_B2G_RIL
michael@0 283 static bool HasWifiManagerSupport(JSContext* /* unused */,
michael@0 284 JSObject* aGlobal);
michael@0 285 #ifdef MOZ_B2G_BT
michael@0 286 static bool HasBluetoothSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 287 #endif // MOZ_B2G_BT
michael@0 288 #ifdef MOZ_B2G_FM
michael@0 289 static bool HasFMRadioSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 290 #endif // MOZ_B2G_FM
michael@0 291 #ifdef MOZ_NFC
michael@0 292 static bool HasNfcSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 293 static bool HasNfcPeerSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 294 static bool HasNfcManagerSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 295 #endif // MOZ_NFC
michael@0 296 #ifdef MOZ_TIME_MANAGER
michael@0 297 static bool HasTimeSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 298 #endif // MOZ_TIME_MANAGER
michael@0 299 #ifdef MOZ_MEDIA_NAVIGATOR
michael@0 300 static bool HasUserMediaSupport(JSContext* /* unused */,
michael@0 301 JSObject* /* unused */);
michael@0 302 #endif // MOZ_MEDIA_NAVIGATOR
michael@0 303
michael@0 304 static bool HasPushNotificationsSupport(JSContext* /* unused */,
michael@0 305 JSObject* aGlobal);
michael@0 306
michael@0 307 static bool HasInputMethodSupport(JSContext* /* unused */, JSObject* aGlobal);
michael@0 308
michael@0 309 static bool HasDataStoreSupport(JSContext* cx, JSObject* aGlobal);
michael@0 310
michael@0 311 static bool HasDownloadsSupport(JSContext* aCx, JSObject* aGlobal);
michael@0 312
michael@0 313 static bool HasPermissionSettingsSupport(JSContext* aCx, JSObject* aGlobal);
michael@0 314
michael@0 315 nsPIDOMWindow* GetParentObject() const
michael@0 316 {
michael@0 317 return GetWindow();
michael@0 318 }
michael@0 319
michael@0 320 virtual JSObject* WrapObject(JSContext* cx) MOZ_OVERRIDE;
michael@0 321
michael@0 322 private:
michael@0 323 bool CheckPermission(const char* type);
michael@0 324 static bool CheckPermission(nsPIDOMWindow* aWindow, const char* aType);
michael@0 325 // GetWindowFromGlobal returns the inner window for this global, if
michael@0 326 // any, else null.
michael@0 327 static already_AddRefed<nsPIDOMWindow> GetWindowFromGlobal(JSObject* aGlobal);
michael@0 328
michael@0 329 nsRefPtr<nsMimeTypeArray> mMimeTypes;
michael@0 330 nsRefPtr<nsPluginArray> mPlugins;
michael@0 331 nsRefPtr<Geolocation> mGeolocation;
michael@0 332 nsRefPtr<DesktopNotificationCenter> mNotification;
michael@0 333 nsRefPtr<battery::BatteryManager> mBatteryManager;
michael@0 334 #ifdef MOZ_B2G_FM
michael@0 335 nsRefPtr<FMRadio> mFMRadio;
michael@0 336 #endif
michael@0 337 nsRefPtr<PowerManager> mPowerManager;
michael@0 338 nsRefPtr<MobileMessageManager> mMobileMessageManager;
michael@0 339 nsRefPtr<Telephony> mTelephony;
michael@0 340 nsRefPtr<network::Connection> mConnection;
michael@0 341 #ifdef MOZ_B2G_RIL
michael@0 342 nsRefPtr<MobileConnectionArray> mMobileConnections;
michael@0 343 nsRefPtr<CellBroadcast> mCellBroadcast;
michael@0 344 nsRefPtr<IccManager> mIccManager;
michael@0 345 nsRefPtr<Voicemail> mVoicemail;
michael@0 346 #endif
michael@0 347 #ifdef MOZ_B2G_BT
michael@0 348 nsRefPtr<bluetooth::BluetoothManager> mBluetooth;
michael@0 349 #endif
michael@0 350 #ifdef MOZ_AUDIO_CHANNEL_MANAGER
michael@0 351 nsRefPtr<system::AudioChannelManager> mAudioChannelManager;
michael@0 352 #endif
michael@0 353 nsRefPtr<nsDOMCameraManager> mCameraManager;
michael@0 354 nsCOMPtr<nsIDOMNavigatorSystemMessages> mMessagesManager;
michael@0 355 nsTArray<nsRefPtr<nsDOMDeviceStorage> > mDeviceStorageStores;
michael@0 356 nsRefPtr<time::TimeManager> mTimeManager;
michael@0 357 nsCOMPtr<nsPIDOMWindow> mWindow;
michael@0 358
michael@0 359 // Hashtable for saving cached objects newresolve created, so we don't create
michael@0 360 // the object twice if asked for it twice, whether due to use of "delete" or
michael@0 361 // due to Xrays. We could probably use a nsJSThingHashtable here, but then
michael@0 362 // we'd need to figure out exactly how to trace that, and that seems to be
michael@0 363 // rocket science. :(
michael@0 364 nsInterfaceHashtable<nsStringHashKey, nsISupports> mCachedResolveResults;
michael@0 365 };
michael@0 366
michael@0 367 } // namespace dom
michael@0 368 } // namespace mozilla
michael@0 369
michael@0 370 nsresult NS_GetNavigatorUserAgent(nsAString& aUserAgent);
michael@0 371
michael@0 372 #endif // mozilla_dom_Navigator_h

mercurial