| 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" | |
| 63 #include "base/mac/mac_util.h" | 62 #include "base/mac/mac_util.h" |
| 64 #include "base/sys_string_conversions.h" | |
| 65 #include "content/public/common/content_debug_logging.h" | |
| 66 #endif | 63 #endif |
| 67 | 64 |
| 68 #if defined(OS_WIN) | 65 #if defined(OS_WIN) |
| 69 #include "content/public/common/sandbox_init.h" | 66 #include "content/public/common/sandbox_init.h" |
| 70 #endif | 67 #endif |
| 71 | 68 |
| 72 using WebKit::WebBindings; | 69 using WebKit::WebBindings; |
| 73 using WebKit::WebCursorInfo; | 70 using WebKit::WebCursorInfo; |
| 74 using WebKit::WebDragData; | 71 using WebKit::WebDragData; |
| 75 using WebKit::WebInputEvent; | 72 using WebKit::WebInputEvent; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 184 |
| 188 private: | 185 private: |
| 189 scoped_refptr<PluginChannelHost> channel_; | 186 scoped_refptr<PluginChannelHost> channel_; |
| 190 int instance_id_; | 187 int instance_id_; |
| 191 unsigned long resource_id_; | 188 unsigned long resource_id_; |
| 192 // Set to true if the response expected is a multibyte response. | 189 // Set to true if the response expected is a multibyte response. |
| 193 // For e.g. response for a HTTP byte range request. | 190 // For e.g. response for a HTTP byte range request. |
| 194 bool multibyte_response_expected_; | 191 bool multibyte_response_expected_; |
| 195 }; | 192 }; |
| 196 | 193 |
| 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 | |
| 213 } // namespace | 194 } // namespace |
| 214 | 195 |
| 215 WebPluginDelegateProxy::WebPluginDelegateProxy( | 196 WebPluginDelegateProxy::WebPluginDelegateProxy( |
| 216 const std::string& mime_type, | 197 const std::string& mime_type, |
| 217 const base::WeakPtr<RenderViewImpl>& render_view) | 198 const base::WeakPtr<RenderViewImpl>& render_view) |
| 218 : render_view_(render_view), | 199 : render_view_(render_view), |
| 219 plugin_(NULL), | 200 plugin_(NULL), |
| 220 uses_shared_bitmaps_(false), | 201 uses_shared_bitmaps_(false), |
| 221 #if defined(OS_MACOSX) | 202 #if defined(OS_MACOSX) |
| 222 uses_compositor_(false), | 203 uses_compositor_(false), |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 scoped_ptr<AutoReset<bool> > track_nested_removes(new AutoReset<bool>( | 318 scoped_ptr<AutoReset<bool> > track_nested_removes(new AutoReset<bool>( |
| 338 PluginChannelHost::GetRemoveTrackingFlag(), true)); | 319 PluginChannelHost::GetRemoveTrackingFlag(), true)); |
| 339 #endif | 320 #endif |
| 340 | 321 |
| 341 IPC::ChannelHandle channel_handle; | 322 IPC::ChannelHandle channel_handle; |
| 342 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPlugin( | 323 if (!RenderThreadImpl::current()->Send(new ViewHostMsg_OpenChannelToPlugin( |
| 343 render_view_->routing_id(), url, page_url_, mime_type_, | 324 render_view_->routing_id(), url, page_url_, mime_type_, |
| 344 &channel_handle, &info_))) { | 325 &channel_handle, &info_))) { |
| 345 continue; | 326 continue; |
| 346 } | 327 } |
| 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 | |
| 352 | 328 |
| 353 if (channel_handle.name.empty()) { | 329 if (channel_handle.name.empty()) { |
| 354 // We got an invalid handle. Either the plugin couldn't be found (which | 330 // We got an invalid handle. Either the plugin couldn't be found (which |
| 355 // shouldn't happen, since if we got here the plugin should exist) or the | 331 // shouldn't happen, since if we got here the plugin should exist) or the |
| 356 // plugin crashed on initialization. | 332 // plugin crashed on initialization. |
| 357 if (!info_.path.empty()) { | 333 if (!info_.path.empty()) { |
| 358 render_view_->PluginCrashed(info_.path); | 334 render_view_->PluginCrashed(info_.path); |
| 359 LOG(ERROR) << "Plug-in crashed on start"; | 335 LOG(ERROR) << "Plug-in crashed on start"; |
| 360 | 336 |
| 361 // Return true so that the plugin widget is created and we can paint the | 337 // Return true so that the plugin widget is created and we can paint the |
| 362 // crashed plugin there. | 338 // crashed plugin there. |
| 363 return true; | 339 return true; |
| 364 } | 340 } |
| 365 LOG(ERROR) << "Plug-in couldn't be found"; | 341 LOG(ERROR) << "Plug-in couldn't be found"; |
| 366 return false; | 342 return false; |
| 367 } | 343 } |
| 368 | 344 |
| 369 channel_host = | 345 channel_host = |
| 370 PluginChannelHost::GetPluginChannelHost( | 346 PluginChannelHost::GetPluginChannelHost( |
| 371 channel_handle, ChildProcess::current()->io_message_loop_proxy()); | 347 channel_handle, ChildProcess::current()->io_message_loop_proxy()); |
| 372 if (!channel_host.get()) { | 348 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 | |
| 383 LOG(ERROR) << "Couldn't get PluginChannelHost"; | 349 LOG(ERROR) << "Couldn't get PluginChannelHost"; |
| 384 continue; | 350 continue; |
| 385 } | 351 } |
| 386 #if defined(OS_MACOSX) | 352 #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")); | |
| 393 track_nested_removes.reset(); | 353 track_nested_removes.reset(); |
| 394 #endif | 354 #endif |
| 395 | 355 |
| 396 { | 356 { |
| 397 // TODO(bauerb): Debugging for http://crbug.com/141055. | 357 // TODO(bauerb): Debugging for http://crbug.com/141055. |
| 398 #if defined(OS_MACOSX) | |
| 399 ScopedLogLevel log_level(-2); // Equivalent to --v=2 | 358 ScopedLogLevel log_level(-2); // Equivalent to --v=2 |
| 400 #endif | |
| 401 result = channel_host->Send(new PluginMsg_CreateInstance( | 359 result = channel_host->Send(new PluginMsg_CreateInstance( |
| 402 mime_type_, &instance_id)); | 360 mime_type_, &instance_id)); |
| 403 if (!result) { | 361 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 | |
| 415 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; | 362 LOG(ERROR) << "Couldn't send PluginMsg_CreateInstance"; |
| 416 continue; | 363 continue; |
| 417 } | 364 } |
| 418 } | 365 } |
| 419 } | 366 } |
| 420 | 367 |
| 421 // Failed too often, give up. | 368 // Failed too often, give up. |
| 422 if (!result) | 369 if (!result) |
| 423 return false; | 370 return false; |
| 424 | 371 |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1581 } | 1528 } |
| 1582 #endif | 1529 #endif |
| 1583 | 1530 |
| 1584 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1531 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
| 1585 int resource_id) { | 1532 int resource_id) { |
| 1586 if (!plugin_) | 1533 if (!plugin_) |
| 1587 return; | 1534 return; |
| 1588 | 1535 |
| 1589 plugin_->URLRedirectResponse(allow, resource_id); | 1536 plugin_->URLRedirectResponse(allow, resource_id); |
| 1590 } | 1537 } |
| OLD | NEW |