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_view_win.h" | 5 #include "chrome/browser/render_widget_host_view_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/gfx/gdi_util.h" | 8 #include "base/gfx/gdi_util.h" |
9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 cursor_is_custom_(false), | 71 cursor_is_custom_(false), |
72 track_mouse_leave_(false), | 72 track_mouse_leave_(false), |
73 ime_notification_(false), | 73 ime_notification_(false), |
74 is_hidden_(false), | 74 is_hidden_(false), |
75 close_on_deactivate_(false), | 75 close_on_deactivate_(false), |
76 tooltip_hwnd_(NULL), | 76 tooltip_hwnd_(NULL), |
77 tooltip_showing_(false), | 77 tooltip_showing_(false), |
78 shutdown_factory_(this), | 78 shutdown_factory_(this), |
79 parent_hwnd_(NULL), | 79 parent_hwnd_(NULL), |
80 is_loading_(false), | 80 is_loading_(false), |
81 focus_on_show_(true) { | 81 activatable_(true) { |
82 render_widget_host_->set_view(this); | 82 render_widget_host_->set_view(this); |
83 renderer_accessible_ = | 83 renderer_accessible_ = |
84 CommandLine().HasSwitch(switches::kEnableRendererAccessibility); | 84 CommandLine().HasSwitch(switches::kEnableRendererAccessibility); |
85 } | 85 } |
86 | 86 |
87 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 87 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
88 if (cursor_is_custom_) | 88 if (cursor_is_custom_) |
89 DestroyIcon(cursor_); | 89 DestroyIcon(cursor_); |
90 ResetTooltip(); | 90 ResetTooltip(); |
91 } | 91 } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 SetCapture(); | 159 SetCapture(); |
160 break; | 160 break; |
161 case WebInputEvent::MOUSE_UP: | 161 case WebInputEvent::MOUSE_UP: |
162 if (GetCapture() == m_hWnd) | 162 if (GetCapture() == m_hWnd) |
163 ReleaseCapture(); | 163 ReleaseCapture(); |
164 break; | 164 break; |
165 } | 165 } |
166 | 166 |
167 render_widget_host_->ForwardMouseEvent(event); | 167 render_widget_host_->ForwardMouseEvent(event); |
168 | 168 |
169 if (event.type == WebInputEvent::MOUSE_DOWN) { | 169 if (activatable_ && event.type == WebInputEvent::MOUSE_DOWN) { |
170 // This is a temporary workaround for bug 765011 to get focus when the | 170 // This is a temporary workaround for bug 765011 to get focus when the |
171 // mouse is clicked. This happens after the mouse down event is sent to | 171 // mouse is clicked. This happens after the mouse down event is sent to |
172 // the renderer because normally Windows does a WM_SETFOCUS after | 172 // the renderer because normally Windows does a WM_SETFOCUS after |
173 // WM_LBUTTONDOWN. | 173 // WM_LBUTTONDOWN. |
174 SetFocus(); | 174 SetFocus(); |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 void RenderWidgetHostViewWin::Focus() { | 178 void RenderWidgetHostViewWin::Focus() { |
179 if (IsWindow()) | 179 if (IsWindow()) |
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 if (!handled_by_webcontents) { | 773 if (!handled_by_webcontents) { |
774 render_widget_host_->ForwardWheelEvent( | 774 render_widget_host_->ForwardWheelEvent( |
775 WebMouseWheelEvent(m_hWnd, message, wparam, lparam)); | 775 WebMouseWheelEvent(m_hWnd, message, wparam, lparam)); |
776 } | 776 } |
777 handled = TRUE; | 777 handled = TRUE; |
778 return 0; | 778 return 0; |
779 } | 779 } |
780 | 780 |
781 LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM, | 781 LRESULT RenderWidgetHostViewWin::OnMouseActivate(UINT, WPARAM, LPARAM, |
782 BOOL& handled) { | 782 BOOL& handled) { |
| 783 if (!activatable_) |
| 784 return MA_NOACTIVATE; |
| 785 |
783 HWND focus_window = GetFocus(); | 786 HWND focus_window = GetFocus(); |
784 if (!::IsWindow(focus_window) || !IsChild(focus_window)) { | 787 if (!::IsWindow(focus_window) || !IsChild(focus_window)) { |
785 // We handle WM_MOUSEACTIVATE to set focus to the underlying plugin | 788 // We handle WM_MOUSEACTIVATE to set focus to the underlying plugin |
786 // child window. This is to ensure that keyboard events are received | 789 // child window. This is to ensure that keyboard events are received |
787 // by the plugin. The correct way to fix this would be send over | 790 // by the plugin. The correct way to fix this would be send over |
788 // an event to the renderer which would then eventually send over | 791 // an event to the renderer which would then eventually send over |
789 // a setFocus call to the plugin widget. This would ensure that | 792 // a setFocus call to the plugin widget. This would ensure that |
790 // the renderer (webkit) knows about the plugin widget receiving | 793 // the renderer (webkit) knows about the plugin widget receiving |
791 // focus. | 794 // focus. |
792 // TODO(iyengar) Do the right thing as per the above comment. | 795 // TODO(iyengar) Do the right thing as per the above comment. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 ::DestroyWindow(tooltip_hwnd_); | 913 ::DestroyWindow(tooltip_hwnd_); |
911 tooltip_hwnd_ = NULL; | 914 tooltip_hwnd_ = NULL; |
912 } | 915 } |
913 | 916 |
914 void RenderWidgetHostViewWin::ShutdownHost() { | 917 void RenderWidgetHostViewWin::ShutdownHost() { |
915 shutdown_factory_.RevokeAll(); | 918 shutdown_factory_.RevokeAll(); |
916 render_widget_host_->Shutdown(); | 919 render_widget_host_->Shutdown(); |
917 // Do not touch any members at this point, |this| has been deleted. | 920 // Do not touch any members at this point, |this| has been deleted. |
918 } | 921 } |
919 | 922 |
OLD | NEW |