OLD | NEW |
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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 | 109 |
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>: mode: '; | 119 s.innerHTML = '<b>Found:</b><br/>'; |
| 120 var t; |
| 121 var b; |
120 | 122 |
121 // TODO(palmer): Combine these 2-line pairs into 1: | 123 addTextNode(this.queryOutputDiv_, ' domain: '); |
122 // addNodeWithText(this.queryOutputDiv_, 'tt', results.sts_observed); | 124 t = addNodeWithText(this.queryOutputDiv_, 'tt', result.domain); |
123 var t = addNode(this.queryOutputDiv_, 'tt'); | 125 b = addNode(this.queryOutputDiv_, 'br'); |
124 t.textContent = modeToString(result.mode); | |
125 | 126 |
126 addTextNode(this.queryOutputDiv_, ' sts_include_subdomains:'); | 127 addTextNode(this.queryOutputDiv_, ' static_upgrade_mode: '); |
| 128 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 129 modeToString(result.static_upgrade_mode)); |
| 130 b = addNode(this.queryOutputDiv_, 'br'); |
127 | 131 |
128 t = addNode(this.queryOutputDiv_, 'tt'); | 132 addTextNode(this.queryOutputDiv_, ' static_sts_include_subdomains: '); |
129 t.textContent = result.sts_subdomains; | 133 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 134 result.static_sts_include_subdomains); |
| 135 b = addNode(this.queryOutputDiv_, 'br'); |
130 | 136 |
131 addTextNode(this.queryOutputDiv_, ' pkp_include_subdomains:'); | 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'); |
132 | 141 |
133 t = addNode(this.queryOutputDiv_, 'tt'); | 142 addTextNode(this.queryOutputDiv_, ' static_sts_observed: '); |
134 t.textContent = result.pkp_subdomains; | 143 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 144 result.static_sts_observed); |
| 145 b = addNode(this.queryOutputDiv_, 'br'); |
135 | 146 |
136 addTextNode(this.queryOutputDiv_, ' sts_observed:'); | 147 addTextNode(this.queryOutputDiv_, ' static_pkp_observed: '); |
| 148 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 149 result.static_pkp_observed); |
| 150 b = addNode(this.queryOutputDiv_, 'br'); |
137 | 151 |
138 t = addNode(this.queryOutputDiv_, 'tt'); | 152 addTextNode(this.queryOutputDiv_, ' static_spki_hashes: '); |
139 t.textContent = result.sts_observed; | |
140 | |
141 addTextNode(this.queryOutputDiv_, ' pkp_observed:'); | |
142 | |
143 t = addNode(this.queryOutputDiv_, 'tt'); | |
144 t.textContent = result.pkp_observed; | |
145 | |
146 addTextNode(this.queryOutputDiv_, ' domain:'); | |
147 | |
148 t = addNode(this.queryOutputDiv_, 'tt'); | |
149 t.textContent = result.domain; | |
150 | |
151 addTextNode(this.queryOutputDiv_, ' pubkey_hashes:'); | |
152 | |
153 t = addNode(this.queryOutputDiv_, 'tt'); | 153 t = addNode(this.queryOutputDiv_, 'tt'); |
154 | 154 |
155 // |public_key_hashes| is an old synonym for what is now | 155 // |public_key_hashes| is an old synonym for what is now |
156 // |preloaded_spki_hashes|, which in turn is a legacy synonym for | 156 // |preloaded_spki_hashes|, which in turn is a legacy synonym for |
157 // |static_spki_hashes|. Look for all three, and also for | 157 // |static_spki_hashes|. |
158 // |dynamic_spki_hashes|. | |
159 if (typeof result.public_key_hashes === 'undefined') | 158 if (typeof result.public_key_hashes === 'undefined') |
160 result.public_key_hashes = ''; | 159 result.public_key_hashes = ''; |
161 if (typeof result.preloaded_spki_hashes === 'undefined') | 160 if (typeof result.preloaded_spki_hashes === 'undefined') |
162 result.preloaded_spki_hashes = ''; | 161 result.preloaded_spki_hashes = ''; |
163 if (typeof result.static_spki_hashes === 'undefined') | 162 if (typeof result.static_spki_hashes === 'undefined') |
164 result.static_spki_hashes = ''; | 163 result.static_spki_hashes = ''; |
165 if (typeof result.dynamic_spki_hashes === 'undefined') | |
166 result.dynamic_spki_hashes = ''; | |
167 | 164 |
168 var hashes = []; | 165 var hashes = []; |
169 if (result.public_key_hashes) | 166 if (result.public_key_hashes) |
170 hashes.push(result.public_key_hashes); | 167 hashes.push(result.public_key_hashes); |
171 if (result.preloaded_spki_hashes) | 168 if (result.preloaded_spki_hashes) |
172 hashes.push(result.preloaded_spki_hashes); | 169 hashes.push(result.preloaded_spki_hashes); |
173 if (result.static_spki_hashes) | 170 if (result.static_spki_hashes) |
174 hashes.push(result.static_spki_hashes); | 171 hashes.push(result.static_spki_hashes); |
175 if (result.dynamic_spki_hashes) | |
176 hashes.push(result.dynamic_spki_hashes); | |
177 | 172 |
178 t.textContent = hashes.join(','); | 173 t.textContent = hashes.join(','); |
| 174 b = addNode(this.queryOutputDiv_, 'br'); |
| 175 |
| 176 addTextNode(this.queryOutputDiv_, ' dynamic_upgrade_mode: '); |
| 177 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 178 modeToString(result.dynamic_upgrade_mode)); |
| 179 b = addNode(this.queryOutputDiv_, 'br'); |
| 180 |
| 181 addTextNode(this.queryOutputDiv_, ' dynamic_sts_include_subdomains: '); |
| 182 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 183 result.dynamic_sts_include_subdomains); |
| 184 b = addNode(this.queryOutputDiv_, 'br'); |
| 185 |
| 186 addTextNode(this.queryOutputDiv_, ' dynamic_pkp_include_subdomains: '); |
| 187 t = addNodeWithText(this.queryOutputDiv_, 'tt', |
| 188 result.dynamic_pkp_include_subdomains); |
| 189 b = addNode(this.queryOutputDiv_, 'br'); |
| 190 |
| 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 typeof result.dynamic_spki_hashes !== 'undefined' ? |
| 204 result.dynamic_spki_hashes : ''); |
| 205 |
179 yellowFade(this.queryOutputDiv_); | 206 yellowFade(this.queryOutputDiv_); |
180 } | 207 } |
181 }; | 208 }; |
182 | 209 |
183 function modeToString(m) { | 210 function modeToString(m) { |
184 // These numbers must match those in | 211 // These numbers must match those in |
185 // TransportSecurityState::DomainState::UpgradeMode. | 212 // TransportSecurityState::DomainState::UpgradeMode. |
186 if (m == 0) { | 213 if (m == 0) { |
187 return 'STRICT'; | 214 return 'STRICT'; |
188 } else if (m == 1) { | 215 } else if (m == 1) { |
189 return 'OPPORTUNISTIC'; | 216 return 'OPPORTUNISTIC'; |
190 } else { | 217 } else { |
191 return 'UNKNOWN'; | 218 return 'UNKNOWN'; |
192 } | 219 } |
193 } | 220 } |
194 | 221 |
195 function yellowFade(element) { | 222 function yellowFade(element) { |
196 element.style.webkitTransitionProperty = 'background-color'; | 223 element.style.webkitTransitionProperty = 'background-color'; |
197 element.style.webkitTransitionDuration = '0'; | 224 element.style.webkitTransitionDuration = '0'; |
198 element.style.backgroundColor = '#fffccf'; | 225 element.style.backgroundColor = '#fffccf'; |
199 setTimeout(function() { | 226 setTimeout(function() { |
200 element.style.webkitTransitionDuration = '1000ms'; | 227 element.style.webkitTransitionDuration = '1000ms'; |
201 element.style.backgroundColor = '#fff'; | 228 element.style.backgroundColor = '#fff'; |
202 }, 0); | 229 }, 0); |
203 } | 230 } |
204 | 231 |
205 return HSTSView; | 232 return HSTSView; |
206 })(); | 233 })(); |
OLD | NEW |