OLD | NEW |
(Empty) | |
| 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 |
| 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 list of proxy hostnames that are cached as "bad". |
| 11 * - Has a button to clear the cached bad proxies. |
| 12 * |
| 13 * @constructor |
| 14 */ |
| 15 function ProxyView(mainBoxId, |
| 16 currentConfigDivId, |
| 17 reloadSettingsButtonId, |
| 18 badProxiesTbodyId, |
| 19 clearBadProxiesButtonId) { |
| 20 DivView.call(this, mainBoxId); |
| 21 |
| 22 // Hook up the UI components. |
| 23 this.currentConfigDiv_ = document.getElementById(currentConfigDivId); |
| 24 this.badProxiesTbody_ = document.getElementById(badProxiesTbodyId); |
| 25 |
| 26 var reloadSettingsButton = document.getElementById(reloadSettingsButtonId); |
| 27 var clearBadProxiesButton = document.getElementById(clearBadProxiesButtonId); |
| 28 |
| 29 clearBadProxiesButton.onclick = g_browser.sendClearBadProxies.bind(g_browser); |
| 30 reloadSettingsButton.onclick = |
| 31 g_browser.sendReloadProxySettings.bind(g_browser); |
| 32 |
| 33 // Register to receive proxy information as it changes. |
| 34 g_browser.addProxySettingsObserver(this); |
| 35 g_browser.addBadProxiesObsever(this); |
| 36 } |
| 37 |
| 38 inherits(ProxyView, DivView); |
| 39 |
| 40 ProxyView.prototype.onProxySettingsChanged = function(proxySettings) { |
| 41 // |proxySettings| is a formatted string describing the settings. |
| 42 this.currentConfigDiv_.innerHTML = '' |
| 43 addTextNode(this.currentConfigDiv_, proxySettings); |
| 44 }; |
| 45 |
| 46 ProxyView.prototype.onBadProxiesChanged = function(badProxies) { |
| 47 this.badProxiesTbody_.innerHTML = ''; |
| 48 |
| 49 // Add a table row for each bad proxy entry. |
| 50 for (var i = 0; i < badProxies.length; ++i) { |
| 51 var entry = badProxies[i]; |
| 52 var badUntilDate = g_browser.convertTimeTicksToDate(entry.bad_until); |
| 53 |
| 54 var tr = addNode(this.badProxiesTbody_, 'tr'); |
| 55 |
| 56 var nameCell = addNode(tr, 'td'); |
| 57 var badUntilCell = addNode(tr, 'td'); |
| 58 |
| 59 addTextNode(nameCell, entry.proxy_uri); |
| 60 addTextNode(badUntilCell, badUntilDate.toLocaleString()); |
| 61 } |
| 62 }; |
OLD | NEW |