Chromium Code Reviews| 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_NAVIGATE_SUGGESTED_URL = 12; | |
|
meacer
2015/07/28 01:18:05
nit: CMD_OPEN_SUGGESTED_URL instead, to be consist
Bhanu Dev
2015/07/30 02:39:09
Done.
| |
| 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 commonNameMismatchInterstitial = loadTimeData.getBoolean( | |
|
meacer
2015/07/28 01:18:05
Could also check for |ssl| here:
var commonNameMi
Bhanu Dev
2015/07/30 02:39:09
Done.
| |
| 95 'common_name_mismatch_interstitial'); | |
|
meacer
2015/07/28 01:18:05
nit: common_name_mismatch instead of common_name_m
Bhanu Dev
2015/07/30 02:39:09
Done.
| |
| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 loadTimeData.getString('openDetails') : | 171 loadTimeData.getString('openDetails') : |
| 168 loadTimeData.getString('closeDetails'); | 172 loadTimeData.getString('closeDetails'); |
| 169 if (!expandedDetails) { | 173 if (!expandedDetails) { |
| 170 // Record a histogram entry only the first time that details is opened. | 174 // Record a histogram entry only the first time that details is opened. |
| 171 sendCommand(CMD_SHOW_MORE_SECTION); | 175 sendCommand(CMD_SHOW_MORE_SECTION); |
| 172 expandedDetails = true; | 176 expandedDetails = true; |
| 173 } | 177 } |
| 174 }); | 178 }); |
| 175 } | 179 } |
| 176 | 180 |
| 181 if (commonNameMismatchInterstitial) { | |
| 182 // Send a command if user clicks the suggested URL. | |
| 183 $('suggest-link').addEventListener('click', function(event) { | |
| 184 sendCommand(CMD_NAVIGATE_SUGGESTED_URL); | |
| 185 }); | |
| 186 } | |
|
meacer
2015/07/28 01:18:05
Move this block above |if (captivePortal)| since i
Bhanu Dev
2015/07/30 02:39:09
Done.
| |
| 187 | |
| 188 | |
|
meacer
2015/07/28 01:18:04
Remove extra line
Bhanu Dev
2015/07/30 02:39:09
Done.
| |
| 177 // TODO(felt): This should be simplified once the Finch trial is no longer | 189 // TODO(felt): This should be simplified once the Finch trial is no longer |
| 178 // needed. | 190 // needed. |
| 179 if (interstitialType == 'SAFEBROWSING' && | 191 if (interstitialType == 'SAFEBROWSING' && |
| 180 loadTimeData.getBoolean('phishing') && $('report-error-link')) { | 192 loadTimeData.getBoolean('phishing') && $('report-error-link')) { |
| 181 $('report-error-link').addEventListener('click', function(event) { | 193 $('report-error-link').addEventListener('click', function(event) { |
| 182 sendCommand(CMD_REPORT_PHISHING_ERROR); | 194 sendCommand(CMD_REPORT_PHISHING_ERROR); |
| 183 }); | 195 }); |
| 184 } | 196 } |
| 185 | 197 |
| 186 preventDefaultOnPoundLinkClicks(); | 198 preventDefaultOnPoundLinkClicks(); |
| 187 setupExtendedReportingCheckbox(); | 199 setupExtendedReportingCheckbox(); |
| 188 setupSSLDebuggingInfo(); | 200 setupSSLDebuggingInfo(); |
| 189 document.addEventListener('keypress', handleKeypress); | 201 document.addEventListener('keypress', handleKeypress); |
| 190 } | 202 } |
| 191 | 203 |
| 192 document.addEventListener('DOMContentLoaded', setupEvents); | 204 document.addEventListener('DOMContentLoaded', setupEvents); |
| OLD | NEW |