| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 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. | |
| 7 | |
| 8 var expandedDetails = false; | |
| 9 | |
| 10 function setupEvents() { | |
| 11 var overridable = loadTimeData.getBoolean('overridable'); | |
| 12 var ssl = loadTimeData.getBoolean('ssl'); | |
| 13 | |
| 14 if (ssl) { | |
| 15 $('body').classList.add('ssl'); | |
| 16 $('error-code').textContent = loadTimeData.getString('errorCode'); | |
| 17 $('error-code').classList.remove('hidden'); | |
| 18 } else { | |
| 19 $('body').classList.add('safe-browsing'); | |
| 20 } | |
| 21 | |
| 22 $('primary-button').addEventListener('click', function() { | |
| 23 if (!ssl) | |
| 24 sendCommand(SB_CMD_TAKE_ME_BACK); | |
| 25 else if (overridable) | |
| 26 sendCommand(CMD_DONT_PROCEED); | |
| 27 else | |
| 28 sendCommand(CMD_RELOAD); | |
| 29 }); | |
| 30 | |
| 31 if (overridable) { | |
| 32 $('proceed-link').addEventListener('click', function(event) { | |
| 33 sendCommand(ssl ? CMD_PROCEED : SB_CMD_PROCEED); | |
| 34 }); | |
| 35 } else if (!ssl) { | |
| 36 $('final-paragraph').classList.add('hidden'); | |
| 37 } | |
| 38 | |
| 39 if (ssl && overridable) { | |
| 40 $('proceed-link').classList.add('small-link'); | |
| 41 } else if ($('help-link')) { | |
| 42 // Overridable SSL page doesn't have this link. | |
| 43 $('help-link').addEventListener('click', function(event) { | |
| 44 if (ssl) | |
| 45 sendCommand(CMD_HELP); | |
| 46 else if (loadTimeData.getBoolean('phishing')) | |
| 47 sendCommand(SB_CMD_LEARN_MORE_2); | |
| 48 else | |
| 49 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); | |
| 50 }); | |
| 51 } | |
| 52 | |
| 53 if (ssl && $('clock-link')) { | |
| 54 $('clock-link').addEventListener('click', function(event) { | |
| 55 sendCommand(CMD_CLOCK); | |
| 56 }); | |
| 57 } | |
| 58 | |
| 59 $('details-button').addEventListener('click', function(event) { | |
| 60 var hiddenDetails = $('details').classList.toggle('hidden'); | |
| 61 $('details-button').innerText = hiddenDetails ? | |
| 62 loadTimeData.getString('openDetails') : | |
| 63 loadTimeData.getString('closeDetails'); | |
| 64 if (!expandedDetails) { | |
| 65 // Record a histogram entry only the first time that details is opened. | |
| 66 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); | |
| 67 expandedDetails = true; | |
| 68 } | |
| 69 }); | |
| 70 | |
| 71 preventDefaultOnPoundLinkClicks(); | |
| 72 setupCheckbox(); | |
| 73 } | |
| 74 | |
| 75 document.addEventListener('DOMContentLoaded', setupEvents); | |
| OLD | NEW |