| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 #include "webkit/plugins/npapi/plugin_group.h" | 52 #include "webkit/plugins/npapi/plugin_group.h" |
| 53 #include "webkit/plugins/npapi/webplugin.h" | 53 #include "webkit/plugins/npapi/webplugin.h" |
| 54 #include "webkit/plugins/plugin_constants.h" | 54 #include "webkit/plugins/plugin_constants.h" |
| 55 #include "webkit/plugins/sad_plugin.h" | 55 #include "webkit/plugins/sad_plugin.h" |
| 56 | 56 |
| 57 #if defined(OS_POSIX) | 57 #if defined(OS_POSIX) |
| 58 #include "ipc/ipc_channel_posix.h" | 58 #include "ipc/ipc_channel_posix.h" |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
| 62 #include "base/mac/crash_logging.h" |
| 62 #include "base/mac/mac_util.h" | 63 #include "base/mac/mac_util.h" |
| 64 #include "base/sys_string_conversions.h" |
| 65 #include "content/public/common/content_debug_logging.h" |
| 63 #endif | 66 #endif |
| 64 | 67 |
| 65 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
| 66 #include "content/public/common/sandbox_init.h" | 69 #include "content/public/common/sandbox_init.h" |
| 67 #endif | 70 #endif |
| 68 | 71 |
| 69 using WebKit::WebBindings; | 72 using WebKit::WebBindings; |
| 70 using WebKit::WebCursorInfo; | 73 using WebKit::WebCursorInfo; |
| 71 using WebKit::WebDragData; | 74 using WebKit::WebDragData; |
| 72 using WebKit::WebInputEvent; | 75 using WebKit::WebInputEvent; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 187 |
| 185 private: | 188 private: |
| 186 scoped_refptr<PluginChannelHost> channel_; | 189 scoped_refptr<PluginChannelHost> channel_; |
| 187 int instance_id_; | 190 int instance_id_; |
| 188 unsigned long resource_id_; | 191 unsigned long resource_id_; |
| 189 // Set to true if the response expected is a multibyte response. | 192 // Set to true if the response expected is a multibyte response. |
| 190 // For e.g. response for a HTTP byte range request. | 193 // For e.g. response for a HTTP byte range request. |
| 191 bool multibyte_response_expected_; | 194 bool multibyte_response_expected_; |
| 192 }; | 195 }; |
| 193 | 196 |
| 197 #if defined(OS_MACOSX) |
| 198 // Helper to load the breakpad information for the given bug, and also |
| 199 // log errors. |
| 200 void LoadKeysAndLogForBug(int bug_id) { |
| 201 std::vector<std::string> messages; |
| 202 |
| 203 CHECK(content::debug::GetMessages(bug_id, &messages)); |
| 204 for (size_t i = 0; i < messages.size(); i++) { |
| 205 std::string key(base::StringPrintf("bug-%d-%lu", bug_id, i)); |
| 206 base::mac::SetCrashKeyValue(base::SysUTF8ToNSString(key), |
| 207 base::SysUTF8ToNSString(messages[i])); |
| 208 LOG(ERROR) << "messages-" << bug_id << "[" << i << "]: " << messages[i]; |
| 209 } |
| 210 } |
| 211 #endif |
| 212 |
| 194 } // namespace | 213 } // namespace |
| 195 | 214 |
| 196 WebPluginDelegateProxy::WebPluginDelegateProxy( | 215 WebPluginDelegateProxy::WebPluginDelegateProxy( |
| 197 const std::string& mime_type, | 216 const std::string& mime_type, |
| 198 const base::WeakPtr<RenderViewImpl>& render_view) | 217 const base::WeakPtr<RenderViewImpl>& render_view) |
| 199 : render_view_(render_view), | 218 : render_view_(render_view), |
| 200 plugin_(NULL), | 219 plugin_(NULL), |
| 201 uses_shared_bitmaps_(false), | 220 uses_shared_bitmaps_(false), |
| 202 #if defined(OS_MACOSX) | 221 #if defined(OS_MACOSX) |
| 203 uses_compositor_(false), | 222 uses_compositor_(false), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 scoped_ptr<AutoReset<bool> > track_nested_removes(new AutoReset<bool>( | 337 scoped_ptr<AutoReset<bool> > track_nested_removes(new AutoReset<bool>( |
| 319 PluginChannelHost::GetRemoveTrackingFlag(), true)); | 338 PluginChannelHost::GetRemoveTrackingFlag(), true)); |
| 320 #endif | 339 #endif |
| 321 | 340 |
| 322 IPC::ChannelHandle channel_handle; | 341 IPC::ChannelHandle channel_handle; |
| 323 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPlugin( | 342 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPlugin( |
| 324 render_view_->routing_id(), url, page_url_, mime_type_, | 343 render_view_->routing_id(), url, page_url_, mime_type_, |
| 325 &channel_handle, &info_))) { | 344 &channel_handle, &info_))) { |
| 326 continue; | 345 continue; |
| 327 } | 346 } |
| 347 #if defined(OS_MACOSX) |
| 348 content::debug::RecordMsg(97285, base::StringPrintf( |
| 349 "OpenChannelToPlugin() {%s, %d}", |
| 350 channel_handle.name.c_str(), channel_handle.socket.fd)); |
| 351 #endif |
| 328 | 352 |
| 329 if (channel_handle.name.empty()) { | 353 if (channel_handle.name.empty()) { |
| 330 // We got an invalid handle. Either the plugin couldn't be found (which | 354 // 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 | 355 // shouldn't happen, since if we got here the plugin should exist) or the |
| 332 // plugin crashed on initialization. | 356 // plugin crashed on initialization. |
| 333 if (!info_.path.empty()) { | 357 if (!info_.path.empty()) { |
| 334 render_view_->PluginCrashed(info_.path); | 358 render_view_->PluginCrashed(info_.path); |
| 335 LOG(ERROR) << "Plug-in crashed on start"; | 359 LOG(ERROR) << "Plug-in crashed on start"; |
| 336 | 360 |
| 337 // Return true so that the plugin widget is created and we can paint the | 361 // Return true so that the plugin widget is created and we can paint the |
| 338 // crashed plugin there. | 362 // crashed plugin there. |
| 339 return true; | 363 return true; |
| 340 } | 364 } |
| 341 LOG(ERROR) << "Plug-in couldn't be found"; | 365 LOG(ERROR) << "Plug-in couldn't be found"; |
| 342 return false; | 366 return false; |
| 343 } | 367 } |
| 344 | 368 |
| 345 channel_host = | 369 channel_host = |
| 346 PluginChannelHost::GetPluginChannelHost( | 370 PluginChannelHost::GetPluginChannelHost( |
| 347 channel_handle, ChildProcess::current()->io_message_loop_proxy()); | 371 channel_handle, ChildProcess::current()->io_message_loop_proxy()); |
| 348 if (!channel_host.get()) { | 372 if (!channel_host.get()) { |
| 373 #if defined(OS_MACOSX) |
| 374 if (channel_handle.socket.fd == -1) { |
| 375 LOG(ERROR) << "http://crbug.com/97285 detected."; |
| 376 LoadKeysAndLogForBug(97285); |
| 377 |
| 378 // Upload the data. This crash used to be in NPChannelBase::Init(). |
| 379 // This point can only be MODE_CLIENT. |
| 380 CHECK_NE(channel_handle.socket.fd, -1); |
| 381 } |
| 382 #endif |
| 349 LOG(ERROR) << "Couldn't get PluginChannelHost"; | 383 LOG(ERROR) << "Couldn't get PluginChannelHost"; |
| 350 continue; | 384 continue; |
| 351 } | 385 } |
| 352 #if defined(OS_MACOSX) | 386 #if defined(OS_MACOSX) |
| 387 content::debug::RecordMsg(141055, base::StringPrintf( |
| 388 "GetPCH() {%s, %d} from {*, %d}, %svalid", |
| 389 channel_host->channel_handle().name.c_str(), |
| 390 channel_host->channel_handle().socket.fd, |
| 391 channel_handle.socket.fd, |
| 392 channel_host->channel_valid() ? "" : "in")); |
| 353 track_nested_removes.reset(); | 393 track_nested_removes.reset(); |
| 354 #endif | 394 #endif |
| 355 | 395 |
| 356 { | 396 { |
| 357 // TODO(bauerb): Debugging for http://crbug.com/141055. | 397 // TODO(bauerb): Debugging for http://crbug.com/141055. |
| 398 #if defined(OS_MACOSX) |
| 358 ScopedLogLevel log_level(-2); // Equivalent to --v=2 | 399 ScopedLogLevel log_level(-2); // Equivalent to --v=2 |
| 400 #endif |
| 359 result = channel_host->Send(new PluginMsg_CreateInstance( | 401 result = channel_host->Send(new PluginMsg_CreateInstance( |
| 360 mime_type_, &instance_id)); | 402 mime_type_, &instance_id)); |
| 361 if (!result) { | 403 if (!result) { |
| 404 #if defined(OS_MACOSX) |
| 405 // Don't crash, but load the info into breakpad on the off |
| 406 // chance that the renderer will crash in the future. Even if |
| 407 // it doesn't, the log messages might be reported. |
| 408 // TODO(shess): The renderer may not survive long enough to |
| 409 // crash. Could have the browser load breakpad instead. |
| 410 LOG(ERROR) << "http://crbug.com/141055 possibly detected."; |
| 411 LoadKeysAndLogForBug(141055); |
| 412 LoadKeysAndLogForBug(97285); |
| 413 #endif |
| 414 |
| 362 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; | 415 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; |
| 363 continue; | 416 continue; |
| 364 } | 417 } |
| 365 } | 418 } |
| 366 } | 419 } |
| 367 | 420 |
| 368 // Failed too often, give up. | 421 // Failed too often, give up. |
| 369 if (!result) | 422 if (!result) |
| 370 return false; | 423 return false; |
| 371 | 424 |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 } | 1581 } |
| 1529 #endif | 1582 #endif |
| 1530 | 1583 |
| 1531 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1584 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
| 1532 int resource_id) { | 1585 int resource_id) { |
| 1533 if (!plugin_) | 1586 if (!plugin_) |
| 1534 return; | 1587 return; |
| 1535 | 1588 |
| 1536 plugin_->URLRedirectResponse(allow, resource_id); | 1589 plugin_->URLRedirectResponse(allow, resource_id); |
| 1537 } | 1590 } |
| OLD | NEW |