Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // TODO(sail): Refactor options_page and remove this include. | 5 // TODO(sail): Refactor options_page and remove this include. |
| 6 <include src="options/options_page.js"/> | 6 <include src="options/options_page.js"/> |
|
Evan Stade
2011/11/15 17:45:19
wtffff
Dan Beam
2011/11/15 18:37:13
Wasn't me. Want me to move?
Evan Stade
2011/11/15 22:46:41
no
| |
| 7 <include src="sync_setup_overlay.js"/> | 7 <include src="sync_setup_overlay.js"/> |
| 8 | 8 |
| 9 cr.define('sync_promo', function() { | 9 cr.define('sync_promo', function() { |
| 10 /** | 10 /** |
| 11 * SyncPromo class | 11 * SyncPromo class |
| 12 * Subclass of options.SyncSetupOverlay that customizes the sync setup | 12 * Subclass of options.SyncSetupOverlay that customizes the sync setup |
| 13 * overlay for use in the new tab page. | 13 * overlay for use in the new tab page. |
| 14 * @class | 14 * @class |
| 15 */ | 15 */ |
| 16 function SyncPromo() { | 16 function SyncPromo() { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 29 CREATE_ACCOUNT_CLICKED: i++, | 29 CREATE_ACCOUNT_CLICKED: i++, |
| 30 SKIP_CLICKED: i++, | 30 SKIP_CLICKED: i++, |
| 31 SIGN_IN_ATTEMPTED: i++, | 31 SIGN_IN_ATTEMPTED: i++, |
| 32 SIGNED_IN_SUCCESSFULLY: i++, | 32 SIGNED_IN_SUCCESSFULLY: i++, |
| 33 ADVANCED_CLICKED: i++, | 33 ADVANCED_CLICKED: i++, |
| 34 ENCRYPTION_HELP_CLICKED: i++, | 34 ENCRYPTION_HELP_CLICKED: i++, |
| 35 CANCELLED_AFTER_SIGN_IN: i++, | 35 CANCELLED_AFTER_SIGN_IN: i++, |
| 36 CONFIRMED_AFTER_SIGN_IN: i++, | 36 CONFIRMED_AFTER_SIGN_IN: i++, |
| 37 CLOSED_TAB: i++, | 37 CLOSED_TAB: i++, |
| 38 CLOSED_WINDOW: i++, | 38 CLOSED_WINDOW: i++, |
| 39 LEFT_DURING_THROBBER: i++, | |
| 39 }; | 40 }; |
| 40 }()); | 41 }()); |
| 41 | 42 |
| 42 cr.addSingletonGetter(SyncPromo); | 43 cr.addSingletonGetter(SyncPromo); |
| 43 | 44 |
| 44 SyncPromo.prototype = { | 45 SyncPromo.prototype = { |
| 45 __proto__: options.SyncSetupOverlay.prototype, | 46 __proto__: options.SyncSetupOverlay.prototype, |
| 46 | 47 |
| 47 showOverlay_: function() { | 48 showOverlay_: function() { |
| 48 $('sync-setup-overlay').hidden = false; | 49 $('sync-setup-overlay').hidden = false; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 if (!createAccountClickedAlready) | 103 if (!createAccountClickedAlready) |
| 103 chrome.send('SyncPromo:UserFlowAction', | 104 chrome.send('SyncPromo:UserFlowAction', |
| 104 [actions.CREATE_ACCOUNT_CLICKED]); | 105 [actions.CREATE_ACCOUNT_CLICKED]); |
| 105 createAccountClickedAlready = true; | 106 createAccountClickedAlready = true; |
| 106 }); | 107 }); |
| 107 | 108 |
| 108 // We listen to the <form>'s submit vs. the <input type="submit"> click so | 109 // We listen to the <form>'s submit vs. the <input type="submit"> click so |
| 109 // we also track users that use the keyboard and press enter. | 110 // we also track users that use the keyboard and press enter. |
| 110 var signInAttemptedAlready = false; | 111 var signInAttemptedAlready = false; |
| 111 $('gaia-login-form').addEventListener('submit', function() { | 112 $('gaia-login-form').addEventListener('submit', function() { |
| 113 ++self.signInAttempts_; | |
| 112 if (!signInAttemptedAlready) | 114 if (!signInAttemptedAlready) |
| 113 chrome.send('SyncPromo:UserFlowAction', [actions.SIGN_IN_ATTEMPTED]); | 115 chrome.send('SyncPromo:UserFlowAction', [actions.SIGN_IN_ATTEMPTED]); |
| 114 signInAttemptedAlready = true; | 116 signInAttemptedAlready = true; |
| 115 }); | 117 }); |
| 116 | 118 |
| 117 var encryptionHelpClickedAlready = false; | 119 var encryptionHelpClickedAlready = false; |
| 118 $('encryption-help-link').addEventListener('click', function() { | 120 $('encryption-help-link').addEventListener('click', function() { |
| 119 if (!encryptionHelpClickedAlready ) | 121 if (!encryptionHelpClickedAlready ) |
| 120 chrome.send('SyncPromo:UserFlowAction', | 122 chrome.send('SyncPromo:UserFlowAction', |
| 121 [actions.ENCRYPTION_HELP_CLICKED]); | 123 [actions.ENCRYPTION_HELP_CLICKED]); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 140 this.infographic_ = $('promo-infographic'); | 142 this.infographic_ = $('promo-infographic'); |
| 141 this.learnMore_ = $('promo-information'); | 143 this.learnMore_ = $('promo-information'); |
| 142 | 144 |
| 143 this.infographic_.addEventListener('webkitTransitionEnd', | 145 this.infographic_.addEventListener('webkitTransitionEnd', |
| 144 this.toggleHidden_.bind(this)); | 146 this.toggleHidden_.bind(this)); |
| 145 this.learnMore_.addEventListener('webkitTransitionEnd', | 147 this.learnMore_.addEventListener('webkitTransitionEnd', |
| 146 this.toggleHidden_.bind(this)); | 148 this.toggleHidden_.bind(this)); |
| 147 }, | 149 }, |
| 148 | 150 |
| 149 /** | 151 /** |
| 152 * Called when the page is unloading to record number of times a user tried | |
| 153 * to sign in and if they left while a throbber was running. | |
| 154 */ | |
| 155 recordPageViewActions_: function() { | |
| 156 chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]); | |
| 157 if (typeof this.throbberStart_ == 'number' && | |
| 158 window.isFinite(this.throbberStart_)) { | |
| 159 chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]); | |
| 160 } | |
| 161 }, | |
| 162 | |
| 163 /** | |
| 150 * Remove the [hidden] attribute from the node that was not previously | 164 * Remove the [hidden] attribute from the node that was not previously |
| 151 * transitioning. | 165 * transitioning. |
| 152 * @param {Event} e A -webkit-transition end event. | 166 * @param {Event} e A -webkit-transition end event. |
| 153 * @private | 167 * @private |
| 154 */ | 168 */ |
| 155 toggleHidden_: function(e) { | 169 toggleHidden_: function(e) { |
| 156 // Only show the other element if the target of this event was hidden | 170 // Only show the other element if the target of this event was hidden |
| 157 // (showing also triggers a transition end). | 171 // (showing also triggers a transition end). |
| 158 if (e.target.hidden) { | 172 if (e.target.hidden) { |
| 159 if (e.target === this.infographic_) | 173 if (e.target === this.infographic_) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 186 }, | 200 }, |
| 187 | 201 |
| 188 /** | 202 /** |
| 189 * Shows or hides the title of the promo page. | 203 * Shows or hides the title of the promo page. |
| 190 * @param {Boolean} visible true if the title should be visible, false | 204 * @param {Boolean} visible true if the title should be visible, false |
| 191 * otherwise. | 205 * otherwise. |
| 192 * @private | 206 * @private |
| 193 */ | 207 */ |
| 194 setPromoTitleVisible_: function(visible) { | 208 setPromoTitleVisible_: function(visible) { |
| 195 $('promo-title').hidden = !visible; | 209 $('promo-title').hidden = !visible; |
| 196 } | 210 }, |
| 211 | |
| 212 /** @inheritDoc */ | |
| 213 setThrobbersVisible_: function(visible) { | |
| 214 if (visible) { | |
| 215 this.throbberStart_ = Date.now(); | |
| 216 } else { | |
| 217 if (typeof this.throbberStart_ == 'number' && | |
| 218 window.isFinite(this.throbberStart_)) { | |
| 219 chrome.send('SyncPromo:RecordThrobberTime', | |
| 220 [Date.now() - this.throbberStart_]); | |
| 221 } | |
| 222 this.throbberStart_ = null; | |
| 223 } | |
| 224 // Pass through to SyncSetupOverlay to handle display logic. | |
| 225 options.SyncSetupOverlay.prototype.setThrobbersVisible_.apply( | |
| 226 this, arguments); | |
| 227 }, | |
| 228 | |
| 229 /** | |
| 230 * Number of times a user attempted to sign in to GAIA during this page | |
| 231 * view. | |
| 232 * @private | |
| 233 */ | |
| 234 signInAttempts_: 0, | |
| 235 | |
| 236 /** | |
| 237 * The start time of a throbber on the page. | |
| 238 * @private | |
| 239 */ | |
| 240 throbberStart_: null, | |
|
Evan Stade
2011/11/15 17:45:19
why are you complicating this by setting it to nul
Dan Beam
2011/11/15 18:37:13
Done.
| |
| 197 }; | 241 }; |
| 198 | 242 |
| 199 SyncPromo.showErrorUI = function() { | 243 SyncPromo.showErrorUI = function() { |
| 200 SyncPromo.getInstance().showErrorUI_(); | 244 SyncPromo.getInstance().showErrorUI_(); |
| 201 }; | 245 }; |
| 202 | 246 |
| 203 SyncPromo.showSetupUI = function() { | 247 SyncPromo.showSetupUI = function() { |
| 204 SyncPromo.getInstance().showSetupUI_(); | 248 SyncPromo.getInstance().showSetupUI_(); |
| 205 }; | 249 }; |
| 206 | 250 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 220 SyncPromo.showStopSyncingUI = function() { | 264 SyncPromo.showStopSyncingUI = function() { |
| 221 SyncPromo.getInstance().showStopSyncingUI_(); | 265 SyncPromo.getInstance().showStopSyncingUI_(); |
| 222 }; | 266 }; |
| 223 | 267 |
| 224 SyncPromo.initialize = function() { | 268 SyncPromo.initialize = function() { |
| 225 SyncPromo.getInstance().initializePage(); | 269 SyncPromo.getInstance().initializePage(); |
| 226 }; | 270 }; |
| 227 | 271 |
| 228 SyncPromo.setPromoTitleVisible = function(visible) { | 272 SyncPromo.setPromoTitleVisible = function(visible) { |
| 229 SyncPromo.getInstance().setPromoTitleVisible_(visible); | 273 SyncPromo.getInstance().setPromoTitleVisible_(visible); |
| 230 } | 274 }; |
| 275 | |
| 276 SyncPromo.recordPageViewActions = function() { | |
| 277 SyncPromo.getInstance().recordPageViewActions_(); | |
| 278 }; | |
| 231 | 279 |
| 232 // Export | 280 // Export |
| 233 return { | 281 return { |
| 234 SyncPromo : SyncPromo | 282 SyncPromo: SyncPromo |
| 235 }; | 283 }; |
| 236 }); | 284 }); |
| 237 | 285 |
| 238 var OptionsPage = options.OptionsPage; | 286 var OptionsPage = options.OptionsPage; |
| 239 var SyncSetupOverlay = sync_promo.SyncPromo; | 287 var SyncSetupOverlay = sync_promo.SyncPromo; |
| 240 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); | 288 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); |
| 289 window.addEventListener('beforeunload', | |
| 290 sync_promo.SyncPromo.recordPageViewActions); | |
| OLD | NEW |