| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/tab_contents/web_drop_target_win.h" | 8 #include "chrome/browser/tab_contents/web_drop_target_win.h" |
| 9 | 9 |
| 10 #include "app/clipboard/clipboard_util_win.h" | 10 #include "app/clipboard/clipboard_util_win.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 111 |
| 112 is_drop_target_ = true; | 112 is_drop_target_ = true; |
| 113 | 113 |
| 114 POINT client_pt = cursor_position; | 114 POINT client_pt = cursor_position; |
| 115 ScreenToClient(GetHWND(), &client_pt); | 115 ScreenToClient(GetHWND(), &client_pt); |
| 116 tab_contents_->render_view_host()->DragTargetDragEnter(drop_data, | 116 tab_contents_->render_view_host()->DragTargetDragEnter(drop_data, |
| 117 gfx::Point(client_pt.x, client_pt.y), | 117 gfx::Point(client_pt.x, client_pt.y), |
| 118 gfx::Point(cursor_position.x, cursor_position.y), | 118 gfx::Point(cursor_position.x, cursor_position.y), |
| 119 WebDragOperationCopy); // FIXME(snej): Send actual operation | 119 WebDragOperationCopy); // FIXME(snej): Send actual operation |
| 120 | 120 |
| 121 // This is non-null if tab_contents_ is showing an ExtensionDOMUI with |
| 122 // support for (at the moment experimental) drag and drop extensions. |
| 123 if (tab_contents_->GetBookmarkDragDelegate()) { |
| 124 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); |
| 125 tab_contents_->GetBookmarkDragDelegate()->OnDragEnter(&os_exchange_data); |
| 126 } |
| 127 |
| 121 // We lie here and always return a DROPEFFECT because we don't want to | 128 // We lie here and always return a DROPEFFECT because we don't want to |
| 122 // wait for the IPC call to return. | 129 // wait for the IPC call to return. |
| 123 return GetPreferredDropEffect(effect); | 130 return GetPreferredDropEffect(effect); |
| 124 } | 131 } |
| 125 | 132 |
| 126 DWORD WebDropTarget::OnDragOver(IDataObject* data_object, | 133 DWORD WebDropTarget::OnDragOver(IDataObject* data_object, |
| 127 DWORD key_state, | 134 DWORD key_state, |
| 128 POINT cursor_position, | 135 POINT cursor_position, |
| 129 DWORD effect) { | 136 DWORD effect) { |
| 130 DCHECK(current_rvh_); | 137 DCHECK(current_rvh_); |
| 131 if (current_rvh_ != tab_contents_->render_view_host()) | 138 if (current_rvh_ != tab_contents_->render_view_host()) |
| 132 OnDragEnter(data_object, key_state, cursor_position, effect); | 139 OnDragEnter(data_object, key_state, cursor_position, effect); |
| 133 | 140 |
| 134 if (tab_contents_->showing_interstitial_page()) | 141 if (tab_contents_->showing_interstitial_page()) |
| 135 return interstitial_drop_target_->OnDragOver(data_object, effect); | 142 return interstitial_drop_target_->OnDragOver(data_object, effect); |
| 136 | 143 |
| 137 POINT client_pt = cursor_position; | 144 POINT client_pt = cursor_position; |
| 138 ScreenToClient(GetHWND(), &client_pt); | 145 ScreenToClient(GetHWND(), &client_pt); |
| 139 tab_contents_->render_view_host()->DragTargetDragOver( | 146 tab_contents_->render_view_host()->DragTargetDragOver( |
| 140 gfx::Point(client_pt.x, client_pt.y), | 147 gfx::Point(client_pt.x, client_pt.y), |
| 141 gfx::Point(cursor_position.x, cursor_position.y), | 148 gfx::Point(cursor_position.x, cursor_position.y), |
| 142 WebDragOperationCopy); // FIXME(snej): Send actual operation | 149 WebDragOperationCopy); // FIXME(snej): Send actual operation |
| 143 | 150 |
| 151 if (tab_contents_->GetBookmarkDragDelegate()) { |
| 152 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); |
| 153 tab_contents_->GetBookmarkDragDelegate()->OnDragOver(&os_exchange_data); |
| 154 } |
| 155 |
| 144 if (!is_drop_target_) | 156 if (!is_drop_target_) |
| 145 return DROPEFFECT_NONE; | 157 return DROPEFFECT_NONE; |
| 146 | 158 |
| 147 return GetPreferredDropEffect(effect); | 159 return GetPreferredDropEffect(effect); |
| 148 } | 160 } |
| 149 | 161 |
| 150 void WebDropTarget::OnDragLeave(IDataObject* data_object) { | 162 void WebDropTarget::OnDragLeave(IDataObject* data_object) { |
| 151 DCHECK(current_rvh_); | 163 DCHECK(current_rvh_); |
| 152 if (current_rvh_ != tab_contents_->render_view_host()) | 164 if (current_rvh_ != tab_contents_->render_view_host()) |
| 153 return; | 165 return; |
| 154 | 166 |
| 155 if (tab_contents_->showing_interstitial_page()) { | 167 if (tab_contents_->showing_interstitial_page()) { |
| 156 interstitial_drop_target_->OnDragLeave(data_object); | 168 interstitial_drop_target_->OnDragLeave(data_object); |
| 157 } else { | 169 } else { |
| 158 tab_contents_->render_view_host()->DragTargetDragLeave(); | 170 tab_contents_->render_view_host()->DragTargetDragLeave(); |
| 159 } | 171 } |
| 172 |
| 173 if (tab_contents_->GetBookmarkDragDelegate()) { |
| 174 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); |
| 175 tab_contents_->GetBookmarkDragDelegate()->OnDragLeave(&os_exchange_data); |
| 176 } |
| 160 } | 177 } |
| 161 | 178 |
| 162 DWORD WebDropTarget::OnDrop(IDataObject* data_object, | 179 DWORD WebDropTarget::OnDrop(IDataObject* data_object, |
| 163 DWORD key_state, | 180 DWORD key_state, |
| 164 POINT cursor_position, | 181 POINT cursor_position, |
| 165 DWORD effect) { | 182 DWORD effect) { |
| 166 DCHECK(current_rvh_); | 183 DCHECK(current_rvh_); |
| 167 if (current_rvh_ != tab_contents_->render_view_host()) | 184 if (current_rvh_ != tab_contents_->render_view_host()) |
| 168 OnDragEnter(data_object, key_state, cursor_position, effect); | 185 OnDragEnter(data_object, key_state, cursor_position, effect); |
| 169 | 186 |
| 170 if (tab_contents_->showing_interstitial_page()) | 187 if (tab_contents_->showing_interstitial_page()) |
| 171 interstitial_drop_target_->OnDragOver(data_object, effect); | 188 interstitial_drop_target_->OnDragOver(data_object, effect); |
| 172 | 189 |
| 173 if (tab_contents_->showing_interstitial_page()) | 190 if (tab_contents_->showing_interstitial_page()) |
| 174 return interstitial_drop_target_->OnDrop(data_object, effect); | 191 return interstitial_drop_target_->OnDrop(data_object, effect); |
| 175 | 192 |
| 176 POINT client_pt = cursor_position; | 193 POINT client_pt = cursor_position; |
| 177 ScreenToClient(GetHWND(), &client_pt); | 194 ScreenToClient(GetHWND(), &client_pt); |
| 178 tab_contents_->render_view_host()->DragTargetDrop( | 195 tab_contents_->render_view_host()->DragTargetDrop( |
| 179 gfx::Point(client_pt.x, client_pt.y), | 196 gfx::Point(client_pt.x, client_pt.y), |
| 180 gfx::Point(cursor_position.x, cursor_position.y)); | 197 gfx::Point(cursor_position.x, cursor_position.y)); |
| 181 | 198 |
| 199 if (tab_contents_->GetBookmarkDragDelegate()) { |
| 200 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); |
| 201 tab_contents_->GetBookmarkDragDelegate()->OnDrop(&os_exchange_data); |
| 202 } |
| 203 |
| 182 current_rvh_ = NULL; | 204 current_rvh_ = NULL; |
| 183 | 205 |
| 184 // We lie and always claim that the drop operation didn't happen because we | 206 // We lie and always claim that the drop operation didn't happen because we |
| 185 // don't want to wait for the renderer to respond. | 207 // don't want to wait for the renderer to respond. |
| 186 return DROPEFFECT_NONE; | 208 return DROPEFFECT_NONE; |
| 187 } | 209 } |
| OLD | NEW |