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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "gfx/rect.h" | 9 #include "gfx/rect.h" |
10 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 void WebPluginImpl::destroy() { | 233 void WebPluginImpl::destroy() { |
234 SetContainer(NULL); | 234 SetContainer(NULL); |
235 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 235 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
236 } | 236 } |
237 | 237 |
238 NPObject* WebPluginImpl::scriptableObject() { | 238 NPObject* WebPluginImpl::scriptableObject() { |
239 return delegate_->GetPluginScriptableObject(); | 239 return delegate_->GetPluginScriptableObject(); |
240 } | 240 } |
241 | 241 |
242 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& paint_rect) { | 242 void WebPluginImpl::paint(WebCanvas* canvas, const WebRect& paint_rect) { |
243 if (!delegate_) | 243 if (!delegate_ || !container_) |
244 return; | 244 return; |
245 | 245 |
| 246 #if defined(OS_WIN) |
| 247 // Force a geometry update if needed to allow plugins like media player |
| 248 // which defer the initial geometry update to work. |
| 249 container_->reportGeometry(); |
| 250 #endif // OS_WIN |
| 251 |
246 // Note that |canvas| is only used when in windowless mode. | 252 // Note that |canvas| is only used when in windowless mode. |
247 delegate_->Paint(canvas, paint_rect); | 253 delegate_->Paint(canvas, paint_rect); |
248 } | 254 } |
249 | 255 |
250 void WebPluginImpl::updateGeometry( | 256 void WebPluginImpl::updateGeometry( |
251 const WebRect& window_rect, const WebRect& clip_rect, | 257 const WebRect& window_rect, const WebRect& clip_rect, |
252 const WebVector<WebRect>& cutout_rects, bool is_visible) { | 258 const WebVector<WebRect>& cutout_rects, bool is_visible) { |
253 WebPluginGeometry new_geometry; | 259 WebPluginGeometry new_geometry; |
254 new_geometry.window = window_; | 260 new_geometry.window = window_; |
255 new_geometry.window_rect = window_rect; | 261 new_geometry.window_rect = window_rect; |
(...skipping 28 matching lines...) Expand all Loading... |
284 // receiving valid plugin geometry. By valid geometry we mean the | 290 // receiving valid plugin geometry. By valid geometry we mean the |
285 // geometry received by a call to setFrameRect in the Webkit | 291 // geometry received by a call to setFrameRect in the Webkit |
286 // layout code path. To workaround this issue we download the | 292 // layout code path. To workaround this issue we download the |
287 // plugin source url on a timer. | 293 // plugin source url on a timer. |
288 MessageLoop::current()->PostDelayedTask( | 294 MessageLoop::current()->PostDelayedTask( |
289 FROM_HERE, method_factory_.NewRunnableMethod( | 295 FROM_HERE, method_factory_.NewRunnableMethod( |
290 &WebPluginImpl::OnDownloadPluginSrcUrl), 0); | 296 &WebPluginImpl::OnDownloadPluginSrcUrl), 0); |
291 } | 297 } |
292 } | 298 } |
293 | 299 |
| 300 #if defined(OS_WIN) |
| 301 // Don't cache the geometry during the first geometry update. The first |
| 302 // geometry update sequence is received when Widget::setParent is called. |
| 303 // For plugins like media player which have a bug where they only honor |
| 304 // the first geometry update, we have a quirk which ignores the first |
| 305 // geometry update. To ensure that these plugins work correctly in cases |
| 306 // where we receive only one geometry update from webkit, we also force |
| 307 // a geometry update during paint which should go out correctly as the |
| 308 // initial geometry update was not cached. |
| 309 if (!first_geometry_update_) |
| 310 geometry_ = new_geometry; |
| 311 #else // OS_WIN |
| 312 geometry_ = new_geometry; |
| 313 #endif // OS_WIN |
294 first_geometry_update_ = false; | 314 first_geometry_update_ = false; |
295 geometry_ = new_geometry; | |
296 } | 315 } |
297 | 316 |
298 void WebPluginImpl::updateFocus(bool focused) { | 317 void WebPluginImpl::updateFocus(bool focused) { |
299 if (accepts_input_events_) | 318 if (accepts_input_events_) |
300 delegate_->SetFocus(focused); | 319 delegate_->SetFocus(focused); |
301 } | 320 } |
302 | 321 |
303 void WebPluginImpl::updateVisibility(bool visible) { | 322 void WebPluginImpl::updateVisibility(bool visible) { |
304 if (!window_ || !page_delegate_) | 323 if (!window_ || !page_delegate_) |
305 return; | 324 return; |
(...skipping 926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { | 1251 WebDevToolsAgent* WebPluginImpl::GetDevToolsAgent() { |
1233 if (!webframe_) | 1252 if (!webframe_) |
1234 return NULL; | 1253 return NULL; |
1235 WebView* view = webframe_->view(); | 1254 WebView* view = webframe_->view(); |
1236 if (!view) | 1255 if (!view) |
1237 return NULL; | 1256 return NULL; |
1238 return view->devToolsAgent(); | 1257 return view->devToolsAgent(); |
1239 } | 1258 } |
1240 | 1259 |
1241 } // namespace webkit_glue | 1260 } // namespace webkit_glue |
OLD | NEW |