| 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/gtk_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 6 | 6 |
| 7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 #include <gtk/gtk.h> | 9 #include <gtk/gtk.h> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "content/browser/renderer_host/render_view_host.h" | 30 #include "content/browser/renderer_host/render_view_host.h" |
| 31 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
| 32 #include "content/common/renderer_preferences.h" | 32 #include "content/common/renderer_preferences.h" |
| 33 #include "googleurl/src/gurl.h" | 33 #include "googleurl/src/gurl.h" |
| 34 #include "grit/theme_resources.h" | 34 #include "grit/theme_resources.h" |
| 35 #include "grit/theme_resources_standard.h" | 35 #include "grit/theme_resources_standard.h" |
| 36 #include "third_party/skia/include/core/SkBitmap.h" | 36 #include "third_party/skia/include/core/SkBitmap.h" |
| 37 #include "third_party/skia/include/core/SkColor.h" | 37 #include "third_party/skia/include/core/SkColor.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/resource/resource_bundle.h" | 39 #include "ui/base/resource/resource_bundle.h" |
| 40 #include "ui/base/text/text_elider.h" |
| 40 #include "ui/base/x/x11_util.h" | 41 #include "ui/base/x/x11_util.h" |
| 41 #include "ui/gfx/gtk_util.h" | 42 #include "ui/gfx/gtk_util.h" |
| 42 #include "ui/gfx/image/image.h" | 43 #include "ui/gfx/image/image.h" |
| 43 | 44 |
| 44 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
| 45 #include "chrome/browser/chromeos/frame/browser_view.h" | 46 #include "chrome/browser/chromeos/frame/browser_view.h" |
| 46 #include "chrome/browser/chromeos/native_dialog_window.h" | 47 #include "chrome/browser/chromeos/native_dialog_window.h" |
| 47 #else | 48 #else |
| 48 #include "chrome/browser/ui/gtk/browser_window_gtk.h" | 49 #include "chrome/browser/ui/gtk/browser_window_gtk.h" |
| 49 #endif | 50 #endif |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 | 774 |
| 774 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { | 775 GdkPoint MakeBidiGdkPoint(gint x, gint y, gint width, bool ltr) { |
| 775 GdkPoint point = {ltr ? x : width - x, y}; | 776 GdkPoint point = {ltr ? x : width - x, y}; |
| 776 return point; | 777 return point; |
| 777 } | 778 } |
| 778 | 779 |
| 779 std::string BuildTooltipTitleFor(string16 title, const GURL& url) { | 780 std::string BuildTooltipTitleFor(string16 title, const GURL& url) { |
| 780 const std::string& url_str = url.possibly_invalid_spec(); | 781 const std::string& url_str = url.possibly_invalid_spec(); |
| 781 const std::string& title_str = UTF16ToUTF8(title); | 782 const std::string& title_str = UTF16ToUTF8(title); |
| 782 | 783 |
| 783 std::string truncated_url = UTF16ToUTF8(l10n_util::TruncateString( | 784 std::string truncated_url = UTF16ToUTF8(ui::TruncateString( |
| 784 UTF8ToUTF16(url_str), kMaxTooltipURLLength)); | 785 UTF8ToUTF16(url_str), kMaxTooltipURLLength)); |
| 785 gchar* escaped_url_cstr = g_markup_escape_text(truncated_url.c_str(), | 786 gchar* escaped_url_cstr = g_markup_escape_text(truncated_url.c_str(), |
| 786 truncated_url.size()); | 787 truncated_url.size()); |
| 787 std::string escaped_url(escaped_url_cstr); | 788 std::string escaped_url(escaped_url_cstr); |
| 788 g_free(escaped_url_cstr); | 789 g_free(escaped_url_cstr); |
| 789 | 790 |
| 790 std::string tooltip; | 791 std::string tooltip; |
| 791 if (url_str == title_str || title.empty()) { | 792 if (url_str == title_str || title.empty()) { |
| 792 return escaped_url; | 793 return escaped_url; |
| 793 } else { | 794 } else { |
| 794 std::string truncated_title = UTF16ToUTF8(l10n_util::TruncateString( | 795 std::string truncated_title = UTF16ToUTF8(ui::TruncateString( |
| 795 title, kMaxTooltipTitleLength)); | 796 title, kMaxTooltipTitleLength)); |
| 796 gchar* escaped_title_cstr = g_markup_escape_text(truncated_title.c_str(), | 797 gchar* escaped_title_cstr = g_markup_escape_text(truncated_title.c_str(), |
| 797 truncated_title.size()); | 798 truncated_title.size()); |
| 798 std::string escaped_title(escaped_title_cstr); | 799 std::string escaped_title(escaped_title_cstr); |
| 799 g_free(escaped_title_cstr); | 800 g_free(escaped_title_cstr); |
| 800 | 801 |
| 801 if (!escaped_url.empty()) | 802 if (!escaped_url.empty()) |
| 802 return std::string("<b>") + escaped_title + "</b>\n" + escaped_url; | 803 return std::string("<b>") + escaped_title + "</b>\n" + escaped_url; |
| 803 else | 804 else |
| 804 return std::string("<b>") + escaped_title + "</b>"; | 805 return std::string("<b>") + escaped_title + "</b>"; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1281 | 1282 |
| 1282 void DoCopy(BrowserWindow* window) { | 1283 void DoCopy(BrowserWindow* window) { |
| 1283 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); | 1284 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); |
| 1284 } | 1285 } |
| 1285 | 1286 |
| 1286 void DoPaste(BrowserWindow* window) { | 1287 void DoPaste(BrowserWindow* window) { |
| 1287 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); | 1288 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); |
| 1288 } | 1289 } |
| 1289 | 1290 |
| 1290 } // namespace gtk_util | 1291 } // namespace gtk_util |
| OLD | NEW |