Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: chrome/browser/resources/chromeos/mobile_setup.js

Issue 12597010: Update activation flow for lte devices not to show 3G loading page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 5
6 cr.define('mobile', function() { 6 cr.define('mobile', function() {
7 7
8 function MobileSetup() { 8 function MobileSetup() {
9 } 9 }
10 10
11 cr.addSingletonGetter(MobileSetup); 11 cr.addSingletonGetter(MobileSetup);
12 12
13 MobileSetup.PLAN_ACTIVATION_UNKNOWN = -2;
13 MobileSetup.PLAN_ACTIVATION_PAGE_LOADING = -1; 14 MobileSetup.PLAN_ACTIVATION_PAGE_LOADING = -1;
14 MobileSetup.PLAN_ACTIVATION_START = 0; 15 MobileSetup.PLAN_ACTIVATION_START = 0;
15 MobileSetup.PLAN_ACTIVATION_TRYING_OTASP = 1; 16 MobileSetup.PLAN_ACTIVATION_TRYING_OTASP = 1;
16 MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 3; 17 MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 3;
17 MobileSetup.PLAN_ACTIVATION_RECONNECTING = 4; 18 MobileSetup.PLAN_ACTIVATION_RECONNECTING = 4;
18 MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING = 5; 19 MobileSetup.PLAN_ACTIVATION_WAITING_FOR_CONNECTION = 5;
19 MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 6; 20 MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING = 6;
20 MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT = 7; 21 MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 7;
21 MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 8; 22 MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT = 8;
22 MobileSetup.PLAN_ACTIVATION_START_OTASP = 9; 23 MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 9;
23 MobileSetup.PLAN_ACTIVATION_OTASP = 10; 24 MobileSetup.PLAN_ACTIVATION_START_OTASP = 10;
25 MobileSetup.PLAN_ACTIVATION_OTASP = 11;
24 MobileSetup.PLAN_ACTIVATION_DONE = 12; 26 MobileSetup.PLAN_ACTIVATION_DONE = 12;
25 MobileSetup.PLAN_ACTIVATION_ERROR = 0xFF; 27 MobileSetup.PLAN_ACTIVATION_ERROR = 0xFF;
26 28
27 MobileSetup.EXTENSION_PAGE_URL = 29 MobileSetup.EXTENSION_PAGE_URL =
28 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab'; 30 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab';
29 MobileSetup.ACTIVATION_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + 31 MobileSetup.ACTIVATION_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL +
30 '/activation.html'; 32 '/activation.html';
33 MobileSetup.PORTAL_OFFLINE_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL +
34 '/portal_offline.html';
31 MobileSetup.REDIRECT_POST_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + 35 MobileSetup.REDIRECT_POST_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL +
32 '/redirect.html'; 36 '/redirect.html';
33 37
34 MobileSetup.localStrings_ = new LocalStrings(); 38 MobileSetup.localStrings_ = new LocalStrings();
35 39
36 MobileSetup.prototype = { 40 MobileSetup.prototype = {
37 // Mobile device information. 41 // Mobile device information.
38 deviceInfo_: null, 42 deviceInfo_: null,
39 frameName_: '', 43 frameName_: '',
40 initialized_: false, 44 initialized_: false,
41 fakedTransaction_: false, 45 fakedTransaction_: false,
42 paymentShown_: false, 46 paymentShown_: false,
43 frameLoadError_: 0, 47 frameLoadError_: 0,
44 frameLoadIgnored_: true, 48 frameLoadIgnored_: true,
49 carrierPageUrl_: null,
45 spinnerInt_: -1, 50 spinnerInt_: -1,
46 // UI states. 51 // UI states.
47 state_: -1, 52 state_: MobileSetup.PLAN_ACTIVATION_UNKNOWN,
48 STATE_UNKNOWN_: 'unknown', 53 STATE_UNKNOWN_: 'unknown',
49 STATE_CONNECTING_: 'connecting', 54 STATE_CONNECTING_: 'connecting',
50 STATE_ERROR_: 'error', 55 STATE_ERROR_: 'error',
51 STATE_PAYMENT_: 'payment', 56 STATE_PAYMENT_: 'payment',
52 STATE_ACTIVATING_: 'activating', 57 STATE_ACTIVATING_: 'activating',
53 STATE_CONNECTED_: 'connected', 58 STATE_CONNECTED_: 'connected',
54 59
55 initialize: function(frame_name, carrierPage) { 60 initialize: function(frame_name, carrierPage) {
56 if (this.initialized_) { 61 if (this.initialized_) {
57 console.log('calling initialize() again?'); 62 console.log('calling initialize() again?');
(...skipping 10 matching lines...) Expand all
68 this.confirm_ = new cr.ui.dialogs.ConfirmDialog(document.body); 73 this.confirm_ = new cr.ui.dialogs.ConfirmDialog(document.body);
69 74
70 window.addEventListener('message', function(e) { 75 window.addEventListener('message', function(e) {
71 self.onMessageReceived_(e); 76 self.onMessageReceived_(e);
72 }); 77 });
73 78
74 $('closeButton').addEventListener('click', function(e) { 79 $('closeButton').addEventListener('click', function(e) {
75 $('finalStatus').classList.add('hidden'); 80 $('finalStatus').classList.add('hidden');
76 }); 81 });
77 82
78 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING});
79 // Kick off activation process. 83 // Kick off activation process.
80 chrome.send('startActivation'); 84 chrome.send('startActivation');
81 }, 85 },
82 86
83 startSpinner_: function() { 87 startSpinner_: function() {
84 this.stopSpinner_(); 88 this.stopSpinner_();
85 this.spinnerInt_ = setInterval(mobile.MobileSetup.drawProgress, 100); 89 this.spinnerInt_ = setInterval(mobile.MobileSetup.drawProgress, 100);
86 }, 90 },
87 91
88 stopSpinner_: function() { 92 stopSpinner_: function() {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 } else if (e.data.type == 'reportTransactionStatusMsg') { 132 } else if (e.data.type == 'reportTransactionStatusMsg') {
129 console.log('calling setTransactionStatus from onMessageReceived_'); 133 console.log('calling setTransactionStatus from onMessageReceived_');
130 chrome.send('setTransactionStatus', [e.data.status]); 134 chrome.send('setTransactionStatus', [e.data.status]);
131 } 135 }
132 }, 136 },
133 137
134 changeState_: function(deviceInfo) { 138 changeState_: function(deviceInfo) {
135 var newState = deviceInfo.state; 139 var newState = deviceInfo.state;
136 if (this.state_ == newState) 140 if (this.state_ == newState)
137 return; 141 return;
138 var main = $('mainbody'); 142
143 // The mobile setup is already in its final state.
144 if (this.state_ == MobileSetup.PLAN_ACTIVATION_DONE ||
145 this.state_ == MobileSetup.PLAN_ACTIVATION_ERROR) {
146 return;
147 }
148
139 // Map handler state to UX. 149 // Map handler state to UX.
140 switch (newState) { 150 switch (newState) {
141 case MobileSetup.PLAN_ACTIVATION_PAGE_LOADING: 151 case MobileSetup.PLAN_ACTIVATION_PAGE_LOADING:
142 case MobileSetup.PLAN_ACTIVATION_START: 152 case MobileSetup.PLAN_ACTIVATION_START:
143 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP: 153 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP:
144 case MobileSetup.PLAN_ACTIVATION_START_OTASP: 154 case MobileSetup.PLAN_ACTIVATION_START_OTASP:
145 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: 155 case MobileSetup.PLAN_ACTIVATION_RECONNECTING:
146 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT: 156 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT:
157 // Activation page should not be shown for devices that are activated
158 // over non cellular network.
159 if (deviceInfo.activate_over_non_cellular_network)
160 break;
161
147 $('statusHeader').textContent = 162 $('statusHeader').textContent =
148 MobileSetup.localStrings_.getString('connecting_header'); 163 MobileSetup.localStrings_.getString('connecting_header');
149 $('auxHeader').textContent = 164 $('auxHeader').textContent =
150 MobileSetup.localStrings_.getString('please_wait'); 165 MobileSetup.localStrings_.getString('please_wait');
151 $('paymentForm').classList.add('hidden'); 166 $('paymentForm').classList.add('hidden');
152 $('finalStatus').classList.add('hidden'); 167 $('finalStatus').classList.add('hidden');
168 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL);
153 $('systemStatus').classList.remove('hidden'); 169 $('systemStatus').classList.remove('hidden');
154 $('carrierPage').classList.remove('hidden');
155 $('canvas').classList.remove('hidden'); 170 $('canvas').classList.remove('hidden');
156 this.startSpinner_(); 171 this.startSpinner_();
157 break; 172 break;
158 case MobileSetup.PLAN_ACTIVATION_TRYING_OTASP: 173 case MobileSetup.PLAN_ACTIVATION_TRYING_OTASP:
159 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: 174 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION:
160 case MobileSetup.PLAN_ACTIVATION_OTASP: 175 case MobileSetup.PLAN_ACTIVATION_OTASP:
176 // Activation page should not be shown for devices that are activated
177 // over non cellular network.
178 if (deviceInfo.activate_over_non_cellular_network)
179 break;
180
161 $('statusHeader').textContent = 181 $('statusHeader').textContent =
162 MobileSetup.localStrings_.getString('activating_header'); 182 MobileSetup.localStrings_.getString('activating_header');
163 $('auxHeader').textContent = 183 $('auxHeader').textContent =
164 MobileSetup.localStrings_.getString('please_wait'); 184 MobileSetup.localStrings_.getString('please_wait');
165 $('paymentForm').classList.add('hidden'); 185 $('paymentForm').classList.add('hidden');
166 $('finalStatus').classList.add('hidden'); 186 $('finalStatus').classList.add('hidden');
187 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL);
167 $('systemStatus').classList.remove('hidden'); 188 $('systemStatus').classList.remove('hidden');
168 $('carrierPage').classList.remove('hidden');
169 $('canvas').classList.remove('hidden'); 189 $('canvas').classList.remove('hidden');
170 this.startSpinner_(); 190 this.startSpinner_();
171 break; 191 break;
172 case MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING: 192 case MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING:
193 // Activation page should not be shown for devices that are activated
194 // over non cellular network.
195 if (!deviceInfo.activate_over_non_cellular_network) {
196 $('statusHeader').textContent =
197 MobileSetup.localStrings_.getString('connecting_header');
198 $('auxHeader').textContent = '';
199 $('paymentForm').classList.add('hidden');
200 $('finalStatus').classList.add('hidden');
201 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL);
202 $('systemStatus').classList.remove('hidden');
203 $('canvas').classList.remove('hidden');
204 }
205 this.loadPaymentFrame_(deviceInfo);
206 break;
207 case MobileSetup.PLAN_ACTIVATION_WAITING_FOR_CONNECTION:
173 $('statusHeader').textContent = 208 $('statusHeader').textContent =
174 MobileSetup.localStrings_.getString('connecting_header'); 209 MobileSetup.localStrings_.getString('portal_unreachable_header');
175 $('auxHeader').textContent = ''; 210 $('auxHeader').textContent = '';
211 $('auxHeader').classList.add('hidden');
176 $('paymentForm').classList.add('hidden'); 212 $('paymentForm').classList.add('hidden');
177 $('finalStatus').classList.add('hidden'); 213 $('finalStatus').classList.add('hidden');
178 $('systemStatus').classList.remove('hidden'); 214 $('systemStatus').classList.remove('hidden');
215 this.setCarrierPage_(MobileSetup.PORTAL_OFFLINE_PAGE_URL);
179 $('canvas').classList.remove('hidden'); 216 $('canvas').classList.remove('hidden');
180 this.loadPaymentFrame_(deviceInfo); 217 this.startSpinner_();
181 break; 218 break;
182 case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT: 219 case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT:
183 $('statusHeader').textContent = ''; 220 $('statusHeader').textContent = '';
184 $('auxHeader').textContent = ''; 221 $('auxHeader').textContent = '';
185 $('finalStatus').classList.add('hidden'); 222 $('finalStatus').classList.add('hidden');
186 $('systemStatus').classList.add('hidden'); 223 $('systemStatus').classList.add('hidden');
187 $('carrierPage').classList.add('hidden');
188 $('paymentForm').classList.remove('hidden'); 224 $('paymentForm').classList.remove('hidden');
189 $('canvas').classList.add('hidden'); 225 $('canvas').classList.add('hidden');
190 this.stopSpinner_(); 226 this.stopSpinner_();
191 this.paymentShown_ = true; 227 this.paymentShown_ = true;
192 break; 228 break;
193 case MobileSetup.PLAN_ACTIVATION_DONE: 229 case MobileSetup.PLAN_ACTIVATION_DONE:
194 $('statusHeader').textContent = ''; 230 $('statusHeader').textContent = '';
195 $('auxHeader').textContent = ''; 231 $('auxHeader').textContent = '';
196 $('finalHeader').textContent = 232 $('finalHeader').textContent =
197 MobileSetup.localStrings_.getString('completed_header'); 233 MobileSetup.localStrings_.getString('completed_header');
198 $('finalMessage').textContent = 234 $('finalMessage').textContent =
199 MobileSetup.localStrings_.getString('completed_text'); 235 MobileSetup.localStrings_.getString('completed_text');
200 $('systemStatus').classList.add('hidden'); 236 $('systemStatus').classList.add('hidden');
201 $('carrierPage').classList.add('hidden');
202 $('paymentForm').classList.remove('hidden');
203 $('closeButton').classList.remove('hidden'); 237 $('closeButton').classList.remove('hidden');
204 $('finalStatus').classList.remove('hidden'); 238 $('finalStatus').classList.remove('hidden');
205 $('canvas').classList.add('hidden'); 239 $('canvas').classList.add('hidden');
206 this.stopSpinner_(); 240 this.stopSpinner_();
207 if (this.paymentShown_) { 241 if (this.paymentShown_) {
208 $('closeButton').classList.remove('hidden'); 242 $('closeButton').classList.remove('hidden');
243 $('paymentForm').classList.remove('hidden');
209 } else { 244 } else {
210 $('closeButton').classList.add('hidden'); 245 $('closeButton').classList.add('hidden');
246 $('paymentForm').classList.add('hidden');
xiyuan 2013/03/14 01:29:17 nit: you can simplify the whole "if" using classLi
tbarzic 2013/03/14 01:36:28 cool
211 } 247 }
212 break; 248 break;
213 case MobileSetup.PLAN_ACTIVATION_ERROR: 249 case MobileSetup.PLAN_ACTIVATION_ERROR:
214 $('statusHeader').textContent = ''; 250 $('statusHeader').textContent = '';
215 $('auxHeader').textContent = ''; 251 $('auxHeader').textContent = '';
216 $('finalHeader').textContent = 252 $('finalHeader').textContent =
217 MobileSetup.localStrings_.getString('error_header'); 253 MobileSetup.localStrings_.getString('error_header');
218 $('finalMessage').textContent = deviceInfo.error; 254 $('finalMessage').textContent = deviceInfo.error;
219 $('systemStatus').classList.add('hidden'); 255 $('systemStatus').classList.add('hidden');
220 $('carrierPage').classList.add('hidden');
221 $('paymentForm').classList.remove('hidden');
222 $('canvas').classList.add('hidden'); 256 $('canvas').classList.add('hidden');
223 this.stopSpinner_(); 257 this.stopSpinner_();
224 if (this.paymentShown_) { 258 if (this.paymentShown_) {
225 $('closeButton').classList.remove('hidden'); 259 $('closeButton').classList.remove('hidden');
260 $('paymentForm').classList.remove('hidden');
226 } else { 261 } else {
227 $('closeButton').classList.add('hidden'); 262 $('closeButton').classList.add('hidden');
263 $('paymentForm').classList.add('hidden');
xiyuan 2013/03/14 01:29:17 nit: same here.
tbarzic 2013/03/14 01:36:28 Done.
228 } 264 }
229 $('finalStatus').classList.remove('hidden'); 265 $('finalStatus').classList.remove('hidden');
230 break; 266 break;
231 } 267 }
232 this.state_ = newState; 268 this.state_ = newState;
233 }, 269 },
234 270
271 setCarrierPage_: function(url) {
272 if (this.carrierPageUrl_ == url)
273 return;
274 this.carrierPageUrl_ = url;
275 $('carrierPage').contentWindow.location.href = url;
276 },
277
235 updateDeviceStatus_: function(deviceInfo) { 278 updateDeviceStatus_: function(deviceInfo) {
236 this.changeState_(deviceInfo); 279 this.changeState_(deviceInfo);
237 }, 280 },
238 281
239 portalFrameLoadError_: function(errorCode) { 282 portalFrameLoadError_: function(errorCode) {
240 if (this.frameLoadIgnored_) 283 if (this.frameLoadIgnored_)
241 return; 284 return;
242 console.log('Portal frame load error detected: ', errorCode); 285 console.log('Portal frame load error detected: ', errorCode);
243 this.frameLoadError_ = errorCode; 286 this.frameLoadError_ = errorCode;
244 }, 287 },
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 367
325 MobileSetup.loadPage = function() { 368 MobileSetup.loadPage = function() {
326 mobile.MobileSetup.getInstance().initialize('paymentForm', 369 mobile.MobileSetup.getInstance().initialize('paymentForm',
327 mobile.MobileSetup.ACTIVATION_PAGE_URL); 370 mobile.MobileSetup.ACTIVATION_PAGE_URL);
328 }; 371 };
329 372
330 // Export 373 // Export
331 return { 374 return {
332 MobileSetup: MobileSetup 375 MobileSetup: MobileSetup
333 }; 376 };
334
335 }); 377 });
336 378
379 document.addEventListener('DOMContentLoaded', mobile.MobileSetup.loadPage);
OLDNEW
« no previous file with comments | « chrome/browser/resources/chromeos/mobile_setup.html ('k') | chrome/browser/ui/webui/chromeos/mobile_setup_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698