| 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/gfx/gtk_util.h" | 7 #include "app/gfx/gtk_util.h" |
| 8 #include "app/gtk_dnd_util.h" | 8 #include "app/gtk_dnd_util.h" |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 BookmarkDragData data(nodes); | 217 BookmarkDragData data(nodes); |
| 218 Pickle pickle; | 218 Pickle pickle; |
| 219 data.WriteToPickle(profile, &pickle); | 219 data.WriteToPickle(profile, &pickle); |
| 220 | 220 |
| 221 gtk_selection_data_set(selection_data, selection_data->target, | 221 gtk_selection_data_set(selection_data, selection_data->target, |
| 222 kBitsInAByte, | 222 kBitsInAByte, |
| 223 static_cast<const guchar*>(pickle.data()), | 223 static_cast<const guchar*>(pickle.data()), |
| 224 pickle.size()); | 224 pickle.size()); |
| 225 break; | 225 break; |
| 226 } | 226 } |
| 227 case GtkDndUtil::NETSCAPE_URL: { |
| 228 // _NETSCAPE_URL format is URL + \n + title. |
| 229 std::string utf8_text = nodes[0]->GetURL().spec() + "\n" + UTF16ToUTF8( |
| 230 nodes[0]->GetTitleAsString16()); |
| 231 gtk_selection_data_set(selection_data, |
| 232 selection_data->target, |
| 233 kBitsInAByte, |
| 234 reinterpret_cast<const guchar*>(utf8_text.c_str()), |
| 235 utf8_text.length()); |
| 236 break; |
| 237 } |
| 227 case GtkDndUtil::TEXT_URI_LIST: { | 238 case GtkDndUtil::TEXT_URI_LIST: { |
| 228 gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * | 239 gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * |
| 229 (nodes.size() + 1))); | 240 (nodes.size() + 1))); |
| 230 for (size_t i = 0; i < nodes.size(); ++i) { | 241 for (size_t i = 0; i < nodes.size(); ++i) { |
| 231 // If the node is a folder, this will be empty. TODO(estade): figure out | 242 // If the node is a folder, this will be empty. TODO(estade): figure out |
| 232 // if there are any ramifications to passing an empty URI. After a | 243 // if there are any ramifications to passing an empty URI. After a |
| 233 // little testing, it seems fine. | 244 // little testing, it seems fine. |
| 234 const GURL& url = nodes[i]->GetURL(); | 245 const GURL& url = nodes[i]->GetURL(); |
| 235 // This const cast should be safe as gtk_selection_data_set_uris() | 246 // This const cast should be safe as gtk_selection_data_set_uris() |
| 236 // makes copies. | 247 // makes copies. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 std::vector<GURL> urls; | 314 std::vector<GURL> urls; |
| 304 GtkDndUtil::ExtractURIList(selection_data, &urls); | 315 GtkDndUtil::ExtractURIList(selection_data, &urls); |
| 305 for (size_t i = 0; i < urls.size(); ++i) { | 316 for (size_t i = 0; i < urls.size(); ++i) { |
| 306 std::string title = GetNameForURL(urls[i]); | 317 std::string title = GetNameForURL(urls[i]); |
| 307 model->AddURL(parent, idx++, UTF8ToWide(title), urls[i]); | 318 model->AddURL(parent, idx++, UTF8ToWide(title), urls[i]); |
| 308 } | 319 } |
| 309 return true; | 320 return true; |
| 310 } | 321 } |
| 311 | 322 |
| 312 } // namespace bookmark_utils | 323 } // namespace bookmark_utils |
| OLD | NEW |