| 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/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #if defined (OS_WIN) | 9 #if defined (OS_WIN) |
| 10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // such a message, subsequent SetSrcAttribute() calls must always send | 132 // such a message, subsequent SetSrcAttribute() calls must always send |
| 133 // NavigateGuest messages to the embedder (even if |src| is empty), so | 133 // NavigateGuest messages to the embedder (even if |src| is empty), so |
| 134 // resize works correctly for all cases (e.g. The embedder can reset the | 134 // resize works correctly for all cases (e.g. The embedder can reset the |
| 135 // guest's |src| to empty value, resize and then set the |src| to a | 135 // guest's |src| to empty value, resize and then set the |src| to a |
| 136 // non-empty value). | 136 // non-empty value). |
| 137 // Additionally, once this instance has navigated, the storage partition | 137 // Additionally, once this instance has navigated, the storage partition |
| 138 // cannot be changed, so this value is used for enforcing this. | 138 // cannot be changed, so this value is used for enforcing this. |
| 139 navigate_src_sent_ = true; | 139 navigate_src_sent_ = true; |
| 140 } | 140 } |
| 141 src_ = src; | 141 src_ = src; |
| 142 guest_crashed_ = false; | |
| 143 } | 142 } |
| 144 | 143 |
| 145 std::string BrowserPlugin::GetPartitionAttribute() const { | 144 std::string BrowserPlugin::GetPartitionAttribute() const { |
| 146 std::string value; | 145 std::string value; |
| 147 if (persist_storage_) | 146 if (persist_storage_) |
| 148 value.append(kPersistPrefix); | 147 value.append(kPersistPrefix); |
| 149 | 148 |
| 150 value.append(storage_partition_id_); | 149 value.append(storage_partition_id_); |
| 151 return value; | 150 return value; |
| 152 } | 151 } |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (!navigate_src_sent_) | 269 if (!navigate_src_sent_) |
| 271 return; | 270 return; |
| 272 BrowserPluginManager::Get()->Send( | 271 BrowserPluginManager::Get()->Send( |
| 273 new BrowserPluginHostMsg_Stop(render_view_->GetRoutingID(), | 272 new BrowserPluginHostMsg_Stop(render_view_->GetRoutingID(), |
| 274 instance_id_)); | 273 instance_id_)); |
| 275 } | 274 } |
| 276 | 275 |
| 277 void BrowserPlugin::Reload() { | 276 void BrowserPlugin::Reload() { |
| 278 if (!navigate_src_sent_) | 277 if (!navigate_src_sent_) |
| 279 return; | 278 return; |
| 280 guest_crashed_ = false; | |
| 281 BrowserPluginManager::Get()->Send( | 279 BrowserPluginManager::Get()->Send( |
| 282 new BrowserPluginHostMsg_Reload(render_view_->GetRoutingID(), | 280 new BrowserPluginHostMsg_Reload(render_view_->GetRoutingID(), |
| 283 instance_id_)); | 281 instance_id_)); |
| 284 } | 282 } |
| 285 | 283 |
| 286 void BrowserPlugin::UpdateRect( | 284 void BrowserPlugin::UpdateRect( |
| 287 int message_id, | 285 int message_id, |
| 288 const BrowserPluginMsg_UpdateRect_Params& params) { | 286 const BrowserPluginMsg_UpdateRect_Params& params) { |
| 289 if (width() != params.view_size.width() || | 287 if (width() != params.view_size.width() || |
| 290 height() != params.view_size.height()) { | 288 height() != params.view_size.height()) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 EventListeners::iterator it = listeners.begin(); | 348 EventListeners::iterator it = listeners.begin(); |
| 351 for (; it != listeners.end(); ++it) { | 349 for (; it != listeners.end(); ++it) { |
| 352 WebKit::WebFrame* frame = plugin.document().frame(); | 350 WebKit::WebFrame* frame = plugin.document().frame(); |
| 353 if (frame) | 351 if (frame) |
| 354 frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 0, NULL); | 352 frame->callFunctionEvenIfScriptDisabled(*it, v8::Object::New(), 0, NULL); |
| 355 } | 353 } |
| 356 } | 354 } |
| 357 | 355 |
| 358 void BrowserPlugin::DidNavigate( | 356 void BrowserPlugin::DidNavigate( |
| 359 const BrowserPluginMsg_DidNavigate_Params& params) { | 357 const BrowserPluginMsg_DidNavigate_Params& params) { |
| 358 // If the guest has just committed a new navigation then it is no longer |
| 359 // crashed. |
| 360 guest_crashed_ = false; |
| 360 src_ = params.url.spec(); | 361 src_ = params.url.spec(); |
| 361 process_id_ = params.process_id; | 362 process_id_ = params.process_id; |
| 362 current_nav_entry_index_ = params.current_entry_index; | 363 current_nav_entry_index_ = params.current_entry_index; |
| 363 nav_entry_count_ = params.entry_count; | 364 nav_entry_count_ = params.entry_count; |
| 364 | 365 |
| 365 if (!HasListeners(kNavigationEventName)) | 366 if (!HasListeners(kNavigationEventName)) |
| 366 return; | 367 return; |
| 367 | 368 |
| 368 WebKit::WebElement plugin = container()->element(); | 369 WebKit::WebElement plugin = container()->element(); |
| 369 v8::HandleScope handle_scope; | 370 v8::HandleScope handle_scope; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 params->resize_pending = resize_pending_; | 639 params->resize_pending = resize_pending_; |
| 639 params->scale_factor = GetDeviceScaleFactor(); | 640 params->scale_factor = GetDeviceScaleFactor(); |
| 640 | 641 |
| 641 if (navigate_src_sent_) { | 642 if (navigate_src_sent_) { |
| 642 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( | 643 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 643 render_view_->GetRoutingID(), | 644 render_view_->GetRoutingID(), |
| 644 instance_id_, | 645 instance_id_, |
| 645 *params)); | 646 *params)); |
| 646 resize_pending_ = true; | 647 resize_pending_ = true; |
| 647 } else { | 648 } else { |
| 648 // Until an actual navigation occurs, there is no browser side embedder | 649 // Until an actual navigation occurs, there is no browser-side embedder |
| 649 // present to notify about geometry updates. In this case, after we've | 650 // present to notify about geometry updates. In this case, after we've |
| 650 // updated the BrowserPlugin's state we are done and we do not send a resize | 651 // updated the BrowserPlugin's state we are done and we do not send a resize |
| 651 // message to the browser. | 652 // message to the browser. |
| 652 pending_resize_params_.reset(params.release()); | 653 pending_resize_params_.reset(params.release()); |
| 653 } | 654 } |
| 654 if (damage_buffer_) | 655 if (damage_buffer_) |
| 655 FreeDamageBuffer(); | 656 FreeDamageBuffer(); |
| 656 damage_buffer_ = new_damage_buffer; | 657 damage_buffer_ = new_damage_buffer; |
| 657 } | 658 } |
| 658 | 659 |
| 659 void BrowserPlugin::FreeDamageBuffer() { | 660 void BrowserPlugin::FreeDamageBuffer() { |
| 660 DCHECK(damage_buffer_); | 661 DCHECK(damage_buffer_); |
| 661 #if defined(OS_MACOSX) | 662 #if defined(OS_MACOSX) |
| 662 // We don't need to (nor we should) send ViewHostMsg_FreeTransportDIB | 663 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB |
| 663 // message to the browser to free the damage buffer since we manage the | 664 // message to the browser to free the damage buffer since we manage the |
| 664 // damage buffer ourselves. | 665 // damage buffer ourselves. |
| 665 delete damage_buffer_; | 666 delete damage_buffer_; |
| 666 #else | 667 #else |
| 667 RenderProcess::current()->FreeTransportDIB(damage_buffer_); | 668 RenderProcess::current()->FreeTransportDIB(damage_buffer_); |
| 668 damage_buffer_ = NULL; | 669 damage_buffer_ = NULL; |
| 669 #endif | 670 #endif |
| 670 } | 671 } |
| 671 | 672 |
| 672 BrowserPluginHostMsg_ResizeGuest_Params* | 673 BrowserPluginHostMsg_ResizeGuest_Params* |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 void* notify_data) { | 797 void* notify_data) { |
| 797 } | 798 } |
| 798 | 799 |
| 799 void BrowserPlugin::didFailLoadingFrameRequest( | 800 void BrowserPlugin::didFailLoadingFrameRequest( |
| 800 const WebKit::WebURL& url, | 801 const WebKit::WebURL& url, |
| 801 void* notify_data, | 802 void* notify_data, |
| 802 const WebKit::WebURLError& error) { | 803 const WebKit::WebURLError& error) { |
| 803 } | 804 } |
| 804 | 805 |
| 805 } // namespace content | 806 } // namespace content |
| OLD | NEW |