| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_BASE_DROP_TARGET_H_ | 5 #ifndef BASE_BASE_DROP_TARGET_H_ |
| 6 #define BASE_BASE_DROP_TARGET_H_ | 6 #define BASE_BASE_DROP_TARGET_H_ |
| 7 | 7 |
| 8 #include <objidl.h> | 8 #include <objidl.h> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 | 11 |
| 12 struct IDropTargetHelper; | 12 struct IDropTargetHelper; |
| 13 | 13 |
| 14 // A DropTarget implementation that takes care of the nitty gritty | 14 // A DropTarget implementation that takes care of the nitty gritty |
| 15 // of dnd. While this class is concrete, subclasses will most likely | 15 // of dnd. While this class is concrete, subclasses will most likely |
| 16 // want to override various OnXXX methods. | 16 // want to override various OnXXX methods. |
| 17 // | 17 // |
| 18 // Because BaseDropTarget is ref counted you shouldn't delete it directly, | 18 // Because BaseDropTarget is ref counted you shouldn't delete it directly, |
| 19 // rather wrap it in a scoped_refptr. Be sure and invoke RevokeDragDrop(m_hWnd) | 19 // rather wrap it in a scoped_refptr. Be sure and invoke RevokeDragDrop(m_hWnd) |
| 20 // before the HWND is deleted too. | 20 // before the HWND is deleted too. |
| 21 // | 21 // |
| 22 // This class is meant to be used in a STA and is not multithread-safe. | 22 // This class is meant to be used in a STA and is not multithread-safe. |
| 23 class BaseDropTarget : public IDropTarget { | 23 class BaseDropTarget : public IDropTarget { |
| 24 public: | 24 public: |
| 25 // Create a new BaseDropTarget associating it with the given HWND. | 25 // Create a new BaseDropTarget associating it with the given HWND. |
| 26 explicit BaseDropTarget(HWND hwnd); | 26 explicit BaseDropTarget(HWND hwnd); |
| 27 virtual ~BaseDropTarget(); | 27 virtual ~BaseDropTarget(); |
| 28 | 28 |
| 29 // When suspend is set to |true|, the drop target does not receive drops from | 29 // When suspended is set to |true|, the drop target does not receive drops |
| 30 // drags initiated within the owning HWND. | 30 // from drags initiated within the owning HWND. |
| 31 // TODO(beng): (http://b/1085385) figure out how we will handle legitimate | 31 // TODO(beng): (http://b/1085385) figure out how we will handle legitimate |
| 32 // drag-drop operations within the same HWND, such as dragging | 32 // drag-drop operations within the same HWND, such as dragging |
| 33 // selected text to an edit field. | 33 // selected text to an edit field. |
| 34 void set_suspend(bool suspend) { suspend_ = suspend; } | 34 bool suspended() const { return suspended_; } |
| 35 void set_suspended(bool suspended) { suspended_ = suspended; } |
| 35 | 36 |
| 36 // IDropTarget implementation: | 37 // IDropTarget implementation: |
| 37 HRESULT __stdcall DragEnter(IDataObject* data_object, | 38 HRESULT __stdcall DragEnter(IDataObject* data_object, |
| 38 DWORD key_state, | 39 DWORD key_state, |
| 39 POINTL cursor_position, | 40 POINTL cursor_position, |
| 40 DWORD* effect); | 41 DWORD* effect); |
| 41 HRESULT __stdcall DragOver(DWORD key_state, | 42 HRESULT __stdcall DragOver(DWORD key_state, |
| 42 POINTL cursor_position, | 43 POINTL cursor_position, |
| 43 DWORD* effect); | 44 DWORD* effect); |
| 44 HRESULT __stdcall DragLeave(); | 45 HRESULT __stdcall DragLeave(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // is passed over the renderer NPAPI interface to gears, so use int32 instead | 114 // is passed over the renderer NPAPI interface to gears, so use int32 instead |
| 114 // of int here. | 115 // of int here. |
| 115 static int32 drag_identity_; | 116 static int32 drag_identity_; |
| 116 | 117 |
| 117 // The HWND of the source. This HWND is used to determine coordinates for | 118 // The HWND of the source. This HWND is used to determine coordinates for |
| 118 // mouse events that are sent to the renderer notifying various drag states. | 119 // mouse events that are sent to the renderer notifying various drag states. |
| 119 HWND hwnd_; | 120 HWND hwnd_; |
| 120 | 121 |
| 121 // Whether or not we are currently processing drag notifications for drags | 122 // Whether or not we are currently processing drag notifications for drags |
| 122 // initiated in this window. | 123 // initiated in this window. |
| 123 bool suspend_; | 124 bool suspended_; |
| 124 | 125 |
| 125 LONG ref_count_; | 126 LONG ref_count_; |
| 126 | 127 |
| 127 DISALLOW_EVIL_CONSTRUCTORS(BaseDropTarget); | 128 DISALLOW_EVIL_CONSTRUCTORS(BaseDropTarget); |
| 128 }; | 129 }; |
| 129 | 130 |
| 130 #endif // BASE_BASE_DROP_TARGET_H_ | 131 #endif // BASE_BASE_DROP_TARGET_H_ |
| OLD | NEW |