15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// File Description:
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//     Contains all the necessary functions for rendering the Welcome page on
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)//     Android.
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)cr.define('welcome', function() {
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  'use strict';
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  function initialize() {
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    // Disable context menus.
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    document.body.oncontextmenu = function(e) {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)      e.preventDefault();
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    $('settings').onclick = function() {
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      chrome.send('showSyncSettings');
20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    };
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    var tosLink = $('tos-link');
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    if (tosLink) {
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      tosLink.onclick = function() {
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)        chrome.send('showTermsOfService');
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)      };
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    }
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    // Set visibility of terms of service footer.
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    $('tos-footer').hidden = !loadTimeData.getBoolean('tosVisible');
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    // Set the initial visibility for the sync footer.
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    chrome.send('updateSyncFooterVisibility');
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  /**
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)   * Sets the visibility of the sync footer.
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)   * @param {boolean} isVisible Whether the sync footer should be visible.
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)   */
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  function setSyncFooterVisible(isVisible) {
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    $('sync-footer').hidden = !isVisible;
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  }
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return an object with all of the exports.
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  return {
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    initialize: initialize,
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    setSyncFooterVisible: setSyncFooterVisible,
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  };
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)});
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)document.addEventListener('DOMContentLoaded', welcome.initialize);
52