Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * |
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_IMAGELIB_IMAGEFACTORY_H_ |
michael@0 | 8 | #define MOZILLA_IMAGELIB_IMAGEFACTORY_H_ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsCOMPtr.h" |
michael@0 | 11 | #include "nsProxyRelease.h" |
michael@0 | 12 | |
michael@0 | 13 | class nsCString; |
michael@0 | 14 | class nsIRequest; |
michael@0 | 15 | class imgStatusTracker; |
michael@0 | 16 | |
michael@0 | 17 | namespace mozilla { |
michael@0 | 18 | namespace image { |
michael@0 | 19 | |
michael@0 | 20 | class Image; |
michael@0 | 21 | class ImageURL; |
michael@0 | 22 | |
michael@0 | 23 | class ImageFactory |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | /** |
michael@0 | 27 | * Registers vars with Preferences. Should only be called on the main thread. |
michael@0 | 28 | */ |
michael@0 | 29 | static void Initialize(); |
michael@0 | 30 | |
michael@0 | 31 | /** |
michael@0 | 32 | * Determines whether it's safe to retarget OnDataAvailable for an image. |
michael@0 | 33 | * |
michael@0 | 34 | * @param aURI The URI of the image. |
michael@0 | 35 | * @param aIsMultipart Whether the image is part of a multipart request. |
michael@0 | 36 | */ |
michael@0 | 37 | static bool CanRetargetOnDataAvailable(ImageURL* aURI, bool aIsMultiPart); |
michael@0 | 38 | |
michael@0 | 39 | /** |
michael@0 | 40 | * Creates a new image with the given properties. |
michael@0 | 41 | * Can be called on or off the main thread. |
michael@0 | 42 | * |
michael@0 | 43 | * @param aRequest The associated request. |
michael@0 | 44 | * @param aStatusTracker A status tracker for the image to use. |
michael@0 | 45 | * @param aMimeType The mimetype of the image. |
michael@0 | 46 | * @param aURI The URI of the image. |
michael@0 | 47 | * @param aIsMultiPart Whether the image is part of a multipart request. |
michael@0 | 48 | * @param aInnerWindowId The window this image belongs to. |
michael@0 | 49 | */ |
michael@0 | 50 | static already_AddRefed<Image> CreateImage(nsIRequest* aRequest, |
michael@0 | 51 | imgStatusTracker* aStatusTracker, |
michael@0 | 52 | const nsCString& aMimeType, |
michael@0 | 53 | ImageURL* aURI, |
michael@0 | 54 | bool aIsMultiPart, |
michael@0 | 55 | uint32_t aInnerWindowId); |
michael@0 | 56 | /** |
michael@0 | 57 | * Creates a new image which isn't associated with a URI or loaded through |
michael@0 | 58 | * the usual image loading mechanism. |
michael@0 | 59 | * |
michael@0 | 60 | * @param aMimeType The mimetype of the image. |
michael@0 | 61 | */ |
michael@0 | 62 | static already_AddRefed<Image> CreateAnonymousImage(const nsCString& aMimeType); |
michael@0 | 63 | |
michael@0 | 64 | private: |
michael@0 | 65 | // Factory functions that create specific types of image containers. |
michael@0 | 66 | static already_AddRefed<Image> CreateRasterImage(nsIRequest* aRequest, |
michael@0 | 67 | imgStatusTracker* aStatusTracker, |
michael@0 | 68 | const nsCString& aMimeType, |
michael@0 | 69 | ImageURL* aURI, |
michael@0 | 70 | uint32_t aImageFlags, |
michael@0 | 71 | uint32_t aInnerWindowId); |
michael@0 | 72 | |
michael@0 | 73 | static already_AddRefed<Image> CreateVectorImage(nsIRequest* aRequest, |
michael@0 | 74 | imgStatusTracker* aStatusTracker, |
michael@0 | 75 | const nsCString& aMimeType, |
michael@0 | 76 | ImageURL* aURI, |
michael@0 | 77 | uint32_t aImageFlags, |
michael@0 | 78 | uint32_t aInnerWindowId); |
michael@0 | 79 | |
michael@0 | 80 | // This is a static factory class, so disallow instantiation. |
michael@0 | 81 | virtual ~ImageFactory() = 0; |
michael@0 | 82 | }; |
michael@0 | 83 | |
michael@0 | 84 | } // namespace image |
michael@0 | 85 | } // namespace mozilla |
michael@0 | 86 | |
michael@0 | 87 | #endif // MOZILLA_IMAGELIB_IMAGEFACTORY_H_ |