Index: chrome/browser/resources/extensions/extension_options_overlay.js |
diff --git a/chrome/browser/resources/extensions/extension_options_overlay.js b/chrome/browser/resources/extensions/extension_options_overlay.js |
index 174e16e63cf2ffb05e315595228c149519c6b1fe..dc1fbeb832c513c9865cbdb6e8e34fa54b0c15be 100644 |
--- a/chrome/browser/resources/extensions/extension_options_overlay.js |
+++ b/chrome/browser/resources/extensions/extension_options_overlay.js |
@@ -40,6 +40,16 @@ cr.define('extensions', function() { |
this.showOverlay_ = showOverlay; |
}, |
+ setInitialFocus: function() { |
+ this.getExtensionOptions_().focus(); |
+ }, |
+ |
+ /** @return {?Element} */ |
+ getExtensionOptions_: function() { |
+ return $('extension-options-overlay-guest').querySelector( |
+ 'extensionoptions'); |
+ }, |
+ |
/** |
* Handles a click on the close button. |
* @param {Event} event The click event. |
@@ -47,10 +57,7 @@ cr.define('extensions', function() { |
*/ |
handleDismiss_: function(event) { |
this.setVisible_(false); |
- var extensionoptions = |
- $('extension-options-overlay-guest') |
- .querySelector('extensionoptions'); |
- |
+ var extensionoptions = this.getExtensionOptions_(); |
if (extensionoptions) |
$('extension-options-overlay-guest').removeChild(extensionoptions); |
@@ -67,6 +74,8 @@ cr.define('extensions', function() { |
* @param {string} extensionName The name of the extension, which is used |
* as the header of the overlay. |
* @param {string} extensionIcon The URL of the extension's icon. |
+ * @param {function():void} shownCallback A function called when show |
+ * animation completes. |
* @suppress {checkTypes} |
* TODO(vitalyp): remove the suppression after adding |
* chrome/renderer/resources/extensions/extension_options.js |
@@ -74,7 +83,8 @@ cr.define('extensions', function() { |
*/ |
setExtensionAndShowOverlay: function(extensionId, |
extensionName, |
- extensionIcon) { |
+ extensionIcon, |
+ shownCallback) { |
var overlay = $('extension-options-overlay'); |
var overlayHeader = $('extension-options-overlay-header'); |
var overlayGuest = $('extension-options-overlay-guest'); |
@@ -125,9 +135,9 @@ cr.define('extensions', function() { |
Math.pow(newWidth - oldWidth, 2) + |
Math.pow(newHeight - oldHeight, 2)); |
- if (animation) { |
+ if (animation) |
animation.cancel(); |
- } |
+ |
animation = overlay.animate([ |
{width: oldWidth + 'px', height: oldHeight + 'px'}, |
{width: newWidth + 'px', height: newHeight + 'px'} |
@@ -138,13 +148,19 @@ cr.define('extensions', function() { |
animation.onfinish = function(e) { |
animation = null; |
+ |
// The <extensionoptions> element is ready to place back in the |
- // overlay. Make sure that it's sized to take up the full |
- // width/height of the overlay. |
+ // overlay. Make sure that it's sized to take up the full width/height |
+ // of the overlay. |
overlayGuest.style.position = ''; |
overlayGuest.style.left = ''; |
overlayGuest.style.width = newWidth + 'px'; |
overlayGuest.style.height = newHeight + 'px'; |
+ |
+ if (shownCallback) { |
+ shownCallback(); |
+ shownCallback = null; |
+ } |
}; |
}.bind(this); |