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

Unified Diff: extensions/renderer/resources/guest_view/web_view_attributes.js

Issue 706473002: Automated the definitions of webview attributes as properties on the webview node. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 | « extensions/renderer/resources/guest_view/web_view.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/guest_view/web_view_attributes.js
diff --git a/extensions/renderer/resources/guest_view/web_view_attributes.js b/extensions/renderer/resources/guest_view/web_view_attributes.js
index 1e02b8965bac464542365305803aa5afe8024271..1144b2ed1cefe76c2b7da3e6849359bf77025d7f 100644
--- a/extensions/renderer/resources/guest_view/web_view_attributes.js
+++ b/extensions/renderer/resources/guest_view/web_view_attributes.js
@@ -27,10 +27,23 @@ WebViewAttribute.prototype.setValue = function(value) {
this.webViewImpl.webviewNode.setAttribute(this.name, value || '');
};
+// Defines this attribute as a property on the webview node.
+WebViewAttribute.prototype.define = function() {
+ Object.defineProperty(this.webViewImpl.webviewNode, this.name, {
+ get: function() {
+ return this.getValue();
+ }.bind(this),
+ set: function(value) {
+ this.setValue(value);
+ }.bind(this),
+ enumerable: true
+ });
+};
+
// Called when the attribute's value changes.
-WebViewAttribute.prototype.handleMutation = function() {}
+WebViewAttribute.prototype.handleMutation = function(oldValue, newValue) {};
-// Attribute specifying whether transparency is allowed in the webview.
+// An attribute that is treated as a Boolean.
function BooleanAttribute(name, webViewImpl) {
WebViewAttribute.call(this, name, webViewImpl);
}
@@ -38,9 +51,8 @@ function BooleanAttribute(name, webViewImpl) {
BooleanAttribute.prototype = new WebViewAttribute();
BooleanAttribute.prototype.getValue = function() {
- // This attribute is treated as a boolean, and is retrieved as such.
return this.webViewImpl.webviewNode.hasAttribute(this.name);
-}
+};
BooleanAttribute.prototype.setValue = function(value) {
if (!value) {
@@ -48,7 +60,7 @@ BooleanAttribute.prototype.setValue = function(value) {
} else {
this.webViewImpl.webviewNode.setAttribute(this.name, '');
}
-}
+};
// Attribute representing the state of the storage partition.
function Partition(webViewImpl) {
@@ -75,7 +87,7 @@ Partition.prototype.handleMutation = function(oldValue, newValue) {
window.console.error(
WebViewConstants.ERROR_MSG_INVALID_PARTITION_ATTRIBUTE);
}
-}
+};
// -----------------------------------------------------------------------------
« no previous file with comments | « extensions/renderer/resources/guest_view/web_view.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698