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/browser_plugin/browser_plugin.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/json/json_string_value_serializer.h" | 7 #include "base/json/json_string_value_serializer.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 gpu_host_id); | 406 gpu_host_id); |
407 } | 407 } |
408 | 408 |
409 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, | 409 void BrowserPlugin::OnGuestContentWindowReady(int instance_id, |
410 int content_window_routing_id) { | 410 int content_window_routing_id) { |
411 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); | 411 DCHECK(content_window_routing_id != MSG_ROUTING_NONE); |
412 content_window_routing_id_ = content_window_routing_id; | 412 content_window_routing_id_ = content_window_routing_id; |
413 } | 413 } |
414 | 414 |
415 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { | 415 void BrowserPlugin::OnGuestGone(int instance_id, int process_id, int status) { |
| 416 // Set the BrowserPlugin in a crashed state before firing event listeners so |
| 417 // that operations on the BrowserPlugin within listeners are aware that |
| 418 // BrowserPlugin is in a crashed state. |
| 419 guest_crashed_ = true; |
| 420 |
416 // We fire the event listeners before painting the sad graphic to give the | 421 // We fire the event listeners before painting the sad graphic to give the |
417 // developer an opportunity to display an alternative overlay image on crash. | 422 // developer an opportunity to display an alternative overlay image on crash. |
418 std::string termination_status = TerminationStatusToString( | 423 std::string termination_status = TerminationStatusToString( |
419 static_cast<base::TerminationStatus>(status)); | 424 static_cast<base::TerminationStatus>(status)); |
420 std::map<std::string, base::Value*> props; | 425 std::map<std::string, base::Value*> props; |
421 props[browser_plugin::kProcessId] = | 426 props[browser_plugin::kProcessId] = |
422 base::Value::CreateIntegerValue(process_id); | 427 base::Value::CreateIntegerValue(process_id); |
423 props[browser_plugin::kReason] = | 428 props[browser_plugin::kReason] = |
424 base::Value::CreateStringValue(termination_status); | 429 base::Value::CreateStringValue(termination_status); |
425 | 430 |
426 // Event listeners may remove the BrowserPlugin from the document. If that | 431 // Event listeners may remove the BrowserPlugin from the document. If that |
427 // happens, the BrowserPlugin will be scheduled for later deletion (see | 432 // happens, the BrowserPlugin will be scheduled for later deletion (see |
428 // BrowserPlugin::destroy()). That will clear the container_ reference, | 433 // BrowserPlugin::destroy()). That will clear the container_ reference, |
429 // but leave other member variables valid below. | 434 // but leave other member variables valid below. |
430 TriggerEvent(browser_plugin::kEventExit, &props); | 435 TriggerEvent(browser_plugin::kEventExit, &props); |
431 | 436 |
432 guest_crashed_ = true; | |
433 // We won't paint the contents of the current backing store again so we might | 437 // We won't paint the contents of the current backing store again so we might |
434 // as well toss it out and save memory. | 438 // as well toss it out and save memory. |
435 backing_store_.reset(); | 439 backing_store_.reset(); |
436 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 440 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
437 // NULL so we shouldn't attempt to access it. | 441 // NULL so we shouldn't attempt to access it. |
438 if (container_) | 442 if (container_) |
439 container_->invalidate(); | 443 container_->invalidate(); |
440 // Turn off compositing so we can display the sad graphic. | 444 // Turn off compositing so we can display the sad graphic. |
441 EnableCompositing(false); | 445 EnableCompositing(false); |
442 } | 446 } |
(...skipping 23 matching lines...) Expand all Loading... |
466 props[browser_plugin::kReason] = base::Value::CreateStringValue(type); | 470 props[browser_plugin::kReason] = base::Value::CreateStringValue(type); |
467 TriggerEvent(browser_plugin::kEventLoadAbort, &props); | 471 TriggerEvent(browser_plugin::kEventLoadAbort, &props); |
468 } | 472 } |
469 | 473 |
470 void BrowserPlugin::OnLoadCommit( | 474 void BrowserPlugin::OnLoadCommit( |
471 int instance_id, | 475 int instance_id, |
472 const BrowserPluginMsg_LoadCommit_Params& params) { | 476 const BrowserPluginMsg_LoadCommit_Params& params) { |
473 // If the guest has just committed a new navigation then it is no longer | 477 // If the guest has just committed a new navigation then it is no longer |
474 // crashed. | 478 // crashed. |
475 guest_crashed_ = false; | 479 guest_crashed_ = false; |
476 if (params.is_top_level) { | 480 if (params.is_top_level) |
477 UpdateDOMAttribute(browser_plugin::kAttributeSrc, params.url.spec()); | 481 UpdateDOMAttribute(browser_plugin::kAttributeSrc, params.url.spec()); |
478 } | 482 |
479 guest_process_id_ = params.process_id; | 483 guest_process_id_ = params.process_id; |
480 guest_route_id_ = params.route_id; | 484 guest_route_id_ = params.route_id; |
481 current_nav_entry_index_ = params.current_entry_index; | 485 current_nav_entry_index_ = params.current_entry_index; |
482 nav_entry_count_ = params.entry_count; | 486 nav_entry_count_ = params.entry_count; |
483 | 487 |
484 std::map<std::string, base::Value*> props; | 488 std::map<std::string, base::Value*> props; |
485 props[browser_plugin::kURL] = | 489 props[browser_plugin::kURL] = |
486 base::Value::CreateStringValue(params.url.spec()); | 490 base::Value::CreateStringValue(params.url.spec()); |
487 props[browser_plugin::kIsTopLevel] = | 491 props[browser_plugin::kIsTopLevel] = |
488 base::Value::CreateBooleanValue(params.is_top_level); | 492 base::Value::CreateBooleanValue(params.is_top_level); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 void BrowserPlugin::Go(int relative_index) { | 805 void BrowserPlugin::Go(int relative_index) { |
802 if (!navigate_src_sent_) | 806 if (!navigate_src_sent_) |
803 return; | 807 return; |
804 browser_plugin_manager()->Send( | 808 browser_plugin_manager()->Send( |
805 new BrowserPluginHostMsg_Go(render_view_routing_id_, | 809 new BrowserPluginHostMsg_Go(render_view_routing_id_, |
806 instance_id_, | 810 instance_id_, |
807 relative_index)); | 811 relative_index)); |
808 } | 812 } |
809 | 813 |
810 void BrowserPlugin::TerminateGuest() { | 814 void BrowserPlugin::TerminateGuest() { |
811 if (!navigate_src_sent_) | 815 if (!navigate_src_sent_ || guest_crashed_) |
812 return; | 816 return; |
813 browser_plugin_manager()->Send( | 817 browser_plugin_manager()->Send( |
814 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, | 818 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, |
815 instance_id_)); | 819 instance_id_)); |
816 } | 820 } |
817 | 821 |
818 void BrowserPlugin::Stop() { | 822 void BrowserPlugin::Stop() { |
819 if (!navigate_src_sent_) | 823 if (!navigate_src_sent_) |
820 return; | 824 return; |
821 browser_plugin_manager()->Send( | 825 browser_plugin_manager()->Send( |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 void* notify_data) { | 1172 void* notify_data) { |
1169 } | 1173 } |
1170 | 1174 |
1171 void BrowserPlugin::didFailLoadingFrameRequest( | 1175 void BrowserPlugin::didFailLoadingFrameRequest( |
1172 const WebKit::WebURL& url, | 1176 const WebKit::WebURL& url, |
1173 void* notify_data, | 1177 void* notify_data, |
1174 const WebKit::WebURLError& error) { | 1178 const WebKit::WebURLError& error) { |
1175 } | 1179 } |
1176 | 1180 |
1177 } // namespace content | 1181 } // namespace content |
OLD | NEW |