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

Unified Diff: extensions/renderer/resources/guest_view/extension_options/extension_options_attributes.js

Issue 1026703004: Refactored extensionOptions to use the new guestViewAttributes module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Addressed Comments. 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_options/extension_options_attributes.js
diff --git a/extensions/renderer/resources/guest_view/extension_options/extension_options_attributes.js b/extensions/renderer/resources/guest_view/extension_options/extension_options_attributes.js
new file mode 100644
index 0000000000000000000000000000000000000000..33cd86228c3b1b9b3b462686bd2de98e7989418f
--- /dev/null
+++ b/extensions/renderer/resources/guest_view/extension_options/extension_options_attributes.js
@@ -0,0 +1,42 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This module implements the attributes of the <extensionoptions> tag.
+
+var GuestViewAttributes = require('guestViewAttributes').GuestViewAttributes;
+var ExtensionOptionsConstants =
+ require('extensionOptionsConstants').ExtensionOptionsConstants;
+var ExtensionOptionsImpl = require('extensionOptions').ExtensionOptionsImpl;
+
+// -----------------------------------------------------------------------------
+// ExtensionAttribute object.
+
+// Attribute that handles extension binded to the extensionoptions.
+function ExtensionAttribute(view) {
+ GuestViewAttributes.Attribute.call(
+ this, ExtensionOptionsConstants.ATTRIBUTE_EXTENSION, view);
+}
+
+ExtensionAttribute.prototype.__proto__ =
+ GuestViewAttributes.Attribute.prototype;
+
+ExtensionAttribute.prototype.handleMutation = function(oldValue, newValue) {
+ // We treat null attribute (attribute removed) and the empty string as
+ // one case.
+ oldValue = oldValue || '';
+ newValue = newValue || '';
Fady Samuel 2015/03/24 17:37:29 This behavior is really confusing. This should beh
paulmeyer 2015/03/24 18:13:40 Done.
+
+ if (oldValue === newValue || !this.elementAttached)
+ return;
+
+ this.view.createGuest();
+};
+
+// -----------------------------------------------------------------------------
+
+// Sets up all of the extensionoptions attributes.
+ExtensionOptionsImpl.prototype.setupAttributes = function() {
+ this.attributes[ExtensionOptionsConstants.ATTRIBUTE_EXTENSION] =
+ new ExtensionAttribute(this);
+};

Powered by Google App Engine
This is Rietveld 408576698