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

Side by Side Diff: chrome/browser/gtk/tab_contents_drag_source.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) 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 "chrome/browser/gtk/tab_contents_drag_source.h" 5 #include "chrome/browser/gtk/tab_contents_drag_source.h"
6 6
7 #include "app/gtk_dnd_util.h" 7 #include "app/gtk_dnd_util.h"
8 #include "base/mime_util.h" 8 #include "base/mime_util.h"
9 #include "chrome/browser/renderer_host/render_view_host_delegate.h" 9 #include "chrome/browser/renderer_host/render_view_host_delegate.h"
10 #include "chrome/browser/tab_contents/tab_contents.h" 10 #include "chrome/browser/tab_contents/tab_contents.h"
11 #include "chrome/browser/tab_contents/tab_contents_view.h" 11 #include "chrome/browser/tab_contents/tab_contents_view.h"
12 #include "chrome/common/gtk_util.h" 12 #include "chrome/common/gtk_util.h"
13 #include "webkit/glue/webdropdata.h" 13 #include "webkit/glue/webdropdata.h"
14 14
15 using WebKit::WebDragOperation;
16 using WebKit::WebDragOperationNone;
17
15 TabContentsDragSource::TabContentsDragSource( 18 TabContentsDragSource::TabContentsDragSource(
16 TabContentsView* tab_contents_view) 19 TabContentsView* tab_contents_view)
17 : tab_contents_view_(tab_contents_view), 20 : tab_contents_view_(tab_contents_view),
18 drag_failed_(false), 21 drag_failed_(false),
19 drag_widget_(NULL) { 22 drag_widget_(NULL) {
20 drag_widget_ = gtk_invisible_new(); 23 drag_widget_ = gtk_invisible_new();
21 g_signal_connect(drag_widget_, "drag-failed", 24 g_signal_connect(drag_widget_, "drag-failed",
22 G_CALLBACK(OnDragFailedThunk), this); 25 G_CALLBACK(OnDragFailedThunk), this);
23 g_signal_connect(drag_widget_, "drag-end", G_CALLBACK(OnDragEndThunk), this); 26 g_signal_connect(drag_widget_, "drag-end", G_CALLBACK(OnDragEndThunk), this);
24 g_signal_connect(drag_widget_, "drag-data-get", 27 g_signal_connect(drag_widget_, "drag-data-get",
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 } 166 }
164 } 167 }
165 168
166 gboolean TabContentsDragSource::OnDragFailed() { 169 gboolean TabContentsDragSource::OnDragFailed() {
167 drag_failed_ = true; 170 drag_failed_ = true;
168 171
169 gfx::Point root = gtk_util::ScreenPoint(GetContentNativeView()); 172 gfx::Point root = gtk_util::ScreenPoint(GetContentNativeView());
170 gfx::Point client = gtk_util::ClientPoint(GetContentNativeView()); 173 gfx::Point client = gtk_util::ClientPoint(GetContentNativeView());
171 174
172 if (tab_contents()->render_view_host()) { 175 if (tab_contents()->render_view_host()) {
173 tab_contents()->render_view_host()->DragSourceCancelledAt( 176 tab_contents()->render_view_host()->DragSourceEndedAt(
174 client.x(), client.y(), root.x(), root.y()); 177 client.x(), client.y(), root.x(), root.y(),
178 WebDragOperationNone);
175 } 179 }
176 180
177 // Let the native failure animation run. 181 // Let the native failure animation run.
178 return FALSE; 182 return FALSE;
179 } 183 }
180 184
181 void TabContentsDragSource::OnDragEnd() { 185 void TabContentsDragSource::OnDragEnd(WebDragOperation operation) {
182 MessageLoopForUI::current()->RemoveObserver(this); 186 MessageLoopForUI::current()->RemoveObserver(this);
183 187
184 if (!drag_failed_) { 188 if (!drag_failed_) {
185 gfx::Point root = gtk_util::ScreenPoint(GetContentNativeView()); 189 gfx::Point root = gtk_util::ScreenPoint(GetContentNativeView());
186 gfx::Point client = gtk_util::ClientPoint(GetContentNativeView()); 190 gfx::Point client = gtk_util::ClientPoint(GetContentNativeView());
187 191
188 if (tab_contents()->render_view_host()) { 192 if (tab_contents()->render_view_host()) {
189 tab_contents()->render_view_host()->DragSourceEndedAt( 193 tab_contents()->render_view_host()->DragSourceEndedAt(
190 client.x(), client.y(), root.x(), root.y()); 194 client.x(), client.y(), root.x(), root.y(), operation);
191 } 195 }
192 } 196 }
193 197
194 if (tab_contents()->render_view_host()) 198 if (tab_contents()->render_view_host())
195 tab_contents()->render_view_host()->DragSourceSystemDragEnded(); 199 tab_contents()->render_view_host()->DragSourceSystemDragEnded();
196 200
197 drop_data_.reset(); 201 drop_data_.reset();
198 } 202 }
199 203
200 gfx::NativeView TabContentsDragSource::GetContentNativeView() const { 204 gfx::NativeView TabContentsDragSource::GetContentNativeView() const {
201 return tab_contents_view_->GetContentNativeView(); 205 return tab_contents_view_->GetContentNativeView();
202 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/tab_contents_drag_source.h ('k') | chrome/browser/renderer_host/render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698