| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_LOADING = -1; | 13 MobileSetup.PLAN_ACTIVATION_PAGE_LOADING = -1; |
| 14 MobileSetup.PLAN_ACTIVATION_START = 0; | 14 MobileSetup.PLAN_ACTIVATION_START = 0; |
| 15 MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 1; | 15 MobileSetup.PLAN_ACTIVATION_TRYING_OTASP = 1; |
| 16 MobileSetup.PLAN_ACTIVATION_RECONNECTING = 2; | 16 MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY = 2; |
| 17 MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 3; | 17 MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION = 3; |
| 18 MobileSetup.PLAN_ACTIVATION_DONE = 4; | 18 MobileSetup.PLAN_ACTIVATION_RECONNECTING = 4; |
| 19 MobileSetup.PLAN_ACTIVATION_ERROR = 5; | 19 MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT = 5; |
| 20 MobileSetup.PLAN_ACTIVATION_DELAY_OTASP = 6; |
| 21 MobileSetup.PLAN_ACTIVATION_START_OTASP = 7; |
| 22 MobileSetup.PLAN_ACTIVATION_OTASP = 8; |
| 23 MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP = 9; |
| 24 MobileSetup.PLAN_ACTIVATION_DONE = 10; |
| 25 MobileSetup.PLAN_ACTIVATION_ERROR = 0xFF; |
| 20 | 26 |
| 21 MobileSetup.ACTIVATION_PAGE_URL = | 27 MobileSetup.ACTIVATION_PAGE_URL = |
| 22 'file:///usr/share/chromeos-assets/mobile/activation.html'; | 28 'file:///usr/share/chromeos-assets/mobile/activation.html'; |
| 23 | 29 |
| 24 MobileSetup.localStrings_ = new LocalStrings(); | 30 MobileSetup.localStrings_ = new LocalStrings(); |
| 25 | 31 |
| 26 MobileSetup.prototype = { | 32 MobileSetup.prototype = { |
| 27 // Mobile device information. | 33 // Mobile device information. |
| 28 deviceInfo_: null, | 34 deviceInfo_: null, |
| 29 frameName_ : '', | 35 frameName_ : '', |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 $('auxHeader').textContent = ''; | 68 $('auxHeader').textContent = ''; |
| 63 $('finalMessage').classList.add('hidden'); | 69 $('finalMessage').classList.add('hidden'); |
| 64 $('errorMessage').classList.add('hidden'); | 70 $('errorMessage').classList.add('hidden'); |
| 65 $('systemStatus').classList.add('hidden'); | 71 $('systemStatus').classList.add('hidden'); |
| 66 $('canvas').classList.add('hidden'); | 72 $('canvas').classList.add('hidden'); |
| 67 $('carrierPage').classList.add('hidden'); | 73 $('carrierPage').classList.add('hidden'); |
| 68 $('paymentForm').classList.remove('hidden'); | 74 $('paymentForm').classList.remove('hidden'); |
| 69 } | 75 } |
| 70 }); | 76 }); |
| 71 | 77 |
| 72 this.changeState_(MobileSetup.PLAN_ACTIVATION_LOADING); | 78 this.changeState_({state: MobileSetup.PLAN_ACTIVATION_PAGE_LOADING}); |
| 73 setInterval(mobile.MobileSetup.drawProgress, 100); | 79 setInterval(mobile.MobileSetup.drawProgress, 100); |
| 74 // Kick off activation process. | 80 // Kick off activation process. |
| 75 chrome.send('startActivation', []); | 81 chrome.send('startActivation', []); |
| 76 }, | 82 }, |
| 77 | 83 |
| 78 loadPaymentFrame_: function(deviceInfo) { | 84 loadPaymentFrame_: function(deviceInfo) { |
| 79 if (deviceInfo) { | 85 if (deviceInfo) { |
| 80 this.deviceInfo_ = deviceInfo; | 86 this.deviceInfo_ = deviceInfo; |
| 81 | 87 |
| 82 $(this.frameName_).contentWindow.location.href = | 88 $(this.frameName_).contentWindow.location.href = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 98 } | 104 } |
| 99 }, | 105 }, |
| 100 | 106 |
| 101 changeState_: function(deviceInfo) { | 107 changeState_: function(deviceInfo) { |
| 102 var new_state = deviceInfo.state; | 108 var new_state = deviceInfo.state; |
| 103 if (this.state_ == new_state) | 109 if (this.state_ == new_state) |
| 104 return; | 110 return; |
| 105 var main = $('mainbody'); | 111 var main = $('mainbody'); |
| 106 // Map handler state to UX. | 112 // Map handler state to UX. |
| 107 switch(new_state) { | 113 switch(new_state) { |
| 108 case MobileSetup.PLAN_ACTIVATION_LOADING: | 114 case MobileSetup.PLAN_ACTIVATION_PAGE_LOADING: |
| 109 case MobileSetup.PLAN_ACTIVATION_START: | 115 case MobileSetup.PLAN_ACTIVATION_START: |
| 116 case MobileSetup.PLAN_ACTIVATION_DELAY_OTASP: |
| 117 case MobileSetup.PLAN_ACTIVATION_START_OTASP: |
| 110 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: | 118 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: |
| 119 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP_TRY: |
| 120 case MobileSetup.PLAN_ACTIVATION_RECONNECTING_OTASP: |
| 111 $('statusHeader').textContent = | 121 $('statusHeader').textContent = |
| 112 MobileSetup.localStrings_.getString('connecting_header'); | 122 MobileSetup.localStrings_.getString('connecting_header'); |
| 113 $('auxHeader').textContent = | 123 $('auxHeader').textContent = |
| 114 MobileSetup.localStrings_.getString('please_wait'); | 124 MobileSetup.localStrings_.getString('please_wait'); |
| 115 $('errorMessage').textContent = ''; | 125 $('errorMessage').textContent = ''; |
| 116 $('paymentForm').classList.add('hidden'); | 126 $('paymentForm').classList.add('hidden'); |
| 117 $('finalMessage').classList.add('hidden'); | 127 $('finalMessage').classList.add('hidden'); |
| 118 $('errorMessage').classList.add('hidden'); | 128 $('errorMessage').classList.add('hidden'); |
| 119 $('systemStatus').classList.remove('hidden'); | 129 $('systemStatus').classList.remove('hidden'); |
| 120 $('canvas').classList.remove('hidden'); | 130 $('canvas').classList.remove('hidden'); |
| 121 $('carrierPage').classList.remove('hidden'); | 131 $('carrierPage').classList.remove('hidden'); |
| 122 break; | 132 break; |
| 133 case MobileSetup.PLAN_ACTIVATION_TRYING_OTASP: |
| 123 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: | 134 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: |
| 135 case MobileSetup.PLAN_ACTIVATION_OTASP: |
| 124 $('statusHeader').textContent = | 136 $('statusHeader').textContent = |
| 125 MobileSetup.localStrings_.getString('activating_header'); | 137 MobileSetup.localStrings_.getString('activating_header'); |
| 126 $('auxHeader').textContent = | 138 $('auxHeader').textContent = |
| 127 MobileSetup.localStrings_.getString('please_wait'); | 139 MobileSetup.localStrings_.getString('please_wait'); |
| 128 $('errorMessage').textContent = ''; | 140 $('errorMessage').textContent = ''; |
| 129 $('paymentForm').classList.add('hidden'); | 141 $('paymentForm').classList.add('hidden'); |
| 130 $('finalMessage').classList.add('hidden'); | 142 $('finalMessage').classList.add('hidden'); |
| 131 $('errorMessage').classList.add('hidden'); | 143 $('errorMessage').classList.add('hidden'); |
| 132 $('systemStatus').classList.remove('hidden'); | 144 $('systemStatus').classList.remove('hidden'); |
| 133 $('canvas').classList.remove('hidden'); | 145 $('canvas').classList.remove('hidden'); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 mobile.MobileSetup.ACTIVATION_PAGE_URL); | 250 mobile.MobileSetup.ACTIVATION_PAGE_URL); |
| 239 }; | 251 }; |
| 240 | 252 |
| 241 // Export | 253 // Export |
| 242 return { | 254 return { |
| 243 MobileSetup: MobileSetup | 255 MobileSetup: MobileSetup |
| 244 }; | 256 }; |
| 245 | 257 |
| 246 }); | 258 }); |
| 247 | 259 |
| OLD | NEW |