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

Unified Diff: chrome/views/tooltip_manager.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 | « chrome/browser/render_widget_host_hwnd.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/views/tooltip_manager.cc
===================================================================
--- chrome/views/tooltip_manager.cc (revision 2027)
+++ chrome/views/tooltip_manager.cc (working copy)
@@ -27,6 +27,9 @@
// Maximum number of lines we allow in the tooltip.
static const int kMaxLines = 6;
+// Maximum number of characters we allow in a tooltip.
+static const int kMaxTooltipLength = 1024;
+
// Breaks |text| along line boundaries, placing each line of text into lines.
static void SplitTooltipString(const std::wstring& text,
std::vector<std::wstring>* lines) {
@@ -272,6 +275,12 @@
*max_width = 0;
*line_count = 0;
+ // 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 (text->length() > kMaxTooltipLength)
+ *text = text->substr(0, kMaxTooltipLength);
+
// Determine the available width for the tooltip.
CPoint screen_loc(position_x, position_y);
View::ConvertPointToScreen(view_container_->GetRootView(), &screen_loc);
« no previous file with comments | « chrome/browser/render_widget_host_hwnd.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698