| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 <include src="extension_error.js"> | 5 <include src="extension_error.js"> |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The type of the extension data object. The definition is based on | 8 * The type of the extension data object. The definition is based on |
| 9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc | 9 * chrome/browser/ui/webui/extensions/extension_basic_info.cc |
| 10 * and | 10 * and |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 this.data_.extensions.forEach(this.createNode_, this); | 126 this.data_.extensions.forEach(this.createNode_, this); |
| 127 | 127 |
| 128 var idToHighlight = this.getIdQueryParam_(); | 128 var idToHighlight = this.getIdQueryParam_(); |
| 129 if (idToHighlight && $(idToHighlight)) | 129 if (idToHighlight && $(idToHighlight)) |
| 130 this.scrollToNode_(idToHighlight); | 130 this.scrollToNode_(idToHighlight); |
| 131 | 131 |
| 132 var idToOpenOptions = this.getOptionsQueryParam_(); | 132 var idToOpenOptions = this.getOptionsQueryParam_(); |
| 133 if (idToOpenOptions && $(idToOpenOptions)) | 133 if (idToOpenOptions && $(idToOpenOptions)) |
| 134 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); | 134 this.showEmbeddedExtensionOptions_(idToOpenOptions, true); |
| 135 | 135 |
| 136 if (this.data_.extensions.length == 0) | 136 var noExtensions = this.data_.extensions.length == 0; |
| 137 this.classList.add('empty-extension-list'); | 137 this.classList.toggle('empty-extension-list', noExtensions); |
| 138 else | |
| 139 this.classList.remove('empty-extension-list'); | |
| 140 }, | 138 }, |
| 141 | 139 |
| 142 /** | 140 /** |
| 143 * Scrolls the page down to the extension node with the given id. | 141 * Scrolls the page down to the extension node with the given id. |
| 144 * @param {string} extensionId The id of the extension to scroll to. | 142 * @param {string} extensionId The id of the extension to scroll to. |
| 145 * @private | 143 * @private |
| 146 */ | 144 */ |
| 147 scrollToNode_: function(extensionId) { | 145 scrollToNode_: function(extensionId) { |
| 148 // Scroll offset should be calculated slightly higher than the actual | 146 // Scroll offset should be calculated slightly higher than the actual |
| 149 // offset of the element being scrolled to, so that it ends up not all | 147 // offset of the element being scrolled to, so that it ends up not all |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 var extension = this.data_.extensions.filter(function(extension) { | 559 var extension = this.data_.extensions.filter(function(extension) { |
| 562 return extension.enabled && extension.id == extensionId; | 560 return extension.enabled && extension.id == extensionId; |
| 563 })[0]; | 561 })[0]; |
| 564 | 562 |
| 565 if (!extension) | 563 if (!extension) |
| 566 return; | 564 return; |
| 567 | 565 |
| 568 if (scroll) | 566 if (scroll) |
| 569 this.scrollToNode_(extensionId); | 567 this.scrollToNode_(extensionId); |
| 570 | 568 |
| 571 document.activeElement.blur(); | |
| 572 | |
| 573 // Add the options query string. Corner case: the 'options' query string | 569 // Add the options query string. Corner case: the 'options' query string |
| 574 // will clobber the 'id' query string if the options link is clicked when | 570 // will clobber the 'id' query string if the options link is clicked when |
| 575 // 'id' is in the URL, or if both query strings are in the URL. | 571 // 'id' is in the URL, or if both query strings are in the URL. |
| 576 uber.replaceState({}, '?options=' + extensionId); | 572 uber.replaceState({}, '?options=' + extensionId); |
| 577 | 573 |
| 574 var overlay = extensions.ExtensionOptionsOverlay.getInstance(); |
| 578 var shownCallback = function() { | 575 var shownCallback = function() { |
| 576 // Call this instead of ExtensionSettings.focusOverlay() because |
| 577 // <extensionoptions> is already the active element. TODO(dbeam): why |
| 578 // do we need to re-focus <extensionoptions> after its showing animation |
| 579 // finishes? Makes very little sense to me. |
| 579 if (cr.ui.FocusOutlineManager.forDocument(document).visible) | 580 if (cr.ui.FocusOutlineManager.forDocument(document).visible) |
| 580 overlay.setInitialFocus(); | 581 overlay.setInitialFocus(); |
| 581 }; | 582 }; |
| 582 | |
| 583 var overlay = extensions.ExtensionOptionsOverlay.getInstance(); | |
| 584 overlay.setExtensionAndShowOverlay(extensionId, extension.name, | 583 overlay.setExtensionAndShowOverlay(extensionId, extension.name, |
| 585 extension.icon, shownCallback); | 584 extension.icon, shownCallback); |
| 586 this.optionsShown_ = true; | 585 this.optionsShown_ = true; |
| 587 | 586 |
| 588 var self = this; | 587 var self = this; |
| 589 $('overlay').addEventListener('cancelOverlay', function f() { | 588 $('overlay').addEventListener('cancelOverlay', function f() { |
| 590 // Restore focus instead of just blurring when this page isn't rebuild | |
| 591 // crazy. http://crbug.com/450818 | |
| 592 document.activeElement.blur(); | |
| 593 self.optionsShown_ = false; | 589 self.optionsShown_ = false; |
| 594 $('overlay').removeEventListener('cancelOverlay', f); | 590 $('overlay').removeEventListener('cancelOverlay', f); |
| 595 }); | 591 }); |
| 596 | |
| 597 // TODO(dbeam): guestview's focus is weird. Only when this is called from | |
| 598 // within this event handler *and* after the showing animation completes | |
| 599 // does this work. | |
| 600 shownCallback(); | |
| 601 }, | 592 }, |
| 602 }; | 593 }; |
| 603 | 594 |
| 604 return { | 595 return { |
| 605 ExtensionsList: ExtensionsList | 596 ExtensionsList: ExtensionsList |
| 606 }; | 597 }; |
| 607 }); | 598 }); |
| OLD | NEW |