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/. */ 4 5 #ifndef mozilla_dom_RemoteDragStartData_h 6 #define mozilla_dom_RemoteDragStartData_h 7 8 #include "nsCOMPtr.h" 9 #include "nsRect.h" 10 #include "mozilla/dom/DataTransfer.h" 11 #include "mozilla/dom/DOMTypes.h" 12 #include "mozilla/gfx/DataSurfaceHelpers.h" 13 14 class nsICookieJarSettings; 15 16 namespace mozilla { 17 namespace dom { 18 19 class IPCDataTransferItem; 20 class BrowserParent; 21 22 /** 23 * This class is used to hold information about a drag 24 * when a drag begins in a content process. 25 */ 26 class RemoteDragStartData { 27 public: 28 NS_INLINE_DECL_REFCOUNTING(RemoteDragStartData) 29 30 RemoteDragStartData(BrowserParent* aBrowserParent, 31 nsTArray<IPCDataTransfer>&& aDataTransfer, 32 const LayoutDeviceIntRect& aRect, 33 nsIPrincipal* aPrincipal, nsIContentSecurityPolicy* aCsp, 34 nsICookieJarSettings* aCookieJarSettings, 35 WindowContext* aSourceWindowContext); 36 SetVisualization(already_AddRefed<gfx::DataSourceSurface> aVisualization)37 void SetVisualization( 38 already_AddRefed<gfx::DataSourceSurface> aVisualization) { 39 mVisualization = aVisualization; 40 } 41 42 // Get the drag image and rectangle, clearing it from this 43 // RemoteDragStartData in the process. TakeVisualization(LayoutDeviceIntRect * aRect)44 already_AddRefed<mozilla::gfx::SourceSurface> TakeVisualization( 45 LayoutDeviceIntRect* aRect) { 46 *aRect = mRect; 47 return mVisualization.forget(); 48 } 49 50 void AddInitialDnDDataTo(DataTransfer* aDataTransfer, 51 nsIPrincipal** aPrincipal, 52 nsIContentSecurityPolicy** aCsp, 53 nsICookieJarSettings** aCookieJarSettings); 54 GetSourceWindowContext()55 WindowContext* GetSourceWindowContext() { return mSourceWindowContext; } 56 57 private: 58 virtual ~RemoteDragStartData(); 59 60 RefPtr<BrowserParent> mBrowserParent; 61 nsTArray<IPCDataTransfer> mDataTransfer; 62 const LayoutDeviceIntRect mRect; 63 nsCOMPtr<nsIPrincipal> mPrincipal; 64 nsCOMPtr<nsIContentSecurityPolicy> mCsp; 65 nsCOMPtr<nsICookieJarSettings> mCookieJarSettings; 66 RefPtr<WindowContext> mSourceWindowContext; 67 RefPtr<mozilla::gfx::SourceSurface> mVisualization; 68 }; 69 70 } // namespace dom 71 } // namespace mozilla 72 73 #endif // mozilla_dom_RemoteDragStartData_h 74