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 (!overridable && ssl) |
12 sendCommand(CMD_DONT_PROCEED); | 21 sendCommand(CMD_RELOAD); |
13 else | 22 else |
14 sendCommand(CMD_RELOAD); | 23 sendCommand(ssl ? CMD_DONT_PROCEED : SB_CMD_GO_BACK); |
Bernhard Bauer
2014/06/09 10:04:03
I think you could reorder this as
if (!ssl)
felt
2014/06/09 14:24:09
Done.
| |
15 }); | 24 }); |
16 | 25 |
17 if (overridable) { | 26 if (overridable) { |
18 $('proceed-link').addEventListener('click', function(event) { | 27 $('proceed-link').addEventListener('click', function(event) { |
19 sendCommand(CMD_PROCEED); | 28 sendCommand(ssl ? CMD_PROCEED : SB_CMD_PROCEED); |
20 event.preventDefault(); | |
21 }); | 29 }); |
22 } | 30 } |
23 | 31 |
24 if (!overridable) { | 32 if (!(ssl && overridable)) { // Overridable SSL page doesn't have this link. |
25 $('help-link').addEventListener('click', function(event) { | 33 $('help-link').addEventListener('click', function(event) { |
26 sendCommand(CMD_HELP); | 34 if (ssl) |
27 event.preventDefault(); | 35 sendCommand(CMD_HELP); |
36 else if (loadTimeData.getBoolean('phishing')) | |
37 sendCommand(SB_CMD_REPORT_ERROR); | |
38 else | |
39 sendCOmmand(SB_CMD_SHOW_DIAGNOSTIC); | |
28 }); | 40 }); |
29 } | 41 } |
30 | 42 |
31 $('details-button').addEventListener('click', function(event) { | 43 $('details-button').addEventListener('click', function(event) { |
32 var hiddenDetails = $('details').classList.toggle('hidden'); | 44 var hiddenDetails = $('details').classList.toggle('hidden'); |
33 $('details-button').innerText = hiddenDetails ? | 45 $('details-button').innerText = hiddenDetails ? |
34 loadTimeData.getString('openDetails') : | 46 loadTimeData.getString('openDetails') : |
35 loadTimeData.getString('closeDetails'); | 47 loadTimeData.getString('closeDetails'); |
36 if (!expandedDetails) { | 48 if (!expandedDetails) { |
37 // Record a histogram entry only the first time that details is opened. | 49 // Record a histogram entry only the first time that details is opened. |
38 sendCommand(CMD_MORE); | 50 sendCommand(ssl ? CMD_MORE : SB_CMD_EXPANDED_MORE); |
39 expandedDetails = true; | 51 expandedDetails = true; |
40 } | 52 } |
41 event.preventDefault(); | |
42 }); | 53 }); |
54 | |
55 preventDefaultOnPoundLinkClicks(); | |
43 } | 56 } |
44 | 57 |
45 document.addEventListener('DOMContentLoaded', setupEvents); | 58 document.addEventListener('DOMContentLoaded', setupEvents); |
OLD | NEW |