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
3 // found in the LICENSE file.
5 <include src
="extension_command_list.js">
7 cr
.define('extensions', function() {
10 // The Extension Commands list object that will be used to show the commands
12 var ExtensionCommandList
= options
.ExtensionCommandList
;
15 * ExtensionCommandsOverlay class
16 * Encapsulated handling of the 'Extension Commands' overlay page.
19 function ExtensionCommandsOverlay() {
22 cr
.addSingletonGetter(ExtensionCommandsOverlay
);
24 ExtensionCommandsOverlay
.prototype = {
26 * Initialize the page.
28 initializePage: function() {
29 var overlay
= $('overlay');
30 cr
.ui
.overlay
.setupOverlay(overlay
);
31 cr
.ui
.overlay
.globalInitialization();
32 overlay
.addEventListener('cancelOverlay', this.handleDismiss_
.bind(this));
34 this.extensionCommandList_
= new ExtensionCommandList(
35 /**@type {HTMLDivElement} */($('extension-command-list')));
37 $('extension-commands-dismiss').addEventListener('click', function() {
38 cr
.dispatchSimpleEvent(overlay
, 'cancelOverlay');
41 // The ExtensionList will update us with its data, so we don't need to
46 * Handles a click on the dismiss button.
47 * @param {Event} e The click event.
49 handleDismiss_: function(e
) {
50 extensions
.ExtensionSettings
.showOverlay(null);
55 * Called by the dom_ui_ to re-populate the page with data representing
56 * the current state of extension commands.
57 * @param {!Array<ExtensionInfo>} extensionsData
59 ExtensionCommandsOverlay
.updateExtensionsData = function(extensionsData
) {
60 var overlay
= ExtensionCommandsOverlay
.getInstance();
61 overlay
.extensionCommandList_
.setData(extensionsData
);
63 var hasAnyCommands
= false;
64 for (var i
= 0; i
< extensionsData
.length
; ++i
) {
65 if (extensionsData
[i
].commands
.length
> 0) {
66 hasAnyCommands
= true;
71 // Make sure the config link is visible, since there are commands to show
72 // and potentially configure.
73 document
.querySelector('.extension-commands-config').hidden
=
76 $('no-commands').hidden
= hasAnyCommands
;
77 overlay
.extensionCommandList_
.classList
.toggle(
78 'empty-extension-commands-list', !hasAnyCommands
);
83 ExtensionCommandsOverlay
: ExtensionCommandsOverlay