Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Side by Side Diff: content/browser/web_contents/web_drag_dest_win.cc

Issue 10386014: Implement WebContentsView::GetDropData for Mac; disable on Aura (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_drag_dest_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 delegate_->DragInitialize(web_contents_); 108 delegate_->DragInitialize(web_contents_);
109 109
110 // Don't pass messages to the renderer if an interstitial page is showing 110 // Don't pass messages to the renderer if an interstitial page is showing
111 // because we don't want the interstitial page to navigate. Instead, 111 // because we don't want the interstitial page to navigate. Instead,
112 // pass the messages on to a separate interstitial DropTarget handler. 112 // pass the messages on to a separate interstitial DropTarget handler.
113 if (web_contents_->ShowingInterstitialPage()) 113 if (web_contents_->ShowingInterstitialPage())
114 return interstitial_drop_target_->OnDragEnter(data_object, effects); 114 return interstitial_drop_target_->OnDragEnter(data_object, effects);
115 115
116 // TODO(tc): PopulateWebDropData can be slow depending on what is in the 116 // TODO(tc): PopulateWebDropData can be slow depending on what is in the
117 // IDataObject. Maybe we can do this in a background thread. 117 // IDataObject. Maybe we can do this in a background thread.
118 WebDropData drop_data; 118 drop_data_.reset(new WebDropData());
119 WebDropData::PopulateWebDropData(data_object, &drop_data); 119 WebDropData::PopulateWebDropData(data_object, drop_data_.get());
120 120
121 if (drop_data.url.is_empty()) 121 if (drop_data_->url.is_empty()) {
122 ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url); 122 ui::OSExchangeDataProviderWin::GetPlainTextURL(data_object,
123 &drop_data_->url);
124 }
123 125
124 drag_cursor_ = WebDragOperationNone; 126 drag_cursor_ = WebDragOperationNone;
125 127
126 POINT client_pt = cursor_position; 128 POINT client_pt = cursor_position;
127 ScreenToClient(GetHWND(), &client_pt); 129 ScreenToClient(GetHWND(), &client_pt);
128 web_contents_->GetRenderViewHost()->DragTargetDragEnter(drop_data, 130 web_contents_->GetRenderViewHost()->DragTargetDragEnter(*drop_data_,
129 gfx::Point(client_pt.x, client_pt.y), 131 gfx::Point(client_pt.x, client_pt.y),
130 gfx::Point(cursor_position.x, cursor_position.y), 132 gfx::Point(cursor_position.x, cursor_position.y),
131 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects)); 133 web_drag_utils_win::WinDragOpMaskToWebDragOpMask(effects));
132 134
133 if (delegate_) 135 if (delegate_)
134 delegate_->OnDragEnter(data_object); 136 delegate_->OnDragEnter(data_object);
135 137
136 // 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
137 // wait for the IPC call to return. 139 // wait for the IPC call to return.
138 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); 140 return web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
(...skipping 29 matching lines...) Expand all
168 return; 170 return;
169 171
170 if (web_contents_->ShowingInterstitialPage()) { 172 if (web_contents_->ShowingInterstitialPage()) {
171 interstitial_drop_target_->OnDragLeave(data_object); 173 interstitial_drop_target_->OnDragLeave(data_object);
172 } else { 174 } else {
173 web_contents_->GetRenderViewHost()->DragTargetDragLeave(); 175 web_contents_->GetRenderViewHost()->DragTargetDragLeave();
174 } 176 }
175 177
176 if (delegate_) 178 if (delegate_)
177 delegate_->OnDragLeave(data_object); 179 delegate_->OnDragLeave(data_object);
180
181 drop_data_.reset();
178 } 182 }
179 183
180 DWORD WebDragDest::OnDrop(IDataObject* data_object, 184 DWORD WebDragDest::OnDrop(IDataObject* data_object,
181 DWORD key_state, 185 DWORD key_state,
182 POINT cursor_position, 186 POINT cursor_position,
183 DWORD effect) { 187 DWORD effect) {
184 DCHECK(current_rvh_); 188 DCHECK(current_rvh_);
185 if (current_rvh_ != web_contents_->GetRenderViewHost()) 189 if (current_rvh_ != web_contents_->GetRenderViewHost())
186 OnDragEnter(data_object, key_state, cursor_position, effect); 190 OnDragEnter(data_object, key_state, cursor_position, effect);
187 191
188 if (web_contents_->ShowingInterstitialPage()) 192 if (web_contents_->ShowingInterstitialPage())
189 interstitial_drop_target_->OnDragOver(data_object, effect); 193 interstitial_drop_target_->OnDragOver(data_object, effect);
190 194
191 if (web_contents_->ShowingInterstitialPage()) 195 if (web_contents_->ShowingInterstitialPage())
192 return interstitial_drop_target_->OnDrop(data_object, effect); 196 return interstitial_drop_target_->OnDrop(data_object, effect);
193 197
194 POINT client_pt = cursor_position; 198 POINT client_pt = cursor_position;
195 ScreenToClient(GetHWND(), &client_pt); 199 ScreenToClient(GetHWND(), &client_pt);
196 web_contents_->GetRenderViewHost()->DragTargetDrop( 200 web_contents_->GetRenderViewHost()->DragTargetDrop(
197 gfx::Point(client_pt.x, client_pt.y), 201 gfx::Point(client_pt.x, client_pt.y),
198 gfx::Point(cursor_position.x, cursor_position.y)); 202 gfx::Point(cursor_position.x, cursor_position.y));
199 203
200 if (delegate_) 204 if (delegate_)
201 delegate_->OnDrop(data_object); 205 delegate_->OnDrop(data_object);
202 206
203 current_rvh_ = NULL; 207 current_rvh_ = NULL;
204 208
209 drop_data_.reset();
Aaron Boodman 2012/05/07 18:50:33 I'm not sure if this is needed, or if OnDragLeave
210
205 // 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.
206 // 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.
207 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_); 213 DWORD drop_effect = web_drag_utils_win::WebDragOpToWinDragOp(drag_cursor_);
208 return drop_effect != DROPEFFECT_MOVE ? drop_effect : DROPEFFECT_COPY; 214 return drop_effect != DROPEFFECT_MOVE ? drop_effect : DROPEFFECT_COPY;
209 } 215 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_drag_dest_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698