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

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: Further clean-up thanks to eroman. 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')
eroman 2014/05/12 22:08:21 Can you delete these three "ifs" now?
palmer 2014/05/13 00:21:31 Oh, weird, I thought I had. Done.
159 result.public_key_hashes = ''; 133 result.public_key_hashes = '';
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 kStaticHashKeys = [
166 if (result.public_key_hashes) 140 'public_key_hashes', 'preloaded_spki_hashes', 'static_spki_hashes'
167 hashes.push(result.public_key_hashes); 141 ];
168 if (result.preloaded_spki_hashes)
169 hashes.push(result.preloaded_spki_hashes);
170 if (result.static_spki_hashes)
171 hashes.push(result.static_spki_hashes);
172 142
173 t.textContent = hashes.join(','); 143 var staticHashes = [];
174 b = addNode(this.queryOutputDiv_, 'br'); 144 for (var i = 0; i < kStaticHashKeys.length; ++i) {
145 var staticHashValue = result[kStaticHashKeys[i]];
146 if (staticHashValue != undefined && staticHashValue != '')
147 staticHashes.push(staticHashValue);
148 }
175 149
176 addTextNode(this.queryOutputDiv_, ' dynamic_upgrade_mode: '); 150 for (var i = 0; i < keys.length; ++i) {
177 t = addNodeWithText(this.queryOutputDiv_, 'tt', 151 var key = keys[i];
178 modeToString(result.dynamic_upgrade_mode)); 152 addTextNode(this.queryOutputDiv_, ' ' + key + ': ');
179 b = addNode(this.queryOutputDiv_, 'br');
180 153
181 addTextNode(this.queryOutputDiv_, ' dynamic_sts_include_subdomains: '); 154 // If there are no static_hashes, do not make it seem like there is a
182 t = addNodeWithText(this.queryOutputDiv_, 'tt', 155 // static PKP policy in place.
183 result.dynamic_sts_include_subdomains || ''); 156 if (staticHashes.length == 0 && key.indexOf('static_pkp_') == 0) {
184 b = addNode(this.queryOutputDiv_, 'br'); 157 addNode(this.queryOutputDiv_, 'br');
158 continue;
159 }
185 160
186 addTextNode(this.queryOutputDiv_, ' dynamic_pkp_include_subdomains: '); 161 if (key === 'static_spki_hashes') {
187 t = addNodeWithText(this.queryOutputDiv_, 'tt', 162 addNodeWithText(this.queryOutputDiv_, 'tt', staticHashes.join(','));
188 result.dynamic_pkp_include_subdomains || ''); 163 } else if (key.indexOf('_upgrade_mode') >= 0) {
189 b = addNode(this.queryOutputDiv_, 'br'); 164 addNodeWithText(this.queryOutputDiv_, 'tt',
190 165 modeToString(result[key]));
191 addTextNode(this.queryOutputDiv_, ' dynamic_sts_observed: '); 166 } else {
192 t = addNodeWithText(this.queryOutputDiv_, 'tt', 167 var value = result[key];
eroman 2014/05/12 22:08:21 consider moving this below the definition of "var
palmer 2014/05/13 00:21:31 Done.
193 result.dynamic_sts_observed || ''); 168 addNodeWithText(this.queryOutputDiv_, 'tt',
194 b = addNode(this.queryOutputDiv_, 'br'); 169 value == undefined ? '' : value);
195 170 }
196 addTextNode(this.queryOutputDiv_, ' dynamic_pkp_observed: '); 171 addNode(this.queryOutputDiv_, 'br');
197 t = addNodeWithText(this.queryOutputDiv_, 'tt', 172 }
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 173
205 yellowFade(this.queryOutputDiv_); 174 yellowFade(this.queryOutputDiv_);
206 } 175 }
207 }; 176 };
208 177
209 function modeToString(m) { 178 function modeToString(m) {
210 // These numbers must match those in 179 // These numbers must match those in
211 // TransportSecurityState::DomainState::UpgradeMode. 180 // TransportSecurityState::DomainState::UpgradeMode.
212 if (m == 0) { 181 if (m == 0) {
213 return 'STRICT'; 182 return 'STRICT';
214 } else if (m == 1) { 183 } else if (m == 1) {
215 return 'OPPORTUNISTIC'; 184 return 'OPPORTUNISTIC';
216 } else { 185 } else {
217 return 'UNKNOWN'; 186 return 'UNKNOWN';
218 } 187 }
219 } 188 }
220 189
221 function yellowFade(element) { 190 function yellowFade(element) {
222 element.style.webkitTransitionProperty = 'background-color'; 191 element.style.webkitTransitionProperty = 'background-color';
223 element.style.webkitTransitionDuration = '0'; 192 element.style.webkitTransitionDuration = '0';
224 element.style.backgroundColor = '#fffccf'; 193 element.style.backgroundColor = '#fffccf';
225 setTimeout(function() { 194 setTimeout(function() {
226 element.style.webkitTransitionDuration = '1000ms'; 195 element.style.webkitTransitionDuration = '1000ms';
227 element.style.backgroundColor = '#fff'; 196 element.style.backgroundColor = '#fff';
228 }, 0); 197 }, 0);
229 } 198 }
230 199
231 return HSTSView; 200 return HSTSView;
232 })(); 201 })();
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