| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/gtk/bookmarks/bookmark_utils_gtk.h" | 5 #include "chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.h" |
| 6 | 6 |
| 7 #include "base/pickle.h" | 7 #include "base/pickle.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, >k_util::kGdkBlack); | 283 gtk_widget_modify_fg(label, GTK_STATE_PRELIGHT, >k_util::kGdkBlack); |
| 284 } | 284 } |
| 285 } | 285 } |
| 286 | 286 |
| 287 // DnD-related ----------------------------------------------------------------- | 287 // DnD-related ----------------------------------------------------------------- |
| 288 | 288 |
| 289 int GetCodeMask(bool folder) { | 289 int GetCodeMask(bool folder) { |
| 290 int rv = ui::CHROME_BOOKMARK_ITEM; | 290 int rv = ui::CHROME_BOOKMARK_ITEM; |
| 291 if (!folder) { | 291 if (!folder) { |
| 292 rv |= ui::TEXT_URI_LIST | | 292 rv |= ui::TEXT_URI_LIST | |
| 293 ui::TEXT_HTML | |
| 293 ui::TEXT_PLAIN | | 294 ui::TEXT_PLAIN | |
| 294 ui::NETSCAPE_URL; | 295 ui::NETSCAPE_URL; |
| 295 } | 296 } |
| 296 return rv; | 297 return rv; |
| 297 } | 298 } |
| 298 | 299 |
| 299 void WriteBookmarkToSelection(const BookmarkNode* node, | 300 void WriteBookmarkToSelection(const BookmarkNode* node, |
| 300 GtkSelectionData* selection_data, | 301 GtkSelectionData* selection_data, |
| 301 guint target_type, | 302 guint target_type, |
| 302 Profile* profile) { | 303 Profile* profile) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 // This const cast should be safe as gtk_selection_data_set_uris() | 345 // This const cast should be safe as gtk_selection_data_set_uris() |
| 345 // makes copies. | 346 // makes copies. |
| 346 uris[i] = const_cast<gchar*>(url.spec().c_str()); | 347 uris[i] = const_cast<gchar*>(url.spec().c_str()); |
| 347 } | 348 } |
| 348 uris[nodes.size()] = NULL; | 349 uris[nodes.size()] = NULL; |
| 349 | 350 |
| 350 gtk_selection_data_set_uris(selection_data, uris); | 351 gtk_selection_data_set_uris(selection_data, uris); |
| 351 free(uris); | 352 free(uris); |
| 352 break; | 353 break; |
| 353 } | 354 } |
| 355 case ui::TEXT_HTML: { |
| 356 std::string utf8_title = UTF16ToUTF8(nodes[0]->GetTitle()); |
| 357 std::string utf8_html = StringPrintf("<a href=\"%s\">%s</a>", |
| 358 nodes[0]->GetURL().spec().c_str(), |
| 359 utf8_title.c_str()); |
| 360 gtk_selection_data_set(selection_data, |
| 361 GetAtomForTarget(ui::TEXT_HTML), |
| 362 kBitsInAByte, |
| 363 reinterpret_cast<const guchar*>(utf8_html.data()), |
| 364 utf8_html.size()); |
| 365 break; |
| 366 } |
| 354 case ui::TEXT_PLAIN: { | 367 case ui::TEXT_PLAIN: { |
| 355 gtk_selection_data_set_text(selection_data, | 368 gtk_selection_data_set_text(selection_data, |
| 356 nodes[0]->GetURL().spec().c_str(), -1); | 369 nodes[0]->GetURL().spec().c_str(), -1); |
| 357 break; | 370 break; |
| 358 } | 371 } |
| 359 default: { | 372 default: { |
| 360 DLOG(ERROR) << "Unsupported drag get type!"; | 373 DLOG(ERROR) << "Unsupported drag get type!"; |
| 361 } | 374 } |
| 362 } | 375 } |
| 363 } | 376 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 GURL url; | 437 GURL url; |
| 425 string16 title; | 438 string16 title; |
| 426 if (!ui::ExtractNetscapeURL(selection_data, &url, &title)) | 439 if (!ui::ExtractNetscapeURL(selection_data, &url, &title)) |
| 427 return false; | 440 return false; |
| 428 | 441 |
| 429 model->AddURL(parent, idx, title, url); | 442 model->AddURL(parent, idx, title, url); |
| 430 return true; | 443 return true; |
| 431 } | 444 } |
| 432 | 445 |
| 433 } // namespace bookmark_utils | 446 } // namespace bookmark_utils |
| OLD | NEW |