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

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

Issue 1029004: GTK: implement extension bookmark manager drag api.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | « chrome/browser/tab_contents/web_drag_dest_gtk.cc ('k') | chrome/chrome_browser.gypi » ('j') | 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) 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"
11 #include "app/os_exchange_data.h" 11 #include "app/os_exchange_data.h"
12 #include "app/os_exchange_data_provider_win.h" 12 #include "app/os_exchange_data_provider_win.h"
13 #include "chrome/browser/bookmarks/bookmark_drag_data.h"
13 #include "chrome/browser/renderer_host/render_view_host.h" 14 #include "chrome/browser/renderer_host/render_view_host.h"
14 #include "chrome/browser/tab_contents/tab_contents.h" 15 #include "chrome/browser/tab_contents/tab_contents.h"
15 #include "gfx/point.h" 16 #include "gfx/point.h"
16 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
17 #include "net/base/net_util.h" 18 #include "net/base/net_util.h"
18 #include "webkit/glue/webdropdata.h" 19 #include "webkit/glue/webdropdata.h"
19 #include "webkit/glue/window_open_disposition.h" 20 #include "webkit/glue/window_open_disposition.h"
20 21
21 using WebKit::WebDragOperationCopy; 22 using WebKit::WebDragOperationCopy;
22 23
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 ScreenToClient(GetHWND(), &client_pt); 116 ScreenToClient(GetHWND(), &client_pt);
116 tab_contents_->render_view_host()->DragTargetDragEnter(drop_data, 117 tab_contents_->render_view_host()->DragTargetDragEnter(drop_data,
117 gfx::Point(client_pt.x, client_pt.y), 118 gfx::Point(client_pt.x, client_pt.y),
118 gfx::Point(cursor_position.x, cursor_position.y), 119 gfx::Point(cursor_position.x, cursor_position.y),
119 WebDragOperationCopy); // FIXME(snej): Send actual operation 120 WebDragOperationCopy); // FIXME(snej): Send actual operation
120 121
121 // This is non-null if tab_contents_ is showing an ExtensionDOMUI with 122 // This is non-null if tab_contents_ is showing an ExtensionDOMUI with
122 // support for (at the moment experimental) drag and drop extensions. 123 // support for (at the moment experimental) drag and drop extensions.
123 if (tab_contents_->GetBookmarkDragDelegate()) { 124 if (tab_contents_->GetBookmarkDragDelegate()) {
124 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); 125 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object));
125 tab_contents_->GetBookmarkDragDelegate()->OnDragEnter(&os_exchange_data); 126 BookmarkDragData bookmark_drag_data;
127 if (bookmark_drag_data.Read(os_exchange_data))
128 tab_contents_->GetBookmarkDragDelegate()->OnDragEnter(bookmark_drag_data);
126 } 129 }
127 130
128 // We lie here and always return a DROPEFFECT because we don't want to 131 // We lie here and always return a DROPEFFECT because we don't want to
129 // wait for the IPC call to return. 132 // wait for the IPC call to return.
130 return GetPreferredDropEffect(effect); 133 return GetPreferredDropEffect(effect);
131 } 134 }
132 135
133 DWORD WebDropTarget::OnDragOver(IDataObject* data_object, 136 DWORD WebDropTarget::OnDragOver(IDataObject* data_object,
134 DWORD key_state, 137 DWORD key_state,
135 POINT cursor_position, 138 POINT cursor_position,
136 DWORD effect) { 139 DWORD effect) {
137 DCHECK(current_rvh_); 140 DCHECK(current_rvh_);
138 if (current_rvh_ != tab_contents_->render_view_host()) 141 if (current_rvh_ != tab_contents_->render_view_host())
139 OnDragEnter(data_object, key_state, cursor_position, effect); 142 OnDragEnter(data_object, key_state, cursor_position, effect);
140 143
141 if (tab_contents_->showing_interstitial_page()) 144 if (tab_contents_->showing_interstitial_page())
142 return interstitial_drop_target_->OnDragOver(data_object, effect); 145 return interstitial_drop_target_->OnDragOver(data_object, effect);
143 146
144 POINT client_pt = cursor_position; 147 POINT client_pt = cursor_position;
145 ScreenToClient(GetHWND(), &client_pt); 148 ScreenToClient(GetHWND(), &client_pt);
146 tab_contents_->render_view_host()->DragTargetDragOver( 149 tab_contents_->render_view_host()->DragTargetDragOver(
147 gfx::Point(client_pt.x, client_pt.y), 150 gfx::Point(client_pt.x, client_pt.y),
148 gfx::Point(cursor_position.x, cursor_position.y), 151 gfx::Point(cursor_position.x, cursor_position.y),
149 WebDragOperationCopy); // FIXME(snej): Send actual operation 152 WebDragOperationCopy); // FIXME(snej): Send actual operation
150 153
151 if (tab_contents_->GetBookmarkDragDelegate()) { 154 if (tab_contents_->GetBookmarkDragDelegate()) {
152 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); 155 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object));
153 tab_contents_->GetBookmarkDragDelegate()->OnDragOver(&os_exchange_data); 156 BookmarkDragData bookmark_drag_data;
157 if (bookmark_drag_data.Read(os_exchange_data))
158 tab_contents_->GetBookmarkDragDelegate()->OnDragOver(bookmark_drag_data);
154 } 159 }
155 160
156 if (!is_drop_target_) 161 if (!is_drop_target_)
157 return DROPEFFECT_NONE; 162 return DROPEFFECT_NONE;
158 163
159 return GetPreferredDropEffect(effect); 164 return GetPreferredDropEffect(effect);
160 } 165 }
161 166
162 void WebDropTarget::OnDragLeave(IDataObject* data_object) { 167 void WebDropTarget::OnDragLeave(IDataObject* data_object) {
163 DCHECK(current_rvh_); 168 DCHECK(current_rvh_);
164 if (current_rvh_ != tab_contents_->render_view_host()) 169 if (current_rvh_ != tab_contents_->render_view_host())
165 return; 170 return;
166 171
167 if (tab_contents_->showing_interstitial_page()) { 172 if (tab_contents_->showing_interstitial_page()) {
168 interstitial_drop_target_->OnDragLeave(data_object); 173 interstitial_drop_target_->OnDragLeave(data_object);
169 } else { 174 } else {
170 tab_contents_->render_view_host()->DragTargetDragLeave(); 175 tab_contents_->render_view_host()->DragTargetDragLeave();
171 } 176 }
172 177
173 if (tab_contents_->GetBookmarkDragDelegate()) { 178 if (tab_contents_->GetBookmarkDragDelegate()) {
174 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); 179 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object));
175 tab_contents_->GetBookmarkDragDelegate()->OnDragLeave(&os_exchange_data); 180 BookmarkDragData bookmark_drag_data;
181 if (bookmark_drag_data.Read(os_exchange_data))
182 tab_contents_->GetBookmarkDragDelegate()->OnDragLeave(bookmark_drag_data);
176 } 183 }
177 } 184 }
178 185
179 DWORD WebDropTarget::OnDrop(IDataObject* data_object, 186 DWORD WebDropTarget::OnDrop(IDataObject* data_object,
180 DWORD key_state, 187 DWORD key_state,
181 POINT cursor_position, 188 POINT cursor_position,
182 DWORD effect) { 189 DWORD effect) {
183 DCHECK(current_rvh_); 190 DCHECK(current_rvh_);
184 if (current_rvh_ != tab_contents_->render_view_host()) 191 if (current_rvh_ != tab_contents_->render_view_host())
185 OnDragEnter(data_object, key_state, cursor_position, effect); 192 OnDragEnter(data_object, key_state, cursor_position, effect);
186 193
187 if (tab_contents_->showing_interstitial_page()) 194 if (tab_contents_->showing_interstitial_page())
188 interstitial_drop_target_->OnDragOver(data_object, effect); 195 interstitial_drop_target_->OnDragOver(data_object, effect);
189 196
190 if (tab_contents_->showing_interstitial_page()) 197 if (tab_contents_->showing_interstitial_page())
191 return interstitial_drop_target_->OnDrop(data_object, effect); 198 return interstitial_drop_target_->OnDrop(data_object, effect);
192 199
193 POINT client_pt = cursor_position; 200 POINT client_pt = cursor_position;
194 ScreenToClient(GetHWND(), &client_pt); 201 ScreenToClient(GetHWND(), &client_pt);
195 tab_contents_->render_view_host()->DragTargetDrop( 202 tab_contents_->render_view_host()->DragTargetDrop(
196 gfx::Point(client_pt.x, client_pt.y), 203 gfx::Point(client_pt.x, client_pt.y),
197 gfx::Point(cursor_position.x, cursor_position.y)); 204 gfx::Point(cursor_position.x, cursor_position.y));
198 205
199 if (tab_contents_->GetBookmarkDragDelegate()) { 206 if (tab_contents_->GetBookmarkDragDelegate()) {
200 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object)); 207 OSExchangeData os_exchange_data(new OSExchangeDataProviderWin(data_object));
201 tab_contents_->GetBookmarkDragDelegate()->OnDrop(&os_exchange_data); 208 BookmarkDragData bookmark_drag_data;
209 if (bookmark_drag_data.Read(os_exchange_data))
210 tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data);
202 } 211 }
203 212
204 current_rvh_ = NULL; 213 current_rvh_ = NULL;
205 214
206 // We lie and always claim that the drop operation didn't happen because we 215 // We lie and always claim that the drop operation didn't happen because we
207 // don't want to wait for the renderer to respond. 216 // don't want to wait for the renderer to respond.
208 return DROPEFFECT_NONE; 217 return DROPEFFECT_NONE;
209 } 218 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/web_drag_dest_gtk.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698