Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(866)

Side by Side Diff: components/security_interstitials/core/browser/resources/interstitial_common.js

Issue 2930043002: Implement V2 design for quiet safe browsing interstitial (Closed)
Patch Set: Remove extra break Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/security_interstitials/core/browser/resources/interstitial_large.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 security interstitials. It is used for both SSL 5 // This is the shared code for security interstitials. It is used for both SSL
6 // interstitials and Safe Browsing interstitials. 6 // interstitials and Safe Browsing interstitials.
7 7
8 // Should match security_interstitials::SecurityInterstitialCommands 8 // Should match security_interstitials::SecurityInterstitialCommands
9 /** @enum| {string} */ 9 /** @enum| {string} */
10 var SecurityInterstitialCommandId = { 10 var SecurityInterstitialCommandId = {
11 CMD_DONT_PROCEED: 0, 11 CMD_DONT_PROCEED: 0,
12 CMD_PROCEED: 1, 12 CMD_PROCEED: 1,
13 // Ways for user to get more information 13 // Ways for user to get more information
14 CMD_SHOW_MORE_SECTION: 2, 14 CMD_SHOW_MORE_SECTION: 2,
15 CMD_OPEN_HELP_CENTER: 3, 15 CMD_OPEN_HELP_CENTER: 3,
16 CMD_OPEN_DIAGNOSTIC: 4, 16 CMD_OPEN_DIAGNOSTIC: 4,
17 // Primary button actions 17 // Primary button actions
18 CMD_RELOAD: 5, 18 CMD_RELOAD: 5,
19 CMD_OPEN_DATE_SETTINGS: 6, 19 CMD_OPEN_DATE_SETTINGS: 6,
20 CMD_OPEN_LOGIN: 7, 20 CMD_OPEN_LOGIN: 7,
21 // Safe Browsing Extended Reporting 21 // Safe Browsing Extended Reporting
22 CMD_DO_REPORT: 8, 22 CMD_DO_REPORT: 8,
23 CMD_DONT_REPORT: 9, 23 CMD_DONT_REPORT: 9,
24 CMD_OPEN_REPORTING_PRIVACY: 10, 24 CMD_OPEN_REPORTING_PRIVACY: 10,
25 CMD_OPEN_WHITEPAPER: 11, 25 CMD_OPEN_WHITEPAPER: 11,
26 // Report a phishing error. 26 // Report a phishing error.
27 CMD_REPORT_PHISHING_ERROR: 12 27 CMD_REPORT_PHISHING_ERROR: 12
28 }; 28 };
29 29
30 var HIDDEN_CLASS = 'hidden';
31
30 /** 32 /**
31 * A convenience method for sending commands to the parent page. 33 * A convenience method for sending commands to the parent page.
32 * @param {string} cmd The command to send. 34 * @param {string} cmd The command to send.
33 */ 35 */
34 function sendCommand(cmd) { 36 function sendCommand(cmd) {
35 // <if expr="not is_ios"> 37 // <if expr="not is_ios">
36 window.domAutomationController.setAutomationId(1); 38 window.domAutomationController.setAutomationId(1);
37 window.domAutomationController.send(cmd); 39 window.domAutomationController.send(cmd);
38 // </if> 40 // </if>
39 // <if expr="is_ios"> 41 // <if expr="is_ios">
40 // TODO(crbug.com/565877): Revisit message passing for WKWebView. 42 // TODO(crbug.com/565877): Revisit message passing for WKWebView.
41 var iframe = document.createElement('IFRAME'); 43 var iframe = document.createElement('IFRAME');
42 iframe.setAttribute('src', 'js-command:' + cmd); 44 iframe.setAttribute('src', 'js-command:' + cmd);
43 document.documentElement.appendChild(iframe); 45 document.documentElement.appendChild(iframe);
44 iframe.parentNode.removeChild(iframe); 46 iframe.parentNode.removeChild(iframe);
45 // </if> 47 // </if>
46 } 48 }
49
50 /**
51 * Call this to stop clicks on <a href="#"> links from scrolling to the top of
52 * the page (and possibly showing a # in the link).
53 */
54 function preventDefaultOnPoundLinkClicks() {
55 document.addEventListener('click', function(e) {
56 var anchor = findAncestor(/** @type {Node} */ (e.target), function(el) {
57 return el.tagName == 'A';
58 });
59 // Use getAttribute() to prevent URL normalization.
60 if (anchor && anchor.getAttribute('href') == '#')
61 e.preventDefault();
62 });
63 }
OLDNEW
« no previous file with comments | « no previous file | components/security_interstitials/core/browser/resources/interstitial_large.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698