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.
6 * Sends a command message to SafeBrowsingBlockingPage::CommandReceived.
7 * @param {string} cmd The command to send.
9 function sendCommand(cmd
) {
10 window
.domAutomationController
.setAutomationId(1);
11 window
.domAutomationController
.send(cmd
);
15 * Records state of the reporting checkbox.
17 function savePreference() {
18 var checkBox
= $('check-report');
20 sendCommand('doReport');
22 sendCommand('dontReport');
26 * Expands or collapses the "see more" section of the page.
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');
35 $('see-more-text').hidden
= false;
36 $('see-less-text').hidden
= true;
37 $('see-more-contents').hidden
= true;
41 /* This sets up 4 conditions for the Field Trial.
42 * The 'NoBrand' conditions don't have the Chrome/Chromium logo at the top.
43 * The 'OneStep' conditions don't hide the proceed button.
45 function setupInterstitialExperiment() {
46 var condition
= templateData
.trialType
;
47 if (condition
== 'cond2MalwareNoBrand' ||
48 condition
== 'cond4PhishingNoBrand') {
49 $('logo').style
.display
= 'none';
50 } else if (condition
== 'cond5MalwareOneStep' ||
51 condition
== 'cond6PhishingOneStep') {
52 $('see-more-contents').hidden
= false;
53 $('see-less-text').hidden
= true;
54 $('see-more-text').hidden
= true;
59 * Onload listener to initialize javascript handlers.
61 document
.addEventListener('DOMContentLoaded', function() {
62 $('proceed-span').hidden
= templateData
.proceedDisabled
;
64 $('back').onclick = function() {
65 sendCommand('takeMeBack');
67 $('proceed').onclick = function(e
) {
68 sendCommand('proceed');
70 $('learn-more-link').onclick = function(e
) {
71 sendCommand('learnMore2');
73 $('show-diagnostic-link').onclick = function(e
) {
74 sendCommand('showDiagnostic');
76 $('report-error-link').onclick = function(e
) {
77 sendCommand('reportError');
79 $('see-more-link').onclick = function(e
) {
81 // preventDefaultOnPoundLinkClicks doesn't work for this link since it
82 // contains <span>s, which confuse preventDefaultOnPoundLinkClicks.
85 $('check-report').onclick
= savePreference
;
87 // All the links are handled by javascript sending commands back to the C++
88 // handler, we don't want the default actions.
89 preventDefaultOnPoundLinkClicks(); // From webui/js/util.js.
91 setupInterstitialExperiment();
93 // Allow jsdisplay elements to be visible now.
94 document
.documentElement
.classList
.remove('loading');