| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_drag_dest_win.h" | 5 #include "content/browser/web_contents/web_drag_dest_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 | 9 |
| 10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, | 122 ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, |
| 123 &drop_data_->url); | 123 &drop_data_->url); |
| 124 | 124 |
| 125 drag_cursor_ = WebDragOperationNone; | 125 drag_cursor_ = WebDragOperationNone; |
| 126 | 126 |
| 127 POINT client_pt = cursor_position; | 127 POINT client_pt = cursor_position; |
| 128 ScreenToClient(GetHWND(), &client_pt); | 128 ScreenToClient(GetHWND(), &client_pt); |
| 129 web_contents_->GetRenderViewHost()->DragTargetDragEnter(*drop_data_, | 129 web_contents_->GetRenderViewHost()->DragTargetDragEnter(*drop_data_, |
| 130 gfx::Point(client_pt.x, client_pt.y), | 130 gfx::Point(client_pt.x, client_pt.y), |
| 131 gfx::Point(cursor_position.x, cursor_position.y), | 131 gfx::Point(cursor_position.x, cursor_position.y), |
| 132 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects)); | 132 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects), |
| 133 0 /* shift/ctrl/alt flags */); |
| 133 | 134 |
| 134 if (delegate_) | 135 if (delegate_) |
| 135 delegate_->OnDragEnter(data_object); | 136 delegate_->OnDragEnter(data_object); |
| 136 | 137 |
| 137 // We lie here and always return a DROPEFFECT because we don't want to | 138 // We lie here and always return a DROPEFFECT because we don't want to |
| 138 // wait for the IPC call to return. | 139 // wait for the IPC call to return. |
| 139 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); | 140 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); |
| 140 } | 141 } |
| 141 | 142 |
| 142 DWORD WebDragDest::OnDragOver(IDataObject* data_object, | 143 DWORD WebDragDest::OnDragOver(IDataObject* data_object, |
| 143 DWORD key_state, | 144 DWORD key_state, |
| 144 POINT cursor_position, | 145 POINT cursor_position, |
| 145 DWORD effects) { | 146 DWORD effects) { |
| 146 DCHECK(current_rvh_); | 147 DCHECK(current_rvh_); |
| 147 if (current_rvh_ != web_contents_->GetRenderViewHost()) | 148 if (current_rvh_ != web_contents_->GetRenderViewHost()) |
| 148 OnDragEnter(data_object, key_state, cursor_position, effects); | 149 OnDragEnter(data_object, key_state, cursor_position, effects); |
| 149 | 150 |
| 150 if (web_contents_->ShowingInterstitialPage()) | 151 if (web_contents_->ShowingInterstitialPage()) |
| 151 return interstitial_drop_target_->OnDragOver(data_object, effects); | 152 return interstitial_drop_target_->OnDragOver(data_object, effects); |
| 152 | 153 |
| 153 POINT client_pt = cursor_position; | 154 POINT client_pt = cursor_position; |
| 154 ScreenToClient(GetHWND(), &client_pt); | 155 ScreenToClient(GetHWND(), &client_pt); |
| 155 web_contents_->GetRenderViewHost()->DragTargetDragOver( | 156 web_contents_->GetRenderViewHost()->DragTargetDragOver( |
| 156 gfx::Point(client_pt.x, client_pt.y), | 157 gfx::Point(client_pt.x, client_pt.y), |
| 157 gfx::Point(cursor_position.x, cursor_position.y), | 158 gfx::Point(cursor_position.x, cursor_position.y), |
| 158 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects)); | 159 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects), |
| 160 0 /* shift/ctrl/alt flags */); |
| 159 | 161 |
| 160 if (delegate_) | 162 if (delegate_) |
| 161 delegate_->OnDragOver(data_object); | 163 delegate_->OnDragOver(data_object); |
| 162 | 164 |
| 163 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); | 165 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); |
| 164 } | 166 } |
| 165 | 167 |
| 166 void WebDragDest::OnDragLeave(IDataObject* data_object) { | 168 void WebDragDest::OnDragLeave(IDataObject* data_object) { |
| 167 DCHECK(current_rvh_); | 169 DCHECK(current_rvh_); |
| 168 if (current_rvh_ != web_contents_->GetRenderViewHost()) | 170 if (current_rvh_ != web_contents_->GetRenderViewHost()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 191 if (web_contents_->ShowingInterstitialPage()) | 193 if (web_contents_->ShowingInterstitialPage()) |
| 192 interstitial_drop_target_->OnDragOver(data_object, effect); | 194 interstitial_drop_target_->OnDragOver(data_object, effect); |
| 193 | 195 |
| 194 if (web_contents_->ShowingInterstitialPage()) | 196 if (web_contents_->ShowingInterstitialPage()) |
| 195 return interstitial_drop_target_->OnDrop(data_object, effect); | 197 return interstitial_drop_target_->OnDrop(data_object, effect); |
| 196 | 198 |
| 197 POINT client_pt = cursor_position; | 199 POINT client_pt = cursor_position; |
| 198 ScreenToClient(GetHWND(), &client_pt); | 200 ScreenToClient(GetHWND(), &client_pt); |
| 199 web_contents_->GetRenderViewHost()->DragTargetDrop( | 201 web_contents_->GetRenderViewHost()->DragTargetDrop( |
| 200 gfx::Point(client_pt.x, client_pt.y), | 202 gfx::Point(client_pt.x, client_pt.y), |
| 201 gfx::Point(cursor_position.x, cursor_position.y)); | 203 gfx::Point(cursor_position.x, cursor_position.y), |
| 204 0 /* shift/ctrl/alt flags */); |
| 202 | 205 |
| 203 if (delegate_) | 206 if (delegate_) |
| 204 delegate_->OnDrop(data_object); | 207 delegate_->OnDrop(data_object); |
| 205 | 208 |
| 206 current_rvh_ = NULL; | 209 current_rvh_ = NULL; |
| 207 | 210 |
| 208 // This isn't always correct, but at least it's a close approximation. | 211 // This isn't always correct, but at least it's a close approximation. |
| 209 // For now, we always map a move to a copy to prevent potential data loss. | 212 // For now, we always map a move to a copy to prevent potential data loss. |
| 210 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); | 213 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); |
| 211 DWORD result = drop_effect != DROPEFFECT_MOVE ? | 214 DWORD result = drop_effect != DROPEFFECT_MOVE ? |
| 212 drop_effect : DROPEFFECT_COPY; | 215 drop_effect : DROPEFFECT_COPY; |
| 213 | 216 |
| 214 drop_data_.reset(); | 217 drop_data_.reset(); |
| 215 return result; | 218 return result; |
| 216 } | 219 } |
| OLD | NEW |