Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Sends a command message to SafeBrowsingBlockingPage::CommandReceived. | |
| 7 * @param {string} cmd The command to send. | |
| 8 */ | |
| 9 function sendCommand(cmd) { | |
| 10 window.domAutomationController.setAutomationId(1); | |
| 11 window.domAutomationController.send(cmd); | |
| 12 } | |
| 13 | |
| 14 /** | |
| 15 * Records state of the reporting checkbox. | |
| 16 */ | |
| 17 function savePreference() { | |
| 18 var checkBox = $('check-report'); | |
| 19 if (checkBox.checked) | |
| 20 sendCommand('doReport'); | |
| 21 else | |
| 22 sendCommand('dontReport'); | |
| 23 } | |
| 24 | |
| 25 /** | |
| 26 * Expands or collapses the "see more" section of the page. | |
| 27 */ | |
| 28 function seeMore() { | |
| 29 if ($('see-less-text').hidden) { | |
| 30 $('see-more-text').hidden = true; | |
| 31 $('see-less-text').hidden = false; | |
| 32 $('see-more-contents').hidden = false; | |
| 33 sendCommand('expandedSeeMore'); | |
| 34 } else { | |
| 35 $('see-more-text').hidden = false; | |
| 36 $('see-less-text').hidden = true; | |
| 37 $('see-more-contents').hidden = true; | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 /** | |
| 42 * Onload listener to initialize javascript handlers. | |
| 43 */ | |
| 44 document.addEventListener('DOMContentLoaded', function() { | |
| 45 $('proceed-span').hidden = templateData.proceedDisabled; | |
| 46 | |
| 47 $('back').onclick = function() { | |
| 48 sendCommand('takeMeBack'); | |
| 49 }; | |
| 50 $('proceed').onclick = function(e) { | |
| 51 sendCommand('proceed'); | |
| 52 }; | |
| 53 $('learn-more-link').onclick = function(e) { | |
| 54 sendCommand('learnMore2'); | |
| 55 }; | |
| 56 $('show-diagnostic-link').onclick = function(e) { | |
| 57 sendCommand('showDiagnostic'); | |
| 58 }; | |
| 59 $('see-more-link').onclick = function(e) { | |
| 60 seeMore(); | |
| 61 // preventDefaultOnPoundLinkClicks doesn't work for this link since it | |
| 62 // contains <span>s, which confuse preventDefaultOnPoundLinkClicks. | |
|
arv (Not doing code reviews)
2012/08/23 14:20:25
preventDefaultOnPoundLinkClicks can be fixed to ha
| |
| 63 e.preventDefault(); | |
| 64 }; | |
| 65 $('check-report').onclick = savePreference; | |
| 66 | |
| 67 // All the links are handled by javascript sending commands back to the C++ | |
| 68 // handler, we don't want the default actions. | |
| 69 preventDefaultOnPoundLinkClicks(); // From shared/js/util.js. | |
| 70 }); | |
| OLD | NEW |