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

Unified Diff: chrome/browser/render_widget_host_hwnd.cc

Issue 2409: Set an upper limit to the number of characters that can appear in a tooltip s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/views/tooltip_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/render_widget_host_hwnd.cc
===================================================================
--- chrome/browser/render_widget_host_hwnd.cc (revision 2027)
+++ chrome/browser/render_widget_host_hwnd.cc (working copy)
@@ -25,6 +25,9 @@
// Tooltips will wrap after this width. Yes, wrap. Imagine that!
static const int kTooltipMaxWidthPixels = 300;
+// Maximum number of characters we allow in a tooltip.
+static const int kMaxTooltipLength = 1024;
+
///////////////////////////////////////////////////////////////////////////////
// RenderWidgetHostHWND, public:
@@ -297,6 +300,13 @@
void RenderWidgetHostHWND::SetTooltipText(const std::wstring& tooltip_text) {
if (tooltip_text != tooltip_text_) {
tooltip_text_ = tooltip_text;
+
+ // Clamp the tooltip length to kMaxTooltipLength so that we don't
+ // accidentally DOS the user with a mega tooltip (since Windows doesn't seem
+ // to do this itself).
+ if (tooltip_text_.length() > kMaxTooltipLength)
+ tooltip_text_ = tooltip_text_.substr(0, kMaxTooltipLength);
+
// Need to check if the tooltip is already showing so that we don't
// immediately show the tooltip with no delay when we move the mouse from
// a region with no tooltip to a region with a tooltip.
« no previous file with comments | « no previous file | chrome/views/tooltip_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698