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'); | |
Bernhard Bauer
2014/11/03 12:18:08
Nit: just indent this four spaces.
lgarron
2014/11/04 02:13:50
Acknowledged.
| |
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 } |
82 else if (badClock) | 84 else { |
felt
2014/11/01 21:39:11
} else {
lgarron
2014/11/04 02:13:50
Acknowledged.
| |
83 sendCommand(SSL_CMD_CLOCK); | 85 $('primary-button').addEventListener('click', function() { |
84 else if (overridable) | 86 if (!ssl) |
85 sendCommand(SSL_CMD_DONT_PROCEED); | 87 sendCommand(SB_CMD_TAKE_ME_BACK); |
86 else | 88 else if (badClock) |
87 sendCommand(SSL_CMD_RELOAD); | 89 sendCommand(SSL_CMD_CLOCK); |
88 }); | 90 else if (overridable) |
91 sendCommand(SSL_CMD_DONT_PROCEED); | |
92 else | |
93 sendCommand(SSL_CMD_RELOAD); | |
94 }); | |
95 } | |
89 | 96 |
90 if (overridable) { | 97 if (overridable) { |
91 $('proceed-link').addEventListener('click', function(event) { | 98 $('proceed-link').addEventListener('click', function(event) { |
92 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); | 99 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); |
93 }); | 100 }); |
94 } else if (!ssl) { | 101 } else if (!ssl) { |
95 $('final-paragraph').classList.add('hidden'); | 102 $('final-paragraph').classList.add('hidden'); |
96 } | 103 } |
97 | 104 |
98 if (ssl && overridable) { | 105 if (ssl && overridable) { |
99 $('proceed-link').classList.add('small-link'); | 106 $('proceed-link').classList.add('small-link'); |
100 } else if ($('help-link')) { | 107 } else if ($('help-link')) { |
101 // Overridable SSL page doesn't have this link. | 108 // Overridable SSL page doesn't have this link. |
102 $('help-link').addEventListener('click', function(event) { | 109 $('help-link').addEventListener('click', function(event) { |
103 if (ssl) | 110 if (ssl) |
104 sendCommand(SSL_CMD_HELP); | 111 sendCommand(SSL_CMD_HELP); |
105 else if (loadTimeData.getBoolean('phishing')) | 112 else if (loadTimeData.getBoolean('phishing')) |
106 sendCommand(SB_CMD_LEARN_MORE_2); | 113 sendCommand(SB_CMD_LEARN_MORE_2); |
107 else | 114 else |
108 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); | 115 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); |
109 }); | 116 }); |
110 } | 117 } |
111 | 118 |
112 $('details-button').addEventListener('click', function(event) { | 119 $('details-button').addEventListener('click', function(event) { |
113 if (badClock) { | 120 var hiddenDetails = $('details').classList.toggle('hidden'); |
114 sendCommand(SSL_CMD_RELOAD); | 121 $('details-button').innerText = hiddenDetails ? |
115 } else { | 122 loadTimeData.getString('openDetails') : |
116 var hiddenDetails = $('details').classList.toggle('hidden'); | 123 loadTimeData.getString('closeDetails'); |
117 $('details-button').innerText = hiddenDetails ? | 124 if (!expandedDetails) { |
118 loadTimeData.getString('openDetails') : | 125 // Record a histogram entry only the first time that details is opened. |
119 loadTimeData.getString('closeDetails'); | 126 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); |
120 if (!expandedDetails) { | 127 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 } | 128 } |
126 }); | 129 }); |
127 | 130 |
128 preventDefaultOnPoundLinkClicks(); | 131 preventDefaultOnPoundLinkClicks(); |
129 setupCheckbox(); | 132 setupCheckbox(); |
130 setupSSLDebuggingInfo(); | 133 setupSSLDebuggingInfo(); |
131 document.addEventListener('keypress', handleKeypress); | 134 document.addEventListener('keypress', handleKeypress); |
132 } | 135 } |
133 | 136 |
134 document.addEventListener('DOMContentLoaded', setupEvents); | 137 document.addEventListener('DOMContentLoaded', setupEvents); |
OLD | NEW |