| 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 "chrome/browser/tab_contents/web_drop_target.h" | 8 #include "chrome/browser/tab_contents/web_drop_target.h" |
| 9 | 9 |
| 10 #include "base/clipboard_util.h" | 10 #include "base/clipboard_util.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 current_rvh_ = web_contents_->render_view_host(); | 93 current_rvh_ = web_contents_->render_view_host(); |
| 94 | 94 |
| 95 // Don't pass messages to the renderer if an interstitial page is showing | 95 // Don't pass messages to the renderer if an interstitial page is showing |
| 96 // because we don't want the interstitial page to navigate. Instead, | 96 // because we don't want the interstitial page to navigate. Instead, |
| 97 // pass the messages on to a separate interstitial DropTarget handler. | 97 // pass the messages on to a separate interstitial DropTarget handler. |
| 98 if (web_contents_->showing_interstitial_page()) | 98 if (web_contents_->showing_interstitial_page()) |
| 99 return interstitial_drop_target_->OnDragEnter(data_object, effect); | 99 return interstitial_drop_target_->OnDragEnter(data_object, effect); |
| 100 | 100 |
| 101 // TODO(tc): PopulateWebDropData can be slow depending on what is in the | 101 // TODO(tc): PopulateWebDropData can be slow depending on what is in the |
| 102 // IDataObject. Maybe we can do this in a background thread. | 102 // IDataObject. Maybe we can do this in a background thread. |
| 103 WebDropData drop_data; | 103 WebDropData drop_data(GetDragIdentity()); |
| 104 WebDropData::PopulateWebDropData(data_object, &drop_data); | 104 WebDropData::PopulateWebDropData(data_object, &drop_data); |
| 105 | 105 |
| 106 if (drop_data.url.is_empty()) | 106 if (drop_data.url.is_empty()) |
| 107 OSExchangeData::GetPlainTextURL(data_object, &drop_data.url); | 107 OSExchangeData::GetPlainTextURL(data_object, &drop_data.url); |
| 108 | 108 |
| 109 is_drop_target_ = true; | 109 is_drop_target_ = true; |
| 110 | 110 |
| 111 POINT client_pt = cursor_position; | 111 POINT client_pt = cursor_position; |
| 112 ScreenToClient(GetHWND(), &client_pt); | 112 ScreenToClient(GetHWND(), &client_pt); |
| 113 web_contents_->render_view_host()->DragTargetDragEnter(drop_data, | 113 web_contents_->render_view_host()->DragTargetDragEnter(drop_data, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 129 | 129 |
| 130 if (web_contents_->showing_interstitial_page()) | 130 if (web_contents_->showing_interstitial_page()) |
| 131 return interstitial_drop_target_->OnDragOver(data_object, effect); | 131 return interstitial_drop_target_->OnDragOver(data_object, effect); |
| 132 | 132 |
| 133 POINT client_pt = cursor_position; | 133 POINT client_pt = cursor_position; |
| 134 ScreenToClient(GetHWND(), &client_pt); | 134 ScreenToClient(GetHWND(), &client_pt); |
| 135 web_contents_->render_view_host()->DragTargetDragOver( | 135 web_contents_->render_view_host()->DragTargetDragOver( |
| 136 gfx::Point(client_pt.x, client_pt.y), | 136 gfx::Point(client_pt.x, client_pt.y), |
| 137 gfx::Point(cursor_position.x, cursor_position.y)); | 137 gfx::Point(cursor_position.x, cursor_position.y)); |
| 138 | 138 |
| 139 // Again we don't wait on the renderer to respond, but this can lead to |
| 140 // a race condition. If the renderer does not want the drop data, then |
| 141 // we won't know until the response from the renderer arrives. So if a |
| 142 // drop happens before the response arrives, we drop on a renderer that |
| 143 // doesn't want the data. TODO(noel): fix this. |
| 144 |
| 139 if (!is_drop_target_) | 145 if (!is_drop_target_) |
| 140 return DROPEFFECT_NONE; | 146 return DROPEFFECT_NONE; |
| 141 | 147 |
| 142 return GetPreferredDropEffect(effect); | 148 return GetPreferredDropEffect(effect); |
| 143 } | 149 } |
| 144 | 150 |
| 145 void WebDropTarget::OnDragLeave(IDataObject* data_object) { | 151 void WebDropTarget::OnDragLeave(IDataObject* data_object) { |
| 146 DCHECK(current_rvh_); | 152 DCHECK(current_rvh_); |
| 147 if (current_rvh_ != web_contents_->render_view_host()) | 153 if (current_rvh_ != web_contents_->render_view_host()) |
| 148 return; | 154 return; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 173 web_contents_->render_view_host()->DragTargetDrop( | 179 web_contents_->render_view_host()->DragTargetDrop( |
| 174 gfx::Point(client_pt.x, client_pt.y), | 180 gfx::Point(client_pt.x, client_pt.y), |
| 175 gfx::Point(cursor_position.x, cursor_position.y)); | 181 gfx::Point(cursor_position.x, cursor_position.y)); |
| 176 | 182 |
| 177 current_rvh_ = NULL; | 183 current_rvh_ = NULL; |
| 178 | 184 |
| 179 // We lie and always claim that the drop operation didn't happen because we | 185 // We lie and always claim that the drop operation didn't happen because we |
| 180 // don't want to wait for the renderer to respond. | 186 // don't want to wait for the renderer to respond. |
| 181 return DROPEFFECT_NONE; | 187 return DROPEFFECT_NONE; |
| 182 } | 188 } |
| OLD | NEW |