summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfsamuel <fsamuel@chromium.org>2015-03-27 17:09:21 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-28 00:10:15 +0000
commit1d139b208626492b3bcdd50a43902d6c91481d27 (patch)
tree2c506b87f62c1535d89e3df2bd6a68ff38f1abe0
parentac201157369195adc785270b14504f7f3f87bf26 (diff)
downloadchromium_src-1d139b208626492b3bcdd50a43902d6c91481d27.zip
chromium_src-1d139b208626492b3bcdd50a43902d6c91481d27.tar.gz
chromium_src-1d139b208626492b3bcdd50a43902d6c91481d27.tar.bz2
GuestView: Lazily push attributes to the browser process on attach
Only push attributes to the browser process on attach that have changed since create. This CL also allows partial changes to autosize parameters. BUG=471402 Review URL: https://codereview.chromium.org/1033373003 Cr-Commit-Position: refs/heads/master@{#322683}
-rw-r--r--extensions/browser/guest_view/guest_view_base.cc14
-rw-r--r--extensions/renderer/resources/guest_view/guest_view_attributes.js13
-rw-r--r--extensions/renderer/resources/guest_view/web_view/web_view.js11
3 files changed, 29 insertions, 9 deletions
diff --git a/extensions/browser/guest_view/guest_view_base.cc b/extensions/browser/guest_view/guest_view_base.cc
index cf518e4..c19a941 100644
--- a/extensions/browser/guest_view/guest_view_base.cc
+++ b/extensions/browser/guest_view/guest_view_base.cc
@@ -785,21 +785,21 @@ double GuestViewBase::GetEmbedderZoomFactor() {
void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) {
// Read the autosize parameters passed in from the embedder.
- bool auto_size_enabled = false;
+ bool auto_size_enabled = auto_size_enabled_;
params.GetBoolean(guestview::kAttributeAutoSize, &auto_size_enabled);
- int max_height = 0;
- int max_width = 0;
+ int max_height = max_auto_size_.height();
+ int max_width = max_auto_size_.width();
params.GetInteger(guestview::kAttributeMaxHeight, &max_height);
params.GetInteger(guestview::kAttributeMaxWidth, &max_width);
- int min_height = 0;
- int min_width = 0;
+ int min_height = min_auto_size_.height();
+ int min_width = min_auto_size_.width();
params.GetInteger(guestview::kAttributeMinHeight, &min_height);
params.GetInteger(guestview::kAttributeMinWidth, &min_width);
- int normal_height = 0;
- int normal_width = 0;
+ int normal_height = normal_size_.height();
+ int normal_width = normal_size_.width();
if (is_full_page_plugin()) {
// The initial size of a full page plugin should be set to fill the
// owner's visible viewport.
diff --git a/extensions/renderer/resources/guest_view/guest_view_attributes.js b/extensions/renderer/resources/guest_view/guest_view_attributes.js
index a4c42b6..7bc33b8 100644
--- a/extensions/renderer/resources/guest_view/guest_view_attributes.js
+++ b/extensions/renderer/resources/guest_view/guest_view_attributes.js
@@ -9,9 +9,10 @@
// Default implementation of a GuestView attribute.
function Attribute(name, view) {
+ this.dirty = false;
+ this.ignoreMutation = false;
this.name = name;
this.view = view;
- this.ignoreMutation = false;
this.defineProperty();
}
@@ -21,6 +22,15 @@ Attribute.prototype.getValue = function() {
return this.view.element.getAttribute(this.name) || '';
};
+// Retrieves and returns the attribute's value if it has been dirtied since
+// the last time this method was called. Returns null otherwise.
+Attribute.prototype.getValueIfDirty = function() {
+ if (!this.dirty)
+ return null;
+ this.dirty = false;
+ return this.getValue();
+};
+
// Sets the attribute's value.
Attribute.prototype.setValue = function(value) {
this.view.element.setAttribute(this.name, value || '');
@@ -51,6 +61,7 @@ Attribute.prototype.maybeHandleMutation = function(oldValue, newValue) {
if (this.ignoreMutation)
return;
+ this.dirty = true;
this.handleMutation(oldValue, newValue);
};
diff --git a/extensions/renderer/resources/guest_view/web_view/web_view.js b/extensions/renderer/resources/guest_view/web_view/web_view.js
index 1b40d15..d1d3677 100644
--- a/extensions/renderer/resources/guest_view/web_view/web_view.js
+++ b/extensions/renderer/resources/guest_view/web_view/web_view.js
@@ -55,6 +55,10 @@ WebViewImpl.setupElement = function(proto) {
// Initiates navigation once the <webview> element is attached to the DOM.
WebViewImpl.prototype.onElementAttached = function() {
+ // Mark all attributes as dirty on attachment.
+ for (var i in this.attributes) {
+ this.attributes[i].dirty = true;
+ }
for (var i in this.attributes) {
this.attributes[i].attach();
}
@@ -64,6 +68,9 @@ WebViewImpl.prototype.onElementAttached = function() {
WebViewImpl.prototype.onElementDetached = function() {
this.guest.destroy();
for (var i in this.attributes) {
+ this.attributes[i].dirty = false;
+ }
+ for (var i in this.attributes) {
this.attributes[i].detach();
}
};
@@ -167,7 +174,9 @@ WebViewImpl.prototype.onAttach = function(storagePartitionId) {
WebViewImpl.prototype.buildContainerParams = function() {
var params = { 'userAgentOverride': this.userAgentOverride };
for (var i in this.attributes) {
- params[i] = this.attributes[i].getValue();
+ var value = this.attributes[i].getValueIfDirty();
+ if (value)
+ params[i] = value;
}
return params;
};