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_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/l10n_util_win.h" | 8 #include "app/l10n_util_win.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "app/view_prop.h" | 10 #include "app/view_prop.h" |
11 #include "app/win/scoped_prop.h" | |
12 #include "base/command_line.h" | 11 #include "base/command_line.h" |
13 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
15 #include "base/process_util.h" | 14 #include "base/process_util.h" |
16 #include "base/scoped_comptr_win.h" | 15 #include "base/scoped_comptr_win.h" |
17 #include "base/thread.h" | 16 #include "base/thread.h" |
18 #include "base/win_util.h" | 17 #include "base/win_util.h" |
19 #include "chrome/browser/accessibility/browser_accessibility_win.h" | 18 #include "chrome/browser/accessibility/browser_accessibility_win.h" |
20 #include "chrome/browser/accessibility/browser_accessibility_manager.h" | 19 #include "chrome/browser/accessibility/browser_accessibility_manager.h" |
21 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 20 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 53 |
55 using app::ViewProp; | 54 using app::ViewProp; |
56 using base::TimeDelta; | 55 using base::TimeDelta; |
57 using base::TimeTicks; | 56 using base::TimeTicks; |
58 using WebKit::WebInputEvent; | 57 using WebKit::WebInputEvent; |
59 using WebKit::WebInputEventFactory; | 58 using WebKit::WebInputEventFactory; |
60 using WebKit::WebMouseEvent; | 59 using WebKit::WebMouseEvent; |
61 using WebKit::WebTextDirection; | 60 using WebKit::WebTextDirection; |
62 using webkit_glue::WebPluginGeometry; | 61 using webkit_glue::WebPluginGeometry; |
63 | 62 |
| 63 const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
| 64 |
64 namespace { | 65 namespace { |
65 | 66 |
66 // Tooltips will wrap after this width. Yes, wrap. Imagine that! | 67 // Tooltips will wrap after this width. Yes, wrap. Imagine that! |
67 const int kTooltipMaxWidthPixels = 300; | 68 const int kTooltipMaxWidthPixels = 300; |
68 | 69 |
69 // Maximum number of characters we allow in a tooltip. | 70 // Maximum number of characters we allow in a tooltip. |
70 const int kMaxTooltipLength = 1024; | 71 const int kMaxTooltipLength = 1024; |
71 | 72 |
72 // A custom MSAA object id used to determine if a screen reader is actively | 73 // A custom MSAA object id used to determine if a screen reader is actively |
73 // listening for MSAA events. | 74 // listening for MSAA events. |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 NotificationType::RENDERER_PROCESS_TERMINATED, | 302 NotificationType::RENDERER_PROCESS_TERMINATED, |
302 NotificationService::AllSources()); | 303 NotificationService::AllSources()); |
303 } | 304 } |
304 | 305 |
305 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 306 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
306 ResetTooltip(); | 307 ResetTooltip(); |
307 } | 308 } |
308 | 309 |
309 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { | 310 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
310 Create(parent); // ATL function to create the window. | 311 Create(parent); // ATL function to create the window. |
311 | |
312 // Add a property indicating that a particular renderer is associated with | |
313 // this window. Used by the GPU process to validate window handles it | |
314 // receives from renderer processes. As this is used by a separate process we | |
315 // have to use ScopedProp here instead of ViewProp. | |
316 int renderer_id = render_widget_host_->process()->id(); | |
317 renderer_id_prop_.reset( | |
318 new app::win::ScopedProp(m_hWnd, | |
319 chrome::kChromiumRendererIdProperty, | |
320 reinterpret_cast<HANDLE>(renderer_id))); | |
321 } | 312 } |
322 | 313 |
323 /////////////////////////////////////////////////////////////////////////////// | 314 /////////////////////////////////////////////////////////////////////////////// |
324 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 315 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
325 | 316 |
326 void RenderWidgetHostViewWin::InitAsPopup( | 317 void RenderWidgetHostViewWin::InitAsPopup( |
327 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 318 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
328 parent_hwnd_ = parent_host_view->GetNativeView(); | 319 parent_hwnd_ = parent_host_view->GetNativeView(); |
329 close_on_deactivate_ = true; | 320 close_on_deactivate_ = true; |
330 Create(parent_hwnd_, NULL, NULL, WS_POPUP, WS_EX_TOOLWINDOW); | 321 Create(parent_hwnd_, NULL, NULL, WS_POPUP, WS_EX_TOOLWINDOW); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 // as they have plugin instances active. Quicktime crashes in this case | 855 // as they have plugin instances active. Quicktime crashes in this case |
865 // because its windowing code cleans up an internal data structure that the | 856 // because its windowing code cleans up an internal data structure that the |
866 // handler for NPP_DestroyStream relies on. | 857 // handler for NPP_DestroyStream relies on. |
867 // | 858 // |
868 // The fix is to detach plugin windows from web contents when it is going | 859 // The fix is to detach plugin windows from web contents when it is going |
869 // away. This will prevent the plugin windows from getting destroyed | 860 // away. This will prevent the plugin windows from getting destroyed |
870 // automatically. The detached plugin windows will get cleaned up in proper | 861 // automatically. The detached plugin windows will get cleaned up in proper |
871 // sequence as part of the usual cleanup when the plugin instance goes away. | 862 // sequence as part of the usual cleanup when the plugin instance goes away. |
872 EnumChildWindows(m_hWnd, DetachPluginWindowsCallback, NULL); | 863 EnumChildWindows(m_hWnd, DetachPluginWindowsCallback, NULL); |
873 | 864 |
874 renderer_id_prop_.reset(); | |
875 props_.reset(); | 865 props_.reset(); |
876 | 866 |
877 CleanupCompositorWindow(); | 867 CleanupCompositorWindow(); |
878 | 868 |
879 ResetTooltip(); | 869 ResetTooltip(); |
880 TrackMouseLeave(false); | 870 TrackMouseLeave(false); |
881 } | 871 } |
882 | 872 |
883 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { | 873 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
884 DCHECK(render_widget_host_->process()->HasConnection()); | 874 DCHECK(render_widget_host_->process()->HasConnection()); |
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 } | 1793 } |
1804 | 1794 |
1805 // static | 1795 // static |
1806 RenderWidgetHostView* | 1796 RenderWidgetHostView* |
1807 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1797 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1808 gfx::NativeView native_view) { | 1798 gfx::NativeView native_view) { |
1809 return ::IsWindow(native_view) ? | 1799 return ::IsWindow(native_view) ? |
1810 reinterpret_cast<RenderWidgetHostView*>( | 1800 reinterpret_cast<RenderWidgetHostView*>( |
1811 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; | 1801 ViewProp::GetValue(native_view, kRenderWidgetHostViewKey)) : NULL; |
1812 } | 1802 } |
OLD | NEW |