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

Side by Side Diff: content/browser/renderer_host/legacy_render_widget_host_win.cc

Issue 151083002: Create a visible window with class name Chrome_RenderWidgetHostHWND which corresponds to the bounds… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
6
7 #include "base/win/windows_version.h"
8 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
9 #include "content/browser/accessibility/browser_accessibility_win.h"
10 #include "ui/base/touch/touch_enabled.h"
11 #include "ui/gfx/geometry/rect.h"
12
13 namespace content {
14
15 LegacyRenderWidgetHostHWND::LegacyRenderWidgetHostHWND(HWND parent)
16 : manager_(NULL),
17 parent_(NULL) {
18 RECT rect = {0};
19 Create(parent, rect, L"Chrome Legacy Helper",
cpu_(ooo_6.6-7.5) 2014/02/04 22:35:58 "Chrome Legacy Window" ?
ananta 2014/02/04 23:30:45 Done.
20 WS_CHILDWINDOW, WS_EX_TRANSPARENT);
21
22 if (base::win::GetVersion() >= base::win::VERSION_WIN7 &&
23 ui::AreTouchEventsEnabled())
24 RegisterTouchWindow(hwnd(), TWF_WANTPALM);
25
26 HRESULT hr = ::CreateStdAccessibleObject(
27 hwnd(), OBJID_WINDOW, IID_IAccessible,
28 reinterpret_cast<void **>(window_accessible_.Receive()));
29
30 if (::IsWindow(hwnd()))
31 SetParentWindow(parent);
32 }
33
34 LegacyRenderWidgetHostHWND::~LegacyRenderWidgetHostHWND() {
35 }
36
37 void LegacyRenderWidgetHostHWND::SetParentWindow(HWND parent) {
38 ::SetParent(hwnd(), parent);
39 parent_ = parent;
40 }
41
42 void LegacyRenderWidgetHostHWND::OnManagerDeleted() {
43 manager_ = NULL;
44 }
45
46 void LegacyRenderWidgetHostHWND::Show() {
47 ::ShowWindow(hwnd(), SW_SHOW);
48 }
49
50 void LegacyRenderWidgetHostHWND::Hide() {
51 ::ShowWindow(hwnd(), SW_HIDE);
52 }
53
54 void LegacyRenderWidgetHostHWND::OnFinalMessage(HWND hwnd) {
55 if (manager_)
56 manager_->OnAccessibleHwndDeleted();
57 delete this;
58 }
59
60 LRESULT LegacyRenderWidgetHostHWND::OnEraseBkGnd(UINT message,
61 WPARAM w_param,
62 LPARAM l_param) {
63 return 1;
64 }
65
66 LRESULT LegacyRenderWidgetHostHWND::OnGetObject(UINT message,
67 WPARAM w_param,
68 LPARAM l_param) {
69 if (OBJID_CLIENT != l_param || !manager_)
70 return static_cast<LRESULT>(0L);
71
72 base::win::ScopedComPtr<IAccessible> root(
73 manager_->GetRoot()->ToBrowserAccessibilityWin());
74 return LresultFromObject(IID_IAccessible, w_param,
75 static_cast<IAccessible*>(root.Detach()));
76 }
77
78 // We send keyboard/mouse/touch messages to the parent window via SendMessage.
79 // While this works, this has the sideeffect of converting input messages into
cpu_(ooo_6.6-7.5) 2014/02/04 22:35:58 side effect
ananta 2014/02/04 23:30:45 Done.
80 // sent messages which changes their priority and could technically result
81 // in these messages starving other messages in the queue. Additionally
82 // keyboard/mouse hooks would not see these messages. The alternative approach
83 // is to set and release capture as needed on the parent to ensure that it
84 // receives all mouse events. However that was shelved due to possible issues
85 // with capture changes.
86 LRESULT LegacyRenderWidgetHostHWND::OnKeyboardRange(UINT message,
87 WPARAM w_param,
88 LPARAM l_param,
89 BOOL& handled) {
90 ::SendMessage(parent_, message, w_param, l_param);
91 return 0;
cpu_(ooo_6.6-7.5) 2014/02/04 22:35:58 return ::SendMessage(parent_, message, w_param, l_
ananta 2014/02/04 23:30:45 Done.
92 }
93
94 LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message,
95 WPARAM w_param,
96 LPARAM l_param,
97 BOOL& handled) {
98 POINT mouse_coords;
99 mouse_coords.x = GET_X_LPARAM(l_param);
100 mouse_coords.y = GET_Y_LPARAM(l_param);
101 ::MapWindowPoints(hwnd(), parent_, &mouse_coords, 1);
102 ::SendMessage(parent_, message, w_param,
103 MAKELPARAM(mouse_coords.x, mouse_coords.y));
104 return 0;
105 }
106
107 LRESULT LegacyRenderWidgetHostHWND::OnMouseActivate(UINT message,
108 WPARAM w_param,
109 LPARAM l_param) {
110 // Don't pass this to DefWindowProc. That results in the WM_MOUSEACTIVATE
111 // message going all the way to the parent which then messes up state
112 // related to focused views, etc. This is because it treats this as if
113 // it lost activation.
114 // Our dummy window should not interfere with focus and activation in
115 // the parent. Return MA_ACTIVATE here ensures that focus state in the parent
116 // is preserved.
117 return MA_ACTIVATE;
118 }
119
120 LRESULT LegacyRenderWidgetHostHWND::OnTouch(UINT message,
121 WPARAM w_param,
122 LPARAM l_param) {
123 ::SendMessage(parent_, message, w_param, l_param);
124 return 0;
125 }
126
127 LRESULT LegacyRenderWidgetHostHWND::OnNCPaint(UINT message,
128 WPARAM w_param,
129 LPARAM l_param) {
130 return 0;
131 }
132
133 LRESULT LegacyRenderWidgetHostHWND::OnPaint(UINT message,
134 WPARAM w_param,
135 LPARAM l_param) {
136 PAINTSTRUCT ps = {0};
137 ::BeginPaint(hwnd(), &ps);
138 ::EndPaint(hwnd(), &ps);
139 return 0;
140 }
141
142 LRESULT LegacyRenderWidgetHostHWND::OnSetCursor(UINT message,
143 WPARAM w_param,
144 LPARAM l_param) {
145 return 0;
146 }
147
148 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698