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.
6 * This view displays information on installed Chrome extensions / apps as well
7 * as Winsock layered service providers and namespace providers.
9 * For each layered service provider, shows the name, dll, and type
10 * information. For each namespace provider, shows the name and
11 * whether or not it's active.
13 var ModulesView
= (function() {
16 // We inherit from DivView.
17 var superClass
= DivView
;
22 function ModulesView() {
23 assertFirstConstructorCall(ModulesView
);
25 // Call superclass's constructor.
26 superClass
.call(this, ModulesView
.MAIN_BOX_ID
);
28 this.serviceProvidersTbody_
=
29 $(ModulesView
.SERVICE_PROVIDERS_TBODY_ID
);
30 this.namespaceProvidersTbody_
=
31 $(ModulesView
.NAMESPACE_PROVIDERS_TBODY_ID
);
33 g_browser
.addServiceProvidersObserver(this, false);
34 g_browser
.addExtensionInfoObserver(this, true);
37 ModulesView
.TAB_ID
= 'tab-handle-modules';
38 ModulesView
.TAB_NAME
= 'Modules';
39 ModulesView
.TAB_HASH
= '#modules';
41 // IDs for special HTML elements in modules_view.html.
42 ModulesView
.MAIN_BOX_ID
= 'modules-view-tab-content';
43 ModulesView
.EXTENSION_INFO_ID
= 'modules-view-extension-info';
44 ModulesView
.WINDOWS_SERVICE_PROVIDERS_ID
=
45 'modules-view-windows-service-providers';
47 cr
.addSingletonGetter(ModulesView
);
49 ModulesView
.prototype = {
50 // Inherit the superclass's methods.
51 __proto__
: superClass
.prototype,
53 onLoadLogFinish: function(data
) {
54 // Show the tab if there are either service providers or extension info.
55 var hasExtensionInfo
= this.onExtensionInfoChanged(data
.extensionInfo
);
56 var hasSpiInfo
= this.onServiceProvidersChanged(data
.serviceProviders
);
57 return hasExtensionInfo
|| hasSpiInfo
;
60 onExtensionInfoChanged: function(extensionInfo
) {
61 var input
= new JsEvalContext({extensionInfo
: extensionInfo
});
62 jstProcess(input
, $(ModulesView
.EXTENSION_INFO_ID
));
63 return !!extensionInfo
;
66 onServiceProvidersChanged: function(serviceProviders
) {
67 var input
= new JsEvalContext(serviceProviders
);
68 jstProcess(input
, $(ModulesView
.WINDOWS_SERVICE_PROVIDERS_ID
));
69 return !!serviceProviders
;
74 * Returns type of a layered service provider.
76 ModulesView
.getLayeredServiceProviderType = function(serviceProvider
) {
77 if (serviceProvider
.chain_length
== 0)
79 if (serviceProvider
.chain_length
== 1)
93 * Returns socket type of a layered service provider as a string.
95 ModulesView
.getLayeredServiceProviderSocketType = function(serviceProvider
) {
96 return tryGetValueWithKey(SOCKET_TYPE
, serviceProvider
.socket_type
);
103 '58': 'IPPROTO_ICMPV6'
107 * Returns protocol type of a layered service provider as a string.
109 ModulesView
.getLayeredServiceProviderProtocolType
=
110 function(serviceProvider
) {
111 return tryGetValueWithKey(PROTOCOL_TYPE
, serviceProvider
.socket_protocol
);
114 var NAMESPACE_PROVIDER_PTYPE
= {
125 * Returns the type of a namespace provider as a string.
127 ModulesView
.getNamespaceProviderType = function(namespaceProvider
) {
128 return tryGetValueWithKey(NAMESPACE_PROVIDER_PTYPE
,
129 namespaceProvider
.type
);