tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

RemoteDragStartData.h (2567B)


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