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 $('extension-commands-dismiss').addEventListener('click',
35 this.handleDismiss_
.bind(this));
37 // This will request the data to show on the page and will get a response
38 // back in returnExtensionsData.
39 chrome
.send('extensionCommandsRequestExtensionsData');
43 * Handles a click on the dismiss button.
44 * @param {Event} e The click event.
46 handleDismiss_: function(e
) {
47 extensions
.ExtensionSettings
.showOverlay(null);
52 * Called by the dom_ui_ to re-populate the page with data representing
53 * the current state of extension commands.
54 * @param {!{commands: Array<{name: string, id: string, commands: ?Array}>}}
57 ExtensionCommandsOverlay
.returnExtensionsData = function(extensionsData
) {
58 ExtensionCommandList
.prototype.data_
= extensionsData
;
59 var extensionCommandList
= $('extension-command-list');
60 ExtensionCommandList
.decorate(extensionCommandList
);
62 // Make sure the config link is visible, since there are commands to show
63 // and potentially configure.
64 document
.querySelector('.extension-commands-config').hidden
=
65 extensionsData
.commands
.length
== 0;
67 $('no-commands').hidden
= extensionsData
.commands
.length
> 0;
68 var list
= $('extension-command-list');
69 if (extensionsData
.commands
.length
== 0)
70 list
.classList
.add('empty-extension-commands-list');
72 list
.classList
.remove('empty-extension-commands-list');
77 ExtensionCommandsOverlay
: ExtensionCommandsOverlay