OLD | NEW |
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_source_gtk.h" | 5 #include "content/browser/web_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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 targets_mask |= ui::CUSTOM_DATA; | 107 targets_mask |= ui::CUSTOM_DATA; |
108 | 108 |
109 // NOTE: Begin a drag even if no targets present. Otherwise, things like | 109 // NOTE: Begin a drag even if no targets present. Otherwise, things like |
110 // draggable list elements will not work. | 110 // draggable list elements will not work. |
111 | 111 |
112 drop_data_.reset(new WebDropData(drop_data)); | 112 drop_data_.reset(new WebDropData(drop_data)); |
113 | 113 |
114 // The image we get from WebKit makes heavy use of alpha-shading. This looks | 114 // The image we get from WebKit makes heavy use of alpha-shading. This looks |
115 // bad on non-compositing WMs. Fall back to the default drag icon. | 115 // bad on non-compositing WMs. Fall back to the default drag icon. |
116 if (!image.isNull() && ui::IsScreenComposited()) | 116 if (!image.isNull() && ui::IsScreenComposited()) |
117 drag_pixbuf_ = gfx::GdkPixbufFromSkBitmap(&image); | 117 drag_pixbuf_ = gfx::GdkPixbufFromSkBitmap(image); |
118 image_offset_ = image_offset; | 118 image_offset_ = image_offset; |
119 | 119 |
120 GtkTargetList* list = ui::GetTargetListFromCodeMask(targets_mask); | 120 GtkTargetList* list = ui::GetTargetListFromCodeMask(targets_mask); |
121 if (targets_mask & ui::CHROME_WEBDROP_FILE_CONTENTS) { | 121 if (targets_mask & ui::CHROME_WEBDROP_FILE_CONTENTS) { |
122 // Looking up the mime type can hit the disk. http://crbug.com/84896 | 122 // Looking up the mime type can hit the disk. http://crbug.com/84896 |
123 base::ThreadRestrictions::ScopedAllowIO allow_io; | 123 base::ThreadRestrictions::ScopedAllowIO allow_io; |
124 drag_file_mime_type_ = gdk_atom_intern( | 124 drag_file_mime_type_ = gdk_atom_intern( |
125 base::nix::GetDataMimeType(drop_data.file_contents).c_str(), FALSE); | 125 base::nix::GetDataMimeType(drop_data.file_contents).c_str(), FALSE); |
126 gtk_target_list_add(list, drag_file_mime_type_, | 126 gtk_target_list_add(list, drag_file_mime_type_, |
127 0, ui::CHROME_WEBDROP_FILE_CONTENTS); | 127 0, ui::CHROME_WEBDROP_FILE_CONTENTS); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 cairo_clip(cr); | 401 cairo_clip(cr); |
402 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 402 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
403 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 403 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
404 cairo_paint(cr); | 404 cairo_paint(cr); |
405 cairo_destroy(cr); | 405 cairo_destroy(cr); |
406 | 406 |
407 return TRUE; | 407 return TRUE; |
408 } | 408 } |
409 | 409 |
410 } // namespace content | 410 } // namespace content |
OLD | NEW |