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 return this.onExtensionInfoChanged(data.extensionInfo) ||
56 this.onServiceProvidersChanged(data.serviceProviders);
59 onExtensionInfoChanged: function(extensionInfo) {
60 var input = new JsEvalContext({extensionInfo: extensionInfo});
61 jstProcess(input, $(ModulesView.EXTENSION_INFO_ID));
62 return !!extensionInfo;
65 onServiceProvidersChanged: function(serviceProviders) {
66 var input = new JsEvalContext(serviceProviders);
67 jstProcess(input, $(ModulesView.WINDOWS_SERVICE_PROVIDERS_ID));
68 return !!serviceProviders;
73 * Returns type of a layered service provider.
75 ModulesView.getLayeredServiceProviderType = function(serviceProvider) {
76 if (serviceProvider.chain_length == 0)
78 if (serviceProvider.chain_length == 1)
92 * Returns socket type of a layered service provider as a string.
94 ModulesView.getLayeredServiceProviderSocketType = function(serviceProvider) {
95 return tryGetValueWithKey(SOCKET_TYPE, serviceProvider.socket_type);
102 '58': 'IPPROTO_ICMPV6'
106 * Returns protocol type of a layered service provider as a string.
108 ModulesView.getLayeredServiceProviderProtocolType =
109 function(serviceProvider) {
110 return tryGetValueWithKey(PROTOCOL_TYPE, serviceProvider.socket_protocol);
113 var NAMESPACE_PROVIDER_PTYPE = {
124 * Returns the type of a namespace provider as a string.
126 ModulesView.getNamespaceProviderType = function(namespaceProvider) {
127 return tryGetValueWithKey(NAMESPACE_PROVIDER_PTYPE,
128 namespaceProvider.type);