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

Side by Side Diff: content/browser/tab_contents/web_drag_source_gtk.cc

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 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
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/tab_contents/web_drag_source_gtk.h" 5 #include "content/browser/tab_contents/web_drag_source_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/nix/mime_util_xdg.h" 10 #include "base/nix/mime_util_xdg.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // No-op. 158 // No-op.
159 } 159 }
160 160
161 void WebDragSourceGtk::DidProcessEvent(GdkEvent* event) { 161 void WebDragSourceGtk::DidProcessEvent(GdkEvent* event) {
162 if (event->type != GDK_MOTION_NOTIFY) 162 if (event->type != GDK_MOTION_NOTIFY)
163 return; 163 return;
164 164
165 GdkEventMotion* event_motion = reinterpret_cast<GdkEventMotion*>(event); 165 GdkEventMotion* event_motion = reinterpret_cast<GdkEventMotion*>(event);
166 gfx::Point client = ui::ClientPoint(GetContentNativeView()); 166 gfx::Point client = ui::ClientPoint(GetContentNativeView());
167 167
168 if (web_contents_->GetRenderViewHost()) { 168 if (GetRenderViewHost()) {
169 web_contents_->GetRenderViewHost()->DragSourceMovedTo( 169 GetRenderViewHost()->DragSourceMovedTo(
170 client.x(), client.y(), 170 client.x(), client.y(),
171 static_cast<int>(event_motion->x_root), 171 static_cast<int>(event_motion->x_root),
172 static_cast<int>(event_motion->y_root)); 172 static_cast<int>(event_motion->y_root));
173 } 173 }
174 } 174 }
175 175
176 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender, 176 void WebDragSourceGtk::OnDragDataGet(GtkWidget* sender,
177 GdkDragContext* context, 177 GdkDragContext* context,
178 GtkSelectionData* selection_data, 178 GtkSelectionData* selection_data,
179 guint target_type, 179 guint target_type,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 293 }
294 294
295 gboolean WebDragSourceGtk::OnDragFailed(GtkWidget* sender, 295 gboolean WebDragSourceGtk::OnDragFailed(GtkWidget* sender,
296 GdkDragContext* context, 296 GdkDragContext* context,
297 GtkDragResult result) { 297 GtkDragResult result) {
298 drag_failed_ = true; 298 drag_failed_ = true;
299 299
300 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); 300 gfx::Point root = ui::ScreenPoint(GetContentNativeView());
301 gfx::Point client = ui::ClientPoint(GetContentNativeView()); 301 gfx::Point client = ui::ClientPoint(GetContentNativeView());
302 302
303 if (web_contents_->GetRenderViewHost()) { 303 if (GetRenderViewHost()) {
304 web_contents_->GetRenderViewHost()->DragSourceEndedAt( 304 GetRenderViewHost()->DragSourceEndedAt(
305 client.x(), client.y(), root.x(), root.y(), 305 client.x(), client.y(), root.x(), root.y(),
306 WebDragOperationNone); 306 WebDragOperationNone);
307 } 307 }
308 308
309 // Let the native failure animation run. 309 // Let the native failure animation run.
310 return FALSE; 310 return FALSE;
311 } 311 }
312 312
313 void WebDragSourceGtk::OnDragBegin(GtkWidget* sender, 313 void WebDragSourceGtk::OnDragBegin(GtkWidget* sender,
314 GdkDragContext* drag_context) { 314 GdkDragContext* drag_context) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 if (!download_url_.is_empty()) { 366 if (!download_url_.is_empty()) {
367 gdk_property_delete(drag_context->source_window, 367 gdk_property_delete(drag_context->source_window,
368 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE)); 368 ui::GetAtomForTarget(ui::DIRECT_SAVE_FILE));
369 } 369 }
370 370
371 if (!drag_failed_) { 371 if (!drag_failed_) {
372 gfx::Point root = ui::ScreenPoint(GetContentNativeView()); 372 gfx::Point root = ui::ScreenPoint(GetContentNativeView());
373 gfx::Point client = ui::ClientPoint(GetContentNativeView()); 373 gfx::Point client = ui::ClientPoint(GetContentNativeView());
374 374
375 if (web_contents_->GetRenderViewHost()) { 375 if (GetRenderViewHost()) {
376 web_contents_->GetRenderViewHost()->DragSourceEndedAt( 376 GetRenderViewHost()->DragSourceEndedAt(
377 client.x(), client.y(), root.x(), root.y(), 377 client.x(), client.y(), root.x(), root.y(),
378 content::GdkDragActionToWebDragOp(drag_context->action)); 378 content::GdkDragActionToWebDragOp(drag_context->action));
379 } 379 }
380 } 380 }
381 381
382 web_contents_->SystemDragEnded(); 382 web_contents_->SystemDragEnded();
383 383
384 drop_data_.reset(); 384 drop_data_.reset();
385 drag_context_ = NULL; 385 drag_context_ = NULL;
386 } 386 }
387 387
388 RenderViewHostImpl* WebDragSourceGtk::GetRenderViewHost() const {
389 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
390 }
391
388 gfx::NativeView WebDragSourceGtk::GetContentNativeView() const { 392 gfx::NativeView WebDragSourceGtk::GetContentNativeView() const {
389 return web_contents_->GetView()->GetContentNativeView(); 393 return web_contents_->GetView()->GetContentNativeView();
390 } 394 }
391 395
392 gboolean WebDragSourceGtk::OnDragIconExpose(GtkWidget* sender, 396 gboolean WebDragSourceGtk::OnDragIconExpose(GtkWidget* sender,
393 GdkEventExpose* event) { 397 GdkEventExpose* event) {
394 cairo_t* cr = gdk_cairo_create(event->window); 398 cairo_t* cr = gdk_cairo_create(event->window);
395 gdk_cairo_rectangle(cr, &event->area); 399 gdk_cairo_rectangle(cr, &event->area);
396 cairo_clip(cr); 400 cairo_clip(cr);
397 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); 401 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
398 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); 402 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0);
399 cairo_paint(cr); 403 cairo_paint(cr);
400 cairo_destroy(cr); 404 cairo_destroy(cr);
401 405
402 return TRUE; 406 return TRUE;
403 } 407 }
404 408
405 } // namespace content 409 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/tab_contents/web_drag_source_gtk.h ('k') | content/browser/tab_contents/web_drag_source_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698