OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "ash/system/chromeos/network/network_connect.h" | 5 #include "ash/system/chromeos/network/network_connect.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/chromeos/network/network_observer.h" | 8 #include "ash/system/chromeos/network/network_observer.h" |
9 #include "ash/system/chromeos/network/network_state_notifier.h" | 9 #include "ash/system/chromeos/network/network_state_notifier.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 namespace network_connect { | 247 namespace network_connect { |
248 | 248 |
249 void ConnectToNetwork(const std::string& service_path, | 249 void ConnectToNetwork(const std::string& service_path, |
250 gfx::NativeWindow owning_window) { | 250 gfx::NativeWindow owning_window) { |
251 const bool check_error_state = true; | 251 const bool check_error_state = true; |
252 CallConnectToNetwork(service_path, check_error_state, owning_window); | 252 CallConnectToNetwork(service_path, check_error_state, owning_window); |
253 } | 253 } |
254 | 254 |
255 void ActivateCellular(const std::string& service_path) { | 255 void ActivateCellular(const std::string& service_path) { |
256 NET_LOG_USER("ActivateCellular", service_path); | 256 NET_LOG_USER("ActivateCellular", service_path); |
257 const DeviceState* cellular_device = | |
258 NetworkHandler::Get()->network_state_handler()-> | |
259 GetDeviceStateByType(flimflam::kTypeCellular); | |
260 if (!cellular_device) { | |
261 NET_LOG_ERROR("ActivateCellular with no Device", service_path); | |
262 return; | |
263 } | |
264 if (!IsDirectActivatedCarrier(cellular_device->carrier())) { | |
265 // For non direct activation, show the mobile setup dialog which can be | |
266 // used to activate the network. | |
267 ash::Shell::GetInstance()->system_tray_delegate()->ShowMobileSetup( | |
268 service_path); | |
269 return; | |
270 } | |
271 const NetworkState* cellular = | 257 const NetworkState* cellular = |
272 NetworkHandler::Get()->network_state_handler()-> | 258 NetworkHandler::Get()->network_state_handler()-> |
273 GetNetworkState(service_path); | 259 GetNetworkState(service_path); |
274 if (!cellular || cellular->type() != flimflam::kTypeCellular) { | 260 if (!cellular || cellular->type() != flimflam::kTypeCellular) { |
275 NET_LOG_ERROR("ActivateCellular with no Service", service_path); | 261 NET_LOG_ERROR("ActivateCellular with no Service", service_path); |
276 return; | 262 return; |
277 } | 263 } |
264 const DeviceState* cellular_device = | |
265 NetworkHandler::Get()->network_state_handler()-> | |
266 GetDeviceState(cellular->device_path()); | |
267 if (!cellular_device) { | |
268 NET_LOG_ERROR("ActivateCellular with no Device", service_path); | |
269 return; | |
270 } | |
271 if (!IsDirectActivatedCarrier(cellular_device->carrier())) { | |
272 // For non direct activation, show the mobile setup dialog which can be | |
273 // used to activate the network. Only show the dialog, if an account | |
274 // management URL is available. | |
275 if (!cellular->payment_url().empty()) | |
276 ash::Shell::GetInstance()->system_tray_delegate()->ShowMobileSetup( | |
277 service_path); | |
stevenjb
2013/08/14 23:19:23
nit: {} around multi-line statement
armansito
2013/08/15 00:35:36
Oh, this is not a multi-line statement. We show mo
| |
278 return; | |
279 } | |
278 if (cellular->activation_state() == flimflam::kActivationStateActivated) { | 280 if (cellular->activation_state() == flimflam::kActivationStateActivated) { |
279 NET_LOG_ERROR("ActivateCellular for activated service", service_path); | 281 NET_LOG_ERROR("ActivateCellular for activated service", service_path); |
280 return; | 282 return; |
281 } | 283 } |
282 | 284 |
283 NetworkHandler::Get()->network_connection_handler()->ActivateNetwork( | 285 NetworkHandler::Get()->network_connection_handler()->ActivateNetwork( |
284 service_path, | 286 service_path, |
285 "", // carrier | 287 "", // carrier |
286 base::Bind(&OnActivateSucceeded, service_path), | 288 base::Bind(&OnActivateSucceeded, service_path), |
287 base::Bind(&OnActivateFailed, service_path)); | 289 base::Bind(&OnActivateFailed, service_path)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 if (StringToLowerASCII(error) == | 390 if (StringToLowerASCII(error) == |
389 StringToLowerASCII(std::string(flimflam::kUnknownString))) { | 391 StringToLowerASCII(std::string(flimflam::kUnknownString))) { |
390 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); | 392 return l10n_util::GetStringUTF16(IDS_CHROMEOS_NETWORK_ERROR_UNKNOWN); |
391 } | 393 } |
392 return l10n_util::GetStringFUTF16(IDS_NETWORK_UNRECOGNIZED_ERROR, | 394 return l10n_util::GetStringFUTF16(IDS_NETWORK_UNRECOGNIZED_ERROR, |
393 UTF8ToUTF16(error)); | 395 UTF8ToUTF16(error)); |
394 } | 396 } |
395 | 397 |
396 } // network_connect | 398 } // network_connect |
397 } // ash | 399 } // ash |
OLD | NEW |