| 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 |
| 6 // used for both SSL interstitials and Safe Browsing interstitials. |
| 7 |
| 5 var expandedDetails = false; | 8 var expandedDetails = false; |
| 6 | 9 |
| 7 function setupEvents() { | 10 function setupEvents() { |
| 8 var overridable = loadTimeData.getBoolean('overridable'); | 11 var overridable = loadTimeData.getBoolean('overridable'); |
| 12 var ssl = loadTimeData.getBoolean('ssl'); |
| 13 |
| 14 if (ssl) |
| 15 applySSLStyle(); |
| 16 else |
| 17 applySafeBrowsingStyle(); |
| 9 | 18 |
| 10 $('primary-button').addEventListener('click', function() { | 19 $('primary-button').addEventListener('click', function() { |
| 11 if (overridable) | 20 if (!ssl) |
| 21 sendCommand(SB_CMD_TAKE_ME_BACK); |
| 22 else if (overridable) |
| 12 sendCommand(CMD_DONT_PROCEED); | 23 sendCommand(CMD_DONT_PROCEED); |
| 13 else | 24 else |
| 14 sendCommand(CMD_RELOAD); | 25 sendCommand(CMD_RELOAD); |
| 15 }); | 26 }); |
| 16 | 27 |
| 17 if (overridable) { | 28 if (overridable) { |
| 18 $('proceed-link').addEventListener('click', function(event) { | 29 $('proceed-link').addEventListener('click', function(event) { |
| 19 sendCommand(CMD_PROCEED); | 30 sendCommand(ssl ? CMD_PROCEED : SB_CMD_PROCEED); |
| 20 event.preventDefault(); | |
| 21 }); | 31 }); |
| 22 } else { | 32 } |
| 33 |
| 34 if (!(ssl && overridable)) { // Overridable SSL page doesn't have this link. |
| 23 $('help-link').addEventListener('click', function(event) { | 35 $('help-link').addEventListener('click', function(event) { |
| 24 sendCommand(CMD_HELP); | 36 if (ssl) |
| 25 event.preventDefault(); | 37 sendCommand(CMD_HELP); |
| 38 else if (loadTimeData.getBoolean('phishing')) |
| 39 sendCommand(SB_CMD_REPORT_ERROR); |
| 40 else |
| 41 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); |
| 26 }); | 42 }); |
| 27 | 43 |
| 28 $('error-code').textContent = loadTimeData.getString('errorCode'); | 44 $('error-code').textContent = loadTimeData.getString('errorCode'); |
| 29 $('error-code').classList.remove('hidden'); | 45 $('error-code').classList.remove('hidden'); |
| 30 } | 46 } |
| 31 | 47 |
| 32 $('details-button').addEventListener('click', function(event) { | 48 $('details-button').addEventListener('click', function(event) { |
| 33 var hiddenDetails = $('details').classList.toggle('hidden'); | 49 var hiddenDetails = $('details').classList.toggle('hidden'); |
| 34 $('details-button').innerText = hiddenDetails ? | 50 $('details-button').innerText = hiddenDetails ? |
| 35 loadTimeData.getString('openDetails') : | 51 loadTimeData.getString('openDetails') : |
| 36 loadTimeData.getString('closeDetails'); | 52 loadTimeData.getString('closeDetails'); |
| 37 if (!expandedDetails) { | 53 if (!expandedDetails) { |
| 38 // Record a histogram entry only the first time that details is opened. | 54 // Record a histogram entry only the first time that details is opened. |
| 39 sendCommand(CMD_MORE); | 55 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); |
| 40 expandedDetails = true; | 56 expandedDetails = true; |
| 41 } | 57 } |
| 42 event.preventDefault(); | |
| 43 }); | 58 }); |
| 59 |
| 60 preventDefaultOnPoundLinkClicks(); |
| 44 } | 61 } |
| 45 | 62 |
| 46 document.addEventListener('DOMContentLoaded', setupEvents); | 63 document.addEventListener('DOMContentLoaded', setupEvents); |
| OLD | NEW |