| OLD | NEW |
| (Empty) |
| 1 // Copyright 2015 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 cr.define('chrome.popular_sites_internals', function() { | |
| 6 'use strict'; | |
| 7 | |
| 8 function initialize() { | |
| 9 function submitUpdate(event) { | |
| 10 $('download-result').textContent = ''; | |
| 11 chrome.send('update', [$('override-url').value, | |
| 12 $('override-country').value, | |
| 13 $('override-version').value]); | |
| 14 event.preventDefault(); | |
| 15 } | |
| 16 | |
| 17 $('submit-update').addEventListener('click', submitUpdate); | |
| 18 | |
| 19 function viewJson(event) { | |
| 20 $('json-value').textContent = ''; | |
| 21 chrome.send('viewJson'); | |
| 22 event.preventDefault(); | |
| 23 } | |
| 24 | |
| 25 $('view-json').addEventListener('click', viewJson); | |
| 26 | |
| 27 chrome.send('registerForEvents'); | |
| 28 } | |
| 29 | |
| 30 function receiveOverrides(url, country, version) { | |
| 31 $('override-url').value = url; | |
| 32 $('override-country').value = country; | |
| 33 $('override-version').value = version; | |
| 34 } | |
| 35 | |
| 36 function receiveDownloadResult(result) { | |
| 37 $('download-result').textContent = result; | |
| 38 } | |
| 39 | |
| 40 function receiveSites(sites) { | |
| 41 jstProcess(new JsEvalContext(sites), $('info')); | |
| 42 // Also clear the json string, since it's likely stale now. | |
| 43 $('json-value').textContent = ''; | |
| 44 } | |
| 45 | |
| 46 function receiveJson(json) { | |
| 47 $('json-value').textContent = json; | |
| 48 } | |
| 49 | |
| 50 // Return an object with all of the exports. | |
| 51 return { | |
| 52 initialize: initialize, | |
| 53 receiveOverrides: receiveOverrides, | |
| 54 receiveDownloadResult: receiveDownloadResult, | |
| 55 receiveSites: receiveSites, | |
| 56 receiveJson: receiveJson, | |
| 57 }; | |
| 58 }); | |
| 59 | |
| 60 document.addEventListener('DOMContentLoaded', | |
| 61 chrome.popular_sites_internals.initialize); | |
| 62 | |
| OLD | NEW |