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 | 9 |
10 function setupEvents() { | 10 function setupEvents() { |
11 var overridable = loadTimeData.getBoolean('overridable'); | 11 var overridable = loadTimeData.getBoolean('overridable'); |
12 var ssl = loadTimeData.getBoolean('ssl'); | 12 var ssl = loadTimeData.getBoolean('ssl'); |
13 | 13 |
14 if (ssl) { | 14 if (ssl) { |
15 $('body').classList.add('ssl'); | 15 $('body').classList.add('ssl'); |
16 setupSSLFinchTrial(); /* From ssl_errors_common.js. */ | 16 setupSSLFinchTrial(); /* From ssl_errors_common.js. */ |
| 17 $('error-code').textContent = loadTimeData.getString('errorCode'); |
| 18 $('error-code').classList.remove('hidden'); |
17 } else { | 19 } else { |
18 $('body').classList.add('safe-browsing'); | 20 $('body').classList.add('safe-browsing'); |
19 setupMalwareFinchExperiment(); /* From safe_browsing_v3.js. */ | 21 setupMalwareFinchExperiment(); /* From safe_browsing_v3.js. */ |
20 } | 22 } |
21 | 23 |
22 $('primary-button').addEventListener('click', function() { | 24 $('primary-button').addEventListener('click', function() { |
23 if (!ssl) | 25 if (!ssl) |
24 sendCommand(SB_CMD_TAKE_ME_BACK); | 26 sendCommand(SB_CMD_TAKE_ME_BACK); |
25 else if (overridable) | 27 else if (overridable) |
26 sendCommand(CMD_DONT_PROCEED); | 28 sendCommand(CMD_DONT_PROCEED); |
(...skipping 16 matching lines...) Expand all Loading... |
43 $('help-link').addEventListener('click', function(event) { | 45 $('help-link').addEventListener('click', function(event) { |
44 if (ssl) | 46 if (ssl) |
45 sendCommand(CMD_HELP); | 47 sendCommand(CMD_HELP); |
46 else if (loadTimeData.getBoolean('phishing')) | 48 else if (loadTimeData.getBoolean('phishing')) |
47 sendCommand(SB_CMD_LEARN_MORE_2); | 49 sendCommand(SB_CMD_LEARN_MORE_2); |
48 else | 50 else |
49 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); | 51 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); |
50 }); | 52 }); |
51 } | 53 } |
52 | 54 |
53 if (ssl && !overridable) { | |
54 $('error-code').textContent = loadTimeData.getString('errorCode'); | |
55 $('error-code').classList.remove('hidden'); | |
56 } | |
57 | |
58 if (ssl && $('clock-link')) { | 55 if (ssl && $('clock-link')) { |
59 $('clock-link').addEventListener('click', function(event) { | 56 $('clock-link').addEventListener('click', function(event) { |
60 sendCommand(CMD_CLOCK); | 57 sendCommand(CMD_CLOCK); |
61 }); | 58 }); |
62 } | 59 } |
63 | 60 |
64 $('details-button').addEventListener('click', function(event) { | 61 $('details-button').addEventListener('click', function(event) { |
65 var hiddenDetails = $('details').classList.toggle('hidden'); | 62 var hiddenDetails = $('details').classList.toggle('hidden'); |
66 $('details-button').innerText = hiddenDetails ? | 63 $('details-button').innerText = hiddenDetails ? |
67 loadTimeData.getString('openDetails') : | 64 loadTimeData.getString('openDetails') : |
68 loadTimeData.getString('closeDetails'); | 65 loadTimeData.getString('closeDetails'); |
69 if (!expandedDetails) { | 66 if (!expandedDetails) { |
70 // Record a histogram entry only the first time that details is opened. | 67 // Record a histogram entry only the first time that details is opened. |
71 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); | 68 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); |
72 expandedDetails = true; | 69 expandedDetails = true; |
73 } | 70 } |
74 }); | 71 }); |
75 | 72 |
76 preventDefaultOnPoundLinkClicks(); | 73 preventDefaultOnPoundLinkClicks(); |
77 setupCheckbox(); | 74 setupCheckbox(); |
78 } | 75 } |
79 | 76 |
80 document.addEventListener('DOMContentLoaded', setupEvents); | 77 document.addEventListener('DOMContentLoaded', setupEvents); |
OLD | NEW |