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_DRAG_SOURCE_H_ | 5 #ifndef BASE_BASE_DRAG_SOURCE_H_ |
6 #define BASE_BASE_DRAG_SOURCE_H_ | 6 #define BASE_BASE_DRAG_SOURCE_H_ |
7 | 7 |
8 #include <objidl.h> | 8 #include <objidl.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/ref_counted.h" |
11 | 12 |
12 /////////////////////////////////////////////////////////////////////////////// | 13 /////////////////////////////////////////////////////////////////////////////// |
13 // | 14 // |
14 // BaseDragSource | 15 // BaseDragSource |
15 // | 16 // |
16 // A base IDropSource implementation. Handles notifications sent by an active | 17 // A base IDropSource implementation. Handles notifications sent by an active |
17 // drag-drop operation as the user mouses over other drop targets on their | 18 // drag-drop operation as the user mouses over other drop targets on their |
18 // system. This object tells Windows whether or not the drag should continue, | 19 // system. This object tells Windows whether or not the drag should continue, |
19 // and supplies the appropriate cursors. | 20 // and supplies the appropriate cursors. |
20 // | 21 // |
21 class BaseDragSource : public IDropSource { | 22 class BaseDragSource : public IDropSource, |
| 23 public base::RefCountedThreadSafe<BaseDragSource> { |
22 public: | 24 public: |
23 BaseDragSource(); | 25 BaseDragSource(); |
24 virtual ~BaseDragSource() { } | 26 virtual ~BaseDragSource() { } |
25 | 27 |
26 // Stop the drag operation at the next chance we get. This doesn't | 28 // Stop the drag operation at the next chance we get. This doesn't |
27 // synchronously stop the drag (since Windows is controlling that), | 29 // synchronously stop the drag (since Windows is controlling that), |
28 // but lets us tell Windows to cancel the drag the next chance we get. | 30 // but lets us tell Windows to cancel the drag the next chance we get. |
29 void CancelDrag() { | 31 void CancelDrag() { |
30 cancel_drag_ = true; | 32 cancel_drag_ = true; |
31 } | 33 } |
32 | 34 |
33 // IDropSource implementation: | 35 // IDropSource implementation: |
34 HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state); | 36 HRESULT __stdcall QueryContinueDrag(BOOL escape_pressed, DWORD key_state); |
35 HRESULT __stdcall GiveFeedback(DWORD effect); | 37 HRESULT __stdcall GiveFeedback(DWORD effect); |
36 | 38 |
37 // IUnknown implementation: | 39 // IUnknown implementation: |
38 HRESULT __stdcall QueryInterface(const IID& iid, void** object); | 40 HRESULT __stdcall QueryInterface(const IID& iid, void** object); |
39 ULONG __stdcall AddRef(); | 41 ULONG __stdcall AddRef(); |
40 ULONG __stdcall Release(); | 42 ULONG __stdcall Release(); |
41 | 43 |
42 protected: | 44 protected: |
43 virtual void OnDragSourceCancel() { } | 45 virtual void OnDragSourceCancel() { } |
44 virtual void OnDragSourceDrop() { } | 46 virtual void OnDragSourceDrop() { } |
45 virtual void OnDragSourceMove() { } | 47 virtual void OnDragSourceMove() { } |
46 | 48 |
47 private: | 49 private: |
48 LONG ref_count_; | |
49 | |
50 // Set to true if we want to cancel the drag operation. | 50 // Set to true if we want to cancel the drag operation. |
51 bool cancel_drag_; | 51 bool cancel_drag_; |
52 | 52 |
53 DISALLOW_EVIL_CONSTRUCTORS(BaseDragSource); | 53 DISALLOW_EVIL_CONSTRUCTORS(BaseDragSource); |
54 }; | 54 }; |
55 | 55 |
56 #endif // BASE_BASE_DRAG_SOURCE_H_ | 56 #endif // BASE_BASE_DRAG_SOURCE_H_ |
OLD | NEW |