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 |
11 // Should match SecurityInterstitialCommands in security_interstitial_page.h | 11 // Should match SecurityInterstitialCommands in security_interstitial_page.h |
12 var CMD_DONT_PROCEED = 0; | 12 var CMD_DONT_PROCEED = 0; |
13 var CMD_PROCEED = 1; | 13 var CMD_PROCEED = 1; |
14 // Ways for user to get more information | 14 // Ways for user to get more information |
15 var CMD_SHOW_MORE_SECTION = 2; | 15 var CMD_SHOW_MORE_SECTION = 2; |
16 var CMD_OPEN_HELP_CENTER = 3; | 16 var CMD_OPEN_HELP_CENTER = 3; |
17 var CMD_OPEN_DIAGNOSTIC = 4; | 17 var CMD_OPEN_DIAGNOSTIC = 4; |
18 // Primary button actions | 18 // Primary button actions |
19 var CMD_RELOAD = 5; | 19 var CMD_RELOAD = 5; |
20 var CMD_OPEN_DATE_SETTINGS = 6; | 20 var CMD_OPEN_DATE_SETTINGS = 6; |
21 var CMD_OPEN_LOGIN = 7; | 21 var CMD_OPEN_LOGIN = 7; |
22 // Safe Browsing Extended Reporting | 22 // Safe Browsing Extended Reporting |
23 var CMD_DO_REPORT = 8; | 23 var CMD_DO_REPORT = 8; |
24 var CMD_DONT_REPORT = 9; | 24 var CMD_DONT_REPORT = 9; |
25 var CMD_OPEN_REPORTING_PRIVACY = 10; | 25 var CMD_OPEN_REPORTING_PRIVACY = 10; |
26 // Report a phishing error. | 26 // Report a phishing error. |
27 var CMD_REPORT_PHISHING_ERROR = 11; | 27 var CMD_REPORT_PHISHING_ERROR = 11; |
28 // Navigate to suggested URL. | |
29 var CMD_OPEN_SUGGESTED_URL = 12; | |
28 | 30 |
29 /** | 31 /** |
30 * A convenience method for sending commands to the parent page. | 32 * A convenience method for sending commands to the parent page. |
31 * @param {string} cmd The command to send. | 33 * @param {string} cmd The command to send. |
32 */ | 34 */ |
33 function sendCommand(cmd) { | 35 function sendCommand(cmd) { |
34 window.domAutomationController.setAutomationId(1); | 36 window.domAutomationController.setAutomationId(1); |
35 window.domAutomationController.send(cmd); | 37 window.domAutomationController.send(cmd); |
36 } | 38 } |
37 | 39 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 } | 84 } |
83 | 85 |
84 function setupEvents() { | 86 function setupEvents() { |
85 var overridable = loadTimeData.getBoolean('overridable'); | 87 var overridable = loadTimeData.getBoolean('overridable'); |
86 var interstitialType = loadTimeData.getString('type'); | 88 var interstitialType = loadTimeData.getString('type'); |
87 var ssl = interstitialType == 'SSL'; | 89 var ssl = interstitialType == 'SSL'; |
88 var captivePortal = interstitialType == 'CAPTIVE_PORTAL'; | 90 var captivePortal = interstitialType == 'CAPTIVE_PORTAL'; |
89 var badClock = ssl && loadTimeData.getBoolean('bad_clock'); | 91 var badClock = ssl && loadTimeData.getBoolean('bad_clock'); |
90 var hidePrimaryButton = badClock && loadTimeData.getBoolean( | 92 var hidePrimaryButton = badClock && loadTimeData.getBoolean( |
91 'hide_primary_button'); | 93 'hide_primary_button'); |
94 var commonNameMismatch = ssl && loadTimeData.getBoolean( | |
95 'common_name_mismatch'); | |
92 | 96 |
93 if (ssl) { | 97 if (ssl) { |
94 $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); | 98 $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); |
95 $('error-code').textContent = loadTimeData.getString('errorCode'); | 99 $('error-code').textContent = loadTimeData.getString('errorCode'); |
96 $('error-code').classList.remove('hidden'); | 100 $('error-code').classList.remove('hidden'); |
97 } else if (captivePortal) { | 101 } else if (captivePortal) { |
98 $('body').classList.add('captive-portal'); | 102 $('body').classList.add('captive-portal'); |
99 } else { | 103 } else { |
100 $('body').classList.add('safe-browsing'); | 104 $('body').classList.add('safe-browsing'); |
101 } | 105 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
142 } else if ($('help-link')) { | 146 } else if ($('help-link')) { |
143 // Overridable SSL page doesn't have this link. | 147 // Overridable SSL page doesn't have this link. |
144 $('help-link').addEventListener('click', function(event) { | 148 $('help-link').addEventListener('click', function(event) { |
145 if (ssl || loadTimeData.getBoolean('phishing')) | 149 if (ssl || loadTimeData.getBoolean('phishing')) |
146 sendCommand(CMD_OPEN_HELP_CENTER); | 150 sendCommand(CMD_OPEN_HELP_CENTER); |
147 else | 151 else |
148 sendCommand(CMD_OPEN_DIAGNOSTIC); | 152 sendCommand(CMD_OPEN_DIAGNOSTIC); |
149 }); | 153 }); |
150 } | 154 } |
151 | 155 |
156 if (commonNameMismatch) { | |
157 // Send a command if user clicks the suggested URL. | |
meacer
2015/07/30 19:40:21
Do you need this comment?
Bhanu Dev
2015/07/31 00:07:15
Done.
| |
158 $('suggest-link').addEventListener('click', function(event) { | |
159 sendCommand(CMD_OPEN_SUGGESTED_URL); | |
160 }); | |
161 } | |
162 | |
152 if (captivePortal) { | 163 if (captivePortal) { |
153 // Captive portal page doesn't have details button. | 164 // Captive portal page doesn't have details button. |
154 $('details-button').classList.add('hidden'); | 165 $('details-button').classList.add('hidden'); |
155 } else { | 166 } else { |
156 $('details-button').addEventListener('click', function(event) { | 167 $('details-button').addEventListener('click', function(event) { |
157 var hiddenDetails = $('details').classList.toggle('hidden'); | 168 var hiddenDetails = $('details').classList.toggle('hidden'); |
158 | 169 |
159 if (mobileNav) { | 170 if (mobileNav) { |
160 // Details appear over the main content on small screens. | 171 // Details appear over the main content on small screens. |
161 $('main-content').classList.toggle('hidden', !hiddenDetails); | 172 $('main-content').classList.toggle('hidden', !hiddenDetails); |
(...skipping 21 matching lines...) Expand all Loading... | |
183 }); | 194 }); |
184 } | 195 } |
185 | 196 |
186 preventDefaultOnPoundLinkClicks(); | 197 preventDefaultOnPoundLinkClicks(); |
187 setupExtendedReportingCheckbox(); | 198 setupExtendedReportingCheckbox(); |
188 setupSSLDebuggingInfo(); | 199 setupSSLDebuggingInfo(); |
189 document.addEventListener('keypress', handleKeypress); | 200 document.addEventListener('keypress', handleKeypress); |
190 } | 201 } |
191 | 202 |
192 document.addEventListener('DOMContentLoaded', setupEvents); | 203 document.addEventListener('DOMContentLoaded', setupEvents); |
OLD | NEW |