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 #include <windows.h> | 5 #include <windows.h> |
6 #include <shlobj.h> | 6 #include <shlobj.h> |
7 | 7 |
8 #include "base/base_drop_target.h" | 8 #include "base/base_drop_target.h" |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 | 11 |
12 /////////////////////////////////////////////////////////////////////////////// | 12 /////////////////////////////////////////////////////////////////////////////// |
13 | 13 |
14 IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL; | 14 IDropTargetHelper* BaseDropTarget::cached_drop_target_helper_ = NULL; |
15 | 15 |
16 BaseDropTarget::BaseDropTarget(HWND hwnd) | 16 BaseDropTarget::BaseDropTarget(HWND hwnd) |
17 : suspend_(false), | 17 : current_data_object_(), |
18 ref_count_(0), | 18 hwnd_(hwnd), |
19 hwnd_(hwnd) { | 19 suspend_(false), |
| 20 ref_count_(0) { |
20 DCHECK(hwnd); | 21 DCHECK(hwnd); |
21 HRESULT result = RegisterDragDrop(hwnd, this); | 22 HRESULT result = RegisterDragDrop(hwnd, this); |
| 23 DCHECK(SUCCEEDED(result)); |
22 } | 24 } |
23 | 25 |
24 BaseDropTarget::~BaseDropTarget() { | 26 BaseDropTarget::~BaseDropTarget() { |
25 } | 27 } |
26 | 28 |
27 // static | 29 // static |
28 IDropTargetHelper* BaseDropTarget::DropHelper() { | 30 IDropTargetHelper* BaseDropTarget::DropHelper() { |
29 if (!cached_drop_target_helper_) { | 31 if (!cached_drop_target_helper_) { |
30 CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, | 32 CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, |
31 IID_IDropTargetHelper, | 33 IID_IDropTargetHelper, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 AddRef(); | 125 AddRef(); |
124 return S_OK; | 126 return S_OK; |
125 } | 127 } |
126 | 128 |
127 ULONG BaseDropTarget::AddRef() { | 129 ULONG BaseDropTarget::AddRef() { |
128 return InterlockedIncrement(&ref_count_); | 130 return InterlockedIncrement(&ref_count_); |
129 } | 131 } |
130 | 132 |
131 ULONG BaseDropTarget::Release() { | 133 ULONG BaseDropTarget::Release() { |
132 if (InterlockedDecrement(&ref_count_) == 0) { | 134 if (InterlockedDecrement(&ref_count_) == 0) { |
133 ULONG copied_refcnt = ref_count_; | |
134 delete this; | 135 delete this; |
135 return copied_refcnt; | 136 return 0U; |
136 } | 137 } |
137 return ref_count_; | 138 return ref_count_; |
138 } | 139 } |
139 | 140 |
140 DWORD BaseDropTarget::OnDragEnter(IDataObject* data_object, | 141 DWORD BaseDropTarget::OnDragEnter(IDataObject* data_object, |
141 DWORD key_state, | 142 DWORD key_state, |
142 POINT cursor_position, | 143 POINT cursor_position, |
143 DWORD effect) { | 144 DWORD effect) { |
144 return DROPEFFECT_NONE; | 145 return DROPEFFECT_NONE; |
145 } | 146 } |
146 | 147 |
147 DWORD BaseDropTarget::OnDragOver(IDataObject* data_object, | 148 DWORD BaseDropTarget::OnDragOver(IDataObject* data_object, |
148 DWORD key_state, | 149 DWORD key_state, |
149 POINT cursor_position, | 150 POINT cursor_position, |
150 DWORD effect) { | 151 DWORD effect) { |
151 return DROPEFFECT_NONE; | 152 return DROPEFFECT_NONE; |
152 } | 153 } |
153 | 154 |
154 void BaseDropTarget::OnDragLeave(IDataObject* data_object) { | 155 void BaseDropTarget::OnDragLeave(IDataObject* data_object) { |
155 } | 156 } |
156 | 157 |
157 DWORD BaseDropTarget::OnDrop(IDataObject* data_object, | 158 DWORD BaseDropTarget::OnDrop(IDataObject* data_object, |
158 DWORD key_state, | 159 DWORD key_state, |
159 POINT cursor_position, | 160 POINT cursor_position, |
160 DWORD effect) { | 161 DWORD effect) { |
161 return DROPEFFECT_NONE; | 162 return DROPEFFECT_NONE; |
162 } | 163 } |
163 | 164 |
OLD | NEW |