| 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 | 5 |
| 6 cr.define('mobile', function() { | 6 cr.define('mobile', function() { |
| 7 | 7 |
| 8 function MobileSetup() { | 8 function MobileSetup() { |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 MobileSetup.EXTENSION_PAGE_URL = | 29 MobileSetup.EXTENSION_PAGE_URL = |
| 30 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab'; | 30 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab'; |
| 31 MobileSetup.ACTIVATION_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + | 31 MobileSetup.ACTIVATION_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + |
| 32 '/activation.html'; | 32 '/activation.html'; |
| 33 MobileSetup.PORTAL_OFFLINE_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + | 33 MobileSetup.PORTAL_OFFLINE_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + |
| 34 '/portal_offline.html'; | 34 '/portal_offline.html'; |
| 35 MobileSetup.REDIRECT_POST_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + | 35 MobileSetup.REDIRECT_POST_PAGE_URL = MobileSetup.EXTENSION_PAGE_URL + |
| 36 '/redirect.html'; | 36 '/redirect.html'; |
| 37 | 37 |
| 38 MobileSetup.localStrings_ = new LocalStrings(); | |
| 39 | |
| 40 MobileSetup.prototype = { | 38 MobileSetup.prototype = { |
| 41 // Mobile device information. | 39 // Mobile device information. |
| 42 deviceInfo_: null, | 40 deviceInfo_: null, |
| 43 frameName_: '', | 41 frameName_: '', |
| 44 initialized_: false, | 42 initialized_: false, |
| 45 fakedTransaction_: false, | 43 fakedTransaction_: false, |
| 46 paymentShown_: false, | 44 paymentShown_: false, |
| 47 frameLoadError_: 0, | 45 frameLoadError_: 0, |
| 48 frameLoadIgnored_: true, | 46 frameLoadIgnored_: true, |
| 49 carrierPageUrl_: null, | 47 carrierPageUrl_: null, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 initialize: function(frame_name, carrierPage) { | 58 initialize: function(frame_name, carrierPage) { |
| 61 if (this.initialized_) { | 59 if (this.initialized_) { |
| 62 console.log('calling initialize() again?'); | 60 console.log('calling initialize() again?'); |
| 63 return; | 61 return; |
| 64 } | 62 } |
| 65 this.initialized_ = true; | 63 this.initialized_ = true; |
| 66 self = this; | 64 self = this; |
| 67 this.frameName_ = frame_name; | 65 this.frameName_ = frame_name; |
| 68 | 66 |
| 69 cr.ui.dialogs.BaseDialog.OK_LABEL = | 67 cr.ui.dialogs.BaseDialog.OK_LABEL = |
| 70 MobileSetup.localStrings_.getString('ok_button'); | 68 loadTimeData.getString('ok_button'); |
| 71 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = | 69 cr.ui.dialogs.BaseDialog.CANCEL_LABEL = |
| 72 MobileSetup.localStrings_.getString('cancel_button'); | 70 loadTimeData.getString('cancel_button'); |
| 73 this.confirm_ = new cr.ui.dialogs.ConfirmDialog(document.body); | 71 this.confirm_ = new cr.ui.dialogs.ConfirmDialog(document.body); |
| 74 | 72 |
| 75 window.addEventListener('message', function(e) { | 73 window.addEventListener('message', function(e) { |
| 76 self.onMessageReceived_(e); | 74 self.onMessageReceived_(e); |
| 77 }); | 75 }); |
| 78 | 76 |
| 79 $('closeButton').addEventListener('click', function(e) { | 77 $('closeButton').addEventListener('click', function(e) { |
| 80 $('finalStatus').classList.add('hidden'); | 78 $('finalStatus').classList.add('hidden'); |
| 81 }); | 79 }); |
| 82 | 80 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 case MobileSetup.PLAN_ACTIVATION_START: | 153 case MobileSetup.PLAN_ACTIVATION_START: |
| 156 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP: | 154 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP: |
| 157 case MobileSetup.PLAN_ACTIVATION_START_OTASP: | 155 case MobileSetup.PLAN_ACTIVATION_START_OTASP: |
| 158 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: | 156 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: |
| 159 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT: | 157 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_PAYMENT: |
| 160 // Activation page should not be shown for the simple activation flow. | 158 // Activation page should not be shown for the simple activation flow. |
| 161 if (simpleActivationFlow) | 159 if (simpleActivationFlow) |
| 162 break; | 160 break; |
| 163 | 161 |
| 164 $('statusHeader').textContent = | 162 $('statusHeader').textContent = |
| 165 MobileSetup.localStrings_.getString('connecting_header'); | 163 loadTimeData.getString('connecting_header'); |
| 166 $('auxHeader').textContent = | 164 $('auxHeader').textContent = |
| 167 MobileSetup.localStrings_.getString('please_wait'); | 165 loadTimeData.getString('please_wait'); |
| 168 $('paymentForm').classList.add('hidden'); | 166 $('paymentForm').classList.add('hidden'); |
| 169 $('finalStatus').classList.add('hidden'); | 167 $('finalStatus').classList.add('hidden'); |
| 170 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL); | 168 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL); |
| 171 $('systemStatus').classList.remove('hidden'); | 169 $('systemStatus').classList.remove('hidden'); |
| 172 $('canvas').classList.remove('hidden'); | 170 $('canvas').classList.remove('hidden'); |
| 173 this.startSpinner_(); | 171 this.startSpinner_(); |
| 174 break; | 172 break; |
| 175 case MobileSetup.PLAN_ACTIVATION_TRYING_OTASP: | 173 case MobileSetup.PLAN_ACTIVATION_TRYING_OTASP: |
| 176 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: | 174 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: |
| 177 case MobileSetup.PLAN_ACTIVATION_OTASP: | 175 case MobileSetup.PLAN_ACTIVATION_OTASP: |
| 178 // Activation page should not be shown for the simple activation flow. | 176 // Activation page should not be shown for the simple activation flow. |
| 179 if (simpleActivationFlow) | 177 if (simpleActivationFlow) |
| 180 break; | 178 break; |
| 181 | 179 |
| 182 $('statusHeader').textContent = | 180 $('statusHeader').textContent = |
| 183 MobileSetup.localStrings_.getString('activating_header'); | 181 loadTimeData.getString('activating_header'); |
| 184 $('auxHeader').textContent = | 182 $('auxHeader').textContent = |
| 185 MobileSetup.localStrings_.getString('please_wait'); | 183 loadTimeData.getString('please_wait'); |
| 186 $('paymentForm').classList.add('hidden'); | 184 $('paymentForm').classList.add('hidden'); |
| 187 $('finalStatus').classList.add('hidden'); | 185 $('finalStatus').classList.add('hidden'); |
| 188 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL); | 186 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL); |
| 189 $('systemStatus').classList.remove('hidden'); | 187 $('systemStatus').classList.remove('hidden'); |
| 190 $('canvas').classList.remove('hidden'); | 188 $('canvas').classList.remove('hidden'); |
| 191 this.startSpinner_(); | 189 this.startSpinner_(); |
| 192 break; | 190 break; |
| 193 case MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING: | 191 case MobileSetup.PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING: |
| 194 // Activation page should not be shown for the simple activation flow. | 192 // Activation page should not be shown for the simple activation flow. |
| 195 if (!simpleActivationFlow) { | 193 if (!simpleActivationFlow) { |
| 196 $('statusHeader').textContent = | 194 $('statusHeader').textContent = |
| 197 MobileSetup.localStrings_.getString('connecting_header'); | 195 loadTimeData.getString('connecting_header'); |
| 198 $('auxHeader').textContent = ''; | 196 $('auxHeader').textContent = ''; |
| 199 $('paymentForm').classList.add('hidden'); | 197 $('paymentForm').classList.add('hidden'); |
| 200 $('finalStatus').classList.add('hidden'); | 198 $('finalStatus').classList.add('hidden'); |
| 201 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL); | 199 this.setCarrierPage_(MobileSetup.ACTIVATION_PAGE_URL); |
| 202 $('systemStatus').classList.remove('hidden'); | 200 $('systemStatus').classList.remove('hidden'); |
| 203 $('canvas').classList.remove('hidden'); | 201 $('canvas').classList.remove('hidden'); |
| 204 } | 202 } |
| 205 this.loadPaymentFrame_(deviceInfo); | 203 this.loadPaymentFrame_(deviceInfo); |
| 206 break; | 204 break; |
| 207 case MobileSetup.PLAN_ACTIVATION_WAITING_FOR_CONNECTION: | 205 case MobileSetup.PLAN_ACTIVATION_WAITING_FOR_CONNECTION: |
| 208 var statusHeaderText; | 206 var statusHeaderText; |
| 209 var carrierPage; | 207 var carrierPage; |
| 210 if (deviceInfo.activation_type == 'NonCellular') { | 208 if (deviceInfo.activation_type == 'NonCellular') { |
| 211 statusHeaderText = MobileSetup.localStrings_.getString( | 209 statusHeaderText = loadTimeData.getString( |
| 212 'portal_unreachable_header'); | 210 'portal_unreachable_header'); |
| 213 carrierPage = MobileSetup.PORTAL_OFFLINE_PAGE_URL; | 211 carrierPage = MobileSetup.PORTAL_OFFLINE_PAGE_URL; |
| 214 } else if (deviceInfo.activation_type == 'OTA') { | 212 } else if (deviceInfo.activation_type == 'OTA') { |
| 215 statusHeaderText = | 213 statusHeaderText = |
| 216 MobileSetup.localStrings_.getString('connecting_header'); | 214 loadTimeData.getString('connecting_header'); |
| 217 carrierPage = MobileSetup.ACTIVATION_PAGE_URL; | 215 carrierPage = MobileSetup.ACTIVATION_PAGE_URL; |
| 218 } | 216 } |
| 219 $('statusHeader').textContent = statusHeaderText; | 217 $('statusHeader').textContent = statusHeaderText; |
| 220 $('auxHeader').textContent = ''; | 218 $('auxHeader').textContent = ''; |
| 221 $('auxHeader').classList.add('hidden'); | 219 $('auxHeader').classList.add('hidden'); |
| 222 $('paymentForm').classList.add('hidden'); | 220 $('paymentForm').classList.add('hidden'); |
| 223 $('finalStatus').classList.add('hidden'); | 221 $('finalStatus').classList.add('hidden'); |
| 224 $('systemStatus').classList.remove('hidden'); | 222 $('systemStatus').classList.remove('hidden'); |
| 225 this.setCarrierPage_(carrierPage); | 223 this.setCarrierPage_(carrierPage); |
| 226 $('canvas').classList.remove('hidden'); | 224 $('canvas').classList.remove('hidden'); |
| 227 this.startSpinner_(); | 225 this.startSpinner_(); |
| 228 break; | 226 break; |
| 229 case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT: | 227 case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT: |
| 230 $('statusHeader').textContent = ''; | 228 $('statusHeader').textContent = ''; |
| 231 $('auxHeader').textContent = ''; | 229 $('auxHeader').textContent = ''; |
| 232 $('finalStatus').classList.add('hidden'); | 230 $('finalStatus').classList.add('hidden'); |
| 233 $('systemStatus').classList.add('hidden'); | 231 $('systemStatus').classList.add('hidden'); |
| 234 $('paymentForm').classList.remove('hidden'); | 232 $('paymentForm').classList.remove('hidden'); |
| 235 $('canvas').classList.add('hidden'); | 233 $('canvas').classList.add('hidden'); |
| 236 this.stopSpinner_(); | 234 this.stopSpinner_(); |
| 237 this.paymentShown_ = true; | 235 this.paymentShown_ = true; |
| 238 break; | 236 break; |
| 239 case MobileSetup.PLAN_ACTIVATION_DONE: | 237 case MobileSetup.PLAN_ACTIVATION_DONE: |
| 240 $('statusHeader').textContent = ''; | 238 $('statusHeader').textContent = ''; |
| 241 $('auxHeader').textContent = ''; | 239 $('auxHeader').textContent = ''; |
| 242 $('finalHeader').textContent = | 240 $('finalHeader').textContent = |
| 243 MobileSetup.localStrings_.getString('completed_header'); | 241 loadTimeData.getString('completed_header'); |
| 244 $('finalMessage').textContent = | 242 $('finalMessage').textContent = |
| 245 MobileSetup.localStrings_.getString('completed_text'); | 243 loadTimeData.getString('completed_text'); |
| 246 $('systemStatus').classList.add('hidden'); | 244 $('systemStatus').classList.add('hidden'); |
| 247 $('closeButton').classList.remove('hidden'); | 245 $('closeButton').classList.remove('hidden'); |
| 248 $('finalStatus').classList.remove('hidden'); | 246 $('finalStatus').classList.remove('hidden'); |
| 249 $('canvas').classList.add('hidden'); | 247 $('canvas').classList.add('hidden'); |
| 250 $('closeButton').classList.toggle('hidden', !this.paymentShown_); | 248 $('closeButton').classList.toggle('hidden', !this.paymentShown_); |
| 251 $('paymentForm').classList.toggle('hidden', !this.paymentShown_); | 249 $('paymentForm').classList.toggle('hidden', !this.paymentShown_); |
| 252 this.stopSpinner_(); | 250 this.stopSpinner_(); |
| 253 break; | 251 break; |
| 254 case MobileSetup.PLAN_ACTIVATION_ERROR: | 252 case MobileSetup.PLAN_ACTIVATION_ERROR: |
| 255 $('statusHeader').textContent = ''; | 253 $('statusHeader').textContent = ''; |
| 256 $('auxHeader').textContent = ''; | 254 $('auxHeader').textContent = ''; |
| 257 $('finalHeader').textContent = | 255 $('finalHeader').textContent = |
| 258 MobileSetup.localStrings_.getString('error_header'); | 256 loadTimeData.getString('error_header'); |
| 259 $('finalMessage').textContent = deviceInfo.error; | 257 $('finalMessage').textContent = deviceInfo.error; |
| 260 $('systemStatus').classList.add('hidden'); | 258 $('systemStatus').classList.add('hidden'); |
| 261 $('canvas').classList.add('hidden'); | 259 $('canvas').classList.add('hidden'); |
| 262 $('closeButton').classList.toggle('hidden', !this.paymentShown_); | 260 $('closeButton').classList.toggle('hidden', !this.paymentShown_); |
| 263 $('paymentForm').classList.toggle('hidden', !this.paymentShown_); | 261 $('paymentForm').classList.toggle('hidden', !this.paymentShown_); |
| 264 $('finalStatus').classList.remove('hidden'); | 262 $('finalStatus').classList.remove('hidden'); |
| 265 this.stopSpinner_(); | 263 this.stopSpinner_(); |
| 266 break; | 264 break; |
| 267 } | 265 } |
| 268 this.state_ = newState; | 266 this.state_ = newState; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 mobile.MobileSetup.ACTIVATION_PAGE_URL); | 368 mobile.MobileSetup.ACTIVATION_PAGE_URL); |
| 371 }; | 369 }; |
| 372 | 370 |
| 373 // Export | 371 // Export |
| 374 return { | 372 return { |
| 375 MobileSetup: MobileSetup | 373 MobileSetup: MobileSetup |
| 376 }; | 374 }; |
| 377 }); | 375 }); |
| 378 | 376 |
| 379 document.addEventListener('DOMContentLoaded', mobile.MobileSetup.loadPage); | 377 document.addEventListener('DOMContentLoaded', mobile.MobileSetup.loadPage); |
| OLD | NEW |