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

Side by Side Diff: chrome/browser/resources/security_warnings/interstitial_v2.js

Issue 664503006: Implementation of the full clock interstitial. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
OLDNEW
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
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 badClock = ssl && loadTimeData.getBoolean('bad_clock');
69 70
70 if (ssl) { 71 if (ssl) {
71 $('body').classList.add('ssl'); 72 var bodyClass = badClock ? 'bad-clock' : 'ssl';
felt 2014/10/23 01:54:10 you could simplify here: $('body').classList.dd(ba
lgarron 2014/10/23 03:02:04 Personally, I prefer not to use ternary operators
felt 2014/10/23 05:26:22 It seems odd to define a variable that's only used
lgarron 2014/10/23 19:37:44 Hmm, I don't really find it odd. In any case, I've
73 $('body').classList.add(bodyClass);
felt 2014/10/23 01:54:10 I'm surprised you don't need both ssl and bad-cloc
lgarron 2014/10/23 03:02:04 Yep, exactly. (I was surprised, too!) If we expec
74
72 $('error-code').textContent = loadTimeData.getString('errorCode'); 75 $('error-code').textContent = loadTimeData.getString('errorCode');
73 $('error-code').classList.remove('hidden'); 76 $('error-code').classList.remove('hidden');
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 (!ssl)
80 sendCommand(SB_CMD_TAKE_ME_BACK); 83 sendCommand(SB_CMD_TAKE_ME_BACK);
84 else if (badClock)
85 sendCommand(SSL_CMD_CLOCK);
81 else if (overridable) 86 else if (overridable)
82 sendCommand(SSL_CMD_DONT_PROCEED); 87 sendCommand(SSL_CMD_DONT_PROCEED);
83 else 88 else
84 sendCommand(SSL_CMD_RELOAD); 89 sendCommand(SSL_CMD_RELOAD);
85 }); 90 });
86 91
87 if (overridable) { 92 if (overridable) {
88 $('proceed-link').addEventListener('click', function(event) { 93 $('proceed-link').addEventListener('click', function(event) {
89 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); 94 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED);
90 }); 95 });
91 } else if (!ssl) { 96 } else if (!ssl) {
92 $('final-paragraph').classList.add('hidden'); 97 $('final-paragraph').classList.add('hidden');
93 } 98 }
94 99
95 if (ssl && overridable) { 100 if (ssl && overridable) {
96 $('proceed-link').classList.add('small-link'); 101 $('proceed-link').classList.add('small-link');
97 } else if ($('help-link')) { 102 } else if ($('help-link')) {
98 // Overridable SSL page doesn't have this link. 103 // Overridable SSL page doesn't have this link.
99 $('help-link').addEventListener('click', function(event) { 104 $('help-link').addEventListener('click', function(event) {
100 if (ssl) 105 if (ssl)
101 sendCommand(SSL_CMD_HELP); 106 sendCommand(SSL_CMD_HELP);
102 else if (loadTimeData.getBoolean('phishing')) 107 else if (loadTimeData.getBoolean('phishing'))
103 sendCommand(SB_CMD_LEARN_MORE_2); 108 sendCommand(SB_CMD_LEARN_MORE_2);
104 else 109 else
105 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); 110 sendCommand(SB_CMD_SHOW_DIAGNOSTIC);
106 }); 111 });
107 } 112 }
108 113
109 if (ssl && $('clock-link')) {
110 $('clock-link').addEventListener('click', function(event) {
111 sendCommand(SSL_CMD_CLOCK);
112 });
113 }
114
115 $('details-button').addEventListener('click', function(event) { 114 $('details-button').addEventListener('click', function(event) {
116 var hiddenDetails = $('details').classList.toggle('hidden'); 115 if (badClock) {
117 $('details-button').innerText = hiddenDetails ? 116 sendCommand(SSL_CMD_RELOAD);
118 loadTimeData.getString('openDetails') : 117 } else {
119 loadTimeData.getString('closeDetails'); 118 var hiddenDetails = $('details').classList.toggle('hidden');
120 if (!expandedDetails) { 119 $('details-button').innerText = hiddenDetails ?
121 // Record a histogram entry only the first time that details is opened. 120 loadTimeData.getString('openDetails') :
122 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); 121 loadTimeData.getString('closeDetails');
123 expandedDetails = true; 122 if (!expandedDetails) {
123 // Record a histogram entry only the first time that details is opened.
124 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE);
125 expandedDetails = true;
126 }
124 } 127 }
125 }); 128 });
126 129
127 preventDefaultOnPoundLinkClicks(); 130 preventDefaultOnPoundLinkClicks();
128 setupCheckbox(); 131 setupCheckbox();
129 setupSSLDebuggingInfo(); 132 setupSSLDebuggingInfo();
130 document.addEventListener('keypress', handleKeypress); 133 document.addEventListener('keypress', handleKeypress);
131 } 134 }
132 135
133 document.addEventListener('DOMContentLoaded', setupEvents); 136 document.addEventListener('DOMContentLoaded', setupEvents);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698