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

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

Issue 12549010: [net] Add an informational bubble to about:net-internals#proxy when using a single SOCKS v5 proxy s… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reword comment to be less lame Created 7 years, 9 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
« no previous file with comments | « chrome/browser/resources/net_internals/proxy_view.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 list of proxy hostnames that are cached as "bad". 10 * - Shows the list of proxy hostnames that are cached as "bad".
(...skipping 28 matching lines...) Expand all
39 // ID for special HTML element in category_tabs.html 39 // ID for special HTML element in category_tabs.html
40 ProxyView.TAB_HANDLE_ID = 'tab-handle-proxy'; 40 ProxyView.TAB_HANDLE_ID = 'tab-handle-proxy';
41 41
42 // IDs for special HTML elements in proxy_view.html 42 // IDs for special HTML elements in proxy_view.html
43 ProxyView.MAIN_BOX_ID = 'proxy-view-tab-content'; 43 ProxyView.MAIN_BOX_ID = 'proxy-view-tab-content';
44 ProxyView.ORIGINAL_SETTINGS_DIV_ID = 'proxy-view-original-settings'; 44 ProxyView.ORIGINAL_SETTINGS_DIV_ID = 'proxy-view-original-settings';
45 ProxyView.EFFECTIVE_SETTINGS_DIV_ID = 'proxy-view-effective-settings'; 45 ProxyView.EFFECTIVE_SETTINGS_DIV_ID = 'proxy-view-effective-settings';
46 ProxyView.RELOAD_SETTINGS_BUTTON_ID = 'proxy-view-reload-settings'; 46 ProxyView.RELOAD_SETTINGS_BUTTON_ID = 'proxy-view-reload-settings';
47 ProxyView.BAD_PROXIES_TBODY_ID = 'proxy-view-bad-proxies-tbody'; 47 ProxyView.BAD_PROXIES_TBODY_ID = 'proxy-view-bad-proxies-tbody';
48 ProxyView.CLEAR_BAD_PROXIES_BUTTON_ID = 'proxy-view-clear-bad-proxies'; 48 ProxyView.CLEAR_BAD_PROXIES_BUTTON_ID = 'proxy-view-clear-bad-proxies';
49 ProxyView.SOCKS_HINTS_DIV_ID = 'proxy-view-socks-hints';
50 ProxyView.SOCKS_HINTS_FLAG_DIV_ID = 'proxy-view-socks-hints-flag';
49 51
50 cr.addSingletonGetter(ProxyView); 52 cr.addSingletonGetter(ProxyView);
51 53
52 ProxyView.prototype = { 54 ProxyView.prototype = {
53 // Inherit the superclass's methods. 55 // Inherit the superclass's methods.
54 __proto__: superClass.prototype, 56 __proto__: superClass.prototype,
55 57
56 onLoadLogFinish: function(data) { 58 onLoadLogFinish: function(data) {
57 return this.onProxySettingsChanged(data.proxySettings) && 59 return this.onProxySettingsChanged(data.proxySettings) &&
58 this.onBadProxiesChanged(data.badProxies); 60 this.onBadProxiesChanged(data.badProxies);
59 }, 61 },
60 62
61 onProxySettingsChanged: function(proxySettings) { 63 onProxySettingsChanged: function(proxySettings) {
62 // Both |original| and |effective| are dictionaries describing the 64 // Both |original| and |effective| are dictionaries describing the
63 // settings. 65 // settings.
64 $(ProxyView.ORIGINAL_SETTINGS_DIV_ID).innerHTML = ''; 66 $(ProxyView.ORIGINAL_SETTINGS_DIV_ID).innerHTML = '';
65 $(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerHTML = ''; 67 $(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerHTML = '';
66 68
67 if (!proxySettings) 69 if (!proxySettings)
mmenke 2013/03/07 20:16:57 Should we be hiding the hints here?
eroman 2013/03/07 20:23:32 Good point. Yes we should.
68 return false; 70 return false;
69 71
70 var original = proxySettings.original; 72 var original = proxySettings.original;
71 var effective = proxySettings.effective; 73 var effective = proxySettings.effective;
72 74
73 $(ProxyView.ORIGINAL_SETTINGS_DIV_ID).innerText = 75 $(ProxyView.ORIGINAL_SETTINGS_DIV_ID).innerText =
74 proxySettingsToString(original); 76 proxySettingsToString(original);
75 $(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerText = 77 $(ProxyView.EFFECTIVE_SETTINGS_DIV_ID).innerText =
76 proxySettingsToString(effective); 78 proxySettingsToString(effective);
79
80 this.updateSocksHints_(effective);
81
77 return true; 82 return true;
78 }, 83 },
79 84
80 onBadProxiesChanged: function(badProxies) { 85 onBadProxiesChanged: function(badProxies) {
81 $(ProxyView.BAD_PROXIES_TBODY_ID).innerHTML = ''; 86 $(ProxyView.BAD_PROXIES_TBODY_ID).innerHTML = '';
82 87
83 if (!badProxies) 88 if (!badProxies)
84 return false; 89 return false;
85 90
86 // Add a table row for each bad proxy entry. 91 // Add a table row for each bad proxy entry.
87 for (var i = 0; i < badProxies.length; ++i) { 92 for (var i = 0; i < badProxies.length; ++i) {
88 var entry = badProxies[i]; 93 var entry = badProxies[i];
89 var badUntilDate = timeutil.convertTimeTicksToDate(entry.bad_until); 94 var badUntilDate = timeutil.convertTimeTicksToDate(entry.bad_until);
90 95
91 var tr = addNode($(ProxyView.BAD_PROXIES_TBODY_ID), 'tr'); 96 var tr = addNode($(ProxyView.BAD_PROXIES_TBODY_ID), 'tr');
92 97
93 var nameCell = addNode(tr, 'td'); 98 var nameCell = addNode(tr, 'td');
94 var badUntilCell = addNode(tr, 'td'); 99 var badUntilCell = addNode(tr, 'td');
95 100
96 addTextNode(nameCell, entry.proxy_uri); 101 addTextNode(nameCell, entry.proxy_uri);
97 timeutil.addNodeWithDate(badUntilCell, badUntilDate); 102 timeutil.addNodeWithDate(badUntilCell, badUntilDate);
98 } 103 }
99 return true; 104 return true;
105 },
106
107 updateSocksHints_: function(proxySettings) {
108 setNodeDisplay($(ProxyView.SOCKS_HINTS_DIV_ID), false);
109
110 var socksProxy = getSocks5Proxy_(proxySettings.single_proxy);
111 if (!socksProxy)
112 return;
113
114 // Suggest a recommended --host-resolver-rules.
115 // NOTE: This does not compensate for any proxy bypass rules. If the
116 // proxy settings include proxy bypasses the user may need to expand the
117 // exclusions for host resolving.
mmenke 2013/03/07 20:16:57 If this isn't a TODO, should this be in the displa
eroman 2013/03/07 20:23:32 I considered just implementing this, however the s
mmenke 2013/03/07 20:26:06 That sounds reasonable. But I was actually thinki
118 var hostResolverRules = 'MAP * ~NOTFOUND , EXCLUDE ' + socksProxy.host;
119 var hostResolverRulesFlag = '--host-resolver-rules="' +
120 hostResolverRules + '"';
121
122 // TODO(eroman): On Linux the ClientInfo.command_line is wrong in that it
123 // doesn't include any quotes around the parameters. This means the
124 // string search above is going to fail :(
125 if (ClientInfo.command_line &&
126 ClientInfo.command_line.indexOf(hostResolverRulesFlag) != -1) {
127 // Chrome is already using the suggested resolver rules.
128 return;
129 }
130
131 $(ProxyView.SOCKS_HINTS_FLAG_DIV_ID).innerText = hostResolverRulesFlag;
132 setNodeDisplay($(ProxyView.SOCKS_HINTS_DIV_ID), true);
100 } 133 }
101 }; 134 };
102 135
136 function getSocks5Proxy_(proxyString) {
137 var pattern = /^socks5:\/\/(.*)$/;
138 var matches = pattern.exec(proxyString);
139
140 if (!matches)
141 return undefined;
mmenke 2013/03/07 20:16:57 I think returning null is a bit more natural.
eroman 2013/03/07 20:23:32 Will do.
142
143 var hostPortString = matches[1];
144
145 matches = /^(.*):(\d+)$/.exec(hostPortString);
146 if (!matches)
147 return undefined;
148
149 var result = {host: matches[1], port: matches[2]};
150
151 // Strip brackets off of IPv6 literals.
152 matches = /^\[(.*)\]$/.exec(result.host);
153 if (matches)
154 result.host = matches[1];
155
156 return result;
157 }
158
103 return ProxyView; 159 return ProxyView;
104 })(); 160 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/net_internals/proxy_view.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698