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

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

Issue 280043003: Clean up the JavaScript for net-internals/#hsts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, hoping the bots stop acting like goats. Created 6 years, 7 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 | « no previous file | 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 * HSTS is HTTPS Strict Transport Security: a way for sites to elect to always 6 * HSTS is HTTPS Strict Transport Security: a way for sites to elect to always
7 * use HTTPS. See http://dev.chromium.org/sts 7 * use HTTPS. See http://dev.chromium.org/sts
8 * 8 *
9 * This UI allows a user to query and update the browser's list of HSTS domains. 9 * This UI allows a user to query and update the browser's list of HSTS domains.
10 * It also allows users to query and update the browser's list of public key 10 * It also allows users to query and update the browser's list of public key
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 if (result.result == false) { 110 if (result.result == false) {
111 this.queryOutputDiv_.innerHTML = '<b>Not found</b>'; 111 this.queryOutputDiv_.innerHTML = '<b>Not found</b>';
112 yellowFade(this.queryOutputDiv_); 112 yellowFade(this.queryOutputDiv_);
113 return; 113 return;
114 } 114 }
115 115
116 this.queryOutputDiv_.innerHTML = ''; 116 this.queryOutputDiv_.innerHTML = '';
117 117
118 var s = addNode(this.queryOutputDiv_, 'span'); 118 var s = addNode(this.queryOutputDiv_, 'span');
119 s.innerHTML = '<b>Found:</b><br/>'; 119 s.innerHTML = '<b>Found:</b><br/>';
120 var t;
121 var b;
122 120
123 addTextNode(this.queryOutputDiv_, ' domain: '); 121 var keys = [
124 t = addNodeWithText(this.queryOutputDiv_, 'tt', result.domain); 122 'domain', 'static_upgrade_mode', 'static_sts_include_subdomains',
125 b = addNode(this.queryOutputDiv_, 'br'); 123 'static_pkp_include_subdomains', 'static_sts_observed',
126 124 'static_pkp_observed', 'static_spki_hashes', 'dynamic_upgrade_mode',
127 addTextNode(this.queryOutputDiv_, ' static_upgrade_mode: '); 125 'dynamic_sts_include_subdomains', 'dynamic_pkp_include_subdomains',
128 t = addNodeWithText(this.queryOutputDiv_, 'tt', 126 'dynamic_sts_observed', 'dynamic_pkp_observed', 'dynamic_spki_hashes'
129 modeToString(result.static_upgrade_mode)); 127 ];
130 b = addNode(this.queryOutputDiv_, 'br');
131
132 addTextNode(this.queryOutputDiv_, ' static_sts_include_subdomains: ');
133 t = addNodeWithText(this.queryOutputDiv_, 'tt',
134 result.static_sts_include_subdomains);
135 b = addNode(this.queryOutputDiv_, 'br');
136
137 addTextNode(this.queryOutputDiv_, ' static_pkp_include_subdomains: ');
138 t = addNodeWithText(this.queryOutputDiv_, 'tt',
139 result.static_pkp_include_subdomains);
140 b = addNode(this.queryOutputDiv_, 'br');
141
142 addTextNode(this.queryOutputDiv_, ' static_sts_observed: ');
143 t = addNodeWithText(this.queryOutputDiv_, 'tt',
144 result.static_sts_observed);
145 b = addNode(this.queryOutputDiv_, 'br');
146
147 addTextNode(this.queryOutputDiv_, ' static_pkp_observed: ');
148 t = addNodeWithText(this.queryOutputDiv_, 'tt',
149 result.static_pkp_observed);
150 b = addNode(this.queryOutputDiv_, 'br');
151
152 addTextNode(this.queryOutputDiv_, ' static_spki_hashes: ');
153 t = addNode(this.queryOutputDiv_, 'tt');
154 128
155 // |public_key_hashes| is an old synonym for what is now 129 // |public_key_hashes| is an old synonym for what is now
156 // |preloaded_spki_hashes|, which in turn is a legacy synonym for 130 // |preloaded_spki_hashes|, which in turn is a legacy synonym for
157 // |static_spki_hashes|. 131 // |static_spki_hashes|.
158 if (typeof result.public_key_hashes === 'undefined') 132 if (typeof result.public_key_hashes === 'undefined')
159 result.public_key_hashes = ''; 133 result.public_key_hashes = '';
eroman 2014/05/12 21:29:13 Modifying the "result" object for display is bad f
palmer 2014/05/12 21:46:51 Done.
160 if (typeof result.preloaded_spki_hashes === 'undefined') 134 if (typeof result.preloaded_spki_hashes === 'undefined')
161 result.preloaded_spki_hashes = ''; 135 result.preloaded_spki_hashes = '';
162 if (typeof result.static_spki_hashes === 'undefined') 136 if (typeof result.static_spki_hashes === 'undefined')
163 result.static_spki_hashes = ''; 137 result.static_spki_hashes = '';
164 138
165 var hashes = []; 139 var staticHashes = [];
eroman 2014/05/12 21:29:13 While you are cleaning up, this can be merged with
palmer 2014/05/12 21:46:51 Done.
166 if (result.public_key_hashes) 140 if (result.public_key_hashes)
167 hashes.push(result.public_key_hashes); 141 staticHashes.push(result.public_key_hashes);
168 if (result.preloaded_spki_hashes) 142 if (result.preloaded_spki_hashes)
169 hashes.push(result.preloaded_spki_hashes); 143 staticHashes.push(result.preloaded_spki_hashes);
170 if (result.static_spki_hashes) 144 if (result.static_spki_hashes)
171 hashes.push(result.static_spki_hashes); 145 staticHashes.push(result.static_spki_hashes);
172 146
173 t.textContent = hashes.join(','); 147 for (var i = 0; i < keys.length; ++i) {
174 b = addNode(this.queryOutputDiv_, 'br'); 148 var key = keys[i];
149 addTextNode(this.queryOutputDiv_, ' ' + key + ': ');
175 150
176 addTextNode(this.queryOutputDiv_, ' dynamic_upgrade_mode: '); 151 // If there are no static_hashes, do not make it seem like there is a
177 t = addNodeWithText(this.queryOutputDiv_, 'tt', 152 // static PKP policy in place.
178 modeToString(result.dynamic_upgrade_mode)); 153 if (staticHashes.length == 0 && key.indexOf('static_pkp_') == 0) {
179 b = addNode(this.queryOutputDiv_, 'br'); 154 addNode(this.queryOutputDiv_, 'br');
155 continue;
156 }
180 157
181 addTextNode(this.queryOutputDiv_, ' dynamic_sts_include_subdomains: '); 158 if (key === 'static_spki_hashes') {
182 t = addNodeWithText(this.queryOutputDiv_, 'tt', 159 addNodeWithText(this.queryOutputDiv_, 'tt', staticHashes.join(','));
183 result.dynamic_sts_include_subdomains || ''); 160 } else if (key.indexOf('_upgrade_mode') >= 0) {
184 b = addNode(this.queryOutputDiv_, 'br'); 161 addNodeWithText(this.queryOutputDiv_, 'tt',
185 162 modeToString(result[key]));
186 addTextNode(this.queryOutputDiv_, ' dynamic_pkp_include_subdomains: '); 163 } else {
187 t = addNodeWithText(this.queryOutputDiv_, 'tt', 164 addNodeWithText(this.queryOutputDiv_, 'tt', result[key] || '');
eroman 2014/05/12 21:29:13 Be aware that this pattern (a || '') will cause a
palmer 2014/05/12 21:46:51 Done.
188 result.dynamic_pkp_include_subdomains || ''); 165 }
189 b = addNode(this.queryOutputDiv_, 'br'); 166 addNode(this.queryOutputDiv_, 'br');
190 167 }
191 addTextNode(this.queryOutputDiv_, ' dynamic_sts_observed: ');
192 t = addNodeWithText(this.queryOutputDiv_, 'tt',
193 result.dynamic_sts_observed || '');
194 b = addNode(this.queryOutputDiv_, 'br');
195
196 addTextNode(this.queryOutputDiv_, ' dynamic_pkp_observed: ');
197 t = addNodeWithText(this.queryOutputDiv_, 'tt',
198 result.dynamic_pkp_observed || '');
199 b = addNode(this.queryOutputDiv_, 'br');
200
201 addTextNode(this.queryOutputDiv_, ' dynamic_spki_hashes: ');
202 t = addNodeWithText(this.queryOutputDiv_, 'tt',
203 result.dynamic_spki_hashes || '');
204 168
205 yellowFade(this.queryOutputDiv_); 169 yellowFade(this.queryOutputDiv_);
206 } 170 }
207 }; 171 };
208 172
209 function modeToString(m) { 173 function modeToString(m) {
210 // These numbers must match those in 174 // These numbers must match those in
211 // TransportSecurityState::DomainState::UpgradeMode. 175 // TransportSecurityState::DomainState::UpgradeMode.
212 if (m == 0) { 176 if (m == 0) {
213 return 'STRICT'; 177 return 'STRICT';
214 } else if (m == 1) { 178 } else if (m == 1) {
215 return 'OPPORTUNISTIC'; 179 return 'OPPORTUNISTIC';
216 } else { 180 } else {
217 return 'UNKNOWN'; 181 return 'UNKNOWN';
218 } 182 }
219 } 183 }
220 184
221 function yellowFade(element) { 185 function yellowFade(element) {
222 element.style.webkitTransitionProperty = 'background-color'; 186 element.style.webkitTransitionProperty = 'background-color';
223 element.style.webkitTransitionDuration = '0'; 187 element.style.webkitTransitionDuration = '0';
224 element.style.backgroundColor = '#fffccf'; 188 element.style.backgroundColor = '#fffccf';
225 setTimeout(function() { 189 setTimeout(function() {
226 element.style.webkitTransitionDuration = '1000ms'; 190 element.style.webkitTransitionDuration = '1000ms';
227 element.style.backgroundColor = '#fff'; 191 element.style.backgroundColor = '#fff';
228 }, 0); 192 }, 0);
229 } 193 }
230 194
231 return HSTSView; 195 return HSTSView;
232 })(); 196 })();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698