summaryrefslogtreecommitdiffstats
path: root/chrome/browser/resources/popular_sites_internals.js
blob: d68e8f9b14cc4237d797e73343df5d07371bceca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

cr.define('chrome.popular_sites_internals', function() {
  'use strict';

  function initialize() {
    function submitDownload(event) {
      $('download-result').textContent = '';
      chrome.send('download', [$('url-input').value,
                               $('country-input').value,
                               $('version-input').value]);
      event.preventDefault();
    }

    $('submit-download').addEventListener('click', submitDownload);

    chrome.send('registerForEvents');
  }

  function receiveDownloadResult(result) {
    $('download-result').textContent = result;
  }

  function receiveSites(sites) {
    jstProcess(new JsEvalContext(sites), $('sites'));
  }

  // Return an object with all of the exports.
  return {
    initialize: initialize,
    receiveDownloadResult: receiveDownloadResult,
    receiveSites: receiveSites,
  };
});

document.addEventListener('DOMContentLoaded',
                          chrome.popular_sites_internals.initialize);