| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 const char kExitEventName[] = "exit"; | 45 const char kExitEventName[] = "exit"; |
| 46 const char kIsTopLevel[] = "isTopLevel"; | 46 const char kIsTopLevel[] = "isTopLevel"; |
| 47 const char kLoadAbortEventName[] = "loadabort"; | 47 const char kLoadAbortEventName[] = "loadabort"; |
| 48 const char kLoadCommitEventName[] = "loadcommit"; | 48 const char kLoadCommitEventName[] = "loadcommit"; |
| 49 const char kLoadRedirectEventName[] = "loadredirect"; | 49 const char kLoadRedirectEventName[] = "loadredirect"; |
| 50 const char kLoadStartEventName[] = "loadstart"; | 50 const char kLoadStartEventName[] = "loadstart"; |
| 51 const char kLoadStopEventName[] = "loadstop"; | 51 const char kLoadStopEventName[] = "loadstop"; |
| 52 const char kNewURL[] = "newUrl"; | 52 const char kNewURL[] = "newUrl"; |
| 53 const char kNewHeight[] = "newHeight"; |
| 54 const char kNewWidth[] = "newWidth"; |
| 53 const char kOldURL[] = "oldUrl"; | 55 const char kOldURL[] = "oldUrl"; |
| 56 const char kOldHeight[] = "oldHeight"; |
| 57 const char kOldWidth[] = "oldWidth"; |
| 54 const char kPartitionAttribute[] = "partition"; | 58 const char kPartitionAttribute[] = "partition"; |
| 55 const char kPersistPrefix[] = "persist:"; | 59 const char kPersistPrefix[] = "persist:"; |
| 56 const char kProcessId[] = "processId"; | 60 const char kProcessId[] = "processId"; |
| 61 const char kSizeChangedEventName[] = "sizechanged"; |
| 57 const char kSrcAttribute[] = "src"; | 62 const char kSrcAttribute[] = "src"; |
| 58 const char kType[] = "type"; | 63 const char kType[] = "type"; |
| 59 const char kURL[] = "url"; | 64 const char kURL[] = "url"; |
| 60 | 65 |
| 61 static std::string TerminationStatusToString(base::TerminationStatus status) { | 66 static std::string TerminationStatusToString(base::TerminationStatus status) { |
| 62 switch (status) { | 67 switch (status) { |
| 63 case base::TERMINATION_STATUS_NORMAL_TERMINATION: | 68 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
| 64 return "normal"; | 69 return "normal"; |
| 65 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: | 70 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 66 return "abnormal"; | 71 return "abnormal"; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 94 max_height_(0), | 99 max_height_(0), |
| 95 max_width_(0), | 100 max_width_(0), |
| 96 min_height_(0), | 101 min_height_(0), |
| 97 min_width_(0), | 102 min_width_(0), |
| 98 process_id_(-1), | 103 process_id_(-1), |
| 99 persist_storage_(false), | 104 persist_storage_(false), |
| 100 content_window_routing_id_(MSG_ROUTING_NONE), | 105 content_window_routing_id_(MSG_ROUTING_NONE), |
| 101 plugin_focused_(false), | 106 plugin_focused_(false), |
| 102 embedder_focused_(false), | 107 embedder_focused_(false), |
| 103 visible_(true), | 108 visible_(true), |
| 109 size_changed_in_flight_(false), |
| 104 current_nav_entry_index_(0), | 110 current_nav_entry_index_(0), |
| 105 nav_entry_count_(0) { | 111 nav_entry_count_(0) { |
| 106 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); | 112 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
| 107 bindings_.reset(new BrowserPluginBindings(this)); | 113 bindings_.reset(new BrowserPluginBindings(this)); |
| 108 | 114 |
| 109 InitializeEvents(); | 115 InitializeEvents(); |
| 110 | 116 |
| 111 ParseAttributes(params); | 117 ParseAttributes(params); |
| 112 } | 118 } |
| 113 | 119 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 // Once this instance has navigated, the storage partition cannot be changed, | 168 // Once this instance has navigated, the storage partition cannot be changed, |
| 163 // so this value is used for enforcing this. | 169 // so this value is used for enforcing this. |
| 164 navigate_src_sent_ = true; | 170 navigate_src_sent_ = true; |
| 165 src_ = src; | 171 src_ = src; |
| 166 } | 172 } |
| 167 | 173 |
| 168 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { | 174 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { |
| 169 if (auto_size_ == auto_size) | 175 if (auto_size_ == auto_size) |
| 170 return; | 176 return; |
| 171 auto_size_ = auto_size; | 177 auto_size_ = auto_size; |
| 178 last_view_size_ = plugin_rect_.size(); |
| 172 UpdateGuestAutoSizeState(); | 179 UpdateGuestAutoSizeState(); |
| 173 } | 180 } |
| 174 | 181 |
| 175 void BrowserPlugin::PopulateAutoSizeParameters( | 182 void BrowserPlugin::PopulateAutoSizeParameters( |
| 176 BrowserPluginHostMsg_AutoSize_Params* params) const { | 183 BrowserPluginHostMsg_AutoSize_Params* params) { |
| 184 // If maxWidth or maxHeight have not been set, set them to the container size. |
| 185 max_height_ = max_height_ ? max_height_ : height(); |
| 186 max_width_ = max_width_ ? max_width_ : width(); |
| 187 // minWidth should not be bigger than maxWidth, and minHeight should not be |
| 188 // bigger than maxHeight. |
| 189 min_height_ = std::min(min_height_, max_height_); |
| 190 min_width_ = std::min(min_width_, max_width_); |
| 177 params->enable = auto_size_; | 191 params->enable = auto_size_; |
| 178 params->max_height = max_height_; | 192 params->max_size = gfx::Size(max_width_, max_height_); |
| 179 params->max_width = max_width_; | 193 params->min_size = gfx::Size(min_width_, min_height_); |
| 180 params->min_height = min_height_; | |
| 181 params->min_width = min_width_; | |
| 182 } | 194 } |
| 183 | 195 |
| 184 void BrowserPlugin::UpdateGuestAutoSizeState() const { | 196 void BrowserPlugin::UpdateGuestAutoSizeState() { |
| 185 if (!navigate_src_sent_) | 197 if (!navigate_src_sent_) |
| 186 return; | 198 return; |
| 187 BrowserPluginHostMsg_AutoSize_Params params; | 199 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
| 188 PopulateAutoSizeParameters(¶ms); | 200 PopulateAutoSizeParameters(&auto_size_params); |
| 201 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
| 202 int view_width = auto_size_params.max_size.width(); |
| 203 int view_height = auto_size_params.max_size.height(); |
| 204 if (!auto_size_params.enable) { |
| 205 view_width = width(); |
| 206 view_height = height(); |
| 207 } |
| 208 TransportDIB* new_damage_buffer = |
| 209 PopulateResizeGuestParameters(&resize_params, view_width, view_height); |
| 210 // AutoSize initiates a resize so we don't want to issue another resize, |
| 211 // we just want to make sure the damage buffer has been updated. |
| 212 resize_params.resize_pending = true; |
| 213 DCHECK(new_damage_buffer); |
| 189 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( | 214 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( |
| 190 render_view_routing_id_, | 215 render_view_routing_id_, |
| 191 instance_id_, | 216 instance_id_, |
| 192 params)); | 217 auto_size_params, |
| 218 resize_params)); |
| 219 if (damage_buffer_) |
| 220 FreeDamageBuffer(); |
| 221 damage_buffer_ = new_damage_buffer; |
| 222 } |
| 223 |
| 224 void BrowserPlugin::SizeChangedDueToAutoSize(const gfx::Size& old_view_size) { |
| 225 size_changed_in_flight_ = false; |
| 226 if (!HasListeners(kSizeChangedEventName)) |
| 227 return; |
| 228 |
| 229 WebKit::WebElement plugin = container()->element(); |
| 230 v8::HandleScope handle_scope; |
| 231 v8::Context::Scope context_scope( |
| 232 plugin.document().frame()->mainWorldScriptContext()); |
| 233 |
| 234 // Construct the sizechanged event object. |
| 235 v8::Local<v8::Object> event = v8::Object::New(); |
| 236 event->Set(v8::String::New(kOldHeight, sizeof(kOldHeight) - 1), |
| 237 v8::Integer::New(old_view_size.height()), |
| 238 v8::ReadOnly); |
| 239 event->Set(v8::String::New(kOldWidth, sizeof(kOldWidth) - 1), |
| 240 v8::Integer::New(old_view_size.width()), |
| 241 v8::ReadOnly); |
| 242 event->Set(v8::String::New(kNewHeight, sizeof(kNewHeight) - 1), |
| 243 v8::Integer::New(last_view_size_.height()), |
| 244 v8::ReadOnly); |
| 245 event->Set(v8::String::New(kNewWidth, sizeof(kNewWidth) - 1), |
| 246 v8::Integer::New(last_view_size_.width()), |
| 247 v8::ReadOnly); |
| 248 TriggerEvent(kSizeChangedEventName, &event); |
| 193 } | 249 } |
| 194 | 250 |
| 195 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { | 251 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { |
| 196 if (max_height_ == max_height) | 252 if (max_height_ == max_height) |
| 197 return; | 253 return; |
| 198 max_height_ = max_height; | 254 max_height_ = max_height; |
| 199 if (!auto_size_) | 255 if (!auto_size_) |
| 200 return; | 256 return; |
| 201 UpdateGuestAutoSizeState(); | 257 UpdateGuestAutoSizeState(); |
| 202 } | 258 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 221 | 277 |
| 222 void BrowserPlugin::SetMinWidthAttribute(int min_width) { | 278 void BrowserPlugin::SetMinWidthAttribute(int min_width) { |
| 223 if (min_width_ == min_width) | 279 if (min_width_ == min_width) |
| 224 return; | 280 return; |
| 225 min_width_ = min_width; | 281 min_width_ = min_width; |
| 226 if (!auto_size_) | 282 if (!auto_size_) |
| 227 return; | 283 return; |
| 228 UpdateGuestAutoSizeState(); | 284 UpdateGuestAutoSizeState(); |
| 229 } | 285 } |
| 230 | 286 |
| 287 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { |
| 288 return size.width() <= max_width_ && size.height() <= max_height_; |
| 289 } |
| 290 |
| 231 NPObject* BrowserPlugin::GetContentWindow() const { | 291 NPObject* BrowserPlugin::GetContentWindow() const { |
| 232 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 292 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| 233 return NULL; | 293 return NULL; |
| 234 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( | 294 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( |
| 235 ChildThread::current()->ResolveRoute(content_window_routing_id_)); | 295 ChildThread::current()->ResolveRoute(content_window_routing_id_)); |
| 236 if (!guest_render_view) | 296 if (!guest_render_view) |
| 237 return NULL; | 297 return NULL; |
| 238 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | 298 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); |
| 239 return guest_frame->windowObject(); | 299 return guest_frame->windowObject(); |
| 240 } | 300 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 return render_view_->GetWebView()->deviceScaleFactor(); | 374 return render_view_->GetWebView()->deviceScaleFactor(); |
| 315 } | 375 } |
| 316 | 376 |
| 317 void BrowserPlugin::InitializeEvents() { | 377 void BrowserPlugin::InitializeEvents() { |
| 318 event_listener_map_[kExitEventName] = EventListeners(); | 378 event_listener_map_[kExitEventName] = EventListeners(); |
| 319 event_listener_map_[kLoadAbortEventName] = EventListeners(); | 379 event_listener_map_[kLoadAbortEventName] = EventListeners(); |
| 320 event_listener_map_[kLoadCommitEventName] = EventListeners(); | 380 event_listener_map_[kLoadCommitEventName] = EventListeners(); |
| 321 event_listener_map_[kLoadRedirectEventName] = EventListeners(); | 381 event_listener_map_[kLoadRedirectEventName] = EventListeners(); |
| 322 event_listener_map_[kLoadStartEventName] = EventListeners(); | 382 event_listener_map_[kLoadStartEventName] = EventListeners(); |
| 323 event_listener_map_[kLoadStopEventName] = EventListeners(); | 383 event_listener_map_[kLoadStopEventName] = EventListeners(); |
| 384 event_listener_map_[kSizeChangedEventName] = EventListeners(); |
| 324 } | 385 } |
| 325 | 386 |
| 326 void BrowserPlugin::RemoveEventListeners() { | 387 void BrowserPlugin::RemoveEventListeners() { |
| 327 EventListenerMap::iterator event_listener_map_iter = | 388 EventListenerMap::iterator event_listener_map_iter = |
| 328 event_listener_map_.begin(); | 389 event_listener_map_.begin(); |
| 329 for (; event_listener_map_iter != event_listener_map_.end(); | 390 for (; event_listener_map_iter != event_listener_map_.end(); |
| 330 ++event_listener_map_iter) { | 391 ++event_listener_map_iter) { |
| 331 EventListeners& listeners = | 392 EventListeners& listeners = |
| 332 event_listener_map_[event_listener_map_iter->first]; | 393 event_listener_map_[event_listener_map_iter->first]; |
| 333 EventListeners::iterator it = listeners.begin(); | 394 EventListeners::iterator it = listeners.begin(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 if (!navigate_src_sent_) | 482 if (!navigate_src_sent_) |
| 422 return; | 483 return; |
| 423 BrowserPluginManager::Get()->Send( | 484 BrowserPluginManager::Get()->Send( |
| 424 new BrowserPluginHostMsg_Reload(render_view_routing_id_, | 485 new BrowserPluginHostMsg_Reload(render_view_routing_id_, |
| 425 instance_id_)); | 486 instance_id_)); |
| 426 } | 487 } |
| 427 | 488 |
| 428 void BrowserPlugin::UpdateRect( | 489 void BrowserPlugin::UpdateRect( |
| 429 int message_id, | 490 int message_id, |
| 430 const BrowserPluginMsg_UpdateRect_Params& params) { | 491 const BrowserPluginMsg_UpdateRect_Params& params) { |
| 431 if (width() != params.view_size.width() || | 492 if ((!auto_size_ && |
| 432 height() != params.view_size.height()) { | 493 (width() != params.view_size.width() || |
| 494 height() != params.view_size.height())) || |
| 495 (auto_size_ && (!InAutoSizeBounds(params.view_size)))) { |
| 433 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 496 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
| 434 render_view_routing_id_, | 497 render_view_routing_id_, |
| 435 instance_id_, | 498 instance_id_, |
| 436 message_id, | 499 message_id, |
| 437 gfx::Size(width(), height()))); | 500 gfx::Size(width(), height()))); |
| 438 return; | 501 return; |
| 439 } | 502 } |
| 503 // If the view size has changed since we last updated. |
| 504 if (auto_size_ && (params.view_size != last_view_size_)) { |
| 505 if (backing_store_) |
| 506 backing_store_->Clear(SK_ColorWHITE); |
| 507 gfx::Size old_view_size = last_view_size_; |
| 508 last_view_size_ = params.view_size; |
| 509 // Schedule a SizeChanged instead of calling it directly to ensure that |
| 510 // the backing store has been updated before the developer attempts to |
| 511 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of |
| 512 // flow control for SizeChanged events. If the guest's view size is changing |
| 513 // rapidly before a SizeChanged event fires, then we avoid scheduling |
| 514 // another SizedChanged event. SizedChanged reads the new size from |
| 515 // |last_view_size_| so we can be sure that it always fires an event |
| 516 // with the last seen view size. |
| 517 if (container_ && !size_changed_in_flight_) { |
| 518 size_changed_in_flight_ = true; |
| 519 MessageLoop::current()->PostTask( |
| 520 FROM_HERE, |
| 521 base::Bind(&BrowserPlugin::SizeChangedDueToAutoSize, |
| 522 base::Unretained(this), |
| 523 old_view_size)); |
| 524 } |
| 525 } |
| 440 | 526 |
| 441 float backing_store_scale_factor = | 527 float backing_store_scale_factor = |
| 442 backing_store_.get() ? backing_store_->GetScaleFactor() : 1.0f; | 528 backing_store_.get() ? backing_store_->GetScaleFactor() : 1.0f; |
| 443 | 529 |
| 444 if (params.is_resize_ack || | 530 if (!backing_store_ || params.is_resize_ack || |
| 445 backing_store_scale_factor != params.scale_factor) { | 531 (backing_store_scale_factor != params.scale_factor) || |
| 532 params.view_size.width() > backing_store_->GetSize().width() || |
| 533 params.view_size.height() > backing_store_->GetSize().height()) { |
| 534 int backing_store_width = auto_size_ ? max_width_ : width(); |
| 535 int backing_store_height = auto_size_ ? max_height_: height(); |
| 446 resize_pending_ = !params.is_resize_ack; | 536 resize_pending_ = !params.is_resize_ack; |
| 447 backing_store_.reset( | 537 backing_store_.reset( |
| 448 new BrowserPluginBackingStore(gfx::Size(width(), height()), | 538 new BrowserPluginBackingStore( |
| 449 params.scale_factor)); | 539 gfx::Size(backing_store_width, backing_store_height), |
| 540 params.scale_factor)); |
| 450 } | 541 } |
| 451 | 542 |
| 452 // Update the backing store. | 543 // Update the backing store. |
| 453 if (!params.scroll_rect.IsEmpty()) { | 544 if (!params.scroll_rect.IsEmpty()) { |
| 454 backing_store_->ScrollBackingStore(params.dx, | 545 backing_store_->ScrollBackingStore(params.dx, |
| 455 params.dy, | 546 params.dy, |
| 456 params.scroll_rect, | 547 params.scroll_rect, |
| 457 params.view_size); | 548 params.view_size); |
| 458 } | 549 } |
| 459 for (unsigned i = 0; i < params.copy_rects.size(); i++) { | 550 for (unsigned i = 0; i < params.copy_rects.size(); i++) { |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 | 862 |
| 772 void BrowserPlugin::updateGeometry( | 863 void BrowserPlugin::updateGeometry( |
| 773 const WebRect& window_rect, | 864 const WebRect& window_rect, |
| 774 const WebRect& clip_rect, | 865 const WebRect& clip_rect, |
| 775 const WebVector<WebRect>& cut_outs_rects, | 866 const WebVector<WebRect>& cut_outs_rects, |
| 776 bool is_visible) { | 867 bool is_visible) { |
| 777 int old_width = width(); | 868 int old_width = width(); |
| 778 int old_height = height(); | 869 int old_height = height(); |
| 779 plugin_rect_ = window_rect; | 870 plugin_rect_ = window_rect; |
| 780 if (auto_size_ || (old_width == window_rect.width && | 871 if (auto_size_ || (old_width == window_rect.width && |
| 781 old_height == window_rect.height)) { | 872 old_height == window_rect.height)) { |
| 782 return; | 873 return; |
| 783 } | 874 } |
| 784 | |
| 785 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); | |
| 786 // Make sure the size of the damage buffer is at least four bytes so that we | |
| 787 // can fit in a magic word to verify that the memory is shared correctly. | |
| 788 size_t size = | |
| 789 std::max(sizeof(unsigned int), | |
| 790 static_cast<size_t>(window_rect.height * | |
| 791 stride * | |
| 792 GetDeviceScaleFactor() * | |
| 793 GetDeviceScaleFactor())); | |
| 794 | |
| 795 // Don't drop the old damage buffer until after we've made sure that the | |
| 796 // browser process has dropped it. | |
| 797 TransportDIB* new_damage_buffer = CreateTransportDIB(size); | |
| 798 pending_resize_params_.reset(); | 875 pending_resize_params_.reset(); |
| 799 | 876 |
| 800 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( | 877 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( |
| 801 new BrowserPluginHostMsg_ResizeGuest_Params); | 878 new BrowserPluginHostMsg_ResizeGuest_Params); |
| 802 params->damage_buffer_id = new_damage_buffer->id(); | 879 |
| 803 #if defined(OS_MACOSX) | 880 TransportDIB* new_damage_buffer = |
| 804 // |damage_buffer_id| is not enough to retrieve the damage buffer (on browser | 881 PopulateResizeGuestParameters(params.get(), width(), height()); |
| 805 // side) since we don't let the browser cache the damage buffer. We need a | 882 DCHECK(new_damage_buffer); |
| 806 // handle to the damage buffer for this. | |
| 807 params->damage_buffer_handle = new_damage_buffer->handle(); | |
| 808 #endif | |
| 809 #if defined(OS_WIN) | |
| 810 params->damage_buffer_size = size; | |
| 811 #endif | |
| 812 params->width = window_rect.width; | |
| 813 params->height = window_rect.height; | |
| 814 params->resize_pending = resize_pending_; | |
| 815 params->scale_factor = GetDeviceScaleFactor(); | |
| 816 | 883 |
| 817 if (navigate_src_sent_) { | 884 if (navigate_src_sent_) { |
| 818 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( | 885 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 819 render_view_routing_id_, | 886 render_view_routing_id_, |
| 820 instance_id_, | 887 instance_id_, |
| 821 *params)); | 888 *params)); |
| 822 resize_pending_ = true; | 889 resize_pending_ = true; |
| 823 } else { | 890 } else { |
| 824 // Until an actual navigation occurs, there is no browser-side embedder | 891 // Until an actual navigation occurs, there is no browser-side embedder |
| 825 // present to notify about geometry updates. In this case, after we've | 892 // present to notify about geometry updates. In this case, after we've |
| (...skipping 12 matching lines...) Expand all Loading... |
| 838 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB | 905 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB |
| 839 // message to the browser to free the damage buffer since we manage the | 906 // message to the browser to free the damage buffer since we manage the |
| 840 // damage buffer ourselves. | 907 // damage buffer ourselves. |
| 841 delete damage_buffer_; | 908 delete damage_buffer_; |
| 842 #else | 909 #else |
| 843 RenderProcess::current()->FreeTransportDIB(damage_buffer_); | 910 RenderProcess::current()->FreeTransportDIB(damage_buffer_); |
| 844 damage_buffer_ = NULL; | 911 damage_buffer_ = NULL; |
| 845 #endif | 912 #endif |
| 846 } | 913 } |
| 847 | 914 |
| 915 TransportDIB* BrowserPlugin::PopulateResizeGuestParameters( |
| 916 BrowserPluginHostMsg_ResizeGuest_Params* params, |
| 917 int view_width, int view_height) { |
| 918 const size_t stride = skia::PlatformCanvas::StrideForWidth(view_width); |
| 919 // Make sure the size of the damage buffer is at least four bytes so that we |
| 920 // can fit in a magic word to verify that the memory is shared correctly. |
| 921 size_t size = |
| 922 std::max(sizeof(unsigned int), |
| 923 static_cast<size_t>(view_height * |
| 924 stride * |
| 925 GetDeviceScaleFactor() * |
| 926 GetDeviceScaleFactor())); |
| 927 |
| 928 // Don't drop the old damage buffer until after we've made sure that the |
| 929 // browser process has dropped it. |
| 930 TransportDIB* new_damage_buffer = CreateTransportDIB(size); |
| 931 params->damage_buffer_id = new_damage_buffer->id(); |
| 932 #if defined(OS_MACOSX) |
| 933 // |damage_buffer_id| is not enough to retrieve the damage buffer (on browser |
| 934 // side) since we don't let the browser cache the damage buffer. We need a |
| 935 // handle to the damage buffer for this. |
| 936 params->damage_buffer_handle = new_damage_buffer->handle(); |
| 937 #endif |
| 938 #if defined(OS_WIN) |
| 939 params->damage_buffer_size = size; |
| 940 #endif |
| 941 params->width = view_width; |
| 942 params->height = view_height; |
| 943 params->resize_pending = resize_pending_; |
| 944 params->scale_factor = GetDeviceScaleFactor(); |
| 945 return new_damage_buffer; |
| 946 } |
| 947 |
| 848 BrowserPluginHostMsg_ResizeGuest_Params* | 948 BrowserPluginHostMsg_ResizeGuest_Params* |
| 849 BrowserPlugin::GetPendingResizeParams() { | 949 BrowserPlugin::GetPendingResizeParams() { |
| 850 if (pending_resize_params_.get()) { | 950 if (pending_resize_params_.get()) { |
| 851 resize_pending_ = true; | 951 resize_pending_ = true; |
| 852 return pending_resize_params_.release(); | 952 return pending_resize_params_.release(); |
| 853 } else { | 953 } else { |
| 854 BrowserPluginHostMsg_ResizeGuest_Params* params = | 954 BrowserPluginHostMsg_ResizeGuest_Params* params = |
| 855 new BrowserPluginHostMsg_ResizeGuest_Params; | 955 new BrowserPluginHostMsg_ResizeGuest_Params; |
| 856 | 956 |
| 857 // We don't have a pending resize to send, so we send an invalid transport | 957 // We don't have a pending resize to send, so we send an invalid transport |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 void* notify_data) { | 1076 void* notify_data) { |
| 977 } | 1077 } |
| 978 | 1078 |
| 979 void BrowserPlugin::didFailLoadingFrameRequest( | 1079 void BrowserPlugin::didFailLoadingFrameRequest( |
| 980 const WebKit::WebURL& url, | 1080 const WebKit::WebURL& url, |
| 981 void* notify_data, | 1081 void* notify_data, |
| 982 const WebKit::WebURLError& error) { | 1082 const WebKit::WebURLError& error) { |
| 983 } | 1083 } |
| 984 | 1084 |
| 985 } // namespace content | 1085 } // namespace content |
| OLD | NEW |