| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * This view displays information on the proxy setup: | 6 * This view displays information on the proxy setup: |
| 7 * | 7 * |
| 8 * - Shows the current proxy settings. | 8 * - Shows the current proxy settings. |
| 9 * - Has a button to reload these settings. | 9 * - Has a button to reload these settings. |
| 10 * - Shows the log entries for the most recent INIT_PROXY_RESOLVER source |
| 10 * - Shows the list of proxy hostnames that are cached as "bad". | 11 * - Shows the list of proxy hostnames that are cached as "bad". |
| 11 * - Has a button to clear the cached bad proxies. | 12 * - Has a button to clear the cached bad proxies. |
| 12 * | 13 * |
| 13 * @constructor | 14 * @constructor |
| 14 */ | 15 */ |
| 15 function ProxyView(mainBoxId, | 16 function ProxyView(mainBoxId, |
| 16 originalSettingsDivId, | 17 originalSettingsDivId, |
| 17 effectiveSettingsDivId, | 18 effectiveSettingsDivId, |
| 18 reloadSettingsButtonId, | 19 reloadSettingsButtonId, |
| 19 badProxiesTbodyId, | 20 badProxiesTbodyId, |
| 20 clearBadProxiesButtonId) { | 21 clearBadProxiesButtonId, |
| 22 proxyResolverLogPreId) { |
| 21 DivView.call(this, mainBoxId); | 23 DivView.call(this, mainBoxId); |
| 22 | 24 |
| 25 this.latestProxySourceEntries_ = null; |
| 26 this.latestProxySourceId_ = 0; |
| 27 |
| 23 // Hook up the UI components. | 28 // Hook up the UI components. |
| 24 this.originalSettingsDiv_ = document.getElementById(originalSettingsDivId); | 29 this.originalSettingsDiv_ = document.getElementById(originalSettingsDivId); |
| 25 this.effectiveSettingsDiv_ = | 30 this.effectiveSettingsDiv_ = |
| 26 document.getElementById(effectiveSettingsDivId); | 31 document.getElementById(effectiveSettingsDivId); |
| 32 this.proxyResolverLogPre_ = document.getElementById(proxyResolverLogPreId); |
| 27 this.badProxiesTbody_ = document.getElementById(badProxiesTbodyId); | 33 this.badProxiesTbody_ = document.getElementById(badProxiesTbodyId); |
| 28 | 34 |
| 29 var reloadSettingsButton = document.getElementById(reloadSettingsButtonId); | 35 var reloadSettingsButton = document.getElementById(reloadSettingsButtonId); |
| 30 var clearBadProxiesButton = document.getElementById(clearBadProxiesButtonId); | 36 var clearBadProxiesButton = document.getElementById(clearBadProxiesButtonId); |
| 31 | 37 |
| 32 clearBadProxiesButton.onclick = g_browser.sendClearBadProxies.bind(g_browser); | 38 clearBadProxiesButton.onclick = g_browser.sendClearBadProxies.bind(g_browser); |
| 33 reloadSettingsButton.onclick = | 39 reloadSettingsButton.onclick = |
| 34 g_browser.sendReloadProxySettings.bind(g_browser); | 40 g_browser.sendReloadProxySettings.bind(g_browser); |
| 35 | 41 |
| 36 // Register to receive proxy information as it changes. | 42 // Register to receive proxy information as it changes. |
| 37 g_browser.addProxySettingsObserver(this); | 43 g_browser.addProxySettingsObserver(this); |
| 38 g_browser.addBadProxiesObserver(this); | 44 g_browser.addBadProxiesObserver(this); |
| 45 g_browser.addLogObserver(this); |
| 39 } | 46 } |
| 40 | 47 |
| 41 inherits(ProxyView, DivView); | 48 inherits(ProxyView, DivView); |
| 42 | 49 |
| 43 ProxyView.prototype.onProxySettingsChanged = function(proxySettings) { | 50 ProxyView.prototype.onProxySettingsChanged = function(proxySettings) { |
| 44 var original = proxySettings.original; | 51 var original = proxySettings.original; |
| 45 var effective = proxySettings.effective; | 52 var effective = proxySettings.effective; |
| 46 | 53 |
| 47 // Both |original| and |effective| are dictionaries describing the settings. | 54 // Both |original| and |effective| are dictionaries describing the settings. |
| 48 this.originalSettingsDiv_.innerHTML = '' | 55 this.originalSettingsDiv_.innerHTML = '' |
| (...skipping 13 matching lines...) Expand all Loading... |
| 62 | 69 |
| 63 var tr = addNode(this.badProxiesTbody_, 'tr'); | 70 var tr = addNode(this.badProxiesTbody_, 'tr'); |
| 64 | 71 |
| 65 var nameCell = addNode(tr, 'td'); | 72 var nameCell = addNode(tr, 'td'); |
| 66 var badUntilCell = addNode(tr, 'td'); | 73 var badUntilCell = addNode(tr, 'td'); |
| 67 | 74 |
| 68 addTextNode(nameCell, entry.proxy_uri); | 75 addTextNode(nameCell, entry.proxy_uri); |
| 69 addTextNode(badUntilCell, badUntilDate.toLocaleString()); | 76 addTextNode(badUntilCell, badUntilDate.toLocaleString()); |
| 70 } | 77 } |
| 71 }; | 78 }; |
| 79 |
| 80 ProxyView.prototype.onLogEntryAdded = function(logEntry) { |
| 81 if (logEntry.source.type != LogSourceType.INIT_PROXY_RESOLVER || |
| 82 this.latestProxySourceId_ > logEntry.source.id) { |
| 83 return; |
| 84 } |
| 85 |
| 86 if (logEntry.source.id > this.latestProxySourceId_) { |
| 87 this.latestProxySourceId_ = logEntry.source.id; |
| 88 this.latestProxySourceEntries_ = []; |
| 89 } |
| 90 |
| 91 this.latestProxySourceEntries_.push(logEntry); |
| 92 this.proxyResolverLogPre_.innerHTML = ''; |
| 93 addTextNode(this.proxyResolverLogPre_, |
| 94 PrintSourceEntriesAsText(this.latestProxySourceEntries_, false)); |
| 95 }; |
| 96 |
| 97 /** |
| 98 * Clears the display of and log entries for the last proxy lookup. |
| 99 */ |
| 100 ProxyView.prototype.clearLog_ = function() { |
| 101 this.latestProxySourceEntries_ = []; |
| 102 // Prevents display of partial logs. |
| 103 ++this.latestProxySourceId_; |
| 104 |
| 105 this.proxyResolverLogPre_.innerHTML = ''; |
| 106 addTextNode(this.proxyResolverLogPre_, 'Deleted.'); |
| 107 }; |
| 108 |
| 109 ProxyView.prototype.onLogEntriesDeleted = function(sourceIds) { |
| 110 if (sourceIds.indexOf(this.latestProxySourceId_) != -1) |
| 111 this.clearLog_(); |
| 112 }; |
| 113 |
| 114 ProxyView.prototype.onAllLogEntriesDeleted = function() { |
| 115 this.clearLog_(); |
| 116 }; |
| OLD | NEW |