OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 (function() { |
| 6 'use strict'; |
| 7 |
| 8 cr.define('cr.translateInternals', function() { |
| 9 |
| 10 /** |
| 11 * Initializes UI and sends a message to the browser for |
| 12 * initialization. |
| 13 */ |
| 14 function initialize() { |
| 15 cr.ui.decorate('tabbox', cr.ui.TabBox); |
| 16 chrome.send('requestInfo'); |
| 17 } |
| 18 |
| 19 /** |
| 20 * Handles the message of 'prefsUpdated' from the browser. |
| 21 * @param {Object} detail The object which represents pref values. |
| 22 */ |
| 23 function onPrefsUpdated(detail) { |
| 24 var p = $('tabpanel-prefs').querySelector('p'); |
| 25 var content = JSON.stringify(detail, null, 2); |
| 26 p.textContent = content; |
| 27 } |
| 28 |
| 29 /** |
| 30 * The callback entry point from the browser. This function will be |
| 31 * called by the browser. |
| 32 * @param {string} message The name of the sent message |
| 33 * @param {Object} detail The argument of the sent message |
| 34 */ |
| 35 function messageHandler(message, detail) { |
| 36 switch (message) { |
| 37 case 'prefsUpdated': |
| 38 cr.translateInternals.onPrefsUpdated(detail); |
| 39 break; |
| 40 default: |
| 41 console.error('Unknown message:', message); |
| 42 break; |
| 43 } |
| 44 } |
| 45 |
| 46 return { |
| 47 initialize: initialize, |
| 48 messageHandler: messageHandler, |
| 49 onPrefsUpdated: onPrefsUpdated |
| 50 }; |
| 51 }); |
| 52 |
| 53 /** |
| 54 * The entry point of the UI. |
| 55 */ |
| 56 function main() { |
| 57 cr.doc.addEventListener('DOMContentLoaded', |
| 58 cr.translateInternals.initialize); |
| 59 } |
| 60 |
| 61 main(); |
| 62 })(); |
OLD | NEW |