• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3// found in the LICENSE file.
4
5// Must match the commands handled by SafeBrowsingBlockingPage::CommandReceived.
6var SB_CMD_DO_REPORT = 'doReport';
7var SB_CMD_DONT_REPORT = 'dontReport';
8var SB_CMD_EXPANDED_SEE_MORE = 'expandedSeeMore';
9var SB_CMD_LEARN_MORE_2 = 'learnMore2';
10var SB_CMD_PROCEED = 'proceed';
11var SB_CMD_REPORT_ERROR = 'reportError';
12var SB_CMD_SHOW_DIAGNOSTIC = 'showDiagnostic';
13var SB_CMD_SHOW_PRIVACY = 'showPrivacy';
14var SB_CMD_TAKE_ME_BACK = 'takeMeBack';
15
16// Other constants defined in safe_browsing_blocking_page.cc.
17var SB_BOX_CHECKED = 'boxchecked';
18var SB_DISPLAY_CHECK_BOX = 'displaycheckbox';
19
20// This sets up the Extended Safe Browsing Reporting opt-in.
21function setupCheckbox() {
22  if (loadTimeData.getBoolean('ssl') || loadTimeData.getBoolean('phishing') ||
23      !loadTimeData.getBoolean(SB_DISPLAY_CHECK_BOX)) {
24    return;
25  }
26
27  $('opt-in-label').innerHTML = loadTimeData.getString('optInLink');
28  $('opt-in-checkbox').checked = loadTimeData.getBoolean(SB_BOX_CHECKED);
29  $('malware-opt-in').classList.remove('hidden');
30
31  $('opt-in-checkbox').addEventListener('click', function() {
32    sendCommand(
33        $('opt-in-checkbox').checked ? SB_CMD_DO_REPORT : SB_CMD_DONT_REPORT);
34  });
35}
36
37function setupMalwareFinchExperiment() {
38  if (loadTimeData.getString('trialCondition') != 'V3Advice')
39    return;
40  // Add all this dynamically instead of into the HTML because it's just a
41  // short-lived experiment.
42  var heading = document.createElement('h2');
43  heading.innerText = loadTimeData.getString('adviceHeading');
44  $('details').insertBefore(heading, $('details').firstChild);
45}
46