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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 G_CALLBACK(OnDragEndThunk), this); | 51 G_CALLBACK(OnDragEndThunk), this); |
52 signals_.Connect(drag_widget_, "drag-data-get", | 52 signals_.Connect(drag_widget_, "drag-data-get", |
53 G_CALLBACK(OnDragDataGetThunk), this); | 53 G_CALLBACK(OnDragDataGetThunk), this); |
54 | 54 |
55 signals_.Connect(drag_icon_, "expose-event", | 55 signals_.Connect(drag_icon_, "expose-event", |
56 G_CALLBACK(OnDragIconExposeThunk), this); | 56 G_CALLBACK(OnDragIconExposeThunk), this); |
57 } | 57 } |
58 | 58 |
59 WebDragSourceGtk::~WebDragSourceGtk() { | 59 WebDragSourceGtk::~WebDragSourceGtk() { |
60 // Break the current drag, if any. | 60 // Break the current drag, if any. |
61 if (drop_data_.get()) { | 61 if (drop_data_) { |
62 gtk_grab_add(drag_widget_); | 62 gtk_grab_add(drag_widget_); |
63 gtk_grab_remove(drag_widget_); | 63 gtk_grab_remove(drag_widget_); |
64 MessageLoopForUI::current()->RemoveObserver(this); | 64 MessageLoopForUI::current()->RemoveObserver(this); |
65 drop_data_.reset(); | 65 drop_data_.reset(); |
66 } | 66 } |
67 | 67 |
68 gtk_widget_destroy(drag_widget_); | 68 gtk_widget_destroy(drag_widget_); |
69 gtk_widget_destroy(drag_icon_); | 69 gtk_widget_destroy(drag_icon_); |
70 } | 70 } |
71 | 71 |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 GURL file_url(std::string(reinterpret_cast<char*>(file_url_value), | 238 GURL file_url(std::string(reinterpret_cast<char*>(file_url_value), |
239 file_url_len)); | 239 file_url_len)); |
240 g_free(file_url_value); | 240 g_free(file_url_value); |
241 base::FilePath file_path; | 241 base::FilePath file_path; |
242 if (net::FileURLToFilePath(file_url, &file_path)) { | 242 if (net::FileURLToFilePath(file_url, &file_path)) { |
243 // Open the file as a stream. | 243 // Open the file as a stream. |
244 scoped_ptr<net::FileStream> file_stream( | 244 scoped_ptr<net::FileStream> file_stream( |
245 CreateFileStreamForDrop( | 245 CreateFileStreamForDrop( |
246 &file_path, | 246 &file_path, |
247 GetContentClient()->browser()->GetNetLog())); | 247 GetContentClient()->browser()->GetNetLog())); |
248 if (file_stream.get()) { | 248 if (file_stream) { |
249 // Start downloading the file to the stream. | 249 // Start downloading the file to the stream. |
250 scoped_refptr<DragDownloadFile> drag_file_downloader = | 250 scoped_refptr<DragDownloadFile> drag_file_downloader = |
251 new DragDownloadFile( | 251 new DragDownloadFile( |
252 file_path, | 252 file_path, |
253 file_stream.Pass(), | 253 file_stream.Pass(), |
254 download_url_, | 254 download_url_, |
255 Referrer(web_contents_->GetURL(), | 255 Referrer(web_contents_->GetURL(), |
256 drop_data_->referrer_policy), | 256 drop_data_->referrer_policy), |
257 web_contents_->GetEncoding(), | 257 web_contents_->GetEncoding(), |
258 web_contents_); | 258 web_contents_); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 cairo_clip(cr); | 399 cairo_clip(cr); |
400 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); | 400 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); |
401 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); | 401 gdk_cairo_set_source_pixbuf(cr, drag_pixbuf_, 0, 0); |
402 cairo_paint(cr); | 402 cairo_paint(cr); |
403 cairo_destroy(cr); | 403 cairo_destroy(cr); |
404 | 404 |
405 return TRUE; | 405 return TRUE; |
406 } | 406 } |
407 | 407 |
408 } // namespace content | 408 } // namespace content |
OLD | NEW |