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/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/bookmarks/bookmark_model.h" | 11 #include "chrome/browser/bookmarks/bookmark_model.h" |
12 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 12 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" | 15 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" |
16 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 16 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
17 #include "chrome/browser/ui/gtk/gtk_util.h" | 17 #include "chrome/browser/ui/gtk/gtk_util.h" |
18 #include "ui/base/dragdrop/gtk_dnd_util.h" | 18 #include "ui/base/dragdrop/gtk_dnd_util.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 uris[i] = const_cast<gchar*>(url.spec().c_str()); | 348 uris[i] = const_cast<gchar*>(url.spec().c_str()); |
349 } | 349 } |
350 uris[nodes.size()] = NULL; | 350 uris[nodes.size()] = NULL; |
351 | 351 |
352 gtk_selection_data_set_uris(selection_data, uris); | 352 gtk_selection_data_set_uris(selection_data, uris); |
353 free(uris); | 353 free(uris); |
354 break; | 354 break; |
355 } | 355 } |
356 case ui::TEXT_HTML: { | 356 case ui::TEXT_HTML: { |
357 std::string utf8_title = UTF16ToUTF8(nodes[0]->GetTitle()); | 357 std::string utf8_title = UTF16ToUTF8(nodes[0]->GetTitle()); |
358 std::string utf8_html = StringPrintf("<a href=\"%s\">%s</a>", | 358 std::string utf8_html = base::StringPrintf("<a href=\"%s\">%s</a>", |
359 nodes[0]->url().spec().c_str(), | 359 nodes[0]->url().spec().c_str(), |
360 utf8_title.c_str()); | 360 utf8_title.c_str()); |
361 gtk_selection_data_set(selection_data, | 361 gtk_selection_data_set(selection_data, |
362 GetAtomForTarget(ui::TEXT_HTML), | 362 GetAtomForTarget(ui::TEXT_HTML), |
363 kBitsInAByte, | 363 kBitsInAByte, |
364 reinterpret_cast<const guchar*>(utf8_html.data()), | 364 reinterpret_cast<const guchar*>(utf8_html.data()), |
365 utf8_html.size()); | 365 utf8_html.size()); |
366 break; | 366 break; |
367 } | 367 } |
368 case ui::TEXT_PLAIN: { | 368 case ui::TEXT_PLAIN: { |
369 gtk_selection_data_set_text(selection_data, | 369 gtk_selection_data_set_text(selection_data, |
370 nodes[0]->url().spec().c_str(), -1); | 370 nodes[0]->url().spec().c_str(), -1); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 GURL url; | 438 GURL url; |
439 string16 title; | 439 string16 title; |
440 if (!ui::ExtractNetscapeURL(selection_data, &url, &title)) | 440 if (!ui::ExtractNetscapeURL(selection_data, &url, &title)) |
441 return false; | 441 return false; |
442 | 442 |
443 model->AddURL(parent, idx, title, url); | 443 model->AddURL(parent, idx, title, url); |
444 return true; | 444 return true; |
445 } | 445 } |
446 | 446 |
447 } // namespace bookmark_utils | 447 } // namespace bookmark_utils |
OLD | NEW |