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

Side by Side Diff: chrome/browser/tab_contents/web_drop_target.cc

Issue 174364: Plumb the DragOperation through all the layers between the platform DnD code ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
OLDNEW
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 "app/os_exchange_data.h" 10 #include "app/os_exchange_data.h"
11 #include "app/os_exchange_data_provider_win.h" 11 #include "app/os_exchange_data_provider_win.h"
12 #include "base/clipboard_util.h" 12 #include "base/clipboard_util.h"
13 #include "base/gfx/point.h" 13 #include "base/gfx/point.h"
14 #include "chrome/browser/renderer_host/render_view_host.h" 14 #include "chrome/browser/renderer_host/render_view_host.h"
15 #include "chrome/browser/tab_contents/tab_contents.h" 15 #include "chrome/browser/tab_contents/tab_contents.h"
16 #include "googleurl/src/gurl.h" 16 #include "googleurl/src/gurl.h"
17 #include "net/base/net_util.h" 17 #include "net/base/net_util.h"
18 #include "webkit/glue/webdropdata.h" 18 #include "webkit/glue/webdropdata.h"
19 #include "webkit/glue/window_open_disposition.h" 19 #include "webkit/glue/window_open_disposition.h"
20 20
21 using WebKit::WebDragOperationCopy;
22
21 namespace { 23 namespace {
22 24
23 // A helper method for getting the preferred drop effect. 25 // A helper method for getting the preferred drop effect.
24 DWORD GetPreferredDropEffect(DWORD effect) { 26 DWORD GetPreferredDropEffect(DWORD effect) {
25 if (effect & DROPEFFECT_COPY) 27 if (effect & DROPEFFECT_COPY)
26 return DROPEFFECT_COPY; 28 return DROPEFFECT_COPY;
27 if (effect & DROPEFFECT_LINK) 29 if (effect & DROPEFFECT_LINK)
28 return DROPEFFECT_LINK; 30 return DROPEFFECT_LINK;
29 if (effect & DROPEFFECT_MOVE) 31 if (effect & DROPEFFECT_MOVE)
30 return DROPEFFECT_MOVE; 32 return DROPEFFECT_MOVE;
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 108
107 if (drop_data.url.is_empty()) 109 if (drop_data.url.is_empty())
108 OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url); 110 OSExchangeDataProviderWin::GetPlainTextURL(data_object, &drop_data.url);
109 111
110 is_drop_target_ = true; 112 is_drop_target_ = true;
111 113
112 POINT client_pt = cursor_position; 114 POINT client_pt = cursor_position;
113 ScreenToClient(GetHWND(), &client_pt); 115 ScreenToClient(GetHWND(), &client_pt);
114 tab_contents_->render_view_host()->DragTargetDragEnter(drop_data, 116 tab_contents_->render_view_host()->DragTargetDragEnter(drop_data,
115 gfx::Point(client_pt.x, client_pt.y), 117 gfx::Point(client_pt.x, client_pt.y),
116 gfx::Point(cursor_position.x, cursor_position.y)); 118 gfx::Point(cursor_position.x, cursor_position.y),
119 WebDragOperationCopy); // FIXME(snej): Send actual operation
117 120
118 // We lie here and always return a DROPEFFECT because we don't want to 121 // We lie here and always return a DROPEFFECT because we don't want to
119 // wait for the IPC call to return. 122 // wait for the IPC call to return.
120 return GetPreferredDropEffect(effect); 123 return GetPreferredDropEffect(effect);
121 } 124 }
122 125
123 DWORD WebDropTarget::OnDragOver(IDataObject* data_object, 126 DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
124 DWORD key_state, 127 DWORD key_state,
125 POINT cursor_position, 128 POINT cursor_position,
126 DWORD effect) { 129 DWORD effect) {
127 DCHECK(current_rvh_); 130 DCHECK(current_rvh_);
128 if (current_rvh_ != tab_contents_->render_view_host()) 131 if (current_rvh_ != tab_contents_->render_view_host())
129 OnDragEnter(data_object, key_state, cursor_position, effect); 132 OnDragEnter(data_object, key_state, cursor_position, effect);
130 133
131 if (tab_contents_->showing_interstitial_page()) 134 if (tab_contents_->showing_interstitial_page())
132 return interstitial_drop_target_->OnDragOver(data_object, effect); 135 return interstitial_drop_target_->OnDragOver(data_object, effect);
133 136
134 POINT client_pt = cursor_position; 137 POINT client_pt = cursor_position;
135 ScreenToClient(GetHWND(), &client_pt); 138 ScreenToClient(GetHWND(), &client_pt);
136 tab_contents_->render_view_host()->DragTargetDragOver( 139 tab_contents_->render_view_host()->DragTargetDragOver(
137 gfx::Point(client_pt.x, client_pt.y), 140 gfx::Point(client_pt.x, client_pt.y),
138 gfx::Point(cursor_position.x, cursor_position.y)); 141 gfx::Point(cursor_position.x, cursor_position.y),
142 WebDragOperationCopy); // FIXME(snej): Send actual operation
139 143
140 if (!is_drop_target_) 144 if (!is_drop_target_)
141 return DROPEFFECT_NONE; 145 return DROPEFFECT_NONE;
142 146
143 return GetPreferredDropEffect(effect); 147 return GetPreferredDropEffect(effect);
144 } 148 }
145 149
146 void WebDropTarget::OnDragLeave(IDataObject* data_object) { 150 void WebDropTarget::OnDragLeave(IDataObject* data_object) {
147 DCHECK(current_rvh_); 151 DCHECK(current_rvh_);
148 if (current_rvh_ != tab_contents_->render_view_host()) 152 if (current_rvh_ != tab_contents_->render_view_host())
(...skipping 25 matching lines...) Expand all
174 tab_contents_->render_view_host()->DragTargetDrop( 178 tab_contents_->render_view_host()->DragTargetDrop(
175 gfx::Point(client_pt.x, client_pt.y), 179 gfx::Point(client_pt.x, client_pt.y),
176 gfx::Point(cursor_position.x, cursor_position.y)); 180 gfx::Point(cursor_position.x, cursor_position.y));
177 181
178 current_rvh_ = NULL; 182 current_rvh_ = NULL;
179 183
180 // We lie and always claim that the drop operation didn't happen because we 184 // We lie and always claim that the drop operation didn't happen because we
181 // don't want to wait for the renderer to respond. 185 // don't want to wait for the renderer to respond.
182 return DROPEFFECT_NONE; 186 return DROPEFFECT_NONE;
183 } 187 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_drag_source.cc ('k') | chrome/browser/views/tab_contents/tab_contents_view_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698