blob: 6e0e43a5dc2575bb8e9644d4e6a6296c28b26e28 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
<include src="extension_command_list.js">
cr.define('extensions', function() {
'use strict';
// The Extension Commands list object that will be used to show the commands
// on the page.
var ExtensionCommandList = options.ExtensionCommandList;
/**
* ExtensionCommandsOverlay class
* Encapsulated handling of the 'Extension Commands' overlay page.
* @constructor
*/
function ExtensionCommandsOverlay() {
}
cr.addSingletonGetter(ExtensionCommandsOverlay);
ExtensionCommandsOverlay.prototype = {
/**
* Initialize the page.
*/
initializePage: function() {
var overlay = $('overlay');
cr.ui.overlay.setupOverlay(overlay);
cr.ui.overlay.globalInitialization();
overlay.addEventListener('cancelOverlay', this.handleDismiss_.bind(this));
this.extensionCommandList_ = new ExtensionCommandList(
/**@type {HTMLDivElement} */($('extension-command-list')));
$('extension-commands-dismiss').addEventListener('click', function() {
cr.dispatchSimpleEvent(overlay, 'cancelOverlay');
});
// The ExtensionList will update us with its data, so we don't need to
// handle that here.
},
/**
* Handles a click on the dismiss button.
* @param {Event} e The click event.
*/
handleDismiss_: function(e) {
extensions.ExtensionSettings.showOverlay(null);
},
};
/**
* Called by the dom_ui_ to re-populate the page with data representing
* the current state of extension commands.
* @param {!Array<chrome.developerPrivate.ExtensionInfo>} extensionsData
*/
ExtensionCommandsOverlay.updateExtensionsData = function(extensionsData) {
var overlay = ExtensionCommandsOverlay.getInstance();
overlay.extensionCommandList_.setData(extensionsData);
var hasAnyCommands = false;
for (var i = 0; i < extensionsData.length; ++i) {
if (extensionsData[i].commands.length > 0) {
hasAnyCommands = true;
break;
}
}
// Make sure the config link is visible, since there are commands to show
// and potentially configure.
document.querySelector('.extension-commands-config').hidden =
!hasAnyCommands;
$('no-commands').hidden = hasAnyCommands;
overlay.extensionCommandList_.classList.toggle(
'empty-extension-commands-list', !hasAnyCommands);
};
// Export
return {
ExtensionCommandsOverlay: ExtensionCommandsOverlay
};
});
|