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

Unified Diff: extensions/renderer/resources/guest_view/extension_view/extension_view_attributes.js

Issue 1017863007: Refactored the attributes modules of extension_view and web_view into guest_view_attributes.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment. Created 5 years, 9 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
Index: extensions/renderer/resources/guest_view/extension_view/extension_view_attributes.js
diff --git a/extensions/renderer/resources/guest_view/extension_view/extension_view_attributes.js b/extensions/renderer/resources/guest_view/extension_view/extension_view_attributes.js
index b83a97e1edd4aea75d0b168fe6ae11edc49f2fb8..d0786ed7962ac37b7869dc65152c87042e7dd9bb 100644
--- a/extensions/renderer/resources/guest_view/extension_view/extension_view_attributes.js
+++ b/extensions/renderer/resources/guest_view/extension_view/extension_view_attributes.js
@@ -4,8 +4,7 @@
// This module implements the attributes of the <extensionview> tag.
-var GuestViewInternal =
- require('binding').Binding.create('guestViewInternal').generate();
+var GuestViewAttributes = require('guestViewAttributes').GuestViewAttributes;
var ExtensionViewImpl = require('extensionView').ExtensionViewImpl;
var ExtensionViewConstants =
require('extensionViewConstants').ExtensionViewConstants;
@@ -13,83 +12,27 @@ var ExtensionViewInternal =
require('extensionViewInternal').ExtensionViewInternal;
// -----------------------------------------------------------------------------
-// Attribute objects.
-
-// Default implementation of a ExtensionView attribute.
-function ExtensionViewAttribute(name, extensionViewImpl) {
- this.name = name;
- this.extensionViewImpl = extensionViewImpl;
- this.ignoreMutation = false;
-
- this.defineProperty();
-}
-
-// Retrieves and returns the attribute's value.
-ExtensionViewAttribute.prototype.getValue = function() {
- return this.extensionViewImpl.element.getAttribute(this.name) || '';
-};
-
-// Sets the attribute's value.
-ExtensionViewAttribute.prototype.setValue = function(value) {
- this.extensionViewImpl.element.setAttribute(this.name, value || '');
-};
-
-// Changes the attribute's value without triggering its mutation handler.
-ExtensionViewAttribute.prototype.setValueIgnoreMutation = function(value) {
- this.ignoreMutation = true;
- this.setValue(value);
- this.ignoreMutation = false;
-}
-
-// Defines this attribute as a property on the extensionview node.
-ExtensionViewAttribute.prototype.defineProperty = function() {
- Object.defineProperty(this.extensionViewImpl.element, 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.
-ExtensionViewAttribute.prototype.maybeHandleMutation =
- function(oldValue, newValue) {
- if (this.ignoreMutation)
- return;
-
- this.handleMutation(oldValue, newValue);
-}
-
-// Called when a change that isn't ignored occurs to the attribute's value.
-ExtensionViewAttribute.prototype.handleMutation =
- function(oldValue, newValue) {};
-
-ExtensionViewAttribute.prototype.reset = function() {
- this.setValueIgnoreMutation();
-}
+// ExtensionAttribute object.
// Attribute that handles extension binded to the extensionview.
-function ExtensionAttribute(extensionViewImpl) {
- ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_EXTENSION,
- extensionViewImpl);
+function ExtensionAttribute(view) {
+ GuestViewAttributes.ReadOnlyAttribute.call(
+ this, ExtensionViewConstants.ATTRIBUTE_EXTENSION, view);
}
-ExtensionAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype;
+ExtensionAttribute.prototype.__proto__ =
+ GuestViewAttributes.ReadOnlyAttribute.prototype;
-ExtensionAttribute.prototype.handleMutation = function(oldValue, newValue) {
- this.setValueIgnoreMutation(oldValue);
-}
+// -----------------------------------------------------------------------------
+// SrcAttribute object.
// Attribute that handles the location and navigation of the extensionview.
-function SrcAttribute(extensionViewImpl) {
- ExtensionViewAttribute.call(this, ExtensionViewConstants.ATTRIBUTE_SRC,
- extensionViewImpl);
+function SrcAttribute(view) {
+ GuestViewAttributes.Attribute.call(
+ this, ExtensionViewConstants.ATTRIBUTE_SRC, view);
}
-SrcAttribute.prototype.__proto__ = ExtensionViewAttribute.prototype;
+SrcAttribute.prototype.__proto__ = GuestViewAttributes.Attribute.prototype;
SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
if (!newValue && oldValue) {
@@ -100,14 +43,12 @@ SrcAttribute.prototype.handleMutation = function(oldValue, newValue) {
};
SrcAttribute.prototype.parse = function() {
- if (!this.extensionViewImpl.elementAttached || !this.getValue())
- return;
-
- if (!this.extensionViewImpl.guest.getId())
+ if (!this.view.elementAttached || !this.getValue() ||
+ !this.view.guest.getId()) {
return;
+ }
- ExtensionViewInternal.navigate(this.extensionViewImpl.guest.getId(),
- this.getValue());
+ ExtensionViewInternal.navigate(this.view.guest.getId(), this.getValue());
};
// -----------------------------------------------------------------------------

Powered by Google App Engine
This is Rietveld 408576698