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

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: 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_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..5206f1dc71346c8082b515fde7b5f038b390b929
--- /dev/null
+++ b/extensions/renderer/resources/guest_view/extension_options/extension_options_attributes.js
@@ -0,0 +1,43 @@
+// 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) {
+ // Once this attribute has been set, it cannot be unset.
+ if (!newValue && oldValue) {
+ this.setValueIgnoreMutation(oldValue);
+ return;
+ }
+
+ if (!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