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/renderer/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include <atlbase.h> | 7 #include <atlbase.h> |
8 | 8 |
9 #include "generated_resources.h" | 9 #include "generated_resources.h" |
10 | 10 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, | 145 WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, |
146 const std::string& clsid, | 146 const std::string& clsid, |
147 RenderView* render_view) | 147 RenderView* render_view) |
148 : render_view_(render_view), | 148 : render_view_(render_view), |
149 mime_type_(mime_type), | 149 mime_type_(mime_type), |
150 clsid_(clsid), | 150 clsid_(clsid), |
151 plugin_(NULL), | 151 plugin_(NULL), |
152 windowless_(false), | 152 windowless_(false), |
153 npobject_(NULL), | 153 npobject_(NULL), |
154 send_deferred_update_geometry_(false), | 154 send_deferred_update_geometry_(false), |
155 visible_(false), | |
156 sad_plugin_(NULL), | 155 sad_plugin_(NULL), |
157 window_script_object_(NULL), | 156 window_script_object_(NULL), |
158 transparent_(false), | 157 transparent_(false), |
159 invalidate_pending_(false) { | 158 invalidate_pending_(false) { |
160 } | 159 } |
161 | 160 |
162 WebPluginDelegateProxy::~WebPluginDelegateProxy() { | 161 WebPluginDelegateProxy::~WebPluginDelegateProxy() { |
163 } | 162 } |
164 | 163 |
165 void WebPluginDelegateProxy::PluginDestroyed() { | 164 void WebPluginDelegateProxy::PluginDestroyed() { |
(...skipping 23 matching lines...) Expand all Loading... |
189 render_view_->PluginDestroyed(this); | 188 render_view_->PluginDestroyed(this); |
190 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 189 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
191 } | 190 } |
192 | 191 |
193 void WebPluginDelegateProxy::FlushGeometryUpdates() { | 192 void WebPluginDelegateProxy::FlushGeometryUpdates() { |
194 if (send_deferred_update_geometry_) { | 193 if (send_deferred_update_geometry_) { |
195 send_deferred_update_geometry_ = false; | 194 send_deferred_update_geometry_ = false; |
196 Send(new PluginMsg_UpdateGeometry(instance_id_, | 195 Send(new PluginMsg_UpdateGeometry(instance_id_, |
197 plugin_rect_, | 196 plugin_rect_, |
198 deferred_clip_rect_, | 197 deferred_clip_rect_, |
199 deferred_cutout_rects_, | |
200 visible_, | |
201 NULL, | 198 NULL, |
202 NULL)); | 199 NULL)); |
203 } | 200 } |
204 } | 201 } |
205 | 202 |
206 bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, | 203 bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, |
207 char** argv, int argc, | 204 char** argv, int argc, |
208 WebPlugin* plugin, | 205 WebPlugin* plugin, |
209 bool load_manually) { | 206 bool load_manually) { |
210 std::wstring channel_name; | 207 std::wstring channel_name; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 340 } |
344 | 341 |
345 void WebPluginDelegateProxy::OnChannelError() { | 342 void WebPluginDelegateProxy::OnChannelError() { |
346 if (plugin_) | 343 if (plugin_) |
347 plugin_->Invalidate(); | 344 plugin_->Invalidate(); |
348 render_view_->PluginCrashed(plugin_path_); | 345 render_view_->PluginCrashed(plugin_path_); |
349 } | 346 } |
350 | 347 |
351 void WebPluginDelegateProxy::UpdateGeometry( | 348 void WebPluginDelegateProxy::UpdateGeometry( |
352 const gfx::Rect& window_rect, | 349 const gfx::Rect& window_rect, |
353 const gfx::Rect& clip_rect, | 350 const gfx::Rect& clip_rect) { |
354 const std::vector<gfx::Rect>& cutout_rects, | |
355 bool visible) { | |
356 plugin_rect_ = window_rect; | 351 plugin_rect_ = window_rect; |
357 if (!windowless_) { | 352 if (!windowless_) { |
358 deferred_clip_rect_ = clip_rect; | 353 deferred_clip_rect_ = clip_rect; |
359 deferred_cutout_rects_ = cutout_rects; | |
360 visible_ = visible; | |
361 send_deferred_update_geometry_ = true; | 354 send_deferred_update_geometry_ = true; |
362 return; | 355 return; |
363 } | 356 } |
364 | 357 |
365 HANDLE transport_store_handle = NULL; | 358 HANDLE transport_store_handle = NULL; |
366 HANDLE background_store_handle = NULL; | 359 HANDLE background_store_handle = NULL; |
367 if (!backing_store_canvas_.get() || | 360 if (!backing_store_canvas_.get() || |
368 (window_rect.width() != backing_store_canvas_->getDevice()->width() || | 361 (window_rect.width() != backing_store_canvas_->getDevice()->width() || |
369 window_rect.height() != backing_store_canvas_->getDevice()->height())) { | 362 window_rect.height() != backing_store_canvas_->getDevice()->height())) { |
370 // Create a shared memory section that the plugin paints into | 363 // Create a shared memory section that the plugin paints into |
371 // asynchronously. | 364 // asynchronously. |
372 ResetWindowlessBitmaps(); | 365 ResetWindowlessBitmaps(); |
373 if (!window_rect.IsEmpty()) { | 366 if (!window_rect.IsEmpty()) { |
374 if (!CreateBitmap(&backing_store_, &backing_store_canvas_) || | 367 if (!CreateBitmap(&backing_store_, &backing_store_canvas_) || |
375 !CreateBitmap(&transport_store_, &transport_store_canvas_) || | 368 !CreateBitmap(&transport_store_, &transport_store_canvas_) || |
376 (transparent_ && | 369 (transparent_ && |
377 !CreateBitmap(&background_store_, &background_store_canvas_))) { | 370 !CreateBitmap(&background_store_, &background_store_canvas_))) { |
378 DCHECK(false); | 371 DCHECK(false); |
379 ResetWindowlessBitmaps(); | 372 ResetWindowlessBitmaps(); |
380 return; | 373 return; |
381 } | 374 } |
382 | 375 |
383 transport_store_handle = transport_store_->handle(); | 376 transport_store_handle = transport_store_->handle(); |
384 if (background_store_.get()) | 377 if (background_store_.get()) |
385 background_store_handle = background_store_->handle(); | 378 background_store_handle = background_store_->handle(); |
386 } | 379 } |
387 } | 380 } |
388 | 381 |
389 IPC::Message* msg = new PluginMsg_UpdateGeometry( | 382 IPC::Message* msg = new PluginMsg_UpdateGeometry( |
390 instance_id_, window_rect, clip_rect, cutout_rects, visible, | 383 instance_id_, window_rect, clip_rect, |
391 transport_store_handle, background_store_handle); | 384 transport_store_handle, background_store_handle); |
392 msg->set_unblock(true); | 385 msg->set_unblock(true); |
393 Send(msg); | 386 Send(msg); |
394 } | 387 } |
395 | 388 |
396 // Copied from render_widget.cc | 389 // Copied from render_widget.cc |
397 static size_t GetPaintBufSize(const gfx::Rect& rect) { | 390 static size_t GetPaintBufSize(const gfx::Rect& rect) { |
398 // TODO(darin): protect against overflow | 391 // TODO(darin): protect against overflow |
399 return 4 * rect.width() * rect.height(); | 392 return 4 * rect.width() * rect.height(); |
400 } | 393 } |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 plugin_->CancelDocumentLoad(); | 745 plugin_->CancelDocumentLoad(); |
753 } | 746 } |
754 | 747 |
755 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( | 748 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( |
756 const std::string& url, const std::string& range_info, | 749 const std::string& url, const std::string& range_info, |
757 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { | 750 HANDLE existing_stream, bool notify_needed, HANDLE notify_data) { |
758 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), | 751 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
759 existing_stream, notify_needed, | 752 existing_stream, notify_needed, |
760 notify_data); | 753 notify_data); |
761 } | 754 } |
OLD | NEW |