Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7675)

Unified Diff: chrome/renderer/resources/extensions/web_view.js

Issue 11554030: <webview>: Add name attribute (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/web_view.js
diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js
index 4577b5383213f876c307c39a72b2d89126c3f8f1..f52429ad87fbecc3dd8a2a49a9bb66c7d749f199 100644
--- a/chrome/renderer/resources/extensions/web_view.js
+++ b/chrome/renderer/resources/extensions/web_view.js
@@ -9,7 +9,7 @@
var watchForTag = require("tagWatcher").watchForTag;
-var WEB_VIEW_ATTRIBUTES = ['src', 'partition'];
+var WEB_VIEW_ATTRIBUTES = ['name', 'src', 'partition'];
// All exposed api methods for <webview>, these are forwarded to the browser
// plugin.
@@ -117,6 +117,11 @@ function WebView(node) {
* @private
*/
WebView.prototype.handleMutation_ = function(mutation) {
+ // This observer monitors mutations to attributes of the <webview> and
+ // updates the BrowserPlugin properties accordingly. In turn, updating
+ // a BrowserPlugin property will update the corresponding BrowserPlugin
+ // attribute, if necessary. See BrowserPlugin::UpdateDOMAttribute for more
+ // details.
this.objectNode_[mutation.attributeName] =
this.node_.getAttribute(mutation.attributeName);
};
@@ -125,8 +130,17 @@ WebView.prototype.handleMutation_ = function(mutation) {
* @private
*/
WebView.prototype.handleObjectMutation_ = function(mutation) {
- this.node_.setAttribute(mutation.attributeName,
- this.objectNode_.getAttribute(mutation.attributeName));
+ // This observer monitors mutations to attributes of the BrowserPlugin and
+ // updates the <webview> attributes accordingly.
+ if (!this.objectNode_.hasAttribute(mutation.attributeName)) {
+ // If an attribute is removed from the BrowserPlugin, then remove it
+ // from the <webview> as well.
+ this.node_.removeAttribute(mutation.attributeName);
+ } else {
+ // Update the <webview> attribute to match the BrowserPlugin attribute.
+ this.node_.setAttribute(mutation.attributeName,
+ this.objectNode_.getAttribute(mutation.attributeName));
+ }
};
/**
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_embedder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698