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

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

Issue 19844003: Remove webkit/plugins/npapi. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove GetDefaultWindowParent Created 7 years, 5 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/accessibility/browser_accessibility_manager.h" 8 #include "content/browser/accessibility/browser_accessibility_manager.h"
9 #include "content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture. h" 9 #include "content/browser/renderer_host/basic_mouse_wheel_smooth_scroll_gesture. h"
10 #include "content/browser/renderer_host/render_process_host_impl.h" 10 #include "content/browser/renderer_host/render_process_host_impl.h"
11 #include "content/browser/renderer_host/render_widget_host_impl.h" 11 #include "content/browser/renderer_host/render_widget_host_impl.h"
12 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" 12 #include "content/port/browser/render_widget_host_view_frame_subscriber.h"
13 #include "content/port/browser/smooth_scroll_gesture.h" 13 #include "content/port/browser/smooth_scroll_gesture.h"
14 #include "third_party/WebKit/public/web/WebScreenInfo.h" 14 #include "third_party/WebKit/public/web/WebScreenInfo.h"
15 #include "ui/gfx/display.h" 15 #include "ui/gfx/display.h"
16 #include "ui/gfx/screen.h" 16 #include "ui/gfx/screen.h"
17 #include "ui/gfx/size_conversions.h" 17 #include "ui/gfx/size_conversions.h"
18 #include "ui/gfx/size_f.h" 18 #include "ui/gfx/size_f.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include "base/command_line.h" 21 #include "base/command_line.h"
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/win/wrapped_window_proc.h" 23 #include "base/win/wrapped_window_proc.h"
24 #include "content/browser/plugin_process_host.h" 24 #include "content/browser/plugin_process_host.h"
25 #include "content/browser/plugin_service_impl.h"
25 #include "content/common/plugin_constants_win.h" 26 #include "content/common/plugin_constants_win.h"
26 #include "content/common/webplugin_geometry.h" 27 #include "content/common/webplugin_geometry.h"
27 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/child_process_data.h" 29 #include "content/public/browser/child_process_data.h"
29 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
30 #include "ui/base/win/dpi.h" 31 #include "ui/base/win/dpi.h"
31 #include "ui/base/win/hwnd_util.h" 32 #include "ui/base/win/hwnd_util.h"
32 #include "ui/gfx/gdi_util.h" 33 #include "ui/gfx/gdi_util.h"
33 #include "webkit/plugins/npapi/plugin_utils.h"
34 #endif 34 #endif
35 35
36 #if defined(TOOLKIT_GTK) 36 #if defined(TOOLKIT_GTK)
37 #include <gdk/gdkx.h> 37 #include <gdk/gdkx.h>
38 #include <gtk/gtk.h> 38 #include <gtk/gtk.h>
39 39
40 #include "content/browser/renderer_host/gtk_window_utils.h" 40 #include "content/browser/renderer_host/gtk_window_utils.h"
41 #endif 41 #endif
42 42
43 namespace content { 43 namespace content {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 static const int kMaxTries = 5; 157 static const int kMaxTries = 5;
158 BrowserThread::PostTask( 158 BrowserThread::PostTask(
159 BrowserThread::IO, 159 BrowserThread::IO,
160 FROM_HERE, 160 FROM_HERE,
161 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent, 161 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent,
162 kMaxTries)); 162 kMaxTries));
163 return new_parent; 163 return new_parent;
164 } 164 }
165 165
166 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) { 166 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) {
167 if (!webkit::npapi::IsPluginDelegateWindow(hwnd)) 167 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd))
168 return TRUE; 168 return TRUE;
169 169
170 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); 170 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam);
171 gfx::Rect rect_in_pixels = ui::win::DIPToScreenRect(*rect); 171 gfx::Rect rect_in_pixels = ui::win::DIPToScreenRect(*rect);
172 static UINT msg = RegisterWindowMessage(kPaintMessageName); 172 static UINT msg = RegisterWindowMessage(kPaintMessageName);
173 WPARAM wparam = rect_in_pixels.x() << 16 | rect_in_pixels.y(); 173 WPARAM wparam = rect_in_pixels.x() << 16 | rect_in_pixels.y();
174 lparam = rect_in_pixels.width() << 16 | rect_in_pixels.height(); 174 lparam = rect_in_pixels.width() << 16 | rect_in_pixels.height();
175 175
176 // SendMessage gets the message across much quicker than PostMessage, since it 176 // SendMessage gets the message across much quicker than PostMessage, since it
177 // doesn't get queued. When the plugin thread calls PeekMessage or other 177 // doesn't get queued. When the plugin thread calls PeekMessage or other
178 // Win32 APIs, sent messages are dispatched automatically. 178 // Win32 APIs, sent messages are dispatched automatically.
179 SendNotifyMessage(hwnd, msg, wparam, lparam); 179 SendNotifyMessage(hwnd, msg, wparam, lparam);
180 180
181 return TRUE; 181 return TRUE;
182 } 182 }
183 183
184 // Windows callback for OnDestroy to detach the plugin windows. 184 // Windows callback for OnDestroy to detach the plugin windows.
185 BOOL CALLBACK DetachPluginWindowsCallbackInternal(HWND window, LPARAM param) { 185 BOOL CALLBACK DetachPluginWindowsCallbackInternal(HWND window, LPARAM param) {
186 RenderWidgetHostViewBase::DetachPluginWindowsCallback(window); 186 RenderWidgetHostViewBase::DetachPluginWindowsCallback(window);
187 return TRUE; 187 return TRUE;
188 } 188 }
189 189
190 } // namespace 190 } // namespace
191 191
192 // static 192 // static
193 void RenderWidgetHostViewBase::DetachPluginWindowsCallback(HWND window) { 193 void RenderWidgetHostViewBase::DetachPluginWindowsCallback(HWND window) {
194 if (webkit::npapi::IsPluginDelegateWindow(window) && 194 if (PluginServiceImpl::GetInstance()->IsPluginWindow(window) &&
195 !IsHungAppWindow(window)) { 195 !IsHungAppWindow(window)) {
196 ::ShowWindow(window, SW_HIDE); 196 ::ShowWindow(window, SW_HIDE);
197 SetParent(window, NULL); 197 SetParent(window, NULL);
198 } 198 }
199 } 199 }
200 200
201 // static 201 // static
202 void RenderWidgetHostViewBase::MovePluginWindowsHelper( 202 void RenderWidgetHostViewBase::MovePluginWindowsHelper(
203 HWND parent, 203 HWND parent,
204 const std::vector<WebPluginGeometry>& moves) { 204 const std::vector<WebPluginGeometry>& moves) {
(...skipping 20 matching lines...) Expand all
225 // As the plugin parent window which lives on the browser UI thread is 225 // As the plugin parent window which lives on the browser UI thread is
226 // destroyed asynchronously, it is possible that we have a stale window 226 // destroyed asynchronously, it is possible that we have a stale window
227 // sent in by the renderer for moving around. 227 // sent in by the renderer for moving around.
228 // Note: get the parent before checking if the window is valid, to avoid a 228 // Note: get the parent before checking if the window is valid, to avoid a
229 // race condition where the window is destroyed after the check but before 229 // race condition where the window is destroyed after the check but before
230 // the GetParent call. 230 // the GetParent call.
231 HWND cur_parent = ::GetParent(window); 231 HWND cur_parent = ::GetParent(window);
232 if (!::IsWindow(window)) 232 if (!::IsWindow(window))
233 continue; 233 continue;
234 234
235 if (!webkit::npapi::IsPluginDelegateWindow(window)) { 235 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(window)) {
236 // The renderer should only be trying to move plugin windows. However, 236 // The renderer should only be trying to move plugin windows. However,
237 // this may happen as a result of a race condition (i.e. even after the 237 // this may happen as a result of a race condition (i.e. even after the
238 // check right above), so we ignore it. 238 // check right above), so we ignore it.
239 continue; 239 continue;
240 } 240 }
241 241
242 if (oop_plugins) { 242 if (oop_plugins) {
243 if (cur_parent == webkit::npapi::GetDefaultWindowParent()) { 243 if (cur_parent == GetDesktopWindow()) {
244 // The plugin window hasn't been parented yet, add an intermediate 244 // The plugin window hasn't been parented yet, add an intermediate
245 // window that lives on this thread to speed up scrolling. Note this 245 // window that lives on this thread to speed up scrolling. Note this
246 // only works with out of process plugins since we depend on 246 // only works with out of process plugins since we depend on
247 // PluginProcessHost to destroy the intermediate HWNDs. 247 // PluginProcessHost to destroy the intermediate HWNDs.
248 cur_parent = ReparentWindow(window, parent); 248 cur_parent = ReparentWindow(window, parent);
249 ::ShowWindow(window, SW_SHOW); // Window was created hidden. 249 ::ShowWindow(window, SW_SHOW); // Window was created hidden.
250 } else if (!IsPluginWrapperWindow(cur_parent)) { 250 } else if (!IsPluginWrapperWindow(cur_parent)) {
251 continue; // Race if plugin process is shutting down. 251 continue; // Race if plugin process is shutting down.
252 } 252 }
253 253
254 // We move the intermediate parent window which doesn't result in cross- 254 // We move the intermediate parent window which doesn't result in cross-
255 // process synchronous Windows messages. 255 // process synchronous Windows messages.
256 window = cur_parent; 256 window = cur_parent;
257 } else { 257 } else {
258 if (cur_parent == webkit::npapi::GetDefaultWindowParent()) 258 if (cur_parent == GetDesktopWindow())
259 SetParent(window, parent); 259 SetParent(window, parent);
260 } 260 }
261 261
262 if (move.visible) 262 if (move.visible)
263 flags |= SWP_SHOWWINDOW; 263 flags |= SWP_SHOWWINDOW;
264 else 264 else
265 flags |= SWP_HIDEWINDOW; 265 flags |= SWP_HIDEWINDOW;
266 266
267 #if defined(USE_AURA) 267 #if defined(USE_AURA)
268 // Without this flag, Windows repaints the parent area uncovered by this 268 // Without this flag, Windows repaints the parent area uncovered by this
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 uint32 RenderWidgetHostViewBase::RendererFrameNumber() { 523 uint32 RenderWidgetHostViewBase::RendererFrameNumber() {
524 return renderer_frame_number_; 524 return renderer_frame_number_;
525 } 525 }
526 526
527 void RenderWidgetHostViewBase::DidReceiveRendererFrame() { 527 void RenderWidgetHostViewBase::DidReceiveRendererFrame() {
528 ++renderer_frame_number_; 528 ++renderer_frame_number_;
529 } 529 }
530 530
531 } // namespace content 531 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698