Chromium Code Reviews| 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 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 faked_transaction_ : false, | 28 faked_transaction_ : false, |
| 29 // UI states. | 29 // UI states. |
| 30 state_ : -1, | 30 state_ : -1, |
| 31 STATE_UNKNOWN_: "unknown", | 31 STATE_UNKNOWN_: "unknown", |
| 32 STATE_CONNECTING_: "connecting", | 32 STATE_CONNECTING_: "connecting", |
| 33 STATE_ERROR_: "error", | 33 STATE_ERROR_: "error", |
| 34 STATE_PAYMENT_: "payment", | 34 STATE_PAYMENT_: "payment", |
| 35 STATE_ACTIVATING_: "activating", | 35 STATE_ACTIVATING_: "activating", |
| 36 STATE_CONNECTED_: "connected", | 36 STATE_CONNECTED_: "connected", |
| 37 | 37 |
| 38 initialize: function(frame_name) { | 38 initialize: function(frame_name, carrierPage) { |
|
satorux1
2010/11/30 05:45:52
something like carrierPageUrl may be nicer.
| |
| 39 if (this.initialized_) { | 39 if (this.initialized_) { |
| 40 console.log('calling initialize() again?'); | 40 console.log('calling initialize() again?'); |
| 41 return; | 41 return; |
| 42 } | 42 } |
| 43 this.initialized_ = true; | 43 this.initialized_ = true; |
| 44 self = this; | 44 self = this; |
| 45 this.frameName_ = frame_name; | 45 this.frameName_ = frame_name; |
| 46 window.addEventListener('message', function(e) { | 46 window.addEventListener('message', function(e) { |
| 47 self.onMessageReceived_(e); | 47 self.onMessageReceived_(e); |
| 48 }); | 48 }); |
| 49 $('closeButton').addEventListener('click', function(e) { | 49 $('closeButton').addEventListener('click', function(e) { |
| 50 $('finalMessage').classList.add('hidden'); | 50 $('finalMessage').classList.add('hidden'); |
| 51 }); | 51 }); |
| 52 $('carrierPage').contentWindow.location.href = | |
| 53 carrierPage; | |
| 52 $(frame_name).addEventListener('load', function(e) { | 54 $(frame_name).addEventListener('load', function(e) { |
| 53 // Flip the visibility of the payment page only after the frame is | 55 // Flip the visibility of the payment page only after the frame is |
| 54 // fully loaded. | 56 // fully loaded. |
| 55 if (self.state_ == MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT) { | 57 if (self.state_ == MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT) { |
| 56 $('statusHeader').textContent = ''; | 58 $('statusHeader').textContent = ''; |
| 59 $('auxHeader').textContent = ''; | |
| 57 $('finalMessage').classList.add('hidden'); | 60 $('finalMessage').classList.add('hidden'); |
| 58 $('errorMessage').classList.add('hidden'); | 61 $('errorMessage').classList.add('hidden'); |
| 59 $('systemStatus').classList.add('hidden'); | 62 $('systemStatus').classList.add('hidden'); |
| 60 $('canvas').classList.add('hidden'); | 63 $('canvas').classList.add('hidden'); |
| 64 $('carrierPage').classList.add('hidden'); | |
| 61 $('paymentForm').classList.remove('hidden'); | 65 $('paymentForm').classList.remove('hidden'); |
| 62 } | 66 } |
| 63 }); | 67 }); |
| 64 | 68 |
| 65 this.changeState_(MobileSetup.PLAN_ACTIVATION_LOADING); | 69 this.changeState_(MobileSetup.PLAN_ACTIVATION_LOADING); |
| 66 setInterval(mobile.MobileSetup.drawProgress, 100); | 70 setInterval(mobile.MobileSetup.drawProgress, 100); |
| 67 // Kick off activation process. | 71 // Kick off activation process. |
| 68 chrome.send('startActivation', []); | 72 chrome.send('startActivation', []); |
| 69 }, | 73 }, |
| 70 | 74 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 96 if (this.state_ == new_state) | 100 if (this.state_ == new_state) |
| 97 return; | 101 return; |
| 98 var main = $('mainbody'); | 102 var main = $('mainbody'); |
| 99 // Map handler state to UX. | 103 // Map handler state to UX. |
| 100 switch(new_state) { | 104 switch(new_state) { |
| 101 case MobileSetup.PLAN_ACTIVATION_LOADING: | 105 case MobileSetup.PLAN_ACTIVATION_LOADING: |
| 102 case MobileSetup.PLAN_ACTIVATION_START: | 106 case MobileSetup.PLAN_ACTIVATION_START: |
| 103 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: | 107 case MobileSetup.PLAN_ACTIVATION_RECONNECTING: |
| 104 $('statusHeader').textContent = | 108 $('statusHeader').textContent = |
| 105 MobileSetup.localStrings_.getString('connecting_header'); | 109 MobileSetup.localStrings_.getString('connecting_header'); |
| 110 $('auxHeader').textContent = | |
| 111 MobileSetup.localStrings_.getString('please_wait'); | |
| 106 $('errorMessage').textContent = ''; | 112 $('errorMessage').textContent = ''; |
| 107 $('paymentForm').classList.add('hidden'); | 113 $('paymentForm').classList.add('hidden'); |
| 108 $('finalMessage').classList.add('hidden'); | 114 $('finalMessage').classList.add('hidden'); |
| 109 $('errorMessage').classList.add('hidden'); | 115 $('errorMessage').classList.add('hidden'); |
| 110 $('systemStatus').classList.remove('hidden'); | 116 $('systemStatus').classList.remove('hidden'); |
| 111 $('canvas').classList.remove('hidden'); | 117 $('canvas').classList.remove('hidden'); |
| 118 $('carrierPage').classList.remove('hidden'); | |
| 112 break; | 119 break; |
| 113 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: | 120 case MobileSetup.PLAN_ACTIVATION_INITIATING_ACTIVATION: |
| 114 $('statusHeader').textContent = | 121 $('statusHeader').textContent = |
| 115 MobileSetup.localStrings_.getString('activating_header'); | 122 MobileSetup.localStrings_.getString('activating_header'); |
| 123 $('auxHeader').textContent = | |
| 124 MobileSetup.localStrings_.getString('please_wait'); | |
| 116 $('errorMessage').textContent = ''; | 125 $('errorMessage').textContent = ''; |
| 117 $('paymentForm').classList.add('hidden'); | 126 $('paymentForm').classList.add('hidden'); |
| 118 $('finalMessage').classList.add('hidden'); | 127 $('finalMessage').classList.add('hidden'); |
| 119 $('errorMessage').classList.add('hidden'); | 128 $('errorMessage').classList.add('hidden'); |
| 120 $('systemStatus').classList.remove('hidden'); | 129 $('systemStatus').classList.remove('hidden'); |
| 121 $('canvas').classList.remove('hidden'); | 130 $('canvas').classList.remove('hidden'); |
| 131 $('carrierPage').classList.remove('hidden'); | |
| 122 break; | 132 break; |
| 123 case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT: | 133 case MobileSetup.PLAN_ACTIVATION_SHOWING_PAYMENT: |
| 124 $('statusHeader').textContent = | 134 $('statusHeader').textContent = |
| 125 MobileSetup.localStrings_.getString('connecting_header'); | 135 MobileSetup.localStrings_.getString('connecting_header'); |
| 136 $('auxHeader').textContent = ''; | |
| 126 $('paymentForm').classList.add('hidden'); | 137 $('paymentForm').classList.add('hidden'); |
| 127 $('finalMessage').classList.add('hidden'); | 138 $('finalMessage').classList.add('hidden'); |
| 128 $('errorMessage').classList.add('hidden'); | 139 $('errorMessage').classList.add('hidden'); |
| 129 $('systemStatus').classList.remove('hidden'); | 140 $('systemStatus').classList.remove('hidden'); |
| 130 $('canvas').classList.remove('hidden'); | 141 $('canvas').classList.remove('hidden'); |
| 131 this.loadPaymentFrame_(deviceInfo); | 142 this.loadPaymentFrame_(deviceInfo); |
| 132 break; | 143 break; |
| 133 case MobileSetup.PLAN_ACTIVATION_DONE: | 144 case MobileSetup.PLAN_ACTIVATION_DONE: |
| 134 $('statusHeader').textContent = ''; | 145 $('statusHeader').textContent = ''; |
| 146 $('auxHeader').textContent = ''; | |
| 135 $('errorMessage').classList.add('hidden'); | 147 $('errorMessage').classList.add('hidden'); |
| 136 $('systemStatus').classList.add('hidden'); | 148 $('systemStatus').classList.add('hidden'); |
| 137 $('canvas').classList.add('hidden'); | 149 $('canvas').classList.add('hidden'); |
| 150 $('carrierPage').classList.add('hidden'); | |
| 138 $('paymentForm').classList.remove('hidden'); | 151 $('paymentForm').classList.remove('hidden'); |
| 139 $('finalMessage').classList.remove('hidden'); | 152 $('finalMessage').classList.remove('hidden'); |
| 140 break; | 153 break; |
| 141 case MobileSetup.PLAN_ACTIVATION_ERROR: | 154 case MobileSetup.PLAN_ACTIVATION_ERROR: |
| 142 $('statusHeader').textContent = | 155 $('statusHeader').textContent = |
| 143 MobileSetup.localStrings_.getString('error_header'); | 156 MobileSetup.localStrings_.getString('error_header'); |
| 157 $('auxHeader').textContent = ''; | |
| 144 $('errorMessage').textContent = deviceInfo.error; | 158 $('errorMessage').textContent = deviceInfo.error; |
| 145 $('paymentForm').classList.add('hidden'); | 159 $('paymentForm').classList.add('hidden'); |
| 146 $('finalMessage').classList.add('hidden'); | 160 $('finalMessage').classList.add('hidden'); |
| 161 $('carrierPage').classList.add('hidden'); | |
| 147 $('canvas').classList.add('hidden'); | 162 $('canvas').classList.add('hidden'); |
| 148 $('errorMessage').classList.remove('hidden'); | 163 $('errorMessage').classList.remove('hidden'); |
| 149 $('systemStatus').classList.remove('hidden'); | 164 $('systemStatus').classList.remove('hidden'); |
| 150 break; | 165 break; |
| 151 } | 166 } |
| 152 this.state_ = new_state; | 167 this.state_ = new_state; |
| 153 }, | 168 }, |
| 154 | 169 |
| 155 updateDeviceStatus_: function(deviceInfo) { | 170 updateDeviceStatus_: function(deviceInfo) { |
| 156 this.changeState_(deviceInfo); | 171 this.changeState_(deviceInfo); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 ctx.fillStyle = "rgba(240, 30, 29, " + opacity + ")"; | 224 ctx.fillStyle = "rgba(240, 30, 29, " + opacity + ")"; |
| 210 ctx.fill(); | 225 ctx.fill(); |
| 211 } | 226 } |
| 212 }; | 227 }; |
| 213 | 228 |
| 214 MobileSetup.deviceStateChanged = function(deviceInfo) { | 229 MobileSetup.deviceStateChanged = function(deviceInfo) { |
| 215 MobileSetup.getInstance().updateDeviceStatus_(deviceInfo); | 230 MobileSetup.getInstance().updateDeviceStatus_(deviceInfo); |
| 216 }; | 231 }; |
| 217 | 232 |
| 218 MobileSetup.loadPage = function() { | 233 MobileSetup.loadPage = function() { |
| 219 mobile.MobileSetup.getInstance().initialize('paymentForm'); | 234 mobile.MobileSetup.getInstance().initialize('paymentForm', |
| 235 'file:///usr/share/chromeos-assets/mobile/activation.html'); | |
|
satorux1
2010/11/30 05:45:52
You could define this as const at the beginning of
zel
2010/11/30 06:07:52
Done.
| |
| 220 }; | 236 }; |
| 221 | 237 |
| 222 // Export | 238 // Export |
| 223 return { | 239 return { |
| 224 MobileSetup: MobileSetup | 240 MobileSetup: MobileSetup |
| 225 }; | 241 }; |
| 226 | 242 |
| 227 }); | 243 }); |
| 228 | 244 |
| OLD | NEW |