OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_BASE_DRAGDROP_DROP_TARGET_H_ | 5 #ifndef UI_BASE_DRAGDROP_DROP_TARGET_H_ |
6 #define UI_BASE_DRAGDROP_DROP_TARGET_H_ | 6 #define UI_BASE_DRAGDROP_DROP_TARGET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <objidl.h> | 9 #include <objidl.h> |
10 | 10 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 // dnd session. | 80 // dnd session. |
81 virtual void OnDragLeave(IDataObject* data_object); | 81 virtual void OnDragLeave(IDataObject* data_object); |
82 | 82 |
83 // Invoked when the drop ends on the window. This should return the operation | 83 // Invoked when the drop ends on the window. This should return the operation |
84 // that was taken. | 84 // that was taken. |
85 virtual DWORD OnDrop(IDataObject* data_object, | 85 virtual DWORD OnDrop(IDataObject* data_object, |
86 DWORD key_state, | 86 DWORD key_state, |
87 POINT cursor_position, | 87 POINT cursor_position, |
88 DWORD effect); | 88 DWORD effect); |
89 | 89 |
90 // Return the drag identity. | |
91 static int32 GetDragIdentity() { return drag_identity_; } | |
92 | |
93 private: | 90 private: |
94 // Returns the cached drop helper, creating one if necessary. The returned | 91 // Returns the cached drop helper, creating one if necessary. The returned |
95 // object is not addrefed. May return NULL if the object couldn't be created. | 92 // object is not addrefed. May return NULL if the object couldn't be created. |
96 static IDropTargetHelper* DropHelper(); | 93 static IDropTargetHelper* DropHelper(); |
97 | 94 |
98 // The data object currently being dragged over this drop target. | 95 // The data object currently being dragged over this drop target. |
99 scoped_refptr<IDataObject> current_data_object_; | 96 scoped_refptr<IDataObject> current_data_object_; |
100 | 97 |
101 // A helper object that is used to provide drag image support while the mouse | 98 // A helper object that is used to provide drag image support while the mouse |
102 // is dragging over the content area. | 99 // is dragging over the content area. |
103 // | 100 // |
104 // DO NOT ACCESS DIRECTLY! Use DropHelper() instead, which will lazily create | 101 // DO NOT ACCESS DIRECTLY! Use DropHelper() instead, which will lazily create |
105 // this if it doesn't exist yet. This object can take tens of milliseconds to | 102 // this if it doesn't exist yet. This object can take tens of milliseconds to |
106 // create, and we don't want to block any window opening for this, especially | 103 // create, and we don't want to block any window opening for this, especially |
107 // since often, DnD will never be used. Instead, we force this penalty to the | 104 // since often, DnD will never be used. Instead, we force this penalty to the |
108 // first time it is actually used. | 105 // first time it is actually used. |
109 static IDropTargetHelper* cached_drop_target_helper_; | 106 static IDropTargetHelper* cached_drop_target_helper_; |
110 | 107 |
111 // The drag identity (id). An up-counter that increases when the cursor first | |
112 // moves over the HWND in a DnD session (OnDragEnter). 0 is reserved to mean | |
113 // the "no/unknown" identity, and is used for initialization. The identity is | |
114 // sent to the renderer in drag enter notifications. Note: the identity value | |
115 // is passed over the renderer NPAPI interface to gears, so use int32 instead | |
116 // of int here. | |
117 static int32 drag_identity_; | |
118 | |
119 // The HWND of the source. This HWND is used to determine coordinates for | 108 // The HWND of the source. This HWND is used to determine coordinates for |
120 // mouse events that are sent to the renderer notifying various drag states. | 109 // mouse events that are sent to the renderer notifying various drag states. |
121 HWND hwnd_; | 110 HWND hwnd_; |
122 | 111 |
123 // Whether or not we are currently processing drag notifications for drags | 112 // Whether or not we are currently processing drag notifications for drags |
124 // initiated in this window. | 113 // initiated in this window. |
125 bool suspended_; | 114 bool suspended_; |
126 | 115 |
127 LONG ref_count_; | 116 LONG ref_count_; |
128 | 117 |
129 DISALLOW_COPY_AND_ASSIGN(DropTarget); | 118 DISALLOW_COPY_AND_ASSIGN(DropTarget); |
130 }; | 119 }; |
131 | 120 |
132 } // namespace ui | 121 } // namespace ui |
133 | 122 |
134 #endif // UI_BASE_DRAGDROP_DROP_TARGET_H_ | 123 #endif // UI_BASE_DRAGDROP_DROP_TARGET_H_ |
OLD | NEW |