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 | /* |
michael@0 | 2 | * Copyright (C) 2012-2014 Mozilla Foundation |
michael@0 | 3 | * |
michael@0 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
michael@0 | 5 | * you may not use this file except in compliance with the License. |
michael@0 | 6 | * You may obtain a copy of the License at |
michael@0 | 7 | * |
michael@0 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
michael@0 | 9 | * |
michael@0 | 10 | * Unless required by applicable law or agreed to in writing, software |
michael@0 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
michael@0 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
michael@0 | 13 | * See the License for the specific language governing permissions and |
michael@0 | 14 | * limitations under the License. |
michael@0 | 15 | */ |
michael@0 | 16 | |
michael@0 | 17 | #ifndef DOM_CAMERA_GONKCAMERACONTROL_H |
michael@0 | 18 | #define DOM_CAMERA_GONKCAMERACONTROL_H |
michael@0 | 19 | |
michael@0 | 20 | #include "base/basictypes.h" |
michael@0 | 21 | #include <media/MediaProfiles.h> |
michael@0 | 22 | #include "mozilla/ReentrantMonitor.h" |
michael@0 | 23 | #include "DeviceStorage.h" |
michael@0 | 24 | #include "CameraControlImpl.h" |
michael@0 | 25 | #include "CameraCommon.h" |
michael@0 | 26 | #include "GonkRecorder.h" |
michael@0 | 27 | #include "GonkCameraHwMgr.h" |
michael@0 | 28 | #include "GonkCameraParameters.h" |
michael@0 | 29 | |
michael@0 | 30 | namespace android { |
michael@0 | 31 | class GonkCameraHardware; |
michael@0 | 32 | class MediaProfiles; |
michael@0 | 33 | class GonkRecorder; |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | namespace mozilla { |
michael@0 | 37 | |
michael@0 | 38 | namespace layers { |
michael@0 | 39 | class TextureClient; |
michael@0 | 40 | class ImageContainer; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | class GonkRecorderProfile; |
michael@0 | 44 | class GonkRecorderProfileManager; |
michael@0 | 45 | |
michael@0 | 46 | class nsGonkCameraControl : public CameraControlImpl |
michael@0 | 47 | { |
michael@0 | 48 | public: |
michael@0 | 49 | nsGonkCameraControl(uint32_t aCameraId); |
michael@0 | 50 | |
michael@0 | 51 | void OnAutoFocusComplete(bool aSuccess); |
michael@0 | 52 | void OnFacesDetected(camera_frame_metadata_t* aMetaData); |
michael@0 | 53 | void OnTakePictureComplete(uint8_t* aData, uint32_t aLength); |
michael@0 | 54 | void OnTakePictureError(); |
michael@0 | 55 | void OnNewPreviewFrame(layers::TextureClient* aBuffer); |
michael@0 | 56 | void OnRecorderEvent(int msg, int ext1, int ext2); |
michael@0 | 57 | void OnError(CameraControlListener::CameraErrorContext aWhere, |
michael@0 | 58 | CameraControlListener::CameraError aError); |
michael@0 | 59 | |
michael@0 | 60 | virtual nsresult Set(uint32_t aKey, const nsAString& aValue) MOZ_OVERRIDE; |
michael@0 | 61 | virtual nsresult Get(uint32_t aKey, nsAString& aValue) MOZ_OVERRIDE; |
michael@0 | 62 | virtual nsresult Set(uint32_t aKey, double aValue) MOZ_OVERRIDE; |
michael@0 | 63 | virtual nsresult Get(uint32_t aKey, double& aValue) MOZ_OVERRIDE; |
michael@0 | 64 | virtual nsresult Set(uint32_t aKey, int32_t aValue) MOZ_OVERRIDE; |
michael@0 | 65 | virtual nsresult Get(uint32_t aKey, int32_t& aValue) MOZ_OVERRIDE; |
michael@0 | 66 | virtual nsresult Set(uint32_t aKey, int64_t aValue) MOZ_OVERRIDE; |
michael@0 | 67 | virtual nsresult Get(uint32_t aKey, int64_t& aValue) MOZ_OVERRIDE; |
michael@0 | 68 | virtual nsresult Set(uint32_t aKey, const Size& aValue) MOZ_OVERRIDE; |
michael@0 | 69 | virtual nsresult Get(uint32_t aKey, Size& aValue) MOZ_OVERRIDE; |
michael@0 | 70 | virtual nsresult Set(uint32_t aKey, const nsTArray<Region>& aRegions) MOZ_OVERRIDE; |
michael@0 | 71 | virtual nsresult Get(uint32_t aKey, nsTArray<Region>& aRegions) MOZ_OVERRIDE; |
michael@0 | 72 | |
michael@0 | 73 | virtual nsresult SetLocation(const Position& aLocation) MOZ_OVERRIDE; |
michael@0 | 74 | |
michael@0 | 75 | virtual nsresult Get(uint32_t aKey, nsTArray<Size>& aSizes) MOZ_OVERRIDE; |
michael@0 | 76 | virtual nsresult Get(uint32_t aKey, nsTArray<nsString>& aValues) MOZ_OVERRIDE; |
michael@0 | 77 | virtual nsresult Get(uint32_t aKey, nsTArray<double>& aValues) MOZ_OVERRIDE; |
michael@0 | 78 | |
michael@0 | 79 | nsresult PushParameters(); |
michael@0 | 80 | nsresult PullParameters(); |
michael@0 | 81 | |
michael@0 | 82 | protected: |
michael@0 | 83 | ~nsGonkCameraControl(); |
michael@0 | 84 | |
michael@0 | 85 | using CameraControlImpl::OnNewPreviewFrame; |
michael@0 | 86 | using CameraControlImpl::OnAutoFocusComplete; |
michael@0 | 87 | using CameraControlImpl::OnFacesDetected; |
michael@0 | 88 | using CameraControlImpl::OnTakePictureComplete; |
michael@0 | 89 | using CameraControlImpl::OnConfigurationChange; |
michael@0 | 90 | using CameraControlImpl::OnError; |
michael@0 | 91 | |
michael@0 | 92 | virtual void BeginBatchParameterSet() MOZ_OVERRIDE; |
michael@0 | 93 | virtual void EndBatchParameterSet() MOZ_OVERRIDE; |
michael@0 | 94 | |
michael@0 | 95 | virtual nsresult StartImpl(const Configuration* aInitialConfig = nullptr) MOZ_OVERRIDE; |
michael@0 | 96 | virtual nsresult StopImpl() MOZ_OVERRIDE; |
michael@0 | 97 | nsresult Initialize(); |
michael@0 | 98 | |
michael@0 | 99 | virtual nsresult SetConfigurationImpl(const Configuration& aConfig) MOZ_OVERRIDE; |
michael@0 | 100 | nsresult SetConfigurationInternal(const Configuration& aConfig); |
michael@0 | 101 | nsresult SetPictureConfiguration(const Configuration& aConfig); |
michael@0 | 102 | nsresult SetVideoConfiguration(const Configuration& aConfig); |
michael@0 | 103 | |
michael@0 | 104 | template<class T> nsresult SetAndPush(uint32_t aKey, const T& aValue); |
michael@0 | 105 | |
michael@0 | 106 | virtual nsresult StartPreviewImpl() MOZ_OVERRIDE; |
michael@0 | 107 | virtual nsresult StopPreviewImpl() MOZ_OVERRIDE; |
michael@0 | 108 | virtual nsresult AutoFocusImpl() MOZ_OVERRIDE; |
michael@0 | 109 | virtual nsresult StartFaceDetectionImpl() MOZ_OVERRIDE; |
michael@0 | 110 | virtual nsresult StopFaceDetectionImpl() MOZ_OVERRIDE; |
michael@0 | 111 | virtual nsresult TakePictureImpl() MOZ_OVERRIDE; |
michael@0 | 112 | virtual nsresult StartRecordingImpl(DeviceStorageFileDescriptor* aFileDescriptor, |
michael@0 | 113 | const StartRecordingOptions* aOptions = nullptr) MOZ_OVERRIDE; |
michael@0 | 114 | virtual nsresult StopRecordingImpl() MOZ_OVERRIDE; |
michael@0 | 115 | virtual nsresult ResumeContinuousFocusImpl() MOZ_OVERRIDE; |
michael@0 | 116 | virtual nsresult PushParametersImpl() MOZ_OVERRIDE; |
michael@0 | 117 | virtual nsresult PullParametersImpl() MOZ_OVERRIDE; |
michael@0 | 118 | virtual already_AddRefed<RecorderProfileManager> GetRecorderProfileManagerImpl() MOZ_OVERRIDE; |
michael@0 | 119 | already_AddRefed<GonkRecorderProfileManager> GetGonkRecorderProfileManager(); |
michael@0 | 120 | |
michael@0 | 121 | nsresult SetupRecording(int aFd, int aRotation, int64_t aMaxFileSizeBytes, |
michael@0 | 122 | int64_t aMaxVideoLengthMs); |
michael@0 | 123 | nsresult SetupRecordingFlash(bool aAutoEnableLowLightTorch); |
michael@0 | 124 | nsresult SetupVideoMode(const nsAString& aProfile); |
michael@0 | 125 | nsresult SetPreviewSize(const Size& aSize); |
michael@0 | 126 | nsresult SetVideoSize(const Size& aSize); |
michael@0 | 127 | nsresult PausePreview(); |
michael@0 | 128 | nsresult GetSupportedSize(const Size& aSize, const nsTArray<Size>& supportedSizes, Size& best); |
michael@0 | 129 | |
michael@0 | 130 | friend class SetPictureSize; |
michael@0 | 131 | friend class SetThumbnailSize; |
michael@0 | 132 | nsresult SetPictureSize(const Size& aSize); |
michael@0 | 133 | nsresult SetPictureSizeImpl(const Size& aSize); |
michael@0 | 134 | nsresult SetThumbnailSize(const Size& aSize); |
michael@0 | 135 | nsresult UpdateThumbnailSize(); |
michael@0 | 136 | nsresult SetThumbnailSizeImpl(const Size& aSize); |
michael@0 | 137 | |
michael@0 | 138 | int32_t RationalizeRotation(int32_t aRotation); |
michael@0 | 139 | |
michael@0 | 140 | android::sp<android::GonkCameraHardware> mCameraHw; |
michael@0 | 141 | |
michael@0 | 142 | Size mLastPictureSize; |
michael@0 | 143 | Size mLastThumbnailSize; |
michael@0 | 144 | Size mLastRecorderSize; |
michael@0 | 145 | uint32_t mPreviewFps; |
michael@0 | 146 | bool mResumePreviewAfterTakingPicture; |
michael@0 | 147 | bool mFlashSupported; |
michael@0 | 148 | bool mLuminanceSupported; |
michael@0 | 149 | bool mAutoFlashModeOverridden; |
michael@0 | 150 | Atomic<uint32_t> mDeferConfigUpdate; |
michael@0 | 151 | GonkCameraParameters mParams; |
michael@0 | 152 | |
michael@0 | 153 | nsRefPtr<mozilla::layers::ImageContainer> mImageContainer; |
michael@0 | 154 | |
michael@0 | 155 | android::MediaProfiles* mMediaProfiles; |
michael@0 | 156 | nsRefPtr<android::GonkRecorder> mRecorder; |
michael@0 | 157 | |
michael@0 | 158 | // Camcorder profile settings for the desired quality level |
michael@0 | 159 | nsRefPtr<GonkRecorderProfileManager> mProfileManager; |
michael@0 | 160 | nsRefPtr<GonkRecorderProfile> mRecorderProfile; |
michael@0 | 161 | |
michael@0 | 162 | nsRefPtr<DeviceStorageFile> mVideoFile; |
michael@0 | 163 | nsString mFileFormat; |
michael@0 | 164 | |
michael@0 | 165 | // Guards against calling StartPreviewImpl() while in OnTakePictureComplete(). |
michael@0 | 166 | ReentrantMonitor mReentrantMonitor; |
michael@0 | 167 | |
michael@0 | 168 | private: |
michael@0 | 169 | nsGonkCameraControl(const nsGonkCameraControl&) MOZ_DELETE; |
michael@0 | 170 | nsGonkCameraControl& operator=(const nsGonkCameraControl&) MOZ_DELETE; |
michael@0 | 171 | }; |
michael@0 | 172 | |
michael@0 | 173 | // camera driver callbacks |
michael@0 | 174 | void OnTakePictureComplete(nsGonkCameraControl* gc, uint8_t* aData, uint32_t aLength); |
michael@0 | 175 | void OnTakePictureError(nsGonkCameraControl* gc); |
michael@0 | 176 | void OnAutoFocusComplete(nsGonkCameraControl* gc, bool aSuccess); |
michael@0 | 177 | void OnAutoFocusMoving(nsGonkCameraControl* gc, bool aIsMoving); |
michael@0 | 178 | void OnFacesDetected(nsGonkCameraControl* gc, camera_frame_metadata_t* aMetaData); |
michael@0 | 179 | void OnNewPreviewFrame(nsGonkCameraControl* gc, layers::TextureClient* aBuffer); |
michael@0 | 180 | void OnShutter(nsGonkCameraControl* gc); |
michael@0 | 181 | void OnClosed(nsGonkCameraControl* gc); |
michael@0 | 182 | void OnError(nsGonkCameraControl* gc, CameraControlListener::CameraError aError, |
michael@0 | 183 | int32_t aArg1, int32_t aArg2); |
michael@0 | 184 | |
michael@0 | 185 | } // namespace mozilla |
michael@0 | 186 | |
michael@0 | 187 | #endif // DOM_CAMERA_GONKCAMERACONTROL_H |