// Copyright (c) 2011 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('sync_promo', function() { /** * SyncPromo class * Subclass of options.SyncSetupOverlay that customizes the sync setup * overlay for use in the new tab page. * @class */ function SyncPromo() { options.SyncSetupOverlay.call(this, 'syncSetup', templateData.syncSetupOverlayTitle, 'sync-setup-overlay'); } // Replicating enum from chrome/common/extensions/extension_constants.h. const actions = (function() { var i = 0; return { VIEWED: i++, LEARN_MORE_CLICKED: i++, ACCOUNT_HELP_CLICKED: i++, CREATE_ACCOUNT_CLICKED: i++, SKIP_CLICKED: i++, SIGN_IN_ATTEMPTED: i++, SIGNED_IN_SUCCESSFULLY: i++, ADVANCED_CLICKED: i++, ENCRYPTION_HELP_CLICKED: i++, CANCELLED_AFTER_SIGN_IN: i++, CONFIRMED_AFTER_SIGN_IN: i++, CLOSED_TAB: i++, CLOSED_WINDOW: i++, }; }()); cr.addSingletonGetter(SyncPromo); SyncPromo.prototype = { __proto__: options.SyncSetupOverlay.prototype, showOverlay_: function() { $('sync-setup-overlay').hidden = false; }, closeOverlay_: function() { chrome.send('SyncPromo:Close'); }, // Initializes the page. initializePage: function() { localStrings = new LocalStrings(); options.SyncSetupOverlay.prototype.initializePage.call(this); // Hide parts of the login UI and show the promo UI. this.hideOuterLoginUI_(); $('sync-setup-login-promo-column').hidden = false; $('promo-skip').hidden = false; this.showSetupUI_(); chrome.send('SyncPromo:Initialize'); var self = this; $('promo-skip-button').addEventListener('click', function() { chrome.send('SyncPromo:UserFlowAction', [actions.SKIP_CLICKED]); self.closeOverlay_(); }); var learnMoreClickedAlready = false; $('promo-learn-more-show').addEventListener('click', function() { self.showLearnMore_(true); if (!learnMoreClickedAlready) chrome.send('SyncPromo:UserFlowAction', [actions.LEARN_MORE_CLICKED]); learnMoreClickedAlready = true; }); $('promo-learn-more-hide').addEventListener('click', function() { self.showLearnMore_(false); }); $('promo-advanced').addEventListener('click', function() { chrome.send('SyncPromo:ShowAdvancedSettings'); }); var accountHelpClickedAlready = false; $('cannot-access-account-link').addEventListener('click', function() { if (!accountHelpClickedAlready) chrome.send('SyncPromo:UserFlowAction', [actions.ACCOUNT_HELP_CLICKED]); accountHelpClickedAlready = true; }); var createAccountClickedAlready = false; $('create-account-link').addEventListener('click', function() { if (!createAccountClickedAlready) chrome.send('SyncPromo:UserFlowAction', [actions.CREATE_ACCOUNT_CLICKED]); createAccountClickedAlready = true; }); // We listen to the