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] = new base::FundamentalValue(process_id); | 426 props[browser_plugin::kProcessId] = new base::FundamentalValue(process_id); |
422 props[browser_plugin::kReason] = new base::StringValue(termination_status); | 427 props[browser_plugin::kReason] = new base::StringValue(termination_status); |
423 | 428 |
424 // Event listeners may remove the BrowserPlugin from the document. If that | 429 // Event listeners may remove the BrowserPlugin from the document. If that |
425 // happens, the BrowserPlugin will be scheduled for later deletion (see | 430 // happens, the BrowserPlugin will be scheduled for later deletion (see |
426 // BrowserPlugin::destroy()). That will clear the container_ reference, | 431 // BrowserPlugin::destroy()). That will clear the container_ reference, |
427 // but leave other member variables valid below. | 432 // but leave other member variables valid below. |
428 TriggerEvent(browser_plugin::kEventExit, &props); | 433 TriggerEvent(browser_plugin::kEventExit, &props); |
429 | 434 |
430 guest_crashed_ = true; | |
431 // We won't paint the contents of the current backing store again so we might | 435 // We won't paint the contents of the current backing store again so we might |
432 // as well toss it out and save memory. | 436 // as well toss it out and save memory. |
433 backing_store_.reset(); | 437 backing_store_.reset(); |
434 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 438 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
435 // NULL so we shouldn't attempt to access it. | 439 // NULL so we shouldn't attempt to access it. |
436 if (container_) | 440 if (container_) |
437 container_->invalidate(); | 441 container_->invalidate(); |
438 // Turn off compositing so we can display the sad graphic. | 442 // Turn off compositing so we can display the sad graphic. |
439 EnableCompositing(false); | 443 EnableCompositing(false); |
440 } | 444 } |
(...skipping 20 matching lines...) Expand all Loading... |
461 props[browser_plugin::kReason] = new base::StringValue(type); | 465 props[browser_plugin::kReason] = new base::StringValue(type); |
462 TriggerEvent(browser_plugin::kEventLoadAbort, &props); | 466 TriggerEvent(browser_plugin::kEventLoadAbort, &props); |
463 } | 467 } |
464 | 468 |
465 void BrowserPlugin::OnLoadCommit( | 469 void BrowserPlugin::OnLoadCommit( |
466 int instance_id, | 470 int instance_id, |
467 const BrowserPluginMsg_LoadCommit_Params& params) { | 471 const BrowserPluginMsg_LoadCommit_Params& params) { |
468 // If the guest has just committed a new navigation then it is no longer | 472 // If the guest has just committed a new navigation then it is no longer |
469 // crashed. | 473 // crashed. |
470 guest_crashed_ = false; | 474 guest_crashed_ = false; |
471 if (params.is_top_level) { | 475 if (params.is_top_level) |
472 UpdateDOMAttribute(browser_plugin::kAttributeSrc, params.url.spec()); | 476 UpdateDOMAttribute(browser_plugin::kAttributeSrc, params.url.spec()); |
473 } | 477 |
474 guest_process_id_ = params.process_id; | 478 guest_process_id_ = params.process_id; |
475 guest_route_id_ = params.route_id; | 479 guest_route_id_ = params.route_id; |
476 current_nav_entry_index_ = params.current_entry_index; | 480 current_nav_entry_index_ = params.current_entry_index; |
477 nav_entry_count_ = params.entry_count; | 481 nav_entry_count_ = params.entry_count; |
478 | 482 |
479 std::map<std::string, base::Value*> props; | 483 std::map<std::string, base::Value*> props; |
480 props[browser_plugin::kURL] = new base::StringValue(params.url.spec()); | 484 props[browser_plugin::kURL] = new base::StringValue(params.url.spec()); |
481 props[browser_plugin::kIsTopLevel] = | 485 props[browser_plugin::kIsTopLevel] = |
482 new base::FundamentalValue(params.is_top_level); | 486 new base::FundamentalValue(params.is_top_level); |
483 TriggerEvent(browser_plugin::kEventLoadCommit, &props); | 487 TriggerEvent(browser_plugin::kEventLoadCommit, &props); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 void BrowserPlugin::Go(int relative_index) { | 794 void BrowserPlugin::Go(int relative_index) { |
791 if (!navigate_src_sent_) | 795 if (!navigate_src_sent_) |
792 return; | 796 return; |
793 browser_plugin_manager()->Send( | 797 browser_plugin_manager()->Send( |
794 new BrowserPluginHostMsg_Go(render_view_routing_id_, | 798 new BrowserPluginHostMsg_Go(render_view_routing_id_, |
795 instance_id_, | 799 instance_id_, |
796 relative_index)); | 800 relative_index)); |
797 } | 801 } |
798 | 802 |
799 void BrowserPlugin::TerminateGuest() { | 803 void BrowserPlugin::TerminateGuest() { |
800 if (!navigate_src_sent_) | 804 if (!navigate_src_sent_ || guest_crashed_) |
801 return; | 805 return; |
802 browser_plugin_manager()->Send( | 806 browser_plugin_manager()->Send( |
803 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, | 807 new BrowserPluginHostMsg_TerminateGuest(render_view_routing_id_, |
804 instance_id_)); | 808 instance_id_)); |
805 } | 809 } |
806 | 810 |
807 void BrowserPlugin::Stop() { | 811 void BrowserPlugin::Stop() { |
808 if (!navigate_src_sent_) | 812 if (!navigate_src_sent_) |
809 return; | 813 return; |
810 browser_plugin_manager()->Send( | 814 browser_plugin_manager()->Send( |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1157 void* notify_data) { | 1161 void* notify_data) { |
1158 } | 1162 } |
1159 | 1163 |
1160 void BrowserPlugin::didFailLoadingFrameRequest( | 1164 void BrowserPlugin::didFailLoadingFrameRequest( |
1161 const WebKit::WebURL& url, | 1165 const WebKit::WebURL& url, |
1162 void* notify_data, | 1166 void* notify_data, |
1163 const WebKit::WebURLError& error) { | 1167 const WebKit::WebURLError& error) { |
1164 } | 1168 } |
1165 | 1169 |
1166 } // namespace content | 1170 } // namespace content |
OLD | NEW |