| OLD | NEW |
| 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/gtk/bookmark_utils_gtk.h" | 5 #include "chrome/browser/gtk/bookmark_utils_gtk.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "base/gfx/gtk_util.h" | 8 #include "base/gfx/gtk_util.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 BookmarkDragData data(nodes); | 183 BookmarkDragData data(nodes); |
| 184 Pickle pickle; | 184 Pickle pickle; |
| 185 data.WriteToPickle(profile, &pickle); | 185 data.WriteToPickle(profile, &pickle); |
| 186 | 186 |
| 187 gtk_selection_data_set(selection_data, selection_data->target, | 187 gtk_selection_data_set(selection_data, selection_data->target, |
| 188 kBitsInAByte, | 188 kBitsInAByte, |
| 189 static_cast<const guchar*>(pickle.data()), | 189 static_cast<const guchar*>(pickle.data()), |
| 190 pickle.size()); | 190 pickle.size()); |
| 191 break; | 191 break; |
| 192 } | 192 } |
| 193 case GtkDndUtil::X_CHROME_TEXT_URI_LIST: { |
| 194 gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * |
| 195 (nodes.size() + 1))); |
| 196 for (size_t i = 0; i < nodes.size(); ++i) { |
| 197 // If the node is a folder, this will be empty. TODO(estade): figure out |
| 198 // if there are any ramifications to passing an empty URI. After a |
| 199 // lttle testing, it seems fine. |
| 200 const GURL& url = nodes[i]->GetURL(); |
| 201 // This const cast should be safe as gtk_selection_data_set_uris() |
| 202 // makes copies. |
| 203 uris[i] = const_cast<gchar*>(url.spec().c_str()); |
| 204 } |
| 205 uris[nodes.size()] = NULL; |
| 206 |
| 207 gtk_selection_data_set_uris(selection_data, uris); |
| 208 free(uris); |
| 209 break; |
| 210 } |
| 193 default: { | 211 default: { |
| 194 DLOG(ERROR) << "Unsupported drag get type!"; | 212 DLOG(ERROR) << "Unsupported drag get type!"; |
| 195 } | 213 } |
| 196 } | 214 } |
| 197 } | 215 } |
| 198 | 216 |
| 199 std::vector<const BookmarkNode*> GetNodesFromSelection( | 217 std::vector<const BookmarkNode*> GetNodesFromSelection( |
| 200 GdkDragContext* context, | 218 GdkDragContext* context, |
| 201 GtkSelectionData* selection_data, | 219 GtkSelectionData* selection_data, |
| 202 guint target_type, | 220 guint target_type, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 223 default: { | 241 default: { |
| 224 DLOG(ERROR) << "Unsupported drag received type: " << target_type; | 242 DLOG(ERROR) << "Unsupported drag received type: " << target_type; |
| 225 } | 243 } |
| 226 } | 244 } |
| 227 } | 245 } |
| 228 | 246 |
| 229 return std::vector<const BookmarkNode*>(); | 247 return std::vector<const BookmarkNode*>(); |
| 230 } | 248 } |
| 231 | 249 |
| 232 } // namespace bookmark_utils | 250 } // namespace bookmark_utils |
| OLD | NEW |