| OLD | NEW |
| 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/renderer/webplugin_delegate_proxy.h" | 5 #include "content/renderer/webplugin_delegate_proxy.h" |
| 6 | 6 |
| 7 #if defined(TOOLKIT_GTK) | 7 #if defined(TOOLKIT_GTK) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #elif defined(USE_X11) | 9 #elif defined(USE_X11) |
| 10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 // Anything else is a named, opaque color or an RGB form with no alpha. | 294 // Anything else is a named, opaque color or an RGB form with no alpha. |
| 295 return false; | 295 return false; |
| 296 } | 296 } |
| 297 | 297 |
| 298 bool WebPluginDelegateProxy::Initialize( | 298 bool WebPluginDelegateProxy::Initialize( |
| 299 const GURL& url, | 299 const GURL& url, |
| 300 const std::vector<std::string>& arg_names, | 300 const std::vector<std::string>& arg_names, |
| 301 const std::vector<std::string>& arg_values, | 301 const std::vector<std::string>& arg_values, |
| 302 webkit::npapi::WebPlugin* plugin, | 302 webkit::npapi::WebPlugin* plugin, |
| 303 bool load_manually) { | 303 bool load_manually) { |
| 304 // TODO(shess): Attempt to work around http://crbug.com/97285 and |
| 305 // http://crbug.com/141055 by retrying the connection. Reports seem |
| 306 // to indicate that the plugin hasn't crashed, and that the problem |
| 307 // is not 100% persistent. |
| 308 const size_t kAttempts = 2; |
| 309 |
| 310 bool result = false; |
| 311 scoped_refptr<PluginChannelHost> channel_host; |
| 312 int instance_id = 0; |
| 313 |
| 314 for (size_t attempt = 0; !result && attempt < kAttempts; attempt++) { |
| 304 #if defined(OS_MACOSX) | 315 #if defined(OS_MACOSX) |
| 305 // TODO(shess): Debugging for http://crbug.com/97285 . See comment | 316 // TODO(shess): Debugging for http://crbug.com/97285 . See comment |
| 306 // in plugin_channel_host.cc. | 317 // in plugin_channel_host.cc. |
| 307 scoped_ptr<AutoReset<bool> > track_nested_removes(new AutoReset<bool>( | 318 scoped_ptr<AutoReset<bool> > track_nested_removes(new AutoReset<bool>( |
| 308 PluginChannelHost::GetRemoveTrackingFlag(), true)); | 319 PluginChannelHost::GetRemoveTrackingFlag(), true)); |
| 309 #endif | 320 #endif |
| 310 | 321 |
| 311 IPC::ChannelHandle channel_handle; | 322 IPC::ChannelHandle channel_handle; |
| 312 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPlugin( | 323 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPlugin( |
| 313 render_view_->routing_id(), url, page_url_, mime_type_, | 324 render_view_->routing_id(), url, page_url_, mime_type_, |
| 314 &channel_handle, &info_))) { | 325 &channel_handle, &info_))) { |
| 315 return false; | 326 continue; |
| 327 } |
| 328 |
| 329 if (channel_handle.name.empty()) { |
| 330 // We got an invalid handle. Either the plugin couldn't be found (which |
| 331 // shouldn't happen, since if we got here the plugin should exist) or the |
| 332 // plugin crashed on initialization. |
| 333 if (!info_.path.empty()) { |
| 334 render_view_->PluginCrashed(info_.path); |
| 335 LOG(ERROR) << "Plug-in crashed on start"; |
| 336 |
| 337 // Return true so that the plugin widget is created and we can paint the |
| 338 // crashed plugin there. |
| 339 return true; |
| 340 } |
| 341 LOG(ERROR) << "Plug-in couldn't be found"; |
| 342 return false; |
| 343 } |
| 344 |
| 345 channel_host = |
| 346 PluginChannelHost::GetPluginChannelHost( |
| 347 channel_handle, ChildProcess::current()->io_message_loop_proxy()); |
| 348 if (!channel_host.get()) { |
| 349 LOG(ERROR) << "Couldn't get PluginChannelHost"; |
| 350 continue; |
| 351 } |
| 352 #if defined(OS_MACOSX) |
| 353 track_nested_removes.reset(); |
| 354 #endif |
| 355 |
| 356 { |
| 357 // TODO(bauerb): Debugging for http://crbug.com/141055. |
| 358 ScopedLogLevel log_level(-2); // Equivalent to --v=2 |
| 359 result = channel_host->Send(new PluginMsg_CreateInstance( |
| 360 mime_type_, &instance_id)); |
| 361 if (!result) { |
| 362 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; |
| 363 continue; |
| 364 } |
| 365 } |
| 316 } | 366 } |
| 317 | 367 |
| 318 if (channel_handle.name.empty()) { | 368 // Failed too often, give up. |
| 319 // We got an invalid handle. Either the plugin couldn't be found (which | 369 if (!result) |
| 320 // shouldn't happen, since if we got here the plugin should exist) or the | |
| 321 // plugin crashed on initialization. | |
| 322 if (!info_.path.empty()) { | |
| 323 render_view_->PluginCrashed(info_.path); | |
| 324 LOG(ERROR) << "Plug-in crashed on start"; | |
| 325 | |
| 326 // Return true so that the plugin widget is created and we can paint the | |
| 327 // crashed plugin there. | |
| 328 return true; | |
| 329 } | |
| 330 LOG(ERROR) << "Plug-in couldn't be found"; | |
| 331 return false; | 370 return false; |
| 332 } | |
| 333 | |
| 334 scoped_refptr<PluginChannelHost> channel_host( | |
| 335 PluginChannelHost::GetPluginChannelHost( | |
| 336 channel_handle, ChildProcess::current()->io_message_loop_proxy())); | |
| 337 if (!channel_host.get()) { | |
| 338 LOG(ERROR) << "Couldn't get PluginChannelHost"; | |
| 339 return false; | |
| 340 } | |
| 341 #if defined(OS_MACOSX) | |
| 342 track_nested_removes.reset(); | |
| 343 #endif | |
| 344 | |
| 345 int instance_id; | |
| 346 { | |
| 347 // TODO(bauerb): Debugging for http://crbug.com/141055. | |
| 348 ScopedLogLevel log_level(-2); // Equivalent to --v=2 | |
| 349 bool result = channel_host->Send(new PluginMsg_CreateInstance( | |
| 350 mime_type_, &instance_id)); | |
| 351 if (!result) { | |
| 352 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; | |
| 353 return false; | |
| 354 } | |
| 355 } | |
| 356 | 371 |
| 357 channel_host_ = channel_host; | 372 channel_host_ = channel_host; |
| 358 instance_id_ = instance_id; | 373 instance_id_ = instance_id; |
| 359 | 374 |
| 360 channel_host_->AddRoute(instance_id_, this, NULL); | 375 channel_host_->AddRoute(instance_id_, this, NULL); |
| 361 | 376 |
| 362 // Now tell the PluginInstance in the plugin process to initialize. | 377 // Now tell the PluginInstance in the plugin process to initialize. |
| 363 PluginMsg_Init_Params params; | 378 PluginMsg_Init_Params params; |
| 364 params.containing_window = render_view_->host_window(); | 379 params.containing_window = render_view_->host_window(); |
| 365 params.url = url; | 380 params.url = url; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 377 LowerCaseEqualsASCII(arg_values[i], "transparent")) || | 392 LowerCaseEqualsASCII(arg_values[i], "transparent")) || |
| 378 (silverlight && LowerCaseEqualsASCII(arg_names[i], "background") && | 393 (silverlight && LowerCaseEqualsASCII(arg_names[i], "background") && |
| 379 SilverlightColorIsTransparent(arg_values[i]))) { | 394 SilverlightColorIsTransparent(arg_values[i]))) { |
| 380 transparent_ = true; | 395 transparent_ = true; |
| 381 } | 396 } |
| 382 } | 397 } |
| 383 params.load_manually = load_manually; | 398 params.load_manually = load_manually; |
| 384 | 399 |
| 385 plugin_ = plugin; | 400 plugin_ = plugin; |
| 386 | 401 |
| 387 bool result = false; | 402 result = false; |
| 388 IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); | 403 IPC::Message* msg = new PluginMsg_Init(instance_id_, params, &result); |
| 389 Send(msg); | 404 Send(msg); |
| 390 | 405 |
| 391 if (!result) | 406 if (!result) |
| 392 LOG(ERROR) << "PluginMsg_Init returned false"; | 407 LOG(ERROR) << "PluginMsg_Init returned false"; |
| 393 | 408 |
| 394 render_view_->RegisterPluginDelegate(this); | 409 render_view_->RegisterPluginDelegate(this); |
| 395 | 410 |
| 396 return result; | 411 return result; |
| 397 } | 412 } |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1513 } | 1528 } |
| 1514 #endif | 1529 #endif |
| 1515 | 1530 |
| 1516 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1531 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
| 1517 int resource_id) { | 1532 int resource_id) { |
| 1518 if (!plugin_) | 1533 if (!plugin_) |
| 1519 return; | 1534 return; |
| 1520 | 1535 |
| 1521 plugin_->URLRedirectResponse(allow, resource_id); | 1536 plugin_->URLRedirectResponse(allow, resource_id); |
| 1522 } | 1537 } |
| OLD | NEW |