widget/windows/nsNativeDragTarget.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

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 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5 #ifndef _nsNativeDragTarget_h_
michael@0 6 #define _nsNativeDragTarget_h_
michael@0 7
michael@0 8 #include "nsCOMPtr.h"
michael@0 9 #include "nsIDragSession.h"
michael@0 10 #include <ole2.h>
michael@0 11 #include <shlobj.h>
michael@0 12
michael@0 13 #ifndef IDropTargetHelper
michael@0 14 #include <shobjidl.h> // Vista drag image interfaces
michael@0 15 #undef LogSeverity // SetupAPI.h #defines this as DWORD
michael@0 16 #endif
michael@0 17
michael@0 18 #include "mozilla/Attributes.h"
michael@0 19
michael@0 20 class nsIDragService;
michael@0 21 class nsIWidget;
michael@0 22
michael@0 23 struct IDataObject;
michael@0 24
michael@0 25 /*
michael@0 26 * nsNativeDragTarget implements the IDropTarget interface and gets most of its
michael@0 27 * behavior from the associated adapter (m_dragDrop).
michael@0 28 */
michael@0 29
michael@0 30 class nsNativeDragTarget MOZ_FINAL : public IDropTarget
michael@0 31 {
michael@0 32 public:
michael@0 33 nsNativeDragTarget(nsIWidget * aWidget);
michael@0 34 ~nsNativeDragTarget();
michael@0 35
michael@0 36 // IUnknown members - see iunknown.h for documentation
michael@0 37 STDMETHODIMP QueryInterface(REFIID, void**);
michael@0 38 STDMETHODIMP_(ULONG) AddRef();
michael@0 39 STDMETHODIMP_(ULONG) Release();
michael@0 40
michael@0 41 // IDataTarget members
michael@0 42
michael@0 43 // Set pEffect based on whether this object can support a drop based on
michael@0 44 // the data available from pSource, the key and mouse states specified
michael@0 45 // in grfKeyState, and the coordinates specified by point. This is
michael@0 46 // called by OLE when a drag enters this object's window (as registered
michael@0 47 // by Initialize).
michael@0 48 STDMETHODIMP DragEnter(LPDATAOBJECT pSource, DWORD grfKeyState,
michael@0 49 POINTL point, DWORD* pEffect);
michael@0 50
michael@0 51 // Similar to DragEnter except it is called frequently while the drag
michael@0 52 // is over this object's window.
michael@0 53 STDMETHODIMP DragOver(DWORD grfKeyState, POINTL point, DWORD* pEffect);
michael@0 54
michael@0 55 // Release the drag-drop source and put internal state back to the point
michael@0 56 // before the call to DragEnter. This is called when the drag leaves
michael@0 57 // without a drop occurring.
michael@0 58 STDMETHODIMP DragLeave();
michael@0 59
michael@0 60 // If point is within our region of interest and pSource's data supports
michael@0 61 // one of our formats, get the data and set pEffect according to
michael@0 62 // grfKeyState (DROPEFFECT_MOVE if the control key was not pressed,
michael@0 63 // DROPEFFECT_COPY if the control key was pressed). Otherwise return
michael@0 64 // E_FAIL.
michael@0 65 STDMETHODIMP Drop(LPDATAOBJECT pSource, DWORD grfKeyState,
michael@0 66 POINTL point, DWORD* pEffect);
michael@0 67 /**
michael@0 68 * Cancel the current drag session, if any.
michael@0 69 */
michael@0 70 void DragCancel();
michael@0 71
michael@0 72 protected:
michael@0 73
michael@0 74 void GetGeckoDragAction(DWORD grfKeyState, LPDWORD pdwEffect,
michael@0 75 uint32_t * aGeckoAction);
michael@0 76 void ProcessDrag(uint32_t aEventType, DWORD grfKeyState,
michael@0 77 POINTL pt, DWORD* pdwEffect);
michael@0 78 void DispatchDragDropEvent(uint32_t aType, POINTL pt);
michael@0 79 void AddLinkSupportIfCanBeGenerated(LPDATAOBJECT aIDataSource);
michael@0 80
michael@0 81 // Native Stuff
michael@0 82 ULONG m_cRef; // reference count
michael@0 83 HWND mHWnd;
michael@0 84 DWORD mEffectsAllowed;
michael@0 85 DWORD mEffectsPreferred;
michael@0 86 bool mTookOwnRef;
michael@0 87
michael@0 88 // Gecko Stuff
michael@0 89 nsIWidget * mWidget;
michael@0 90 nsIDragService * mDragService;
michael@0 91 // Drag target helper
michael@0 92 IDropTargetHelper * GetDropTargetHelper();
michael@0 93
michael@0 94
michael@0 95 private:
michael@0 96 // Drag target helper
michael@0 97 IDropTargetHelper * mDropTargetHelper;
michael@0 98 };
michael@0 99
michael@0 100 #endif // _nsNativeDragTarget_h_
michael@0 101
michael@0 102

mercurial