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 var keyPressState = 0; | 9 var keyPressState = 0; |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 } | 60 } |
61 | 61 |
62 function toggleDebuggingInfo() { | 62 function toggleDebuggingInfo() { |
63 $('error-debugging-info').classList.toggle('hidden'); | 63 $('error-debugging-info').classList.toggle('hidden'); |
64 } | 64 } |
65 | 65 |
66 function setupEvents() { | 66 function setupEvents() { |
67 var overridable = loadTimeData.getBoolean('overridable'); | 67 var overridable = loadTimeData.getBoolean('overridable'); |
68 var ssl = loadTimeData.getString('type') === 'SSL'; | 68 var ssl = loadTimeData.getString('type') === 'SSL'; |
69 var badClock = ssl && loadTimeData.getBoolean('bad_clock'); | 69 var badClock = ssl && loadTimeData.getBoolean('bad_clock'); |
| 70 var hidePrimaryButton = badClock && loadTimeData.getBoolean( |
| 71 'hide_primary_button'); |
70 | 72 |
71 if (ssl) { | 73 if (ssl) { |
72 $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); | 74 $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); |
73 $('error-code').textContent = loadTimeData.getString('errorCode'); | 75 $('error-code').textContent = loadTimeData.getString('errorCode'); |
74 $('error-code').classList.remove('hidden'); | 76 $('error-code').classList.remove('hidden'); |
75 } else { | 77 } else { |
76 $('body').classList.add('safe-browsing'); | 78 $('body').classList.add('safe-browsing'); |
77 } | 79 } |
78 | 80 |
79 $('primary-button').addEventListener('click', function() { | 81 if (hidePrimaryButton) { |
80 if (!ssl) | 82 $('primary-button').classList.add('hidden'); |
81 sendCommand(SB_CMD_TAKE_ME_BACK); | 83 } else { |
82 else if (badClock) | 84 $('primary-button').addEventListener('click', function() { |
83 sendCommand(SSL_CMD_CLOCK); | 85 if (!ssl) |
84 else if (overridable) | 86 sendCommand(SB_CMD_TAKE_ME_BACK); |
85 sendCommand(SSL_CMD_DONT_PROCEED); | 87 else if (badClock) |
86 else | 88 sendCommand(SSL_CMD_CLOCK); |
87 sendCommand(SSL_CMD_RELOAD); | 89 else if (overridable) |
88 }); | 90 sendCommand(SSL_CMD_DONT_PROCEED); |
| 91 else |
| 92 sendCommand(SSL_CMD_RELOAD); |
| 93 }); |
| 94 } |
89 | 95 |
90 if (overridable) { | 96 if (overridable) { |
91 $('proceed-link').addEventListener('click', function(event) { | 97 $('proceed-link').addEventListener('click', function(event) { |
92 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); | 98 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); |
93 }); | 99 }); |
94 } else if (!ssl) { | 100 } else if (!ssl) { |
95 $('final-paragraph').classList.add('hidden'); | 101 $('final-paragraph').classList.add('hidden'); |
96 } | 102 } |
97 | 103 |
98 if (ssl && overridable) { | 104 if (ssl && overridable) { |
99 $('proceed-link').classList.add('small-link'); | 105 $('proceed-link').classList.add('small-link'); |
100 } else if ($('help-link')) { | 106 } else if ($('help-link')) { |
101 // Overridable SSL page doesn't have this link. | 107 // Overridable SSL page doesn't have this link. |
102 $('help-link').addEventListener('click', function(event) { | 108 $('help-link').addEventListener('click', function(event) { |
103 if (ssl) | 109 if (ssl) |
104 sendCommand(SSL_CMD_HELP); | 110 sendCommand(SSL_CMD_HELP); |
105 else if (loadTimeData.getBoolean('phishing')) | 111 else if (loadTimeData.getBoolean('phishing')) |
106 sendCommand(SB_CMD_LEARN_MORE_2); | 112 sendCommand(SB_CMD_LEARN_MORE_2); |
107 else | 113 else |
108 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); | 114 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); |
109 }); | 115 }); |
110 } | 116 } |
111 | 117 |
112 $('details-button').addEventListener('click', function(event) { | 118 $('details-button').addEventListener('click', function(event) { |
113 if (badClock) { | 119 var hiddenDetails = $('details').classList.toggle('hidden'); |
114 sendCommand(SSL_CMD_RELOAD); | 120 $('details-button').innerText = hiddenDetails ? |
115 } else { | 121 loadTimeData.getString('openDetails') : |
116 var hiddenDetails = $('details').classList.toggle('hidden'); | 122 loadTimeData.getString('closeDetails'); |
117 $('details-button').innerText = hiddenDetails ? | 123 if (!expandedDetails) { |
118 loadTimeData.getString('openDetails') : | 124 // Record a histogram entry only the first time that details is opened. |
119 loadTimeData.getString('closeDetails'); | 125 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); |
120 if (!expandedDetails) { | 126 expandedDetails = true; |
121 // Record a histogram entry only the first time that details is opened. | |
122 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); | |
123 expandedDetails = true; | |
124 } | |
125 } | 127 } |
126 }); | 128 }); |
127 | 129 |
128 preventDefaultOnPoundLinkClicks(); | 130 preventDefaultOnPoundLinkClicks(); |
129 setupCheckbox(); | 131 setupCheckbox(); |
130 setupSSLDebuggingInfo(); | 132 setupSSLDebuggingInfo(); |
131 document.addEventListener('keypress', handleKeypress); | 133 document.addEventListener('keypress', handleKeypress); |
132 } | 134 } |
133 | 135 |
134 document.addEventListener('DOMContentLoaded', setupEvents); | 136 document.addEventListener('DOMContentLoaded', setupEvents); |
OLD | NEW |