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

Side by Side Diff: content/browser/web_contents/web_drag_dest_gtk.cc

Issue 18281002: Move WebDropData to content::DropData and split off conversion function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build error. Created 7 years, 5 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/web_contents/web_drag_dest_gtk.h" 5 #include "content/browser/web_contents/web_drag_dest_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 103
104 drop_data_.reset(); 104 drop_data_.reset();
105 } 105 }
106 106
107 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, 107 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
108 GdkDragContext* context, 108 GdkDragContext* context,
109 gint x, gint y, 109 gint x, gint y,
110 guint time) { 110 guint time) {
111 if (context_ != context) { 111 if (context_ != context) {
112 context_ = context; 112 context_ = context;
113 drop_data_.reset(new WebDropData); 113 drop_data_.reset(new DropData);
114 is_drop_target_ = false; 114 is_drop_target_ = false;
115 115
116 if (delegate()) 116 if (delegate())
117 delegate()->DragInitialize(web_contents_); 117 delegate()->DragInitialize(web_contents_);
118 118
119 // text/plain must come before text/uri-list. This is a hack that works in 119 // text/plain must come before text/uri-list. This is a hack that works in
120 // conjunction with OnDragDataReceived. Since some file managers populate 120 // conjunction with OnDragDataReceived. Since some file managers populate
121 // text/plain with file URLs when dragging files, we want to handle 121 // text/plain with file URLs when dragging files, we want to handle
122 // text/uri-list after text/plain so that the plain text can be cleared if 122 // text/uri-list after text/plain so that the plain text can be cleared if
123 // it's a file drag. 123 // it's a file drag.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 for (gchar** uri_iter = uris; *uri_iter; uri_iter++) { 197 for (gchar** uri_iter = uris; *uri_iter; uri_iter++) {
198 // Most file managers populate text/uri-list with file URLs when 198 // Most file managers populate text/uri-list with file URLs when
199 // dragging files. To avoid exposing file system paths to web content, 199 // dragging files. To avoid exposing file system paths to web content,
200 // file URLs are never set as the URL content for the drop. 200 // file URLs are never set as the URL content for the drop.
201 // TODO(estade): Can the filenames have a non-UTF8 encoding? 201 // TODO(estade): Can the filenames have a non-UTF8 encoding?
202 GURL url(*uri_iter); 202 GURL url(*uri_iter);
203 base::FilePath file_path; 203 base::FilePath file_path;
204 if (url.SchemeIs(chrome::kFileScheme) && 204 if (url.SchemeIs(chrome::kFileScheme) &&
205 net::FileURLToFilePath(url, &file_path)) { 205 net::FileURLToFilePath(url, &file_path)) {
206 drop_data_->filenames.push_back( 206 drop_data_->filenames.push_back(
207 WebDropData::FileInfo(UTF8ToUTF16(file_path.value()), 207 DropData::FileInfo(UTF8ToUTF16(file_path.value()), string16()));
208 string16()));
209 // This is a hack. Some file managers also populate text/plain with 208 // This is a hack. Some file managers also populate text/plain with
210 // a file URL when dragging files, so we clear it to avoid exposing 209 // a file URL when dragging files, so we clear it to avoid exposing
211 // it to the web content. 210 // it to the web content.
212 drop_data_->text = base::NullableString16(); 211 drop_data_->text = base::NullableString16();
213 } else if (!drop_data_->url.is_valid()) { 212 } else if (!drop_data_->url.is_valid()) {
214 // Also set the first non-file URL as the URL content for the drop. 213 // Also set the first non-file URL as the URL content for the drop.
215 drop_data_->url = url; 214 drop_data_->url = url;
216 } 215 }
217 } 216 }
218 g_strfreev(uris); 217 g_strfreev(uris);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 gtk_drag_finish(context, is_drop_target_, FALSE, time); 329 gtk_drag_finish(context, is_drop_target_, FALSE, time);
331 330
332 return TRUE; 331 return TRUE;
333 } 332 }
334 333
335 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const { 334 RenderViewHostImpl* WebDragDestGtk::GetRenderViewHost() const {
336 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost()); 335 return static_cast<RenderViewHostImpl*>(web_contents_->GetRenderViewHost());
337 } 336 }
338 337
339 } // namespace content 338 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_drag_dest_gtk.h ('k') | content/browser/web_contents/web_drag_dest_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698