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