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

Unified Diff: chrome/renderer/resources/extensions/extension_options.js

Issue 990223002: <extensionoptions>: Remove dead code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed broken test 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
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/extension_options_events.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/extensions/extension_options.js
diff --git a/chrome/renderer/resources/extensions/extension_options.js b/chrome/renderer/resources/extensions/extension_options.js
index 26bb7a24fe2783b4bd490ab7a461f2446c9f6fe8..6fc31f9fe702167851cc82691103c65dd1644320 100644
--- a/chrome/renderer/resources/extensions/extension_options.js
+++ b/chrome/renderer/resources/extensions/extension_options.js
@@ -2,24 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var DocumentNatives = requireNative('document_natives');
var ExtensionOptionsEvents =
require('extensionOptionsEvents').ExtensionOptionsEvents;
var GuestView = require('guestView').GuestView;
var GuestViewContainer = require('guestViewContainer').GuestViewContainer;
-var GuestViewInternal =
- require('binding').Binding.create('guestViewInternal').generate();
-var IdGenerator = requireNative('id_generator');
-var utils = require('utils');
-
-// Mapping of the autosize attribute names to default values
-var AUTO_SIZE_ATTRIBUTES = {
- 'autosize': 'on',
- 'maxheight': window.innerHeight,
- 'maxwidth': window.innerWidth,
- 'minheight': 32,
- 'minwidth': 32
-};
function ExtensionOptionsImpl(extensionoptionsElement) {
GuestViewContainer.call(this, extensionoptionsElement, 'extensionoptions');
@@ -33,31 +19,14 @@ ExtensionOptionsImpl.prototype.__proto__ = GuestViewContainer.prototype;
ExtensionOptionsImpl.VIEW_TYPE = 'ExtensionOptions';
-// Add extra functionality to |this.element|.
-ExtensionOptionsImpl.setupElement = function(proto) {
- var apiMethods = [
- 'setDeferAutoSize',
- 'resumeDeferredAutoSize'
- ];
-
- // Forward proto.foo* method calls to ExtensionOptionsImpl.foo*.
- GuestViewContainer.forwardApiMethods(proto, apiMethods);
-}
-
ExtensionOptionsImpl.prototype.onElementAttached = function() {
this.createGuest();
}
ExtensionOptionsImpl.prototype.buildContainerParams = function() {
- var params = {
- 'autosize': this.element.hasAttribute('autosize'),
- 'maxheight': parseInt(this.maxheight || 0),
- 'maxwidth': parseInt(this.maxwidth || 0),
- 'minheight': parseInt(this.minheight || 0),
- 'minwidth': parseInt(this.minwidth || 0),
+ return {
'extensionId': this.element.getAttribute('extension')
};
- return params;
};
ExtensionOptionsImpl.prototype.createGuest = function() {
@@ -92,92 +61,11 @@ ExtensionOptionsImpl.prototype.handleAttributeMutation =
if (name == 'extension') {
this.createGuest();
- } else if (AUTO_SIZE_ATTRIBUTES.hasOwnProperty(name) > -1) {
- this[name] = newValue;
- this.resetSizeConstraintsIfInvalid();
-
- if (!this.guest.getId())
- return;
-
- this.guest.setSize({
- 'enableAutoSize': this.element.hasAttribute('autosize'),
- 'min': {
- 'width': parseInt(this.minwidth || 0),
- 'height': parseInt(this.minheight || 0)
- },
- 'max': {
- 'width': parseInt(this.maxwidth || 0),
- 'height': parseInt(this.maxheight || 0)
- }
- });
}
};
-ExtensionOptionsImpl.prototype.onSizeChanged =
- function(newWidth, newHeight, oldWidth, oldHeight) {
- if (this.autosizeDeferred) {
- this.deferredAutoSizeState = {
- newWidth: newWidth,
- newHeight: newHeight,
- oldWidth: oldWidth,
- oldHeight: oldHeight
- };
- } else {
- this.resize(newWidth, newHeight, oldWidth, oldHeight);
- }
-};
-
-ExtensionOptionsImpl.prototype.resize =
- function(newWidth, newHeight, oldWidth, oldHeight) {
- this.element.style.width = newWidth + 'px';
- this.element.style.height = newHeight + 'px';
-
- // Do not allow the options page's dimensions to shrink. This ensures that the
- // options page has a consistent UI. If the new size is larger than the
- // minimum, make that the new minimum size.
- if (newWidth > this.minwidth)
- this.minwidth = newWidth;
- if (newHeight > this.minheight)
- this.minheight = newHeight;
-
- this.guest.setSize({
- 'enableAutoSize': this.element.hasAttribute('autosize'),
- 'min': {
- 'width': parseInt(this.minwidth || 0),
- 'height': parseInt(this.minheight || 0)
- },
- 'max': {
- 'width': parseInt(this.maxwidth || 0),
- 'height': parseInt(this.maxheight || 0)
- }
- });
-};
-
ExtensionOptionsImpl.prototype.setupElementProperties = function() {
- utils.forEach(AUTO_SIZE_ATTRIBUTES, function(attributeName) {
- // Get the size constraints from the <extensionoptions> tag, or use the
- // defaults if not specified
- if (this.element.hasAttribute(attributeName)) {
- this[attributeName] =
- this.element.getAttribute(attributeName);
- } else {
- this[attributeName] = AUTO_SIZE_ATTRIBUTES[attributeName];
- }
-
- Object.defineProperty(this.element, attributeName, {
- get: function() {
- return this[attributeName];
- }.bind(this),
- set: function(value) {
- this.element.setAttribute(attributeName, value);
- }.bind(this),
- enumerable: true
- });
- }, this);
-
- this.resetSizeConstraintsIfInvalid();
-
- Object.defineProperty(this.element, 'extension', {
+ $Object.defineProperty(this.element, 'extension', {
get: function() {
return this.element.getAttribute('extension');
}.bind(this),
@@ -188,43 +76,4 @@ ExtensionOptionsImpl.prototype.setupElementProperties = function() {
});
};
-ExtensionOptionsImpl.prototype.resetSizeConstraintsIfInvalid = function () {
- if (this.minheight > this.maxheight || this.minheight < 0) {
- this.minheight = AUTO_SIZE_ATTRIBUTES.minheight;
- this.maxheight = AUTO_SIZE_ATTRIBUTES.maxheight;
- }
- if (this.minwidth > this.maxwidth || this.minwidth < 0) {
- this.minwidth = AUTO_SIZE_ATTRIBUTES.minwidth;
- this.maxwidth = AUTO_SIZE_ATTRIBUTES.maxwidth;
- }
-};
-
-/**
- * Toggles whether the element should automatically resize to its preferred
- * size. If set to true, when the element receives new autosize dimensions,
- * it passes them to the embedder in a sizechanged event, but does not resize
- * itself to those dimensions until the embedder calls resumeDeferredAutoSize.
- * This allows the embedder to defer the resizing until it is ready.
- * When set to false, the element resizes whenever it receives new autosize
- * dimensions.
- */
-ExtensionOptionsImpl.prototype.setDeferAutoSize = function(value) {
- if (!value)
- resumeDeferredAutoSize();
- this.autosizeDeferred = value;
-};
-
-/**
- * Allows the element to resize to most recent set of autosize dimensions if
- * autosizing is being deferred.
- */
-ExtensionOptionsImpl.prototype.resumeDeferredAutoSize = function() {
- if (this.autosizeDeferred) {
- this.resize(this.deferredAutoSizeState.newWidth,
- this.deferredAutoSizeState.newHeight,
- this.deferredAutoSizeState.oldWidth,
- this.deferredAutoSizeState.oldHeight);
- }
-};
-
GuestViewContainer.registerElement(ExtensionOptionsImpl);
« no previous file with comments | « no previous file | chrome/renderer/resources/extensions/extension_options_events.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698