| 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 security_interstitials::SecurityInterstitialCommands | |
| 12 var CMD_DONT_PROCEED = 0; | |
| 13 var CMD_PROCEED = 1; | |
| 14 // Ways for user to get more information | |
| 15 var CMD_SHOW_MORE_SECTION = 2; | |
| 16 var CMD_OPEN_HELP_CENTER = 3; | |
| 17 var CMD_OPEN_DIAGNOSTIC = 4; | |
| 18 // Primary button actions | |
| 19 var CMD_RELOAD = 5; | |
| 20 var CMD_OPEN_DATE_SETTINGS = 6; | |
| 21 var CMD_OPEN_LOGIN = 7; | |
| 22 // Safe Browsing Extended Reporting | |
| 23 var CMD_DO_REPORT = 8; | |
| 24 var CMD_DONT_REPORT = 9; | |
| 25 var CMD_OPEN_REPORTING_PRIVACY = 10; | |
| 26 var CMD_OPEN_WHITEPAPER = 11; | |
| 27 // Report a phishing error. | |
| 28 var CMD_REPORT_PHISHING_ERROR = 12; | |
| 29 | |
| 30 /** | |
| 31 * A convenience method for sending commands to the parent page. | |
| 32 * @param {string} cmd The command to send. | |
| 33 */ | |
| 34 function sendCommand(cmd) { | |
| 35 // <if expr="not is_ios"> | |
| 36 window.domAutomationController.setAutomationId(1); | |
| 37 window.domAutomationController.send(cmd); | |
| 38 // </if> | |
| 39 // <if expr="is_ios"> | |
| 40 // TODO(crbug.com/565877): Revisit message passing for WKWebView. | |
| 41 var iframe = document.createElement('IFRAME'); | |
| 42 iframe.setAttribute('src', 'js-command:' + cmd); | |
| 43 document.documentElement.appendChild(iframe); | |
| 44 iframe.parentNode.removeChild(iframe); | |
| 45 // </if> | |
| 46 } | |
| 47 | |
| 48 /** | 11 /** |
| 49 * This allows errors to be skippped by typing a secret phrase into the page. | 12 * This allows errors to be skippped by typing a secret phrase into the page. |
| 50 * @param {string} e The key that was just pressed. | 13 * @param {string} e The key that was just pressed. |
| 51 */ | 14 */ |
| 52 function handleKeypress(e) { | 15 function handleKeypress(e) { |
| 53 var BYPASS_SEQUENCE = 'badidea'; | 16 var BYPASS_SEQUENCE = 'badidea'; |
| 54 if (BYPASS_SEQUENCE.charCodeAt(keyPressState) == e.keyCode) { | 17 if (BYPASS_SEQUENCE.charCodeAt(keyPressState) == e.keyCode) { |
| 55 keyPressState++; | 18 keyPressState++; |
| 56 if (keyPressState == BYPASS_SEQUENCE.length) { | 19 if (keyPressState == BYPASS_SEQUENCE.length) { |
| 57 sendCommand(CMD_PROCEED); | 20 sendCommand(CMD_PROCEED); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 }); | 167 }); |
| 205 } | 168 } |
| 206 | 169 |
| 207 preventDefaultOnPoundLinkClicks(); | 170 preventDefaultOnPoundLinkClicks(); |
| 208 setupExtendedReportingCheckbox(); | 171 setupExtendedReportingCheckbox(); |
| 209 setupSSLDebuggingInfo(); | 172 setupSSLDebuggingInfo(); |
| 210 document.addEventListener('keypress', handleKeypress); | 173 document.addEventListener('keypress', handleKeypress); |
| 211 } | 174 } |
| 212 | 175 |
| 213 document.addEventListener('DOMContentLoaded', setupEvents); | 176 document.addEventListener('DOMContentLoaded', setupEvents); |
| OLD | NEW |