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"></include>
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.
55 ExtensionCommandsOverlay.returnExtensionsData = function(extensionsData) {
56 ExtensionCommandList.prototype.data_ = extensionsData;
57 var extensionCommandList = $('extension-command-list');
58 ExtensionCommandList.decorate(extensionCommandList);
60 // Make sure the config link is visible, since there are commands to show
61 // and potentially configure.
62 document.querySelector('.extension-commands-config').hidden =
63 extensionsData.commands.length == 0;
65 $('no-commands').hidden = extensionsData.commands.length > 0;
66 var list = $('extension-command-list');
67 if (extensionsData.commands.length == 0)
68 list.classList.add('empty-extension-commands-list');
70 list.classList.remove('empty-extension-commands-list');
75 ExtensionCommandsOverlay: ExtensionCommandsOverlay