OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/render_widget_host_hwnd.h" | 5 #include "chrome/browser/render_widget_host_hwnd.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/gfx/bitmap_header.h" | 8 #include "base/gfx/bitmap_header.h" |
9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
11 #include "base/win_util.h" | 11 #include "base/win_util.h" |
12 #include "chrome/browser/render_process_host.h" | 12 #include "chrome/browser/render_process_host.h" |
13 // TODO(beng): (Cleanup) we should not need to include this file... see comment | 13 // TODO(beng): (Cleanup) we should not need to include this file... see comment |
14 // in |DidBecomeSelected|. | 14 // in |DidBecomeSelected|. |
15 #include "chrome/browser/render_view_host.h" | 15 #include "chrome/browser/render_view_host.h" |
16 #include "chrome/browser/render_widget_host.h" | 16 #include "chrome/browser/render_widget_host.h" |
17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
19 #include "chrome/common/l10n_util.h" | 19 #include "chrome/common/l10n_util.h" |
20 #include "chrome/common/plugin_messages.h" | 20 #include "chrome/common/plugin_messages.h" |
21 #include "chrome/common/win_util.h" | 21 #include "chrome/common/win_util.h" |
22 #include "chrome/views/hwnd_view_container.h" | 22 #include "chrome/views/hwnd_view_container.h" |
23 #include "webkit/glue/webcursor.h" | 23 #include "webkit/glue/webcursor.h" |
24 | 24 |
25 // Tooltips will wrap after this width. Yes, wrap. Imagine that! | 25 // Tooltips will wrap after this width. Yes, wrap. Imagine that! |
26 static const int kTooltipMaxWidthPixels = 300; | 26 static const int kTooltipMaxWidthPixels = 300; |
27 | 27 |
| 28 // Maximum number of characters we allow in a tooltip. |
| 29 static const int kMaxTooltipLength = 1024; |
| 30 |
28 /////////////////////////////////////////////////////////////////////////////// | 31 /////////////////////////////////////////////////////////////////////////////// |
29 // RenderWidgetHostHWND, public: | 32 // RenderWidgetHostHWND, public: |
30 | 33 |
31 RenderWidgetHostHWND::RenderWidgetHostHWND( | 34 RenderWidgetHostHWND::RenderWidgetHostHWND( |
32 RenderWidgetHost* render_widget_host) | 35 RenderWidgetHost* render_widget_host) |
33 : RenderWidgetHostView(), | 36 : RenderWidgetHostView(), |
34 render_widget_host_(render_widget_host), | 37 render_widget_host_(render_widget_host), |
35 real_cursor_(LoadCursor(NULL, IDC_ARROW)), | 38 real_cursor_(LoadCursor(NULL, IDC_ARROW)), |
36 real_cursor_type_(WebCursor::ARROW), | 39 real_cursor_type_(WebCursor::ARROW), |
37 track_mouse_leave_(false), | 40 track_mouse_leave_(false), |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 // (caused by windows messages resulting from the DestroyWindow) from | 293 // (caused by windows messages resulting from the DestroyWindow) from |
291 // triggering further destructions. The deletion of this is handled by | 294 // triggering further destructions. The deletion of this is handled by |
292 // OnFinalMessage(); | 295 // OnFinalMessage(); |
293 close_on_deactivate_ = false; | 296 close_on_deactivate_ = false; |
294 DestroyWindow(); | 297 DestroyWindow(); |
295 } | 298 } |
296 | 299 |
297 void RenderWidgetHostHWND::SetTooltipText(const std::wstring& tooltip_text) { | 300 void RenderWidgetHostHWND::SetTooltipText(const std::wstring& tooltip_text) { |
298 if (tooltip_text != tooltip_text_) { | 301 if (tooltip_text != tooltip_text_) { |
299 tooltip_text_ = tooltip_text; | 302 tooltip_text_ = tooltip_text; |
| 303 |
| 304 // Clamp the tooltip length to kMaxTooltipLength so that we don't |
| 305 // accidentally DOS the user with a mega tooltip (since Windows doesn't seem |
| 306 // to do this itself). |
| 307 if (tooltip_text_.length() > kMaxTooltipLength) |
| 308 tooltip_text_ = tooltip_text_.substr(0, kMaxTooltipLength); |
| 309 |
300 // Need to check if the tooltip is already showing so that we don't | 310 // Need to check if the tooltip is already showing so that we don't |
301 // immediately show the tooltip with no delay when we move the mouse from | 311 // immediately show the tooltip with no delay when we move the mouse from |
302 // a region with no tooltip to a region with a tooltip. | 312 // a region with no tooltip to a region with a tooltip. |
303 if (::IsWindow(tooltip_hwnd_) && tooltip_showing_) { | 313 if (::IsWindow(tooltip_hwnd_) && tooltip_showing_) { |
304 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); | 314 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); |
305 ::SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0); | 315 ::SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0); |
306 } | 316 } |
307 } else { | 317 } else { |
308 // Make sure the tooltip gets closed after TTN_POP gets sent. For some | 318 // Make sure the tooltip gets closed after TTN_POP gets sent. For some |
309 // reason this doesn't happen automatically, so moving the mouse around | 319 // reason this doesn't happen automatically, so moving the mouse around |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 | 847 |
838 return TRUE; | 848 return TRUE; |
839 } | 849 } |
840 | 850 |
841 void RenderWidgetHostHWND::ShutdownHost() { | 851 void RenderWidgetHostHWND::ShutdownHost() { |
842 shutdown_factory_.RevokeAll(); | 852 shutdown_factory_.RevokeAll(); |
843 render_widget_host_->Shutdown(); | 853 render_widget_host_->Shutdown(); |
844 // Do not touch any members at this point, |this| has been deleted. | 854 // Do not touch any members at this point, |this| has been deleted. |
845 } | 855 } |
846 | 856 |
OLD | NEW |