Chromium Code Reviews| Index: content/renderer/browser_plugin/browser_plugin.cc |
| diff --git a/content/renderer/browser_plugin/browser_plugin.cc b/content/renderer/browser_plugin/browser_plugin.cc |
| index 5b2fce11d00b624bd19c5598988e72a718f44c1e..a41bbc33324d56069277474c3956604daf779981 100644 |
| --- a/content/renderer/browser_plugin/browser_plugin.cc |
| +++ b/content/renderer/browser_plugin/browser_plugin.cc |
| @@ -90,6 +90,11 @@ BrowserPlugin::BrowserPlugin( |
| guest_crashed_(false), |
| resize_pending_(false), |
| navigate_src_sent_(false), |
| + autosize_(false), |
| + maxheight_(0), |
| + maxwidth_(0), |
| + minheight_(0), |
| + minwidth_(0), |
| process_id_(-1), |
| persist_storage_(false), |
| content_window_routing_id_(MSG_ROUTING_NONE), |
| @@ -133,14 +138,17 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) { |
| // after creation. If |src| is empty, we can delay the creation until we |
| // acutally need it. |
| if (!navigate_src_sent_) { |
| + BrowserPluginHostMsg_CreateGuest_Params params; |
| + params.storage_partition_id = storage_partition_id_; |
| + params.persist_storage = persist_storage_; |
| + params.focused = focused_; |
| + params.visible = visible_; |
| + PopulateAutoSizeParameters(¶ms.autosize); |
| BrowserPluginManager::Get()->Send( |
| new BrowserPluginHostMsg_CreateGuest( |
| render_view_routing_id_, |
| instance_id_, |
| - storage_partition_id_, |
| - persist_storage_, |
| - focused_, |
| - visible_)); |
| + params)); |
| } |
| scoped_ptr<BrowserPluginHostMsg_ResizeGuest_Params> params( |
| @@ -160,6 +168,89 @@ void BrowserPlugin::SetSrcAttribute(const std::string& src) { |
| src_ = src; |
| } |
| +bool BrowserPlugin::GetAutoSizeAttribute() const { |
| + return autosize_; |
| +} |
| + |
| +void BrowserPlugin::SetAutoSizeAttribute(bool autosize) { |
| + if (autosize_ == autosize) |
| + return; |
| + autosize_ = autosize; |
| + UpdateGuestAutoSizeState(); |
| +} |
| + |
| +void BrowserPlugin::PopulateAutoSizeParameters( |
| + BrowserPluginHostMsg_AutoSize_Params* params) const { |
| + params->enable = autosize_; |
| + params->maxheight = maxheight_; |
| + params->maxwidth = maxwidth_; |
| + params->minheight = minheight_; |
| + params->minwidth = minwidth_; |
| +} |
| + |
| +void BrowserPlugin::UpdateGuestAutoSizeState() const { |
| + if (!navigate_src_sent_) |
| + return; |
| + BrowserPluginHostMsg_AutoSize_Params params; |
| + PopulateAutoSizeParameters(¶ms); |
| + BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetAutoSize( |
| + render_view_routing_id_, |
| + instance_id_, |
| + params)); |
| +} |
| + |
| +int BrowserPlugin::GetMaxHeightAttribute() const { |
|
jam
2012/11/02 19:11:10
nit: all these getters should jus be unix_hacker s
Fady Samuel
2012/11/02 20:32:23
Done.
|
| + return maxheight_; |
| +} |
| + |
| +void BrowserPlugin::SetMaxHeightAttribute(int maxheight) { |
| + if (maxheight_ == maxheight) |
| + return; |
| + maxheight_ = maxheight; |
| + if (!autosize_) |
| + return; |
| + UpdateGuestAutoSizeState(); |
| +} |
| + |
| +int BrowserPlugin::GetMaxWidthAttribute() const { |
| + return maxwidth_; |
| +} |
| + |
| +void BrowserPlugin::SetMaxWidthAttribute(int maxwidth) { |
| + if (maxwidth_ == maxwidth) |
| + return; |
| + maxwidth_ = maxwidth; |
| + if (!autosize_) |
| + return; |
| + UpdateGuestAutoSizeState(); |
| +} |
| + |
| +int BrowserPlugin::GetMinHeightAttribute() const { |
| + return minheight_; |
| +} |
| + |
| +void BrowserPlugin::SetMinHeightAttribute(int minheight) { |
| + if (minheight_ == minheight) |
| + return; |
| + minheight_ = minheight; |
| + if (!autosize_) |
| + return; |
| + UpdateGuestAutoSizeState(); |
| +} |
| + |
| +int BrowserPlugin::GetMinWidthAttribute() const { |
| + return minwidth_; |
| +} |
| + |
| +void BrowserPlugin::SetMinWidthAttribute(int minwidth) { |
| + if (minwidth_ == minwidth) |
| + return; |
| + minwidth_ = minwidth; |
| + if (!autosize_) |
| + return; |
| + UpdateGuestAutoSizeState(); |
| +} |
| + |
| NPObject* BrowserPlugin::GetContentWindow() const { |
| if (content_window_routing_id_ == MSG_ROUTING_NONE) |
| return NULL; |
| @@ -278,9 +369,6 @@ void BrowserPlugin::TriggerEvent(const std::string& event_name, |
| v8::Local<v8::Object>* event) { |
| WebKit::WebElement plugin = container()->element(); |
| - // TODO(fsamuel): Copying the event listeners is insufficent because |
| - // new persistent handles are not created when the copy constructor is |
| - // called. See http://crbug.com/155044. |
| const EventListeners& listeners = event_listener_map_[event_name.c_str()]; |
| // A v8::Local copy of the listeners is created from the v8::Persistent |
| // listeners before firing them. This is to ensure that if one of these |
| @@ -688,8 +776,8 @@ void BrowserPlugin::updateGeometry( |
| int old_width = width(); |
| int old_height = height(); |
| plugin_rect_ = window_rect; |
| - if (old_width == window_rect.width && |
| - old_height == window_rect.height) { |
| + if (autosize_ || (old_width == window_rect.width && |
| + old_height == window_rect.height)) { |
| return; |
| } |