OLD | NEW |
(Empty) | |
| 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 overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this)); |
| 32 |
| 33 $('extensionCommandsDismiss').addEventListener('click', |
| 34 this.handleDismiss_.bind(this)); |
| 35 |
| 36 // This will request the data to show on the page and will get a response |
| 37 // back in returnExtensionsData. |
| 38 chrome.send('extensionCommandsRequestExtensionsData'); |
| 39 }, |
| 40 |
| 41 /** |
| 42 * Handles a click on the dismiss button. |
| 43 * @param {Event} e The click event. |
| 44 */ |
| 45 handleDismiss_: function(e) { |
| 46 ExtensionSettings.showOverlay(null); |
| 47 }, |
| 48 }; |
| 49 |
| 50 /** |
| 51 * Called by the dom_ui_ to re-populate the page with data representing |
| 52 * the current state of extension commands. |
| 53 */ |
| 54 ExtensionCommandsOverlay.returnExtensionsData = function(extensionsData) { |
| 55 ExtensionCommandList.prototype.data_ = extensionsData; |
| 56 var extensionCommandList = $('extension-command-list'); |
| 57 ExtensionCommandList.decorate(extensionCommandList); |
| 58 |
| 59 // Make sure the config link is visible, since there are commands to show |
| 60 // and potentially configure. |
| 61 document.querySelector('.extension-commands-config').hidden = |
| 62 extensionsData.commands.length == 0; |
| 63 |
| 64 $('no-commands').hidden = extensionsData.commands.length > 0; |
| 65 var list = $('extension-command-list'); |
| 66 if (extensionsData.commands.length == 0) |
| 67 list.classList.add('empty-extension-commands-list'); |
| 68 else |
| 69 list.classList.remove('empty-extension-commands-list'); |
| 70 } |
| 71 |
| 72 // Export |
| 73 return { |
| 74 ExtensionCommandsOverlay: ExtensionCommandsOverlay |
| 75 }; |
| 76 }); |
| 77 |
| 78 // Update the C++ call so this isn't necessary. |
| 79 var ExtensionCommandsOverlay = extensions.ExtensionCommandsOverlay; |
OLD | NEW |