| 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 26 matching lines...) Expand all Loading... |
| 93 auto_size_(false), | 98 auto_size_(false), |
| 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 focused_(false), | 106 focused_(false), |
| 102 visible_(true), | 107 visible_(true), |
| 108 size_changed_in_flight_(false), |
| 103 current_nav_entry_index_(0), | 109 current_nav_entry_index_(0), |
| 104 nav_entry_count_(0) { | 110 nav_entry_count_(0) { |
| 105 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); | 111 BrowserPluginManager::Get()->AddBrowserPlugin(instance_id, this); |
| 106 bindings_.reset(new BrowserPluginBindings(this)); | 112 bindings_.reset(new BrowserPluginBindings(this)); |
| 107 | 113 |
| 108 InitializeEvents(); | 114 InitializeEvents(); |
| 109 | 115 |
| 110 ParseAttributes(params); | 116 ParseAttributes(params); |
| 111 } | 117 } |
| 112 | 118 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // Once this instance has navigated, the storage partition cannot be changed, | 167 // Once this instance has navigated, the storage partition cannot be changed, |
| 162 // so this value is used for enforcing this. | 168 // so this value is used for enforcing this. |
| 163 navigate_src_sent_ = true; | 169 navigate_src_sent_ = true; |
| 164 src_ = src; | 170 src_ = src; |
| 165 } | 171 } |
| 166 | 172 |
| 167 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { | 173 void BrowserPlugin::SetAutoSizeAttribute(bool auto_size) { |
| 168 if (auto_size_ == auto_size) | 174 if (auto_size_ == auto_size) |
| 169 return; | 175 return; |
| 170 auto_size_ = auto_size; | 176 auto_size_ = auto_size; |
| 177 last_view_size_ = plugin_rect_.size(); |
| 171 UpdateGuestAutoSizeState(); | 178 UpdateGuestAutoSizeState(); |
| 172 } | 179 } |
| 173 | 180 |
| 174 void BrowserPlugin::PopulateAutoSizeParameters( | 181 void BrowserPlugin::PopulateAutoSizeParameters( |
| 175 BrowserPluginHostMsg_AutoSize_Params* params) const { | 182 BrowserPluginHostMsg_AutoSize_Params* params) { |
| 183 // If maxWidth or maxHeight have not been set, set them to the container size. |
| 184 max_height_ = max_height_ ? max_height_ : height(); |
| 185 max_width_ = max_width_ ? max_width_ : width(); |
| 186 // minWidth should not be bigger than maxWidth, and minHeight should not be |
| 187 // bigger than maxHeight. |
| 188 min_height_ = std::min(min_height_, max_height_); |
| 189 min_width_ = std::min(min_width_, max_width_); |
| 176 params->enable = auto_size_; | 190 params->enable = auto_size_; |
| 177 params->max_height = max_height_; | 191 params->max_size = gfx::Size(max_width_, max_height_); |
| 178 params->max_width = max_width_; | 192 params->min_size = gfx::Size(min_width_, min_height_); |
| 179 params->min_height = min_height_; | |
| 180 params->min_width = min_width_; | |
| 181 } | 193 } |
| 182 | 194 |
| 183 void BrowserPlugin::UpdateGuestAutoSizeState() const { | 195 void BrowserPlugin::UpdateGuestAutoSizeState() { |
| 184 if (!navigate_src_sent_) | 196 if (!navigate_src_sent_) |
| 185 return; | 197 return; |
| 186 BrowserPluginHostMsg_AutoSize_Params params; | 198 BrowserPluginHostMsg_AutoSize_Params auto_size_params; |
| 187 PopulateAutoSizeParameters(¶ms); | 199 PopulateAutoSizeParameters(&auto_size_params); |
| 200 BrowserPluginHostMsg_ResizeGuest_Params resize_params; |
| 201 int view_width = auto_size_params.max_size.width(); |
| 202 int view_height = auto_size_params.max_size.height(); |
| 203 if (!auto_size_params.enable) { |
| 204 view_width = width(); |
| 205 view_height = height(); |
| 206 } |
| 207 TransportDIB* new_damage_buffer = |
| 208 PopulateResizeGuestParameters(&resize_params, view_width, view_height); |
| 209 // AutoSize initiates a resize so we don't want to issue another resize, |
| 210 // we just want to make sure the damage buffer has been updated. |
| 211 resize_params.resize_pending = true; |
| 212 DCHECK(new_damage_buffer); |
| 188 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( | 213 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( |
| 189 render_view_routing_id_, | 214 render_view_routing_id_, |
| 190 instance_id_, | 215 instance_id_, |
| 191 params)); | 216 auto_size_params, |
| 217 resize_params)); |
| 218 if (damage_buffer_) |
| 219 FreeDamageBuffer(); |
| 220 damage_buffer_ = new_damage_buffer; |
| 221 } |
| 222 |
| 223 void BrowserPlugin::SizeChangedDueToAutoSize(const gfx::Size& old_view_size) { |
| 224 size_changed_in_flight_ = false; |
| 225 if (!HasListeners(kSizeChangedEventName)) |
| 226 return; |
| 227 |
| 228 WebKit::WebElement plugin = container()->element(); |
| 229 v8::HandleScope handle_scope; |
| 230 v8::Context::Scope context_scope( |
| 231 plugin.document().frame()->mainWorldScriptContext()); |
| 232 |
| 233 // Construct the sizechanged event object. |
| 234 v8::Local<v8::Object> event = v8::Object::New(); |
| 235 event->Set(v8::String::New(kOldHeight, sizeof(kOldHeight) - 1), |
| 236 v8::Integer::New(old_view_size.height()), |
| 237 v8::ReadOnly); |
| 238 event->Set(v8::String::New(kOldWidth, sizeof(kOldWidth) - 1), |
| 239 v8::Integer::New(old_view_size.width()), |
| 240 v8::ReadOnly); |
| 241 event->Set(v8::String::New(kNewHeight, sizeof(kNewHeight) - 1), |
| 242 v8::Integer::New(last_view_size_.height()), |
| 243 v8::ReadOnly); |
| 244 event->Set(v8::String::New(kNewWidth, sizeof(kNewWidth) - 1), |
| 245 v8::Integer::New(last_view_size_.width()), |
| 246 v8::ReadOnly); |
| 247 TriggerEvent(kSizeChangedEventName, &event); |
| 192 } | 248 } |
| 193 | 249 |
| 194 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { | 250 void BrowserPlugin::SetMaxHeightAttribute(int max_height) { |
| 195 if (max_height_ == max_height) | 251 if (max_height_ == max_height) |
| 196 return; | 252 return; |
| 197 max_height_ = max_height; | 253 max_height_ = max_height; |
| 198 if (!auto_size_) | 254 if (!auto_size_) |
| 199 return; | 255 return; |
| 200 UpdateGuestAutoSizeState(); | 256 UpdateGuestAutoSizeState(); |
| 201 } | 257 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 220 | 276 |
| 221 void BrowserPlugin::SetMinWidthAttribute(int min_width) { | 277 void BrowserPlugin::SetMinWidthAttribute(int min_width) { |
| 222 if (min_width_ == min_width) | 278 if (min_width_ == min_width) |
| 223 return; | 279 return; |
| 224 min_width_ = min_width; | 280 min_width_ = min_width; |
| 225 if (!auto_size_) | 281 if (!auto_size_) |
| 226 return; | 282 return; |
| 227 UpdateGuestAutoSizeState(); | 283 UpdateGuestAutoSizeState(); |
| 228 } | 284 } |
| 229 | 285 |
| 286 bool BrowserPlugin::InAutoSizeBounds(const gfx::Size& size) const { |
| 287 return size.width() <= max_width_ && size.height() <= max_height_; |
| 288 } |
| 289 |
| 230 NPObject* BrowserPlugin::GetContentWindow() const { | 290 NPObject* BrowserPlugin::GetContentWindow() const { |
| 231 if (content_window_routing_id_ == MSG_ROUTING_NONE) | 291 if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| 232 return NULL; | 292 return NULL; |
| 233 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( | 293 RenderViewImpl* guest_render_view = static_cast<RenderViewImpl*>( |
| 234 ChildThread::current()->ResolveRoute(content_window_routing_id_)); | 294 ChildThread::current()->ResolveRoute(content_window_routing_id_)); |
| 235 if (!guest_render_view) | 295 if (!guest_render_view) |
| 236 return NULL; | 296 return NULL; |
| 237 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); | 297 WebKit::WebFrame* guest_frame = guest_render_view->GetWebView()->mainFrame(); |
| 238 return guest_frame->windowObject(); | 298 return guest_frame->windowObject(); |
| 239 } | 299 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 return render_view_->GetWebView()->deviceScaleFactor(); | 373 return render_view_->GetWebView()->deviceScaleFactor(); |
| 314 } | 374 } |
| 315 | 375 |
| 316 void BrowserPlugin::InitializeEvents() { | 376 void BrowserPlugin::InitializeEvents() { |
| 317 event_listener_map_[kExitEventName] = EventListeners(); | 377 event_listener_map_[kExitEventName] = EventListeners(); |
| 318 event_listener_map_[kLoadAbortEventName] = EventListeners(); | 378 event_listener_map_[kLoadAbortEventName] = EventListeners(); |
| 319 event_listener_map_[kLoadCommitEventName] = EventListeners(); | 379 event_listener_map_[kLoadCommitEventName] = EventListeners(); |
| 320 event_listener_map_[kLoadRedirectEventName] = EventListeners(); | 380 event_listener_map_[kLoadRedirectEventName] = EventListeners(); |
| 321 event_listener_map_[kLoadStartEventName] = EventListeners(); | 381 event_listener_map_[kLoadStartEventName] = EventListeners(); |
| 322 event_listener_map_[kLoadStopEventName] = EventListeners(); | 382 event_listener_map_[kLoadStopEventName] = EventListeners(); |
| 383 event_listener_map_[kSizeChangedEventName] = EventListeners(); |
| 323 } | 384 } |
| 324 | 385 |
| 325 void BrowserPlugin::RemoveEventListeners() { | 386 void BrowserPlugin::RemoveEventListeners() { |
| 326 EventListenerMap::iterator event_listener_map_iter = | 387 EventListenerMap::iterator event_listener_map_iter = |
| 327 event_listener_map_.begin(); | 388 event_listener_map_.begin(); |
| 328 for (; event_listener_map_iter != event_listener_map_.end(); | 389 for (; event_listener_map_iter != event_listener_map_.end(); |
| 329 ++event_listener_map_iter) { | 390 ++event_listener_map_iter) { |
| 330 EventListeners& listeners = | 391 EventListeners& listeners = |
| 331 event_listener_map_[event_listener_map_iter->first]; | 392 event_listener_map_[event_listener_map_iter->first]; |
| 332 EventListeners::iterator it = listeners.begin(); | 393 EventListeners::iterator it = listeners.begin(); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 if (!navigate_src_sent_) | 481 if (!navigate_src_sent_) |
| 421 return; | 482 return; |
| 422 BrowserPluginManager::Get()->Send( | 483 BrowserPluginManager::Get()->Send( |
| 423 new BrowserPluginHostMsg_Reload(render_view_routing_id_, | 484 new BrowserPluginHostMsg_Reload(render_view_routing_id_, |
| 424 instance_id_)); | 485 instance_id_)); |
| 425 } | 486 } |
| 426 | 487 |
| 427 void BrowserPlugin::UpdateRect( | 488 void BrowserPlugin::UpdateRect( |
| 428 int message_id, | 489 int message_id, |
| 429 const BrowserPluginMsg_UpdateRect_Params& params) { | 490 const BrowserPluginMsg_UpdateRect_Params& params) { |
| 430 if (width() != params.view_size.width() || | 491 if ((!auto_size_ && |
| 431 height() != params.view_size.height()) { | 492 (width() != params.view_size.width() || |
| 493 height() != params.view_size.height())) || |
| 494 (auto_size_ && (!InAutoSizeBounds(params.view_size)))) { |
| 432 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( | 495 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_UpdateRect_ACK( |
| 433 render_view_routing_id_, | 496 render_view_routing_id_, |
| 434 instance_id_, | 497 instance_id_, |
| 435 message_id, | 498 message_id, |
| 436 gfx::Size(width(), height()))); | 499 gfx::Size(width(), height()))); |
| 437 return; | 500 return; |
| 438 } | 501 } |
| 502 // If the view size has changed since we last updated. |
| 503 if (auto_size_ && (params.view_size != last_view_size_)) { |
| 504 if (backing_store_) |
| 505 backing_store_->Clear(SK_ColorWHITE); |
| 506 gfx::Size old_view_size = last_view_size_; |
| 507 last_view_size_ = params.view_size; |
| 508 // Schedule a SizeChanged instead of calling it directly to ensure that |
| 509 // the backing store has been updated before the developer attempts to |
| 510 // resize to avoid flicker. |size_changed_in_flight_| acts as a form of |
| 511 // flow control for SizeChanged events. If the guest's view size is changing |
| 512 // rapidly before a SizeChanged event fires, then we avoid scheduling |
| 513 // another SizedChanged event. SizedChanged reads the new size from |
| 514 // |last_view_size_| so we can be sure that it always fires an event |
| 515 // with the last seen view size. |
| 516 if (container_ && !size_changed_in_flight_) { |
| 517 size_changed_in_flight_ = true; |
| 518 MessageLoop::current()->PostTask( |
| 519 FROM_HERE, |
| 520 base::Bind(&BrowserPlugin::SizeChangedDueToAutoSize, |
| 521 base::Unretained(this), |
| 522 old_view_size)); |
| 523 } |
| 524 } |
| 439 | 525 |
| 440 float backing_store_scale_factor = | 526 float backing_store_scale_factor = |
| 441 backing_store_.get() ? backing_store_->GetScaleFactor() : 1.0f; | 527 backing_store_.get() ? backing_store_->GetScaleFactor() : 1.0f; |
| 442 | 528 |
| 443 if (params.is_resize_ack || | 529 if (!backing_store_ || params.is_resize_ack || |
| 444 backing_store_scale_factor != params.scale_factor) { | 530 (backing_store_scale_factor != params.scale_factor) || |
| 531 params.view_size.width() > backing_store_->GetSize().width() || |
| 532 params.view_size.height() > backing_store_->GetSize().height()) { |
| 533 int backing_store_width = auto_size_ ? max_width_ : width(); |
| 534 int backing_store_height = auto_size_ ? max_height_: height(); |
| 445 resize_pending_ = !params.is_resize_ack; | 535 resize_pending_ = !params.is_resize_ack; |
| 446 backing_store_.reset( | 536 backing_store_.reset( |
| 447 new BrowserPluginBackingStore(gfx::Size(width(), height()), | 537 new BrowserPluginBackingStore( |
| 448 params.scale_factor)); | 538 gfx::Size(backing_store_width, backing_store_height), |
| 539 params.scale_factor)); |
| 449 } | 540 } |
| 450 | 541 |
| 451 // Update the backing store. | 542 // Update the backing store. |
| 452 if (!params.scroll_rect.IsEmpty()) { | 543 if (!params.scroll_rect.IsEmpty()) { |
| 453 backing_store_->ScrollBackingStore(params.dx, | 544 backing_store_->ScrollBackingStore(params.dx, |
| 454 params.dy, | 545 params.dy, |
| 455 params.scroll_rect, | 546 params.scroll_rect, |
| 456 params.view_size); | 547 params.view_size); |
| 457 } | 548 } |
| 458 for (unsigned i = 0; i < params.copy_rects.size(); i++) { | 549 for (unsigned i = 0; i < params.copy_rects.size(); i++) { |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 837 |
| 747 void BrowserPlugin::updateGeometry( | 838 void BrowserPlugin::updateGeometry( |
| 748 const WebRect& window_rect, | 839 const WebRect& window_rect, |
| 749 const WebRect& clip_rect, | 840 const WebRect& clip_rect, |
| 750 const WebVector<WebRect>& cut_outs_rects, | 841 const WebVector<WebRect>& cut_outs_rects, |
| 751 bool is_visible) { | 842 bool is_visible) { |
| 752 int old_width = width(); | 843 int old_width = width(); |
| 753 int old_height = height(); | 844 int old_height = height(); |
| 754 plugin_rect_ = window_rect; | 845 plugin_rect_ = window_rect; |
| 755 if (auto_size_ || (old_width == window_rect.width && | 846 if (auto_size_ || (old_width == window_rect.width && |
| 756 old_height == window_rect.height)) { | 847 old_height == window_rect.height)) { |
| 757 return; | 848 return; |
| 758 } | 849 } |
| 759 | |
| 760 const size_t stride = skia::PlatformCanvas::StrideForWidth(window_rect.width); | |
| 761 // Make sure the size of the damage buffer is at least four bytes so that we | |
| 762 // can fit in a magic word to verify that the memory is shared correctly. | |
| 763 size_t size = | |
| 764 std::max(sizeof(unsigned int), | |
| 765 static_cast<size_t>(window_rect.height * | |
| 766 stride * | |
| 767 GetDeviceScaleFactor() * | |
| 768 GetDeviceScaleFactor())); | |
| 769 | |
| 770 // Don't drop the old damage buffer until after we've made sure that the | |
| 771 // browser process has dropped it. | |
| 772 TransportDIB* new_damage_buffer = CreateTransportDIB(size); | |
| 773 pending_resize_params_.reset(); | 850 pending_resize_params_.reset(); |
| 774 | 851 |
| 775 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( | 852 scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( |
| 776 new BrowserPluginHostMsg_ResizeGuest_Params); | 853 new BrowserPluginHostMsg_ResizeGuest_Params); |
| 777 params->damage_buffer_id = new_damage_buffer->id(); | 854 |
| 778 #if defined(OS_MACOSX) | 855 TransportDIB* new_damage_buffer = |
| 779 // |damage_buffer_id| is not enough to retrieve the damage buffer (on browser | 856 PopulateResizeGuestParameters(params.get(), width(), height()); |
| 780 // side) since we don't let the browser cache the damage buffer. We need a | 857 DCHECK(new_damage_buffer); |
| 781 // handle to the damage buffer for this. | |
| 782 params->damage_buffer_handle = new_damage_buffer->handle(); | |
| 783 #endif | |
| 784 #if defined(OS_WIN) | |
| 785 params->damage_buffer_size = size; | |
| 786 #endif | |
| 787 params->width = window_rect.width; | |
| 788 params->height = window_rect.height; | |
| 789 params->resize_pending = resize_pending_; | |
| 790 params->scale_factor = GetDeviceScaleFactor(); | |
| 791 | 858 |
| 792 if (navigate_src_sent_) { | 859 if (navigate_src_sent_) { |
| 793 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( | 860 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_ResizeGuest( |
| 794 render_view_routing_id_, | 861 render_view_routing_id_, |
| 795 instance_id_, | 862 instance_id_, |
| 796 *params)); | 863 *params)); |
| 797 resize_pending_ = true; | 864 resize_pending_ = true; |
| 798 } else { | 865 } else { |
| 799 // Until an actual navigation occurs, there is no browser-side embedder | 866 // Until an actual navigation occurs, there is no browser-side embedder |
| 800 // present to notify about geometry updates. In this case, after we've | 867 // present to notify about geometry updates. In this case, after we've |
| (...skipping 12 matching lines...) Expand all Loading... |
| 813 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB | 880 // We don't need to (nor should we) send ViewHostMsg_FreeTransportDIB |
| 814 // message to the browser to free the damage buffer since we manage the | 881 // message to the browser to free the damage buffer since we manage the |
| 815 // damage buffer ourselves. | 882 // damage buffer ourselves. |
| 816 delete damage_buffer_; | 883 delete damage_buffer_; |
| 817 #else | 884 #else |
| 818 RenderProcess::current()->FreeTransportDIB(damage_buffer_); | 885 RenderProcess::current()->FreeTransportDIB(damage_buffer_); |
| 819 damage_buffer_ = NULL; | 886 damage_buffer_ = NULL; |
| 820 #endif | 887 #endif |
| 821 } | 888 } |
| 822 | 889 |
| 890 TransportDIB* BrowserPlugin::PopulateResizeGuestParameters( |
| 891 BrowserPluginHostMsg_ResizeGuest_Params* params, |
| 892 int view_width, int view_height) { |
| 893 const size_t stride = skia::PlatformCanvas::StrideForWidth(view_width); |
| 894 // Make sure the size of the damage buffer is at least four bytes so that we |
| 895 // can fit in a magic word to verify that the memory is shared correctly. |
| 896 size_t size = |
| 897 std::max(sizeof(unsigned int), |
| 898 static_cast<size_t>(view_height * |
| 899 stride * |
| 900 GetDeviceScaleFactor() * |
| 901 GetDeviceScaleFactor())); |
| 902 |
| 903 // Don't drop the old damage buffer until after we've made sure that the |
| 904 // browser process has dropped it. |
| 905 TransportDIB* new_damage_buffer = CreateTransportDIB(size); |
| 906 params->damage_buffer_id = new_damage_buffer->id(); |
| 907 #if defined(OS_MACOSX) |
| 908 // |damage_buffer_id| is not enough to retrieve the damage buffer (on browser |
| 909 // side) since we don't let the browser cache the damage buffer. We need a |
| 910 // handle to the damage buffer for this. |
| 911 params->damage_buffer_handle = new_damage_buffer->handle(); |
| 912 #endif |
| 913 #if defined(OS_WIN) |
| 914 params->damage_buffer_size = size; |
| 915 #endif |
| 916 params->width = view_width; |
| 917 params->height = view_height; |
| 918 params->resize_pending = resize_pending_; |
| 919 params->scale_factor = GetDeviceScaleFactor(); |
| 920 return new_damage_buffer; |
| 921 } |
| 922 |
| 823 BrowserPluginHostMsg_ResizeGuest_Params* | 923 BrowserPluginHostMsg_ResizeGuest_Params* |
| 824 BrowserPlugin::GetPendingResizeParams() { | 924 BrowserPlugin::GetPendingResizeParams() { |
| 825 if (pending_resize_params_.get()) { | 925 if (pending_resize_params_.get()) { |
| 826 resize_pending_ = true; | 926 resize_pending_ = true; |
| 827 return pending_resize_params_.release(); | 927 return pending_resize_params_.release(); |
| 828 } else { | 928 } else { |
| 829 BrowserPluginHostMsg_ResizeGuest_Params* params = | 929 BrowserPluginHostMsg_ResizeGuest_Params* params = |
| 830 new BrowserPluginHostMsg_ResizeGuest_Params; | 930 new BrowserPluginHostMsg_ResizeGuest_Params; |
| 831 | 931 |
| 832 // We don't have a pending resize to send, so we send an invalid transport | 932 // We don't have a pending resize to send, so we send an invalid transport |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 void* notify_data) { | 1054 void* notify_data) { |
| 955 } | 1055 } |
| 956 | 1056 |
| 957 void BrowserPlugin::didFailLoadingFrameRequest( | 1057 void BrowserPlugin::didFailLoadingFrameRequest( |
| 958 const WebKit::WebURL& url, | 1058 const WebKit::WebURL& url, |
| 959 void* notify_data, | 1059 void* notify_data, |
| 960 const WebKit::WebURLError& error) { | 1060 const WebKit::WebURLError& error) { |
| 961 } | 1061 } |
| 962 | 1062 |
| 963 } // namespace content | 1063 } // namespace content |
| OLD | NEW |