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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef DOM_CAMERA_DOMCAMERACONTROL_H |
michael@0 | 6 | #define DOM_CAMERA_DOMCAMERACONTROL_H |
michael@0 | 7 | |
michael@0 | 8 | #include "nsCOMPtr.h" |
michael@0 | 9 | #include "nsAutoPtr.h" |
michael@0 | 10 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 11 | #include "mozilla/dom/CameraControlBinding.h" |
michael@0 | 12 | #include "ICameraControl.h" |
michael@0 | 13 | #include "CameraCommon.h" |
michael@0 | 14 | #include "DOMMediaStream.h" |
michael@0 | 15 | #include "AudioChannelAgent.h" |
michael@0 | 16 | #include "nsProxyRelease.h" |
michael@0 | 17 | #include "nsHashPropertyBag.h" |
michael@0 | 18 | #include "DeviceStorage.h" |
michael@0 | 19 | #include "DOMCameraControlListener.h" |
michael@0 | 20 | |
michael@0 | 21 | class nsDOMDeviceStorage; |
michael@0 | 22 | class nsPIDOMWindow; |
michael@0 | 23 | class nsIDOMBlob; |
michael@0 | 24 | |
michael@0 | 25 | namespace mozilla { |
michael@0 | 26 | |
michael@0 | 27 | namespace dom { |
michael@0 | 28 | class CameraCapabilities; |
michael@0 | 29 | class CameraPictureOptions; |
michael@0 | 30 | class CameraStartRecordingOptions; |
michael@0 | 31 | template<typename T> class Optional; |
michael@0 | 32 | } |
michael@0 | 33 | class ErrorResult; |
michael@0 | 34 | class StartRecordingHelper; |
michael@0 | 35 | |
michael@0 | 36 | // Main camera control. |
michael@0 | 37 | class nsDOMCameraControl MOZ_FINAL : public DOMMediaStream |
michael@0 | 38 | { |
michael@0 | 39 | public: |
michael@0 | 40 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMCameraControl, DOMMediaStream) |
michael@0 | 41 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 42 | |
michael@0 | 43 | // Because this header's filename doesn't match its C++ or DOM-facing |
michael@0 | 44 | // classname, we can't rely on the [Func="..."] WebIDL tag to implicitly |
michael@0 | 45 | // include the right header for us; instead we must explicitly include a |
michael@0 | 46 | // HasSupport() method in each header. We can get rid of these with the |
michael@0 | 47 | // Great Renaming proposed in bug 983177. |
michael@0 | 48 | static bool HasSupport(JSContext* aCx, JSObject* aGlobal); |
michael@0 | 49 | |
michael@0 | 50 | nsDOMCameraControl(uint32_t aCameraId, |
michael@0 | 51 | const dom::CameraConfiguration& aInitialConfig, |
michael@0 | 52 | dom::GetCameraCallback* aOnSuccess, |
michael@0 | 53 | dom::CameraErrorCallback* aOnError, |
michael@0 | 54 | nsPIDOMWindow* aWindow); |
michael@0 | 55 | |
michael@0 | 56 | void Shutdown(); |
michael@0 | 57 | |
michael@0 | 58 | nsPIDOMWindow* GetParentObject() const { return mWindow; } |
michael@0 | 59 | |
michael@0 | 60 | // Attributes. |
michael@0 | 61 | void GetEffect(nsString& aEffect, ErrorResult& aRv); |
michael@0 | 62 | void SetEffect(const nsAString& aEffect, ErrorResult& aRv); |
michael@0 | 63 | void GetWhiteBalanceMode(nsString& aMode, ErrorResult& aRv); |
michael@0 | 64 | void SetWhiteBalanceMode(const nsAString& aMode, ErrorResult& aRv); |
michael@0 | 65 | void GetSceneMode(nsString& aMode, ErrorResult& aRv); |
michael@0 | 66 | void SetSceneMode(const nsAString& aMode, ErrorResult& aRv); |
michael@0 | 67 | void GetFlashMode(nsString& aMode, ErrorResult& aRv); |
michael@0 | 68 | void SetFlashMode(const nsAString& aMode, ErrorResult& aRv); |
michael@0 | 69 | void GetFocusMode(nsString& aMode, ErrorResult& aRv); |
michael@0 | 70 | void SetFocusMode(const nsAString& aMode, ErrorResult& aRv); |
michael@0 | 71 | double GetZoom(ErrorResult& aRv); |
michael@0 | 72 | void SetZoom(double aZoom, ErrorResult& aRv); |
michael@0 | 73 | void GetMeteringAreas(JSContext* aCx, |
michael@0 | 74 | JS::MutableHandle<JS::Value> aMeteringAreas, |
michael@0 | 75 | ErrorResult& aRv); |
michael@0 | 76 | void SetMeteringAreas(JSContext* aCx, JS::Handle<JS::Value> aAreas, ErrorResult& aRv); |
michael@0 | 77 | void GetFocusAreas(JSContext* aCx, |
michael@0 | 78 | JS::MutableHandle<JS::Value> aFocusAreas, |
michael@0 | 79 | ErrorResult& aRv); |
michael@0 | 80 | void SetFocusAreas(JSContext* aCx, JS::Handle<JS::Value> aAreas, ErrorResult& aRv); |
michael@0 | 81 | void GetPictureSize(JSContext* aCx, |
michael@0 | 82 | JS::MutableHandle<JS::Value> aSize, |
michael@0 | 83 | ErrorResult& aRv); |
michael@0 | 84 | void SetPictureSize(JSContext* aCx, JS::Handle<JS::Value> aSize, ErrorResult& aRv); |
michael@0 | 85 | void GetThumbnailSize(JSContext* aCx, |
michael@0 | 86 | JS::MutableHandle<JS::Value> aSize, |
michael@0 | 87 | ErrorResult& aRv); |
michael@0 | 88 | void SetThumbnailSize(JSContext* aCx, JS::Handle<JS::Value> aSize, ErrorResult& aRv); |
michael@0 | 89 | double GetFocalLength(ErrorResult& aRv); |
michael@0 | 90 | double GetFocusDistanceNear(ErrorResult& aRv); |
michael@0 | 91 | double GetFocusDistanceOptimum(ErrorResult& aRv); |
michael@0 | 92 | double GetFocusDistanceFar(ErrorResult& aRv); |
michael@0 | 93 | void SetExposureCompensation(const dom::Optional<double>& aCompensation, ErrorResult& aRv); |
michael@0 | 94 | double GetExposureCompensation(ErrorResult& aRv); |
michael@0 | 95 | int32_t SensorAngle(); |
michael@0 | 96 | already_AddRefed<dom::CameraCapabilities> Capabilities(); |
michael@0 | 97 | void GetIsoMode(nsString& aMode, ErrorResult& aRv); |
michael@0 | 98 | void SetIsoMode(const nsAString& aMode, ErrorResult& aRv); |
michael@0 | 99 | |
michael@0 | 100 | // Unsolicited event handlers. |
michael@0 | 101 | dom::CameraShutterCallback* GetOnShutter(); |
michael@0 | 102 | void SetOnShutter(dom::CameraShutterCallback* aCb); |
michael@0 | 103 | dom::CameraClosedCallback* GetOnClosed(); |
michael@0 | 104 | void SetOnClosed(dom::CameraClosedCallback* aCb); |
michael@0 | 105 | dom::CameraRecorderStateChange* GetOnRecorderStateChange(); |
michael@0 | 106 | void SetOnRecorderStateChange(dom::CameraRecorderStateChange* aCb); |
michael@0 | 107 | dom::CameraPreviewStateChange* GetOnPreviewStateChange(); |
michael@0 | 108 | void SetOnPreviewStateChange(dom::CameraPreviewStateChange* aCb); |
michael@0 | 109 | dom::CameraAutoFocusMovingCallback* GetOnAutoFocusMoving(); |
michael@0 | 110 | void SetOnAutoFocusMoving(dom::CameraAutoFocusMovingCallback* aCb); |
michael@0 | 111 | dom::CameraFaceDetectionCallback* GetOnFacesDetected(); |
michael@0 | 112 | void SetOnFacesDetected(dom::CameraFaceDetectionCallback* aCb); |
michael@0 | 113 | |
michael@0 | 114 | // Methods. |
michael@0 | 115 | void SetConfiguration(const dom::CameraConfiguration& aConfiguration, |
michael@0 | 116 | const dom::Optional<dom::OwningNonNull<dom::CameraSetConfigurationCallback> >& aOnSuccess, |
michael@0 | 117 | const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError, |
michael@0 | 118 | ErrorResult& aRv); |
michael@0 | 119 | void AutoFocus(dom::CameraAutoFocusCallback& aOnSuccess, |
michael@0 | 120 | const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError, |
michael@0 | 121 | ErrorResult& aRv); |
michael@0 | 122 | void StartFaceDetection(ErrorResult& aRv); |
michael@0 | 123 | void StopFaceDetection(ErrorResult& aRv); |
michael@0 | 124 | void TakePicture(const dom::CameraPictureOptions& aOptions, |
michael@0 | 125 | dom::CameraTakePictureCallback& aOnSuccess, |
michael@0 | 126 | const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError, |
michael@0 | 127 | ErrorResult& aRv); |
michael@0 | 128 | void StartRecording(const dom::CameraStartRecordingOptions& aOptions, |
michael@0 | 129 | nsDOMDeviceStorage& storageArea, |
michael@0 | 130 | const nsAString& filename, |
michael@0 | 131 | dom::CameraStartRecordingCallback& aOnSuccess, |
michael@0 | 132 | const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError, |
michael@0 | 133 | ErrorResult& aRv); |
michael@0 | 134 | void StopRecording(ErrorResult& aRv); |
michael@0 | 135 | void ResumePreview(ErrorResult& aRv); |
michael@0 | 136 | void ReleaseHardware(const dom::Optional<dom::OwningNonNull<dom::CameraReleaseCallback> >& aOnSuccess, |
michael@0 | 137 | const dom::Optional<dom::OwningNonNull<dom::CameraErrorCallback> >& aOnError, |
michael@0 | 138 | ErrorResult& aRv); |
michael@0 | 139 | void ResumeContinuousFocus(ErrorResult& aRv); |
michael@0 | 140 | |
michael@0 | 141 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 142 | |
michael@0 | 143 | protected: |
michael@0 | 144 | virtual ~nsDOMCameraControl(); |
michael@0 | 145 | |
michael@0 | 146 | class DOMCameraConfiguration MOZ_FINAL : public dom::CameraConfiguration |
michael@0 | 147 | { |
michael@0 | 148 | public: |
michael@0 | 149 | NS_INLINE_DECL_REFCOUNTING(DOMCameraConfiguration) |
michael@0 | 150 | |
michael@0 | 151 | DOMCameraConfiguration(); |
michael@0 | 152 | DOMCameraConfiguration(const dom::CameraConfiguration& aConfiguration); |
michael@0 | 153 | |
michael@0 | 154 | // Additional configuration options that aren't exposed to the DOM |
michael@0 | 155 | uint32_t mMaxFocusAreas; |
michael@0 | 156 | uint32_t mMaxMeteringAreas; |
michael@0 | 157 | |
michael@0 | 158 | private: |
michael@0 | 159 | // Private destructor, to discourage deletion outside of Release(): |
michael@0 | 160 | ~DOMCameraConfiguration(); |
michael@0 | 161 | }; |
michael@0 | 162 | |
michael@0 | 163 | friend class DOMCameraControlListener; |
michael@0 | 164 | friend class mozilla::StartRecordingHelper; |
michael@0 | 165 | |
michael@0 | 166 | void OnCreatedFileDescriptor(bool aSucceeded); |
michael@0 | 167 | |
michael@0 | 168 | void OnAutoFocusComplete(bool aAutoFocusSucceeded); |
michael@0 | 169 | void OnAutoFocusMoving(bool aIsMoving); |
michael@0 | 170 | void OnTakePictureComplete(nsIDOMBlob* aPicture); |
michael@0 | 171 | void OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces); |
michael@0 | 172 | |
michael@0 | 173 | void OnHardwareStateChange(DOMCameraControlListener::HardwareState aState); |
michael@0 | 174 | void OnPreviewStateChange(DOMCameraControlListener::PreviewState aState); |
michael@0 | 175 | void OnRecorderStateChange(CameraControlListener::RecorderState aState, int32_t aStatus, int32_t aTrackNum); |
michael@0 | 176 | void OnConfigurationChange(DOMCameraConfiguration* aConfiguration); |
michael@0 | 177 | void OnShutter(); |
michael@0 | 178 | void OnError(CameraControlListener::CameraErrorContext aContext, const nsAString& mError); |
michael@0 | 179 | |
michael@0 | 180 | bool IsWindowStillActive(); |
michael@0 | 181 | |
michael@0 | 182 | nsresult NotifyRecordingStatusChange(const nsString& aMsg); |
michael@0 | 183 | |
michael@0 | 184 | nsRefPtr<ICameraControl> mCameraControl; // non-DOM camera control |
michael@0 | 185 | |
michael@0 | 186 | // An agent used to join audio channel service. |
michael@0 | 187 | nsCOMPtr<nsIAudioChannelAgent> mAudioChannelAgent; |
michael@0 | 188 | |
michael@0 | 189 | nsresult Set(JSContext* aCx, uint32_t aKey, const JS::Value& aValue, uint32_t aLimit); |
michael@0 | 190 | nsresult Get(JSContext* aCx, uint32_t aKey, JS::Value* aValue); |
michael@0 | 191 | |
michael@0 | 192 | nsRefPtr<DOMCameraConfiguration> mCurrentConfiguration; |
michael@0 | 193 | nsRefPtr<dom::CameraCapabilities> mCapabilities; |
michael@0 | 194 | |
michael@0 | 195 | // solicited camera control event handlers |
michael@0 | 196 | nsRefPtr<dom::GetCameraCallback> mGetCameraOnSuccessCb; |
michael@0 | 197 | nsRefPtr<dom::CameraErrorCallback> mGetCameraOnErrorCb; |
michael@0 | 198 | nsRefPtr<dom::CameraAutoFocusCallback> mAutoFocusOnSuccessCb; |
michael@0 | 199 | nsRefPtr<dom::CameraErrorCallback> mAutoFocusOnErrorCb; |
michael@0 | 200 | nsRefPtr<dom::CameraTakePictureCallback> mTakePictureOnSuccessCb; |
michael@0 | 201 | nsRefPtr<dom::CameraErrorCallback> mTakePictureOnErrorCb; |
michael@0 | 202 | nsRefPtr<dom::CameraStartRecordingCallback> mStartRecordingOnSuccessCb; |
michael@0 | 203 | nsRefPtr<dom::CameraErrorCallback> mStartRecordingOnErrorCb; |
michael@0 | 204 | nsRefPtr<dom::CameraReleaseCallback> mReleaseOnSuccessCb; |
michael@0 | 205 | nsRefPtr<dom::CameraErrorCallback> mReleaseOnErrorCb; |
michael@0 | 206 | nsRefPtr<dom::CameraSetConfigurationCallback> mSetConfigurationOnSuccessCb; |
michael@0 | 207 | nsRefPtr<dom::CameraErrorCallback> mSetConfigurationOnErrorCb; |
michael@0 | 208 | |
michael@0 | 209 | // unsolicited event handlers |
michael@0 | 210 | nsRefPtr<dom::CameraShutterCallback> mOnShutterCb; |
michael@0 | 211 | nsRefPtr<dom::CameraClosedCallback> mOnClosedCb; |
michael@0 | 212 | nsRefPtr<dom::CameraRecorderStateChange> mOnRecorderStateChangeCb; |
michael@0 | 213 | nsRefPtr<dom::CameraPreviewStateChange> mOnPreviewStateChangeCb; |
michael@0 | 214 | nsRefPtr<dom::CameraAutoFocusMovingCallback> mOnAutoFocusMovingCb; |
michael@0 | 215 | nsRefPtr<dom::CameraFaceDetectionCallback> mOnFacesDetectedCb; |
michael@0 | 216 | |
michael@0 | 217 | // Camera event listener; we only need this weak reference so that |
michael@0 | 218 | // we can remove the listener from the camera when we're done |
michael@0 | 219 | // with it. |
michael@0 | 220 | DOMCameraControlListener* mListener; |
michael@0 | 221 | |
michael@0 | 222 | // our viewfinder stream |
michael@0 | 223 | CameraPreviewMediaStream* mInput; |
michael@0 | 224 | |
michael@0 | 225 | // set once when this object is created |
michael@0 | 226 | nsCOMPtr<nsPIDOMWindow> mWindow; |
michael@0 | 227 | |
michael@0 | 228 | dom::CameraStartRecordingOptions mOptions; |
michael@0 | 229 | nsRefPtr<DeviceStorageFileDescriptor> mDSFileDescriptor; |
michael@0 | 230 | |
michael@0 | 231 | private: |
michael@0 | 232 | nsDOMCameraControl(const nsDOMCameraControl&) MOZ_DELETE; |
michael@0 | 233 | nsDOMCameraControl& operator=(const nsDOMCameraControl&) MOZ_DELETE; |
michael@0 | 234 | }; |
michael@0 | 235 | |
michael@0 | 236 | } // namespace mozilla |
michael@0 | 237 | |
michael@0 | 238 | #endif // DOM_CAMERA_DOMCAMERACONTROL_H |