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 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" |
6 | 6 |
7 #include <ctype.h> | 7 #include <ctype.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 const char kSetIPConfigMessage[] = "setIPConfig"; | 105 const char kSetIPConfigMessage[] = "setIPConfig"; |
106 const char kSetPreferNetworkMessage[] = "setPreferNetwork"; | 106 const char kSetPreferNetworkMessage[] = "setPreferNetwork"; |
107 const char kSetServerHostname[] = "setServerHostname"; | 107 const char kSetServerHostname[] = "setServerHostname"; |
108 const char kSetSimCardLockMessage[] = "setSimCardLock"; | 108 const char kSetSimCardLockMessage[] = "setSimCardLock"; |
109 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; | 109 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; |
110 | 110 |
111 // These are strings used to communicate with JavaScript. | 111 // These are strings used to communicate with JavaScript. |
112 const char kTagActivate[] = "activate"; | 112 const char kTagActivate[] = "activate"; |
113 const char kTagAddConnection[] = "add"; | 113 const char kTagAddConnection[] = "add"; |
114 const char kTagCarrierSelectFlag[] = "showCarrierSelect"; | 114 const char kTagCarrierSelectFlag[] = "showCarrierSelect"; |
115 const char kTagCarrierUrl[] = "carrierUrl"; | |
116 const char kTagCellularAvailable[] = "cellularAvailable"; | 115 const char kTagCellularAvailable[] = "cellularAvailable"; |
117 const char kTagCellularEnabled[] = "cellularEnabled"; | 116 const char kTagCellularEnabled[] = "cellularEnabled"; |
118 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; | 117 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; |
119 const char kTagConfigure[] = "configure"; | 118 const char kTagConfigure[] = "configure"; |
120 const char kTagConnect[] = "connect"; | 119 const char kTagConnect[] = "connect"; |
121 const char kTagDeviceConnected[] = "deviceConnected"; | 120 const char kTagDeviceConnected[] = "deviceConnected"; |
122 const char kTagDisconnect[] = "disconnect"; | 121 const char kTagDisconnect[] = "disconnect"; |
123 const char kTagErrorMessage[] = "errorMessage"; | 122 const char kTagErrorMessage[] = "errorMessage"; |
124 const char kTagForget[] = "forget"; | 123 const char kTagForget[] = "forget"; |
125 const char kTagOptions[] = "options"; | 124 const char kTagOptions[] = "options"; |
126 const char kTagRememberedList[] = "rememberedList"; | 125 const char kTagRememberedList[] = "rememberedList"; |
127 const char kTagCarriers[] = "carriers"; | 126 const char kTagCarriers[] = "carriers"; |
128 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; | 127 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; |
129 const char kTagShowActivateButton[] = "showActivateButton"; | |
130 const char kTagShowViewAccountButton[] = "showViewAccountButton"; | 128 const char kTagShowViewAccountButton[] = "showViewAccountButton"; |
131 const char kTagTrue[] = "true"; | 129 const char kTagTrue[] = "true"; |
132 const char kTagVpnList[] = "vpnList"; | 130 const char kTagVpnList[] = "vpnList"; |
133 const char kTagWifiAvailable[] = "wifiAvailable"; | 131 const char kTagWifiAvailable[] = "wifiAvailable"; |
134 const char kTagWifiEnabled[] = "wifiEnabled"; | 132 const char kTagWifiEnabled[] = "wifiEnabled"; |
135 const char kTagWimaxAvailable[] = "wimaxAvailable"; | 133 const char kTagWimaxAvailable[] = "wimaxAvailable"; |
136 const char kTagWimaxEnabled[] = "wimaxEnabled"; | 134 const char kTagWimaxEnabled[] = "wimaxEnabled"; |
137 const char kTagWiredList[] = "wiredList"; | 135 const char kTagWiredList[] = "wiredList"; |
138 const char kTagWirelessList[] = "wirelessList"; | 136 const char kTagWirelessList[] = "wirelessList"; |
139 | 137 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // Device settings. | 226 // Device settings. |
229 const DeviceState* device = | 227 const DeviceState* device = |
230 NetworkHandler::Get()->network_state_handler()->GetDeviceState( | 228 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
231 cellular->device_path()); | 229 cellular->device_path()); |
232 if (device) { | 230 if (device) { |
233 const base::DictionaryValue& device_properties = device->properties(); | 231 const base::DictionaryValue& device_properties = device->properties(); |
234 | 232 |
235 carrier_id = device->home_provider_id(); | 233 carrier_id = device->home_provider_id(); |
236 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); | 234 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); |
237 | 235 |
238 MobileConfig* config = MobileConfig::GetInstance(); | |
239 if (config->IsReady()) { | |
240 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); | |
241 if (carrier && !carrier->top_up_url().empty()) | |
242 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); | |
243 } | |
244 | |
245 const base::ListValue* supported_carriers; | 236 const base::ListValue* supported_carriers; |
246 if (device_properties.GetListWithoutPathExpansion( | 237 if (device_properties.GetListWithoutPathExpansion( |
247 shill::kSupportedCarriersProperty, &supported_carriers)) { | 238 shill::kSupportedCarriersProperty, &supported_carriers)) { |
248 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); | 239 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); |
249 dictionary->SetInteger( | 240 dictionary->SetInteger( |
250 kTagCurrentCarrierIndex, | 241 kTagCurrentCarrierIndex, |
251 FindCurrentCarrierIndex(supported_carriers, device)); | 242 FindCurrentCarrierIndex(supported_carriers, device)); |
252 } else { | 243 } else { |
253 // In case of any error, set the current carrier tag to -1 indicating | 244 // In case of any error, set the current carrier tag to -1 indicating |
254 // to the JS code to fallback to a single carrier. | 245 // to the JS code to fallback to a single carrier. |
255 dictionary->SetInteger(kTagCurrentCarrierIndex, -1); | 246 dictionary->SetInteger(kTagCurrentCarrierIndex, -1); |
256 } | 247 } |
257 } | 248 } |
258 | 249 |
259 // Don't show any account management related buttons if the activation | 250 if (cellular->activation_state() == shill::kActivationStateActivating || |
260 // state is unknown. | 251 cellular->activation_state() == shill::kActivationStateActivated) { |
261 if (cellular->activation_state() == shill::kActivationStateUnknown) { | |
262 VLOG(2) << "Activation state unknown. Don't display buttons."; | |
263 return; | |
264 } | |
265 | |
266 if (cellular->activation_state() != shill::kActivationStateActivating && | |
267 cellular->activation_state() != shill::kActivationStateActivated) { | |
268 dictionary->SetBoolean(kTagShowActivateButton, true); | |
269 } else { | |
270 // TODO(stevenjb): Determine if we actually need this check. The payment url | 252 // TODO(stevenjb): Determine if we actually need this check. The payment url |
271 // property is commented as 'Deprecated' in service_constants.h and appears | 253 // property is commented as 'Deprecated' in service_constants.h and appears |
272 // to be unset in Shill, but we still reference it in mobile_setup.cc. | 254 // to be unset in Shill, but we still reference it in mobile_setup.cc. |
273 bool may_show_portal_button = !cellular->payment_url().empty(); | 255 bool may_show_portal_button = !cellular->payment_url().empty(); |
274 | 256 |
275 // If no online payment URL was provided by shill, fall back to | 257 // If no online payment URL was provided by shill, fall back to |
276 // MobileConfig to determine if the "View Account" should be shown. | 258 // MobileConfig to determine if the "View Account" should be shown. |
277 if (!may_show_portal_button && MobileConfig::GetInstance()->IsReady()) { | 259 if (!may_show_portal_button && MobileConfig::GetInstance()->IsReady()) { |
278 const MobileConfig::Carrier* carrier = | 260 const MobileConfig::Carrier* carrier = |
279 MobileConfig::GetInstance()->GetCarrier(carrier_id); | 261 MobileConfig::GetInstance()->GetCarrier(carrier_id); |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 dictionary->SetBoolean( | 1118 dictionary->SetBoolean( |
1137 kTagWimaxAvailable, | 1119 kTagWimaxAvailable, |
1138 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1120 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
1139 dictionary->SetBoolean( | 1121 dictionary->SetBoolean( |
1140 kTagWimaxEnabled, | 1122 kTagWimaxEnabled, |
1141 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1123 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
1142 } | 1124 } |
1143 | 1125 |
1144 } // namespace options | 1126 } // namespace options |
1145 } // namespace chromeos | 1127 } // namespace chromeos |
OLD | NEW |