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. 4 5 <include src="extension_command_list.js"></include> 6 7 cr.define('extensions', function() { 8 'use strict'; 9 10 // The Extension Commands list object that will be used to show the commands 11 // on the page. 12 var ExtensionCommandList = options.ExtensionCommandList; 13 14 /** 15 * ExtensionCommandsOverlay class 16 * Encapsulated handling of the 'Extension Commands' overlay page. 17 * @constructor 18 */ 19 function ExtensionCommandsOverlay() { 20 } 21 22 cr.addSingletonGetter(ExtensionCommandsOverlay); 23 24 ExtensionCommandsOverlay.prototype = { 25 /** 26 * Initialize the page. 27 */ 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)); 33 34 $('extension-commands-dismiss').addEventListener('click', 35 this.handleDismiss_.bind(this)); 36 37 // This will request the data to show on the page and will get a response 38 // back in returnExtensionsData. 39 chrome.send('extensionCommandsRequestExtensionsData'); 40 }, 41 42 /** 43 * Handles a click on the dismiss button. 44 * @param {Event} e The click event. 45 */ 46 handleDismiss_: function(e) { 47 extensions.ExtensionSettings.showOverlay(null); 48 }, 49 }; 50 51 /** 52 * Called by the dom_ui_ to re-populate the page with data representing 53 * the current state of extension commands. 54 */ 55 ExtensionCommandsOverlay.returnExtensionsData = function(extensionsData) { 56 ExtensionCommandList.prototype.data_ = extensionsData; 57 var extensionCommandList = $('extension-command-list'); 58 ExtensionCommandList.decorate(extensionCommandList); 59 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; 64 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'); 69 else 70 list.classList.remove('empty-extension-commands-list'); 71 } 72 73 // Export 74 return { 75 ExtensionCommandsOverlay: ExtensionCommandsOverlay 76 }; 77 }); 78