Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1452)

Side by Side Diff: chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc

Issue 23731010: Move text_elider to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update3 Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/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/themes/theme_properties.h" 15 #include "chrome/browser/themes/theme_properties.h"
16 #include "chrome/browser/ui/gtk/gtk_chrome_button.h" 16 #include "chrome/browser/ui/gtk/gtk_chrome_button.h"
17 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 17 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
18 #include "chrome/browser/ui/gtk/gtk_util.h" 18 #include "chrome/browser/ui/gtk/gtk_util.h"
19 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
21 #include "grit/ui_strings.h" 21 #include "grit/ui_strings.h"
22 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
23 #include "ui/base/dragdrop/gtk_dnd_util.h" 23 #include "ui/base/dragdrop/gtk_dnd_util.h"
24 #include "ui/base/gtk/gtk_hig_constants.h" 24 #include "ui/base/gtk/gtk_hig_constants.h"
25 #include "ui/base/gtk/gtk_screen_util.h" 25 #include "ui/base/gtk/gtk_screen_util.h"
26 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle.h" 27 #include "ui/base/resource/resource_bundle.h"
28 #include "ui/base/text/text_elider.h"
29 #include "ui/gfx/canvas_skia_paint.h" 28 #include "ui/gfx/canvas_skia_paint.h"
30 #include "ui/gfx/font.h" 29 #include "ui/gfx/font.h"
31 #include "ui/gfx/image/image.h" 30 #include "ui/gfx/image/image.h"
31 #include "ui/gfx/text_elider.h"
32 32
33 namespace { 33 namespace {
34 34
35 // Spacing between the favicon and the text. 35 // Spacing between the favicon and the text.
36 const int kBarButtonPadding = 4; 36 const int kBarButtonPadding = 4;
37 37
38 // Used in gtk_selection_data_set(). (I assume from this parameter that gtk has 38 // Used in gtk_selection_data_set(). (I assume from this parameter that gtk has
39 // to some really exotic hardware...) 39 // to some really exotic hardware...)
40 const int kBitsInAByte = 8; 40 const int kBitsInAByte = 8;
41 41
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 if (node->is_folder()) 270 if (node->is_folder())
271 return std::string(); 271 return std::string();
272 272
273 return gtk_util::BuildTooltipTitleFor(node->GetTitle(), node->url()); 273 return gtk_util::BuildTooltipTitleFor(node->GetTitle(), node->url());
274 } 274 }
275 275
276 std::string BuildMenuLabelFor(const BookmarkNode* node) { 276 std::string BuildMenuLabelFor(const BookmarkNode* node) {
277 // This breaks on word boundaries. Ideally we would break on character 277 // This breaks on word boundaries. Ideally we would break on character
278 // boundaries. 278 // boundaries.
279 std::string elided_name = UTF16ToUTF8( 279 std::string elided_name = UTF16ToUTF8(
280 ui::TruncateString(node->GetTitle(), kMaxCharsOnAMenuLabel)); 280 gfx::TruncateString(node->GetTitle(), kMaxCharsOnAMenuLabel));
281 281
282 if (elided_name.empty()) { 282 if (elided_name.empty()) {
283 elided_name = UTF16ToUTF8(ui::TruncateString( 283 elided_name = UTF16ToUTF8(gfx::TruncateString(
284 UTF8ToUTF16(node->url().possibly_invalid_spec()), 284 UTF8ToUTF16(node->url().possibly_invalid_spec()),
285 kMaxCharsOnAMenuLabel)); 285 kMaxCharsOnAMenuLabel));
286 } 286 }
287 287
288 return elided_name; 288 return elided_name;
289 } 289 }
290 290
291 const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget) { 291 const BookmarkNode* BookmarkNodeForWidget(GtkWidget* widget) {
292 return reinterpret_cast<const BookmarkNode*>( 292 return reinterpret_cast<const BookmarkNode*>(
293 g_object_get_data(G_OBJECT(widget), kBookmarkNode)); 293 g_object_get_data(G_OBJECT(widget), kBookmarkNode));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 return net::GetSuggestedFilename(url, 484 return net::GetSuggestedFilename(url,
485 std::string(), 485 std::string(),
486 std::string(), 486 std::string(),
487 std::string(), 487 std::string(),
488 std::string(), 488 std::string(),
489 std::string()); 489 std::string());
490 } else { 490 } else {
491 return l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME); 491 return l10n_util::GetStringUTF16(IDS_APP_UNTITLED_SHORTCUT_FILE_NAME);
492 } 492 }
493 } 493 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/avatar_menu_item_gtk.cc ('k') | chrome/browser/ui/gtk/content_setting_bubble_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698