| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <atlbase.h> | 10 #include <atlbase.h> |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 158 } |
| 159 | 159 |
| 160 WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, | 160 WebPluginDelegateProxy::WebPluginDelegateProxy(const std::string& mime_type, |
| 161 const std::string& clsid, | 161 const std::string& clsid, |
| 162 RenderView* render_view) | 162 RenderView* render_view) |
| 163 : render_view_(render_view), | 163 : render_view_(render_view), |
| 164 plugin_(NULL), | 164 plugin_(NULL), |
| 165 windowless_(false), | 165 windowless_(false), |
| 166 mime_type_(mime_type), | 166 mime_type_(mime_type), |
| 167 clsid_(clsid), | 167 clsid_(clsid), |
| 168 send_deferred_update_geometry_(false), | |
| 169 npobject_(NULL), | 168 npobject_(NULL), |
| 170 window_script_object_(NULL), | 169 window_script_object_(NULL), |
| 171 sad_plugin_(NULL), | 170 sad_plugin_(NULL), |
| 172 invalidate_pending_(false), | 171 invalidate_pending_(false), |
| 173 transparent_(false) { | 172 transparent_(false) { |
| 174 } | 173 } |
| 175 | 174 |
| 176 WebPluginDelegateProxy::~WebPluginDelegateProxy() { | 175 WebPluginDelegateProxy::~WebPluginDelegateProxy() { |
| 177 } | 176 } |
| 178 | 177 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 197 | 196 |
| 198 if (channel_host_) { | 197 if (channel_host_) { |
| 199 channel_host_->RemoveRoute(instance_id_); | 198 channel_host_->RemoveRoute(instance_id_); |
| 200 Send(new PluginMsg_DestroyInstance(instance_id_)); | 199 Send(new PluginMsg_DestroyInstance(instance_id_)); |
| 201 } | 200 } |
| 202 | 201 |
| 203 render_view_->PluginDestroyed(this); | 202 render_view_->PluginDestroyed(this); |
| 204 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 203 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 205 } | 204 } |
| 206 | 205 |
| 207 void WebPluginDelegateProxy::FlushGeometryUpdates() { | |
| 208 if (send_deferred_update_geometry_) { | |
| 209 send_deferred_update_geometry_ = false; | |
| 210 Send(new PluginMsg_UpdateGeometry(instance_id_, | |
| 211 plugin_rect_, | |
| 212 deferred_clip_rect_, | |
| 213 TransportDIB::Id(), | |
| 214 TransportDIB::Id())); | |
| 215 } | |
| 216 } | |
| 217 | |
| 218 bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, | 206 bool WebPluginDelegateProxy::Initialize(const GURL& url, char** argn, |
| 219 char** argv, int argc, | 207 char** argv, int argc, |
| 220 WebPlugin* plugin, | 208 WebPlugin* plugin, |
| 221 bool load_manually) { | 209 bool load_manually) { |
| 222 std::string channel_name; | 210 std::string channel_name; |
| 223 FilePath plugin_path; | 211 FilePath plugin_path; |
| 224 if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin( | 212 if (!RenderThread::current()->Send(new ViewHostMsg_OpenChannelToPlugin( |
| 225 url, mime_type_, clsid_, webkit_glue::GetWebKitLocale(), | 213 url, mime_type_, clsid_, webkit_glue::GetWebKitLocale(), |
| 226 &channel_name, &plugin_path))) | 214 &channel_name, &plugin_path))) |
| 227 return false; | 215 return false; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 void WebPluginDelegateProxy::OnChannelError() { | 353 void WebPluginDelegateProxy::OnChannelError() { |
| 366 if (plugin_) | 354 if (plugin_) |
| 367 plugin_->Invalidate(); | 355 plugin_->Invalidate(); |
| 368 render_view_->PluginCrashed(plugin_path_); | 356 render_view_->PluginCrashed(plugin_path_); |
| 369 } | 357 } |
| 370 | 358 |
| 371 void WebPluginDelegateProxy::UpdateGeometry( | 359 void WebPluginDelegateProxy::UpdateGeometry( |
| 372 const gfx::Rect& window_rect, | 360 const gfx::Rect& window_rect, |
| 373 const gfx::Rect& clip_rect) { | 361 const gfx::Rect& clip_rect) { |
| 374 plugin_rect_ = window_rect; | 362 plugin_rect_ = window_rect; |
| 375 if (!windowless_) { | |
| 376 deferred_clip_rect_ = clip_rect; | |
| 377 send_deferred_update_geometry_ = true; | |
| 378 return; | |
| 379 } | |
| 380 | 363 |
| 381 // Be careful to explicitly call the default constructors for these ids, | 364 // Be careful to explicitly call the default constructors for these ids, |
| 382 // as they can be POD on some platforms and we want them initialized. | 365 // as they can be POD on some platforms and we want them initialized. |
| 383 TransportDIB::Id transport_store_id = TransportDIB::Id(); | 366 TransportDIB::Id transport_store_id = TransportDIB::Id(); |
| 384 TransportDIB::Id background_store_id = TransportDIB::Id(); | 367 TransportDIB::Id background_store_id = TransportDIB::Id(); |
| 385 | 368 |
| 369 if (windowless_) { |
| 386 #if defined(OS_WIN) | 370 #if defined(OS_WIN) |
| 387 // TODO(port): use TransportDIB instead of allocating these directly. | 371 // TODO(port): use TransportDIB instead of allocating these directly. |
| 388 if (!backing_store_canvas_.get() || | 372 if (!backing_store_canvas_.get() || |
| 389 (window_rect.width() != backing_store_canvas_->getDevice()->width() || | 373 (window_rect.width() != backing_store_canvas_->getDevice()->width() || |
| 390 window_rect.height() != backing_store_canvas_->getDevice()->height())) { | 374 window_rect.height() != backing_store_canvas_->getDevice()->height()))
{ |
| 391 // Create a shared memory section that the plugin paints into | 375 // Create a shared memory section that the plugin paints into |
| 392 // asynchronously. | 376 // asynchronously. |
| 393 ResetWindowlessBitmaps(); | 377 ResetWindowlessBitmaps(); |
| 394 if (!window_rect.IsEmpty()) { | 378 if (!window_rect.IsEmpty()) { |
| 395 if (!CreateBitmap(&backing_store_, &backing_store_canvas_) || | 379 if (!CreateBitmap(&backing_store_, &backing_store_canvas_) || |
| 396 !CreateBitmap(&transport_store_, &transport_store_canvas_) || | 380 !CreateBitmap(&transport_store_, &transport_store_canvas_) || |
| 397 (transparent_ && | 381 (transparent_ && |
| 398 !CreateBitmap(&background_store_, &background_store_canvas_))) { | 382 !CreateBitmap(&background_store_, &background_store_canvas_))) { |
| 399 DCHECK(false); | 383 DCHECK(false); |
| 400 ResetWindowlessBitmaps(); | 384 ResetWindowlessBitmaps(); |
| 401 return; | 385 return; |
| 386 } |
| 387 |
| 388 // TODO(port): once we use TransportDIB we will properly fill in these |
| 389 // ids; for now we just fill in the HANDLE field. |
| 390 transport_store_id.handle = transport_store_->handle(); |
| 391 if (background_store_.get()) |
| 392 background_store_id.handle = background_store_->handle(); |
| 402 } | 393 } |
| 403 | |
| 404 // TODO(port): once we use TransportDIB we will properly fill in these | |
| 405 // ids; for now we just fill in the HANDLE field. | |
| 406 transport_store_id.handle = transport_store_->handle(); | |
| 407 if (background_store_.get()) | |
| 408 background_store_id.handle = background_store_->handle(); | |
| 409 } | 394 } |
| 395 #else |
| 396 // TODO(port): refactor our allocation of backing stores. |
| 397 NOTIMPLEMENTED(); |
| 398 #endif |
| 410 } | 399 } |
| 411 #else | |
| 412 // TODO(port): refactor our allocation of backing stores. | |
| 413 NOTIMPLEMENTED(); | |
| 414 #endif | |
| 415 | 400 |
| 416 IPC::Message* msg = new PluginMsg_UpdateGeometry( | 401 IPC::Message* msg = new PluginMsg_UpdateGeometry( |
| 417 instance_id_, window_rect, clip_rect, | 402 instance_id_, window_rect, clip_rect, |
| 418 transport_store_id, background_store_id); | 403 transport_store_id, background_store_id); |
| 419 msg->set_unblock(true); | 404 msg->set_unblock(true); |
| 420 Send(msg); | 405 Send(msg); |
| 421 } | 406 } |
| 422 | 407 |
| 423 #if defined(OS_WIN) | 408 #if defined(OS_WIN) |
| 424 // Copied from render_widget.cc | 409 // Copied from render_widget.cc |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 plugin_->CancelDocumentLoad(); | 909 plugin_->CancelDocumentLoad(); |
| 925 } | 910 } |
| 926 | 911 |
| 927 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( | 912 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( |
| 928 const std::string& url, const std::string& range_info, | 913 const std::string& url, const std::string& range_info, |
| 929 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { | 914 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { |
| 930 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), | 915 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
| 931 existing_stream, notify_needed, | 916 existing_stream, notify_needed, |
| 932 notify_data); | 917 notify_data); |
| 933 } | 918 } |
| OLD | NEW |