| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk_dnd_util.h" | 7 #include "app/gtk_dnd_util.h" | 
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" | 
| 9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" | 
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" | 
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 239     gtk_widget_set_tooltip_markup(button, tooltip.c_str()); | 239     gtk_widget_set_tooltip_markup(button, tooltip.c_str()); | 
| 240 | 240 | 
| 241   g_object_set_data(G_OBJECT(button), bookmark_utils::kBookmarkNode, | 241   g_object_set_data(G_OBJECT(button), bookmark_utils::kBookmarkNode, | 
| 242                     AsVoid(node)); | 242                     AsVoid(node)); | 
| 243 } | 243 } | 
| 244 | 244 | 
| 245 std::string BuildTooltipFor(const BookmarkNode* node) { | 245 std::string BuildTooltipFor(const BookmarkNode* node) { | 
| 246   const std::string& url = node->GetURL().possibly_invalid_spec(); | 246   const std::string& url = node->GetURL().possibly_invalid_spec(); | 
| 247   const std::string& title = UTF16ToUTF8(node->GetTitle()); | 247   const std::string& title = UTF16ToUTF8(node->GetTitle()); | 
| 248 | 248 | 
| 249   std::string truncated_url = WideToUTF8(l10n_util::TruncateString( | 249   std::string truncated_url = UTF16ToUTF8(l10n_util::TruncateString( | 
| 250       UTF8ToWide(url), kMaxTooltipURLLength)); | 250       UTF8ToUTF16(url), kMaxTooltipURLLength)); | 
| 251   gchar* escaped_url_cstr = g_markup_escape_text(truncated_url.c_str(), | 251   gchar* escaped_url_cstr = g_markup_escape_text(truncated_url.c_str(), | 
| 252                                                  truncated_url.size()); | 252                                                  truncated_url.size()); | 
| 253   std::string escaped_url(escaped_url_cstr); | 253   std::string escaped_url(escaped_url_cstr); | 
| 254   g_free(escaped_url_cstr); | 254   g_free(escaped_url_cstr); | 
| 255 | 255 | 
| 256   std::string tooltip; | 256   std::string tooltip; | 
| 257   if (url == title || title.empty()) { | 257   if (url == title || title.empty()) { | 
| 258     return escaped_url; | 258     return escaped_url; | 
| 259   } else { | 259   } else { | 
| 260     std::string truncated_title = WideToUTF8(l10n_util::TruncateString( | 260     std::string truncated_title = UTF16ToUTF8(l10n_util::TruncateString( | 
| 261         UTF16ToWideHack(node->GetTitle()), kMaxTooltipTitleLength)); | 261         node->GetTitle(), kMaxTooltipTitleLength)); | 
| 262     gchar* escaped_title_cstr = g_markup_escape_text(truncated_title.c_str(), | 262     gchar* escaped_title_cstr = g_markup_escape_text(truncated_title.c_str(), | 
| 263                                                      truncated_title.size()); | 263                                                      truncated_title.size()); | 
| 264     std::string escaped_title(escaped_title_cstr); | 264     std::string escaped_title(escaped_title_cstr); | 
| 265     g_free(escaped_title_cstr); | 265     g_free(escaped_title_cstr); | 
| 266 | 266 | 
| 267     if (!escaped_url.empty()) | 267     if (!escaped_url.empty()) | 
| 268       return std::string("<b>") + escaped_title + "</b>\n" + escaped_url; | 268       return std::string("<b>") + escaped_title + "</b>\n" + escaped_url; | 
| 269     else | 269     else | 
| 270       return std::string("<b>") + escaped_title + "</b>"; | 270       return std::string("<b>") + escaped_title + "</b>"; | 
| 271   } | 271   } | 
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 432   GURL url; | 432   GURL url; | 
| 433   string16 title; | 433   string16 title; | 
| 434   if (!gtk_dnd_util::ExtractNetscapeURL(selection_data, &url, &title)) | 434   if (!gtk_dnd_util::ExtractNetscapeURL(selection_data, &url, &title)) | 
| 435     return false; | 435     return false; | 
| 436 | 436 | 
| 437   model->AddURL(parent, idx, title, url); | 437   model->AddURL(parent, idx, title, url); | 
| 438   return true; | 438   return true; | 
| 439 } | 439 } | 
| 440 | 440 | 
| 441 }  // namespace bookmark_utils | 441 }  // namespace bookmark_utils | 
| OLD | NEW | 
|---|