Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This is the shared code for the new (Chrome 37) security interstitials. It is | 5 // This is the shared code for the new (Chrome 37) security interstitials. It is |
| 6 // used for both SSL interstitials and Safe Browsing interstitials. | 6 // used for both SSL interstitials and Safe Browsing interstitials. |
| 7 | 7 |
| 8 var expandedDetails = false; | 8 var expandedDetails = false; |
| 9 var keyPressState = 0; | |
| 10 | |
| 11 // A convenience method for sending commands to the parent page. | |
|
Dan Beam
2014/08/19 16:55:10
nit: // ... -> /* ...
* @param {..
felt
2014/08/19 21:04:51
Done.
| |
| 12 function sendCommand(cmd) { | |
| 13 window.domAutomationController.setAutomationId(1); | |
| 14 window.domAutomationController.send(cmd); | |
| 15 } | |
| 16 | |
| 17 // This allows errors to be skippped by typing "danger" into the page. | |
|
Dan Beam
2014/08/19 16:55:10
same
felt
2014/08/19 21:04:51
Done.
| |
| 18 function handleKeypress(e) { | |
| 19 var BYPASS_SEQUENCE = 'danger'; | |
| 20 if (BYPASS_SEQUENCE.charCodeAt(keyPressState) == e.keyCode) { | |
| 21 keyPressState++; | |
| 22 if (keyPressState == BYPASS_SEQUENCE.length) { | |
| 23 sendCommand(CMD_PROCEED); | |
| 24 keyPressState = 0; | |
| 25 } | |
| 26 } else { | |
| 27 keyPressState = 0; | |
| 28 } | |
| 29 } | |
| 9 | 30 |
| 10 function setupEvents() { | 31 function setupEvents() { |
| 11 var overridable = loadTimeData.getBoolean('overridable'); | 32 var overridable = loadTimeData.getBoolean('overridable'); |
| 12 var ssl = loadTimeData.getBoolean('ssl'); | 33 var ssl = loadTimeData.getBoolean('ssl'); |
| 13 | 34 |
| 14 if (ssl) { | 35 if (ssl) { |
| 15 $('body').classList.add('ssl'); | 36 $('body').classList.add('ssl'); |
| 16 $('error-code').textContent = loadTimeData.getString('errorCode'); | 37 $('error-code').textContent = loadTimeData.getString('errorCode'); |
| 17 $('error-code').classList.remove('hidden'); | 38 $('error-code').classList.remove('hidden'); |
| 18 } else { | 39 } else { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 loadTimeData.getString('closeDetails'); | 84 loadTimeData.getString('closeDetails'); |
| 64 if (!expandedDetails) { | 85 if (!expandedDetails) { |
| 65 // Record a histogram entry only the first time that details is opened. | 86 // Record a histogram entry only the first time that details is opened. |
| 66 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); | 87 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); |
| 67 expandedDetails = true; | 88 expandedDetails = true; |
| 68 } | 89 } |
| 69 }); | 90 }); |
| 70 | 91 |
| 71 preventDefaultOnPoundLinkClicks(); | 92 preventDefaultOnPoundLinkClicks(); |
| 72 setupCheckbox(); | 93 setupCheckbox(); |
| 94 document.addEventListener('keypress', handleKeypress); | |
| 73 } | 95 } |
| 74 | 96 |
| 75 document.addEventListener('DOMContentLoaded', setupEvents); | 97 document.addEventListener('DOMContentLoaded', setupEvents); |
| OLD | NEW |