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/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
6 | 6 |
7 // If this gets included after the gtk headers, then a bunch of compiler | 7 // If this gets included after the gtk headers, then a bunch of compiler |
8 // errors happen because of a "#define Status int" in Xlib.h, which interacts | 8 // errors happen because of a "#define Status int" in Xlib.h, which interacts |
9 // badly with URLRequestStatus::Status. | 9 // badly with URLRequestStatus::Status. |
10 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 700 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
701 } | 701 } |
702 | 702 |
703 void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) { | 703 void RenderWidgetHostViewGtk::SetTooltipText(const std::wstring& tooltip_text) { |
704 // Maximum number of characters we allow in a tooltip. | 704 // Maximum number of characters we allow in a tooltip. |
705 const int kMaxTooltipLength = 8 << 10; | 705 const int kMaxTooltipLength = 8 << 10; |
706 // Clamp the tooltip length to kMaxTooltipLength so that we don't | 706 // Clamp the tooltip length to kMaxTooltipLength so that we don't |
707 // accidentally DOS the user with a mega tooltip (since GTK doesn't do | 707 // accidentally DOS the user with a mega tooltip (since GTK doesn't do |
708 // this itself). | 708 // this itself). |
709 // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream. | 709 // I filed https://bugzilla.gnome.org/show_bug.cgi?id=604641 upstream. |
710 const std::wstring& clamped_tooltip = | 710 const string16 clamped_tooltip = |
711 l10n_util::TruncateString(tooltip_text, kMaxTooltipLength); | 711 l10n_util::TruncateString(WideToUTF16Hack(tooltip_text), |
| 712 kMaxTooltipLength); |
712 | 713 |
713 if (clamped_tooltip.empty()) { | 714 if (clamped_tooltip.empty()) { |
714 gtk_widget_set_has_tooltip(view_.get(), FALSE); | 715 gtk_widget_set_has_tooltip(view_.get(), FALSE); |
715 } else { | 716 } else { |
716 gtk_widget_set_tooltip_text(view_.get(), | 717 gtk_widget_set_tooltip_text(view_.get(), |
717 WideToUTF8(clamped_tooltip).c_str()); | 718 UTF16ToUTF8(clamped_tooltip).c_str()); |
718 #if defined(OS_CHROMEOS) | 719 #if defined(OS_CHROMEOS) |
719 tooltip_window_->SetTooltipText(clamped_tooltip); | 720 tooltip_window_->SetTooltipText(UTF16ToWideHack(clamped_tooltip)); |
720 #endif // defined(OS_CHROMEOS) | 721 #endif // defined(OS_CHROMEOS) |
721 } | 722 } |
722 } | 723 } |
723 | 724 |
724 void RenderWidgetHostViewGtk::SelectionChanged(const std::string& text) { | 725 void RenderWidgetHostViewGtk::SelectionChanged(const std::string& text) { |
725 if (!text.empty()) { | 726 if (!text.empty()) { |
726 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); | 727 GtkClipboard* x_clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); |
727 gtk_clipboard_set_text(x_clipboard, text.c_str(), text.length()); | 728 gtk_clipboard_set_text(x_clipboard, text.c_str(), text.length()); |
728 } | 729 } |
729 } | 730 } |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 } | 1068 } |
1068 | 1069 |
1069 // static | 1070 // static |
1070 RenderWidgetHostView* | 1071 RenderWidgetHostView* |
1071 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1072 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1072 gfx::NativeView widget) { | 1073 gfx::NativeView widget) { |
1073 gpointer user_data = g_object_get_data(G_OBJECT(widget), | 1074 gpointer user_data = g_object_get_data(G_OBJECT(widget), |
1074 kRenderWidgetHostViewKey); | 1075 kRenderWidgetHostViewKey); |
1075 return reinterpret_cast<RenderWidgetHostView*>(user_data); | 1076 return reinterpret_cast<RenderWidgetHostView*>(user_data); |
1076 } | 1077 } |
OLD | NEW |