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 // Must match the commands handled by SafeBrowsingBlockingPage::CommandReceived. | 5 // Must match the commands handled by SafeBrowsingBlockingPage::CommandReceived. |
6 var SB_CMD_DO_REPORT = 'doReport'; | 6 var SB_CMD_DO_REPORT = 'doReport'; |
7 var SB_CMD_DONT_REPORT = 'dontReport'; | 7 var SB_CMD_DONT_REPORT = 'dontReport'; |
8 var SB_CMD_EXPANDED_SEE_MORE = 'expandedSeeMore'; | 8 var SB_CMD_EXPANDED_SEE_MORE = 'expandedSeeMore'; |
9 var SB_CMD_LEARN_MORE_2 = 'learnMore2'; | 9 var SB_CMD_LEARN_MORE_2 = 'learnMore2'; |
10 var SB_CMD_PROCEED = 'proceed'; | 10 var SB_CMD_PROCEED = 'proceed'; |
11 var SB_CMD_SHOW_DIAGNOSTIC = 'showDiagnostic'; | 11 var SB_CMD_SHOW_DIAGNOSTIC = 'showDiagnostic'; |
12 var SB_CMD_SHOW_PRIVACY = 'showPrivacy'; | 12 var SB_CMD_SHOW_PRIVACY = 'showPrivacy'; |
13 var SB_CMD_TAKE_ME_BACK = 'takeMeBack'; | 13 var SB_CMD_TAKE_ME_BACK = 'takeMeBack'; |
14 | 14 |
15 // Other constants defined in safe_browsing_blocking_page.cc. | 15 // Must match SSLBlockingPageCommands in ssl_blocking_page.h. |
felt
2015/02/19 00:32:32
Hmm, seems unfortunate to have SSLBlockingPageComm
estark
2015/02/19 02:32:08
Hm, when you say "setupCheckbox should be moved" y
felt
2015/02/24 01:57:52
Yes, renaming it to extended_reporting.js could wo
estark
2015/02/24 18:47:08
Done.
| |
16 var SSL_CMD_DO_REPORT = 6; | |
17 var SSL_CMD_DONT_REPORT = 7; | |
18 | |
19 // Other constants defined in security_interstitial_page.h. | |
16 var SB_BOX_CHECKED = 'boxchecked'; | 20 var SB_BOX_CHECKED = 'boxchecked'; |
17 var SB_DISPLAY_CHECK_BOX = 'displaycheckbox'; | 21 var SB_DISPLAY_CHECK_BOX = 'displaycheckbox'; |
18 | 22 |
19 // This sets up the Extended Safe Browsing Reporting opt-in. | 23 // This sets up the Extended Safe Browsing Reporting opt-in, either for |
20 function setupCheckbox() { | 24 // reporting malware or invalid certificate chains, depending on which |
21 if (loadTimeData.getString('type') != 'SAFEBROWSING' || | 25 // |type| is passed in. |type| can be 'SAFEBROWSING' or |
26 // 'SSL' (to set up the invalid cert collection checkbox). | |
27 function setupCheckbox(type) { | |
28 if (type != 'SAFEBROWSING' && type != 'SSL') { | |
felt
2015/02/19 00:32:32
what other type might this be? what are you checki
estark
2015/02/19 02:32:08
Oops, this check was blatantly wrong: replaced it
| |
29 throw new Error('setupCheckbox called for invalid interstitial.'); | |
30 } | |
31 | |
32 if (loadTimeData.getString('type') != type || | |
felt
2015/02/19 00:32:32
if you're going to check loadTimeData.getString('t
estark
2015/02/19 02:32:08
Done.
| |
22 !loadTimeData.getBoolean(SB_DISPLAY_CHECK_BOX)) { | 33 !loadTimeData.getBoolean(SB_DISPLAY_CHECK_BOX)) { |
23 return; | 34 return; |
24 } | 35 } |
25 | 36 |
26 $('opt-in-label').innerHTML = loadTimeData.getString('optInLink'); | 37 $('opt-in-label').innerHTML = loadTimeData.getString('optInLink'); |
27 $('opt-in-checkbox').checked = loadTimeData.getBoolean(SB_BOX_CHECKED); | 38 $('opt-in-checkbox').checked = loadTimeData.getBoolean(SB_BOX_CHECKED); |
28 $('malware-opt-in').classList.remove('hidden'); | 39 $('malware-opt-in').classList.remove('hidden'); |
29 $('body').classList.add('safe-browsing-has-checkbox'); | 40 $('body').classList.add('safe-browsing-has-checkbox'); |
30 | 41 |
31 $('opt-in-checkbox').addEventListener('click', function() { | 42 $('opt-in-checkbox').addEventListener('click', function() { |
32 sendCommand( | 43 var command; |
33 $('opt-in-checkbox').checked ? SB_CMD_DO_REPORT : SB_CMD_DONT_REPORT); | 44 if ($('opt-in-checkbox').checked) { |
45 command = type == 'SAFEBROWSING' ? SB_CMD_DO_REPORT : SSL_CMD_DO_REPORT; | |
46 } else { | |
47 command = type == 'SAFEBROWSING' ? | |
48 SB_CMD_DONT_REPORT : SSL_CMD_DONT_REPORT; | |
49 } | |
50 sendCommand(command); | |
34 }); | 51 }); |
35 } | 52 } |
OLD | NEW |