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

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: 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..b6edb2136283bae4d4e103c725fe1f9094a5234d
--- /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
Fady Samuel 2015/03/20 19:53:57 We will never hit this case I think. I believe han
paulmeyer 2015/03/24 17:31:42 This case is hit if, say, the extension attribute
+ // one case.
+ oldValue = oldValue || '';
+ newValue = newValue || '';
+
+ if (oldValue === newValue)
+ 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