Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/browser/resources/net_internals/proxyview.js

Issue 7531005: Rename the net_internals file names to include hyphens. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add some missing files Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 /**
6 * This view displays information on the proxy setup:
7 *
8 * - Shows the current proxy settings.
9 * - Has a button to reload these settings.
10 * - Shows the log entries for the most recent INIT_PROXY_RESOLVER source
11 * - Shows the list of proxy hostnames that are cached as "bad".
12 * - Has a button to clear the cached bad proxies.
13 *
14 * @constructor
15 */
16 function ProxyView() {
17 const mainBoxId = 'proxyTabContent';
18 const originalSettingsDivId = 'proxyOriginalSettings';
19 const effectiveSettingsDivId = 'proxyEffectiveSettings';
20 const reloadSettingsButtonId = 'proxyReloadSettings';
21 const badProxiesTbodyId = 'badProxiesTableBody';
22 const clearBadProxiesButtonId = 'clearBadProxies';
23 const proxyResolverLogPreId = 'proxyResolverLog';
24
25 DivView.call(this, mainBoxId);
26
27 this.latestProxySourceId_ = 0;
28
29 // Hook up the UI components.
30 this.originalSettingsDiv_ = $(originalSettingsDivId);
31 this.effectiveSettingsDiv_ = $(effectiveSettingsDivId);
32 this.proxyResolverLogPre_ = $(proxyResolverLogPreId);
33 this.badProxiesTbody_ = $(badProxiesTbodyId);
34
35 var reloadSettingsButton = $(reloadSettingsButtonId);
36 var clearBadProxiesButton = $(clearBadProxiesButtonId);
37
38 clearBadProxiesButton.onclick = g_browser.sendClearBadProxies.bind(g_browser);
39 reloadSettingsButton.onclick =
40 g_browser.sendReloadProxySettings.bind(g_browser);
41
42 // Register to receive proxy information as it changes.
43 g_browser.addProxySettingsObserver(this);
44 g_browser.addBadProxiesObserver(this);
45 g_browser.sourceTracker.addObserver(this);
46 }
47
48 inherits(ProxyView, DivView);
49
50 ProxyView.prototype.onLoadLogStart = function(data) {
51 // Need to reset this so the latest proxy source from the dump can be
52 // identified when the log entries are loaded.
53 this.latestProxySourceId_ = 0;
54 };
55
56 ProxyView.prototype.onLoadLogFinish = function(data, tabData) {
57 // It's possible that the last INIT_PROXY_RESOLVER source was deleted from the
58 // log, but earlier sources remain. When that happens, clear the list of
59 // entries here, to avoid displaying misleading information.
60 if (tabData != this.latestProxySourceId_)
61 this.clearLog_();
62 return this.onProxySettingsChanged(data.proxySettings) &&
63 this.onBadProxiesChanged(data.badProxies);
64 };
65
66 /**
67 * Save view-specific state.
68 *
69 * Save the greatest seen proxy source id, so we will not incorrectly identify
70 * the log source associated with the current proxy configuration.
71 */
72 ProxyView.prototype.saveState = function() {
73 return this.latestProxySourceId_;
74 };
75
76 ProxyView.prototype.onProxySettingsChanged = function(proxySettings) {
77 // Both |original| and |effective| are dictionaries describing the settings.
78 this.originalSettingsDiv_.innerHTML = '';
79 this.effectiveSettingsDiv_.innerHTML = '';
80
81 if (!proxySettings)
82 return false;
83
84 var original = proxySettings.original;
85 var effective = proxySettings.effective;
86
87 if (!original || !effective)
88 return false;
89
90 addTextNode(this.originalSettingsDiv_, proxySettingsToString(original));
91 addTextNode(this.effectiveSettingsDiv_, proxySettingsToString(effective));
92 return true;
93 };
94
95 ProxyView.prototype.onBadProxiesChanged = function(badProxies) {
96 this.badProxiesTbody_.innerHTML = '';
97
98 if (!badProxies)
99 return false;
100
101 // Add a table row for each bad proxy entry.
102 for (var i = 0; i < badProxies.length; ++i) {
103 var entry = badProxies[i];
104 var badUntilDate = convertTimeTicksToDate(entry.bad_until);
105
106 var tr = addNode(this.badProxiesTbody_, 'tr');
107
108 var nameCell = addNode(tr, 'td');
109 var badUntilCell = addNode(tr, 'td');
110
111 addTextNode(nameCell, entry.proxy_uri);
112 addTextNode(badUntilCell, badUntilDate.toLocaleString());
113 }
114 return true;
115 };
116
117 ProxyView.prototype.onSourceEntryUpdated = function(sourceEntry) {
118 if (sourceEntry.getSourceType() != LogSourceType.INIT_PROXY_RESOLVER ||
119 this.latestProxySourceId_ > sourceEntry.getSourceId()) {
120 return;
121 }
122
123 this.latestProxySourceId_ = sourceEntry.getSourceId();
124
125 this.proxyResolverLogPre_.innerHTML = '';
126 addTextNode(this.proxyResolverLogPre_, sourceEntry.printAsText());
127 };
128
129 /**
130 * Clears the display of and log entries for the last proxy lookup.
131 */
132 ProxyView.prototype.clearLog_ = function() {
133 // Prevents display of partial logs.
134 ++this.latestProxySourceId_;
135
136 this.proxyResolverLogPre_.innerHTML = '';
137 addTextNode(this.proxyResolverLogPre_, 'Deleted.');
138 };
139
140 ProxyView.prototype.onSourceEntriesDeleted = function(sourceIds) {
141 if (sourceIds.indexOf(this.latestProxySourceId_) != -1)
142 this.clearLog_();
143 };
144
145 ProxyView.prototype.onAllSourceEntriesDeleted = function() {
146 this.clearLog_();
147 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698