| 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; | 9 var keyPressState = 0; |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 $('error-debugging-info').appendChild(pElem); | 59 $('error-debugging-info').appendChild(pElem); |
| 60 } | 60 } |
| 61 | 61 |
| 62 function toggleDebuggingInfo() { | 62 function toggleDebuggingInfo() { |
| 63 $('error-debugging-info').classList.toggle('hidden'); | 63 $('error-debugging-info').classList.toggle('hidden'); |
| 64 } | 64 } |
| 65 | 65 |
| 66 function setupEvents() { | 66 function setupEvents() { |
| 67 var overridable = loadTimeData.getBoolean('overridable'); | 67 var overridable = loadTimeData.getBoolean('overridable'); |
| 68 var ssl = loadTimeData.getString('type') === 'SSL'; | 68 var ssl = loadTimeData.getString('type') === 'SSL'; |
| 69 var badClock = ssl && loadTimeData.getBoolean('bad_clock'); |
| 69 | 70 |
| 70 if (ssl) { | 71 if (ssl) { |
| 71 $('body').classList.add('ssl'); | 72 $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); |
| 72 $('error-code').textContent = loadTimeData.getString('errorCode'); | 73 $('error-code').textContent = loadTimeData.getString('errorCode'); |
| 73 $('error-code').classList.remove('hidden'); | 74 $('error-code').classList.remove('hidden'); |
| 74 } else { | 75 } else { |
| 75 $('body').classList.add('safe-browsing'); | 76 $('body').classList.add('safe-browsing'); |
| 76 } | 77 } |
| 77 | 78 |
| 78 $('primary-button').addEventListener('click', function() { | 79 $('primary-button').addEventListener('click', function() { |
| 79 if (!ssl) | 80 if (!ssl) |
| 80 sendCommand(SB_CMD_TAKE_ME_BACK); | 81 sendCommand(SB_CMD_TAKE_ME_BACK); |
| 82 else if (badClock) |
| 83 sendCommand(SSL_CMD_CLOCK); |
| 81 else if (overridable) | 84 else if (overridable) |
| 82 sendCommand(SSL_CMD_DONT_PROCEED); | 85 sendCommand(SSL_CMD_DONT_PROCEED); |
| 83 else | 86 else |
| 84 sendCommand(SSL_CMD_RELOAD); | 87 sendCommand(SSL_CMD_RELOAD); |
| 85 }); | 88 }); |
| 86 | 89 |
| 87 if (overridable) { | 90 if (overridable) { |
| 88 $('proceed-link').addEventListener('click', function(event) { | 91 $('proceed-link').addEventListener('click', function(event) { |
| 89 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); | 92 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); |
| 90 }); | 93 }); |
| 91 } else if (!ssl) { | 94 } else if (!ssl) { |
| 92 $('final-paragraph').classList.add('hidden'); | 95 $('final-paragraph').classList.add('hidden'); |
| 93 } | 96 } |
| 94 | 97 |
| 95 if (ssl && overridable) { | 98 if (ssl && overridable) { |
| 96 $('proceed-link').classList.add('small-link'); | 99 $('proceed-link').classList.add('small-link'); |
| 97 } else if ($('help-link')) { | 100 } else if ($('help-link')) { |
| 98 // Overridable SSL page doesn't have this link. | 101 // Overridable SSL page doesn't have this link. |
| 99 $('help-link').addEventListener('click', function(event) { | 102 $('help-link').addEventListener('click', function(event) { |
| 100 if (ssl) | 103 if (ssl) |
| 101 sendCommand(SSL_CMD_HELP); | 104 sendCommand(SSL_CMD_HELP); |
| 102 else if (loadTimeData.getBoolean('phishing')) | 105 else if (loadTimeData.getBoolean('phishing')) |
| 103 sendCommand(SB_CMD_LEARN_MORE_2); | 106 sendCommand(SB_CMD_LEARN_MORE_2); |
| 104 else | 107 else |
| 105 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); | 108 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); |
| 106 }); | 109 }); |
| 107 } | 110 } |
| 108 | 111 |
| 109 if (ssl && $('clock-link')) { | |
| 110 $('clock-link').addEventListener('click', function(event) { | |
| 111 sendCommand(SSL_CMD_CLOCK); | |
| 112 }); | |
| 113 } | |
| 114 | |
| 115 $('details-button').addEventListener('click', function(event) { | 112 $('details-button').addEventListener('click', function(event) { |
| 116 var hiddenDetails = $('details').classList.toggle('hidden'); | 113 if (badClock) { |
| 117 $('details-button').innerText = hiddenDetails ? | 114 sendCommand(SSL_CMD_RELOAD); |
| 118 loadTimeData.getString('openDetails') : | 115 } else { |
| 119 loadTimeData.getString('closeDetails'); | 116 var hiddenDetails = $('details').classList.toggle('hidden'); |
| 120 if (!expandedDetails) { | 117 $('details-button').innerText = hiddenDetails ? |
| 121 // Record a histogram entry only the first time that details is opened. | 118 loadTimeData.getString('openDetails') : |
| 122 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); | 119 loadTimeData.getString('closeDetails'); |
| 123 expandedDetails = true; | 120 if (!expandedDetails) { |
| 121 // Record a histogram entry only the first time that details is opened. |
| 122 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); |
| 123 expandedDetails = true; |
| 124 } |
| 124 } | 125 } |
| 125 }); | 126 }); |
| 126 | 127 |
| 127 preventDefaultOnPoundLinkClicks(); | 128 preventDefaultOnPoundLinkClicks(); |
| 128 setupCheckbox(); | 129 setupCheckbox(); |
| 129 setupSSLDebuggingInfo(); | 130 setupSSLDebuggingInfo(); |
| 130 document.addEventListener('keypress', handleKeypress); | 131 document.addEventListener('keypress', handleKeypress); |
| 131 } | 132 } |
| 132 | 133 |
| 133 document.addEventListener('DOMContentLoaded', setupEvents); | 134 document.addEventListener('DOMContentLoaded', setupEvents); |
| OLD | NEW |