[sql] Remove _HAS_EXCEPTIONS=0 from build info.
[chromium-blink-merge.git] / chrome / browser / resources / extensions / extension_commands_overlay.js
blob9b51f341f90fc764d2f789ad9de6f40fc5a399e3
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() {
8 'use strict';
10 // The Extension Commands list object that will be used to show the commands
11 // on the page.
12 var ExtensionCommandList = options.ExtensionCommandList;
14 /**
15 * ExtensionCommandsOverlay class
16 * Encapsulated handling of the 'Extension Commands' overlay page.
17 * @constructor
19 function ExtensionCommandsOverlay() {
22 cr.addSingletonGetter(ExtensionCommandsOverlay);
24 ExtensionCommandsOverlay.prototype = {
25 /**
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');
39 });
41 // The ExtensionList will update us with its data, so we don't need to
42 // handle that here.
45 /**
46 * Handles a click on the dismiss button.
47 * @param {Event} e The click event.
49 handleDismiss_: function(e) {
50 extensions.ExtensionSettings.showOverlay(null);
54 /**
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;
67 break;
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 =
74 !hasAnyCommands;
76 $('no-commands').hidden = hasAnyCommands;
77 overlay.extensionCommandList_.classList.toggle(
78 'empty-extension-commands-list', !hasAnyCommands);
81 // Export
82 return {
83 ExtensionCommandsOverlay: ExtensionCommandsOverlay
85 });