OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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="../options2/options_page.js"/> | 6 <include src="../options2/options_page.js"/> |
7 <include src="../shared/js/util.js"/> | 7 <include src="../shared/js/util.js"/> |
8 <include src="../sync_setup_overlay.js"/> | 8 <include src="../sync_setup_overlay.js"/> |
9 | 9 |
10 cr.define('sync_promo', function() { | 10 cr.define('sync_promo', function() { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 }, | 55 }, |
56 | 56 |
57 // Initializes the page. | 57 // Initializes the page. |
58 initializePage: function() { | 58 initializePage: function() { |
59 options.SyncSetupOverlay.prototype.initializePage.call(this); | 59 options.SyncSetupOverlay.prototype.initializePage.call(this); |
60 | 60 |
61 // Hide parts of the login UI and show the promo UI. | 61 // Hide parts of the login UI and show the promo UI. |
62 this.hideOuterLoginUI_(); | 62 this.hideOuterLoginUI_(); |
63 $('promo-skip').hidden = false; | 63 $('promo-skip').hidden = false; |
64 | 64 |
65 this.showSetupUI_(); | |
66 chrome.send('SyncPromo:Initialize'); | 65 chrome.send('SyncPromo:Initialize'); |
67 | 66 |
68 var self = this; | 67 var self = this; |
69 | 68 |
70 $('promo-skip-button').addEventListener('click', function() { | 69 $('promo-skip-button').addEventListener('click', function() { |
71 chrome.send('SyncPromo:UserSkipped'); | 70 chrome.send('SyncPromo:UserSkipped'); |
72 self.closeOverlay_(); | 71 self.closeOverlay_(); |
73 }); | 72 }); |
74 | 73 |
75 var learnMoreClickedAlready = false; | 74 var learnMoreClickedAlready = false; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 $('choose-datatypes-cancel').addEventListener('click', cancelFunc); | 132 $('choose-datatypes-cancel').addEventListener('click', cancelFunc); |
134 | 133 |
135 // Add the source parameter to the document so that it can be used to | 134 // Add the source parameter to the document so that it can be used to |
136 // selectively show and hide elements using CSS. | 135 // selectively show and hide elements using CSS. |
137 var params = parseQueryParams(document.location); | 136 var params = parseQueryParams(document.location); |
138 if (params.source == '0') | 137 if (params.source == '0') |
139 document.documentElement.setAttribute('isstartup', ''); | 138 document.documentElement.setAttribute('isstartup', ''); |
140 }, | 139 }, |
141 | 140 |
142 /** | 141 /** |
143 * Called when the page is unloading to record number of times a user tried | 142 * Called when the page is unloading. |
144 * to sign in and if they left while a throbber was running. | |
145 * @private | 143 * @private |
146 */ | 144 */ |
147 recordPageViewActions_: function() { | 145 onUnload: function() { |
| 146 // Record number of times a user tried to sign in and if they left |
| 147 // while a throbber was running. |
148 chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]); | 148 chrome.send('SyncPromo:RecordSignInAttempts', [this.signInAttempts_]); |
149 if (this.throbberStart_) | 149 if (this.throbberStart_) |
150 chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]); | 150 chrome.send('SyncPromo:UserFlowAction', [actions.LEFT_DURING_THROBBER]); |
| 151 chrome.send('SyncSetupDidClosePage'); |
151 }, | 152 }, |
152 | 153 |
153 /** @inheritDoc */ | 154 /** @inheritDoc */ |
154 sendConfiguration_: function() { | 155 sendConfiguration_: function() { |
155 chrome.send('SyncPromo:UserFlowAction', | 156 chrome.send('SyncPromo:UserFlowAction', |
156 [actions.CONFIRMED_AFTER_SIGN_IN]); | 157 [actions.CONFIRMED_AFTER_SIGN_IN]); |
157 options.SyncSetupOverlay.prototype.sendConfiguration_.apply(this, | 158 options.SyncSetupOverlay.prototype.sendConfiguration_.apply(this, |
158 arguments); | 159 arguments); |
159 }, | 160 }, |
160 | 161 |
(...skipping 24 matching lines...) Expand all Loading... |
185 * The start time of a throbber on the page. | 186 * The start time of a throbber on the page. |
186 * @private | 187 * @private |
187 */ | 188 */ |
188 throbberStart_: 0, | 189 throbberStart_: 0, |
189 }; | 190 }; |
190 | 191 |
191 SyncPromo.showErrorUI = function() { | 192 SyncPromo.showErrorUI = function() { |
192 SyncPromo.getInstance().showErrorUI_(); | 193 SyncPromo.getInstance().showErrorUI_(); |
193 }; | 194 }; |
194 | 195 |
195 SyncPromo.showSetupUI = function() { | |
196 SyncPromo.getInstance().showSetupUI_(); | |
197 }; | |
198 | |
199 SyncPromo.showSyncSetupPage = function(page, args) { | 196 SyncPromo.showSyncSetupPage = function(page, args) { |
200 SyncPromo.getInstance().showSyncSetupPage_(page, args); | 197 SyncPromo.getInstance().showSyncSetupPage_(page, args); |
201 }; | 198 }; |
202 | 199 |
203 SyncPromo.showSuccessAndClose = function() { | 200 SyncPromo.showSuccessAndClose = function() { |
204 SyncPromo.getInstance().showSuccessAndClose_(); | 201 SyncPromo.getInstance().showSuccessAndClose_(); |
205 }; | 202 }; |
206 | 203 |
207 SyncPromo.showSuccessAndSettingUp = function() { | 204 SyncPromo.showSuccessAndSettingUp = function() { |
208 chrome.send('SyncPromo:UserFlowAction', [actions.SIGNED_IN_SUCCESSFULLY]); | 205 chrome.send('SyncPromo:UserFlowAction', [actions.SIGNED_IN_SUCCESSFULLY]); |
209 SyncPromo.getInstance().showSuccessAndSettingUp_(); | 206 SyncPromo.getInstance().showSuccessAndSettingUp_(); |
210 }; | 207 }; |
211 | 208 |
212 SyncPromo.showStopSyncingUI = function() { | 209 SyncPromo.showStopSyncingUI = function() { |
213 SyncPromo.getInstance().showStopSyncingUI_(); | 210 SyncPromo.getInstance().showStopSyncingUI_(); |
214 }; | 211 }; |
215 | 212 |
216 SyncPromo.initialize = function() { | 213 SyncPromo.initialize = function() { |
217 SyncPromo.getInstance().initializePage(); | 214 SyncPromo.getInstance().initializePage(); |
218 }; | 215 }; |
219 | 216 |
220 SyncPromo.recordPageViewActions = function() { | 217 SyncPromo.onUnload = function() { |
221 SyncPromo.getInstance().recordPageViewActions_(); | 218 SyncPromo.getInstance().onUnload(); |
222 }; | 219 }; |
223 | 220 |
224 SyncPromo.populatePromoMessage = function(resName) { | 221 SyncPromo.populatePromoMessage = function(resName) { |
225 SyncPromo.getInstance().populatePromoMessage_(resName); | 222 SyncPromo.getInstance().populatePromoMessage_(resName); |
226 }; | 223 }; |
227 | 224 |
228 // Export | 225 // Export |
229 return { | 226 return { |
230 SyncPromo: SyncPromo | 227 SyncPromo: SyncPromo |
231 }; | 228 }; |
232 }); | 229 }); |
233 | 230 |
234 var OptionsPage = options.OptionsPage; | 231 var OptionsPage = options.OptionsPage; |
235 var SyncSetupOverlay = sync_promo.SyncPromo; | 232 var SyncSetupOverlay = sync_promo.SyncPromo; |
236 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); | 233 window.addEventListener('DOMContentLoaded', sync_promo.SyncPromo.initialize); |
237 window.addEventListener('beforeunload', | 234 window.addEventListener('unload', |
238 sync_promo.SyncPromo.recordPageViewActions.bind(sync_promo.SyncPromo)); | 235 sync_promo.SyncPromo.onUnload.bind(sync_promo.SyncPromo)); |
OLD | NEW |