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

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

Issue 318213002: Add custom interstitial for captive portals. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix trybot errors (memory leak + unused code) Created 5 years, 12 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 | Annotate | Revision Log
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 pElem.appendChild(spanValue); 58 pElem.appendChild(spanValue);
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 interstitialType = loadTimeData.getString('type');
69 var ssl = interstitialType == 'SSL';
felt 2014/12/28 15:40:52 is there a reason you changed this from === to ==?
meacer 2015/01/08 14:29:16 Changed this upon bauerb's comment: https://codere
70 var captivePortal = interstitialType == 'CAPTIVE_PORTAL';
69 var badClock = ssl && loadTimeData.getBoolean('bad_clock'); 71 var badClock = ssl && loadTimeData.getBoolean('bad_clock');
70 var hidePrimaryButton = badClock && loadTimeData.getBoolean( 72 var hidePrimaryButton = badClock && loadTimeData.getBoolean(
71 'hide_primary_button'); 73 'hide_primary_button');
72 74
73 if (ssl) { 75 if (ssl) {
74 $('body').classList.add(badClock ? 'bad-clock' : 'ssl'); 76 $('body').classList.add(badClock ? 'bad-clock' : 'ssl');
75 $('error-code').textContent = loadTimeData.getString('errorCode'); 77 $('error-code').textContent = loadTimeData.getString('errorCode');
76 $('error-code').classList.remove('hidden'); 78 $('error-code').classList.remove('hidden');
79 } else if (captivePortal) {
80 $('body').classList.add('captive-portal');
77 } else { 81 } else {
78 $('body').classList.add('safe-browsing'); 82 $('body').classList.add('safe-browsing');
79 } 83 }
80 84
81 if (hidePrimaryButton) { 85 if (hidePrimaryButton) {
82 $('primary-button').classList.add('hidden'); 86 $('primary-button').classList.add('hidden');
83 } else { 87 } else {
84 $('primary-button').addEventListener('click', function() { 88 $('primary-button').addEventListener('click', function() {
85 if (!ssl) 89 switch (interstitialType) {
86 sendCommand(SB_CMD_TAKE_ME_BACK); 90 case 'CAPTIVE_PORTAL':
87 else if (badClock) 91 sendCommand(CAPTIVEPORTAL_CMD_OPEN_LOGIN_PAGE);
88 sendCommand(SSL_CMD_CLOCK); 92 break;
89 else if (overridable) 93
90 sendCommand(SSL_CMD_DONT_PROCEED); 94 case 'SSL':
91 else 95 if (badClock)
92 sendCommand(SSL_CMD_RELOAD); 96 sendCommand(SSL_CMD_CLOCK);
97 else if (overridable)
98 sendCommand(SSL_CMD_DONT_PROCEED);
99 else
100 sendCommand(SSL_CMD_RELOAD);
101 break;
102
103 case 'SAFEBROWSING':
104 sendCommand(SB_CMD_TAKE_ME_BACK);
105 break;
106
107 default:
108 throw 'Invalid interstitial type';
109 }
93 }); 110 });
94 } 111 }
95 112
96 if (overridable) { 113 if (overridable) {
114 // Captive portal page isn't overridable.
97 $('proceed-link').addEventListener('click', function(event) { 115 $('proceed-link').addEventListener('click', function(event) {
98 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED); 116 sendCommand(ssl ? SSL_CMD_PROCEED : SB_CMD_PROCEED);
99 }); 117 });
100 } else if (!ssl) { 118 } else if (!ssl) {
101 $('final-paragraph').classList.add('hidden'); 119 $('final-paragraph').classList.add('hidden');
102 } 120 }
103 121
104 if (ssl && overridable) { 122 if (ssl && overridable) {
105 $('proceed-link').classList.add('small-link'); 123 $('proceed-link').classList.add('small-link');
106 } else if ($('help-link')) { 124 } else if ($('help-link')) {
107 // Overridable SSL page doesn't have this link. 125 // Overridable SSL page doesn't have this link.
108 $('help-link').addEventListener('click', function(event) { 126 $('help-link').addEventListener('click', function(event) {
109 if (ssl) 127 if (ssl)
110 sendCommand(SSL_CMD_HELP); 128 sendCommand(SSL_CMD_HELP);
111 else if (loadTimeData.getBoolean('phishing')) 129 else if (loadTimeData.getBoolean('phishing'))
112 sendCommand(SB_CMD_LEARN_MORE_2); 130 sendCommand(SB_CMD_LEARN_MORE_2);
113 else 131 else
114 sendCommand(SB_CMD_SHOW_DIAGNOSTIC); 132 sendCommand(SB_CMD_SHOW_DIAGNOSTIC);
115 }); 133 });
116 } 134 }
117 135
118 $('details-button').addEventListener('click', function(event) { 136 if (captivePortal) {
119 var hiddenDetails = $('details').classList.toggle('hidden'); 137 // Captive portal page doesn't have details button.
120 $('details-button').innerText = hiddenDetails ? 138 $('details-button').classList.add('hidden');
121 loadTimeData.getString('openDetails') : 139 } else {
122 loadTimeData.getString('closeDetails'); 140 $('details-button').addEventListener('click', function(event) {
123 if (!expandedDetails) { 141 var hiddenDetails = $('details').classList.toggle('hidden');
124 // Record a histogram entry only the first time that details is opened. 142 $('details-button').innerText = hiddenDetails ?
125 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE); 143 loadTimeData.getString('openDetails') :
126 expandedDetails = true; 144 loadTimeData.getString('closeDetails');
127 } 145 if (!expandedDetails) {
128 }); 146 // Record a histogram entry only the first time that details is opened.
147 sendCommand(ssl ? SSL_CMD_MORE : SB_CMD_EXPANDED_SEE_MORE);
148 expandedDetails = true;
149 }
150 });
151 }
129 152
130 preventDefaultOnPoundLinkClicks(); 153 preventDefaultOnPoundLinkClicks();
131 setupCheckbox(); 154 setupCheckbox();
132 setupSSLDebuggingInfo(); 155 setupSSLDebuggingInfo();
133 document.addEventListener('keypress', handleKeypress); 156 document.addEventListener('keypress', handleKeypress);
134 } 157 }
135 158
136 document.addEventListener('DOMContentLoaded', setupEvents); 159 document.addEventListener('DOMContentLoaded', setupEvents);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698