OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 cr.define('mobile', function() { | 5 cr.define('mobile', function() { |
6 | 6 |
7 // TODO(tbarzic): Share code with mobile_setup.js. | 7 // TODO(tbarzic): Share code with mobile_setup.js. |
8 var EXTENSION_BASE_URL = | 8 var EXTENSION_BASE_URL = |
9 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab/'; | 9 'chrome-extension://iadeocfgjdjdmpenejdbfeaocpbikmab/'; |
10 var REDIRECT_POST_PAGE_URL = EXTENSION_BASE_URL + 'redirect.html?autoPost=1'; | 10 var REDIRECT_POST_PAGE_URL = EXTENSION_BASE_URL + 'redirect.html?autoPost=1'; |
11 var PORTAL_OFFLINE_PAGE_URL = EXTENSION_BASE_URL + 'portal_offline.html'; | 11 var PORTAL_OFFLINE_PAGE_URL = EXTENSION_BASE_URL + 'portal_offline.html'; |
12 var INVALID_DEVICE_INFO_PAGE_URL = | 12 var INVALID_DEVICE_INFO_PAGE_URL = |
13 EXTENSION_BASE_URL + 'invalid_device_info.html'; | 13 EXTENSION_BASE_URL + 'invalid_device_info.html'; |
14 | 14 |
15 var NetworkState = { | 15 var NetworkState = { |
16 UNKNOWN: 0, | 16 UNKNOWN: 0, |
17 PORTAL_REACHABLE: 1, | 17 PORTAL_REACHABLE: 1, |
18 PORTAL_UNREACHABLE: 2 | 18 PORTAL_UNREACHABLE: 2 |
19 }; | 19 }; |
20 | 20 |
21 var CarrierPageType = { | 21 var CarrierPageType = { |
22 NOT_SET: 0, | 22 NOT_SET: 0, |
23 PORTAL_OFFLINE: 1, | 23 PORTAL_OFFLINE: 1, |
24 INVALID_DEVICE_INFO: 2 | 24 INVALID_DEVICE_INFO: 2 |
25 }; | 25 }; |
26 | 26 |
27 var localStrings = new LocalStrings(); | |
28 | |
29 function PortalImpl() { | 27 function PortalImpl() { |
30 // Mobile device information. | 28 // Mobile device information. |
31 this.deviceInfo_ = null; | 29 this.deviceInfo_ = null; |
32 this.spinnerInt_ = -1; | 30 this.spinnerInt_ = -1; |
33 this.networkState_ = NetworkState.UNKNOWN; | 31 this.networkState_ = NetworkState.UNKNOWN; |
34 this.portalFrameSet_ = false; | 32 this.portalFrameSet_ = false; |
35 this.carrierPageType_ = CarrierPageType.NOT_SET; | 33 this.carrierPageType_ = CarrierPageType.NOT_SET; |
36 } | 34 } |
37 | 35 |
38 cr.addSingletonGetter(PortalImpl); | 36 cr.addSingletonGetter(PortalImpl); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 setCarrierPage_: function(type) { | 89 setCarrierPage_: function(type) { |
92 // The page is already set, nothing to do. | 90 // The page is already set, nothing to do. |
93 if (type == this.carrierPageType_) | 91 if (type == this.carrierPageType_) |
94 return; | 92 return; |
95 | 93 |
96 switch (type) { | 94 switch (type) { |
97 case CarrierPageType.PORTAL_OFFLINE: | 95 case CarrierPageType.PORTAL_OFFLINE: |
98 $('carrierPage').contentWindow.location.href = | 96 $('carrierPage').contentWindow.location.href = |
99 PORTAL_OFFLINE_PAGE_URL; | 97 PORTAL_OFFLINE_PAGE_URL; |
100 $('statusHeader').textContent = | 98 $('statusHeader').textContent = |
101 localStrings.getString('portal_unreachable_header'); | 99 loadTimeData.getString('portal_unreachable_header'); |
102 this.startSpinner_(); | 100 this.startSpinner_(); |
103 break; | 101 break; |
104 case CarrierPageType.INVALID_DEVICE_INFO: | 102 case CarrierPageType.INVALID_DEVICE_INFO: |
105 $('carrierPage').contentWindow.location.href = | 103 $('carrierPage').contentWindow.location.href = |
106 INVALID_DEVICE_INFO_PAGE_URL; | 104 INVALID_DEVICE_INFO_PAGE_URL; |
107 $('statusHeader').textContent = | 105 $('statusHeader').textContent = |
108 localStrings.getString('invalid_device_info_header'); | 106 loadTimeData.getString('invalid_device_info_header'); |
109 this.stopSpinner_(); | 107 this.stopSpinner_(); |
110 break; | 108 break; |
111 case CarrierPageType.NOT_SET: | 109 case CarrierPageType.NOT_SET: |
112 $('carrierPage').contentWindow.location.href = 'about:blank'; | 110 $('carrierPage').contentWindow.location.href = 'about:blank'; |
113 $('statusHeader').textContent = ''; | 111 $('statusHeader').textContent = ''; |
114 this.stopSpinner_(); | 112 this.stopSpinner_(); |
115 break; | 113 break; |
116 default: | 114 default: |
117 break; | 115 break; |
118 } | 116 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 }; | 210 }; |
213 | 211 |
214 // Export | 212 // Export |
215 return { | 213 return { |
216 MobileSetupPortal: MobileSetupPortal | 214 MobileSetupPortal: MobileSetupPortal |
217 }; | 215 }; |
218 }); | 216 }); |
219 | 217 |
220 document.addEventListener('DOMContentLoaded', | 218 document.addEventListener('DOMContentLoaded', |
221 mobile.MobileSetupPortal.loadPage); | 219 mobile.MobileSetupPortal.loadPage); |
OLD | NEW |