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

Unified Diff: chrome/browser/resources/extensions/extension_options_overlay.js

Issue 900623003: extensions: focus options overlay content when shown. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@policy-icon-label
Patch Set: blur() just in case Created 5 years, 10 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: 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);

Powered by Google App Engine
This is Rietveld 408576698