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

Side by Side Diff: chrome/browser/tab_contents/web_drag_dest_gtk.cc

Issue 1691018: GTK: make tabbed bookmark manager compatible with more types of drops. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: naming Created 10 years, 7 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
« no previous file with comments | « chrome/browser/bookmarks/bookmark_drag_data.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/tab_contents/web_drag_dest_gtk.h" 5 #include "chrome/browser/tab_contents/web_drag_dest_gtk.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "app/gtk_dnd_util.h" 9 #include "app/gtk_dnd_util.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 } 67 }
68 68
69 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender, 69 gboolean WebDragDestGtk::OnDragMotion(GtkWidget* sender,
70 GdkDragContext* context, 70 GdkDragContext* context,
71 gint x, gint y, 71 gint x, gint y,
72 guint time) { 72 guint time) {
73 if (context_ != context) { 73 if (context_ != context) {
74 context_ = context; 74 context_ = context;
75 drop_data_.reset(new WebDropData); 75 drop_data_.reset(new WebDropData);
76 bookmark_drag_data_.Clear();
76 is_drop_target_ = false; 77 is_drop_target_ = false;
77 78
78 static int supported_targets[] = { 79 static int supported_targets[] = {
79 gtk_dnd_util::TEXT_PLAIN, 80 gtk_dnd_util::TEXT_PLAIN,
80 gtk_dnd_util::TEXT_URI_LIST, 81 gtk_dnd_util::TEXT_URI_LIST,
81 gtk_dnd_util::TEXT_HTML, 82 gtk_dnd_util::TEXT_HTML,
82 gtk_dnd_util::NETSCAPE_URL, 83 gtk_dnd_util::NETSCAPE_URL,
83 gtk_dnd_util::CHROME_NAMED_URL, 84 gtk_dnd_util::CHROME_NAMED_URL,
84 gtk_dnd_util::CHROME_BOOKMARK_ITEM, 85 gtk_dnd_util::CHROME_BOOKMARK_ITEM,
85 // TODO(estade): support image drags? 86 // TODO(estade): support image drags?
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 drop_data_->text_html = 152 drop_data_->text_html =
152 UTF8ToUTF16(std::string(reinterpret_cast<char*>(data->data), 153 UTF8ToUTF16(std::string(reinterpret_cast<char*>(data->data),
153 data->length)); 154 data->length));
154 // We leave the base URL empty. 155 // We leave the base URL empty.
155 } else if (data->target == 156 } else if (data->target ==
156 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::NETSCAPE_URL)) { 157 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::NETSCAPE_URL)) {
157 std::string netscape_url(reinterpret_cast<char*>(data->data), 158 std::string netscape_url(reinterpret_cast<char*>(data->data),
158 data->length); 159 data->length);
159 size_t split = netscape_url.find_first_of('\n'); 160 size_t split = netscape_url.find_first_of('\n');
160 if (split != std::string::npos) { 161 if (split != std::string::npos) {
161 drop_data_->url_title = UTF8ToUTF16(netscape_url.substr(0, split)); 162 drop_data_->url = GURL(netscape_url.substr(0, split));
162 if (split < netscape_url.size() - 1) 163 if (split < netscape_url.size() - 1)
163 drop_data_->url = GURL(netscape_url.substr(split + 1)); 164 drop_data_->url_title = UTF8ToUTF16(netscape_url.substr(split + 1));
164 } 165 }
165 } else if (data->target == 166 } else if (data->target ==
166 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_NAMED_URL)) { 167 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_NAMED_URL)) {
167 gtk_dnd_util::ExtractNamedURL(data, 168 gtk_dnd_util::ExtractNamedURL(data,
168 &drop_data_->url, &drop_data_->url_title); 169 &drop_data_->url, &drop_data_->url_title);
169 } else if (data->target == 170 }
170 gtk_dnd_util::GetAtomForTarget( 171 }
171 gtk_dnd_util::CHROME_BOOKMARK_ITEM)) { 172
173 // For CHROME_BOOKMARK_ITEM, we have to handle the case where the drag source
174 // doesn't have any data available for us. In this case we try to synthesize a
175 // URL bookmark.
176 if (data->target ==
177 gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) {
178 if (data->data) {
172 bookmark_drag_data_.ReadFromVector( 179 bookmark_drag_data_.ReadFromVector(
173 bookmark_utils::GetNodesFromSelection( 180 bookmark_utils::GetNodesFromSelection(
174 NULL, data, 181 NULL, data,
175 gtk_dnd_util::CHROME_BOOKMARK_ITEM, 182 gtk_dnd_util::CHROME_BOOKMARK_ITEM,
176 tab_contents_->profile(), NULL, NULL)); 183 tab_contents_->profile(), NULL, NULL));
177 bookmark_drag_data_.SetOriginatingProfile(tab_contents_->profile()); 184 bookmark_drag_data_.SetOriginatingProfile(tab_contents_->profile());
185 } else {
186 bookmark_drag_data_.ReadFromTuple(drop_data_->url,
187 drop_data_->url_title);
178 } 188 }
179 } 189 }
180 190
181 if (data_requests_ == 0) { 191 if (data_requests_ == 0) {
182 // Tell the renderer about the drag. 192 // Tell the renderer about the drag.
183 // |x| and |y| are seemingly arbitrary at this point. 193 // |x| and |y| are seemingly arbitrary at this point.
184 tab_contents_->render_view_host()-> 194 tab_contents_->render_view_host()->
185 DragTargetDragEnter(*drop_data_.get(), 195 DragTargetDragEnter(*drop_data_.get(),
186 gtk_util::ClientPoint(widget_), 196 gtk_util::ClientPoint(widget_),
187 gtk_util::ScreenPoint(widget_), 197 gtk_util::ScreenPoint(widget_),
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // support for (at the moment experimental) drag and drop extensions. 237 // support for (at the moment experimental) drag and drop extensions.
228 if (tab_contents_->GetBookmarkDragDelegate()) 238 if (tab_contents_->GetBookmarkDragDelegate())
229 tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data_); 239 tab_contents_->GetBookmarkDragDelegate()->OnDrop(bookmark_drag_data_);
230 240
231 // The second parameter is just an educated guess as to whether or not the 241 // The second parameter is just an educated guess as to whether or not the
232 // drag succeeded, but at least we will get the drag-end animation right 242 // drag succeeded, but at least we will get the drag-end animation right
233 // sometimes. 243 // sometimes.
234 gtk_drag_finish(context, is_drop_target_, FALSE, time); 244 gtk_drag_finish(context, is_drop_target_, FALSE, time);
235 return TRUE; 245 return TRUE;
236 } 246 }
OLDNEW
« no previous file with comments | « chrome/browser/bookmarks/bookmark_drag_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698