| 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 applyMalwareStyle(); |
| 9 | 18 |
| 10 $('primary-button').addEventListener('click', function() { | 19 $('primary-button').addEventListener('click', function() { |
| 11 if (overridable) | 20 if (!ssl) |
| 21 sendCommand(SB_CMD_GO_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 } | 32 } |
| 23 | 33 |
| 24 if (!overridable) { | 34 if (!(ssl && overridable)) { // Overridable SSL page doesn't have this link. |
| 25 $('help-link').addEventListener('click', function(event) { | 35 $('help-link').addEventListener('click', function(event) { |
| 26 sendCommand(CMD_HELP); | 36 if (ssl) |
| 27 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); |
| 28 }); | 42 }); |
| 29 } | 43 } |
| 30 | 44 |
| 31 $('details-button').addEventListener('click', function(event) { | 45 $('details-button').addEventListener('click', function(event) { |
| 32 var hiddenDetails = $('details').classList.toggle('hidden'); | 46 var hiddenDetails = $('details').classList.toggle('hidden'); |
| 33 $('details-button').innerText = hiddenDetails ? | 47 $('details-button').innerText = hiddenDetails ? |
| 34 loadTimeData.getString('openDetails') : | 48 loadTimeData.getString('openDetails') : |
| 35 loadTimeData.getString('closeDetails'); | 49 loadTimeData.getString('closeDetails'); |
| 36 if (!expandedDetails) { | 50 if (!expandedDetails) { |
| 37 // Record a histogram entry only the first time that details is opened. | 51 // Record a histogram entry only the first time that details is opened. |
| 38 sendCommand(CMD_MORE); | 52 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_MORE); |
| 39 expandedDetails = true; | 53 expandedDetails = true; |
| 40 } | 54 } |
| 41 event.preventDefault(); | |
| 42 }); | 55 }); |
| 56 |
| 57 preventDefaultOnPoundLinkClicks(); |
| 43 } | 58 } |
| 44 | 59 |
| 45 document.addEventListener('DOMContentLoaded', setupEvents); | 60 document.addEventListener('DOMContentLoaded', setupEvents); |
| OLD | NEW |