Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chromeos/network/network_connection_handler.cc

Issue 21046008: Convert all connect code to use NetworkHandler instead of NetworkLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chromeos/network/network_connection_handler.h" 5 #include "chromeos/network/network_connection_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "chromeos/chromeos_switches.h" 10 #include "chromeos/chromeos_switches.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 dest->SetStringWithoutPathExpansion(key, string_value); 55 dest->SetStringWithoutPathExpansion(key, string_value);
56 } 56 }
57 57
58 bool NetworkRequiresActivation(const NetworkState* network) { 58 bool NetworkRequiresActivation(const NetworkState* network) {
59 return (network->type() == flimflam::kTypeCellular && 59 return (network->type() == flimflam::kTypeCellular &&
60 (network->activation_state() != flimflam::kActivationStateActivated || 60 (network->activation_state() != flimflam::kActivationStateActivated ||
61 network->cellular_out_of_credits())); 61 network->cellular_out_of_credits()));
62 } 62 }
63 63
64 bool VPNIsConfigured(const std::string& service_path, 64 bool VPNIsConfigured(const std::string& service_path,
65 const base::DictionaryValue& service_properties) { 65 const std::string& provider_type,
66 // VPN Provider values are read from the "Provider" dictionary, not the 66 const base::DictionaryValue& provider_properties) {
67 // "Provider.Type", etc keys (which are used only to set the values).
68 const base::DictionaryValue* provider_properties;
69 if (!service_properties.GetDictionaryWithoutPathExpansion(
70 flimflam::kProviderProperty, &provider_properties)) {
71 NET_LOG_ERROR("VPN Provider Dictionary not present", service_path);
72 return false;
73 }
74 std::string provider_type;
75 if (!provider_properties->GetStringWithoutPathExpansion(
76 flimflam::kTypeProperty, &provider_type)) {
77 NET_LOG_ERROR("VPN Provider Type not present", service_path);
78 return false;
79 }
80 if (provider_type == flimflam::kProviderOpenVpn) { 67 if (provider_type == flimflam::kProviderOpenVpn) {
81 std::string hostname; 68 std::string hostname;
82 provider_properties->GetStringWithoutPathExpansion( 69 provider_properties.GetStringWithoutPathExpansion(
83 flimflam::kHostProperty, &hostname); 70 flimflam::kHostProperty, &hostname);
84 if (hostname.empty()) { 71 if (hostname.empty()) {
85 NET_LOG_EVENT("OpenVPN: No hostname", service_path); 72 NET_LOG_EVENT("OpenVPN: No hostname", service_path);
86 return false; 73 return false;
87 } 74 }
88 std::string username; 75 std::string username;
89 provider_properties->GetStringWithoutPathExpansion( 76 provider_properties.GetStringWithoutPathExpansion(
90 flimflam::kOpenVPNUserProperty, &username); 77 flimflam::kOpenVPNUserProperty, &username);
91 if (username.empty()) { 78 if (username.empty()) {
92 NET_LOG_EVENT("OpenVPN: No username", service_path); 79 NET_LOG_EVENT("OpenVPN: No username", service_path);
93 return false; 80 return false;
94 } 81 }
95 bool passphrase_required = false; 82 bool passphrase_required = false;
96 provider_properties->GetBooleanWithoutPathExpansion( 83 provider_properties.GetBooleanWithoutPathExpansion(
97 flimflam::kPassphraseRequiredProperty, &passphrase_required); 84 flimflam::kPassphraseRequiredProperty, &passphrase_required);
98 std::string passphrase; 85 if (passphrase_required) {
99 provider_properties->GetStringWithoutPathExpansion( 86 NET_LOG_EVENT("OpenVPN: Passphrase Required", service_path);
100 flimflam::kOpenVPNPasswordProperty, &passphrase);
101 if (passphrase_required && passphrase.empty()) {
102 NET_LOG_EVENT("OpenVPN: No passphrase", service_path);
103 return false; 87 return false;
104 } 88 }
105 NET_LOG_EVENT("OpenVPN Is Configured", service_path); 89 NET_LOG_EVENT("OpenVPN Is Configured", service_path);
106 } else { 90 } else {
107 bool passphrase_required = false; 91 bool passphrase_required = false;
108 std::string passphrase; 92 std::string passphrase;
109 provider_properties->GetBooleanWithoutPathExpansion( 93 provider_properties.GetBooleanWithoutPathExpansion(
110 flimflam::kL2tpIpsecPskRequiredProperty, &passphrase_required); 94 flimflam::kL2tpIpsecPskRequiredProperty, &passphrase_required);
111 provider_properties->GetStringWithoutPathExpansion( 95 if (passphrase_required) {
112 flimflam::kL2tpIpsecPskProperty, &passphrase); 96 NET_LOG_EVENT("VPN: Passphrase Required", service_path);
113 if (passphrase_required && passphrase.empty())
114 return false; 97 return false;
98 }
115 NET_LOG_EVENT("VPN Is Configured", service_path); 99 NET_LOG_EVENT("VPN Is Configured", service_path);
116 } 100 }
117 return true; 101 return true;
118 } 102 }
119 103
120 } // namespace 104 } // namespace
121 105
122 const char NetworkConnectionHandler::kErrorNotFound[] = "not-found"; 106 const char NetworkConnectionHandler::kErrorNotFound[] = "not-found";
123 const char NetworkConnectionHandler::kErrorConnected[] = "connected"; 107 const char NetworkConnectionHandler::kErrorConnected[] = "connected";
124 const char NetworkConnectionHandler::kErrorConnecting[] = "connecting"; 108 const char NetworkConnectionHandler::kErrorConnecting[] = "connecting";
125 const char NetworkConnectionHandler::kErrorNotConnected[] = "not-connected"; 109 const char NetworkConnectionHandler::kErrorNotConnected[] = "not-connected";
126 const char NetworkConnectionHandler::kErrorPassphraseRequired[] = 110 const char NetworkConnectionHandler::kErrorPassphraseRequired[] =
127 "passphrase-required"; 111 "passphrase-required";
128 const char NetworkConnectionHandler::kErrorActivationRequired[] = 112 const char NetworkConnectionHandler::kErrorActivationRequired[] =
129 "activation-required"; 113 "activation-required";
130 const char NetworkConnectionHandler::kErrorCertificateRequired[] = 114 const char NetworkConnectionHandler::kErrorCertificateRequired[] =
131 "certificate-required"; 115 "certificate-required";
132 const char NetworkConnectionHandler::kErrorConfigurationRequired[] = 116 const char NetworkConnectionHandler::kErrorConfigurationRequired[] =
133 "configuration-required"; 117 "configuration-required";
134 const char NetworkConnectionHandler::kErrorAuthenticationRequired[] = 118 const char NetworkConnectionHandler::kErrorAuthenticationRequired[] =
135 "authentication-required"; 119 "authentication-required";
136 const char NetworkConnectionHandler::kErrorShillError[] = "shill-error"; 120 const char NetworkConnectionHandler::kErrorShillError[] = "shill-error";
137 const char NetworkConnectionHandler::kErrorConnectFailed[] = "connect-failed"; 121 const char NetworkConnectionHandler::kErrorConnectFailed[] = "connect-failed";
138 const char NetworkConnectionHandler::kErrorDisconnectFailed[] = 122 const char NetworkConnectionHandler::kErrorMissingProvider[] =
139 "disconnect-failed"; 123 "missing-provider";
140 const char NetworkConnectionHandler::kErrorMissingProviderType[] =
141 "missing-provider-type";
142 const char NetworkConnectionHandler::kErrorUnknown[] = "unknown-error"; 124 const char NetworkConnectionHandler::kErrorUnknown[] = "unknown-error";
143 125
144 struct NetworkConnectionHandler::ConnectRequest { 126 struct NetworkConnectionHandler::ConnectRequest {
145 ConnectRequest(const std::string& service_path, 127 ConnectRequest(const std::string& service_path,
146 const base::Closure& success, 128 const base::Closure& success,
147 const network_handler::ErrorCallback& error) 129 const network_handler::ErrorCallback& error)
148 : service_path(service_path), 130 : service_path(service_path),
149 connect_state(CONNECT_REQUESTED), 131 connect_state(CONNECT_REQUESTED),
150 success_callback(success), 132 success_callback(success),
151 error_callback(error) { 133 error_callback(error) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 178 }
197 if (network_state_handler) { 179 if (network_state_handler) {
198 network_state_handler_ = network_state_handler; 180 network_state_handler_ = network_state_handler;
199 network_state_handler_->AddObserver(this, FROM_HERE); 181 network_state_handler_->AddObserver(this, FROM_HERE);
200 } 182 }
201 network_configuration_handler_ = network_configuration_handler; 183 network_configuration_handler_ = network_configuration_handler;
202 } 184 }
203 185
204 void NetworkConnectionHandler::LoggedInStateChanged( 186 void NetworkConnectionHandler::LoggedInStateChanged(
205 LoginState::LoggedInState state) { 187 LoginState::LoggedInState state) {
206 NET_LOG_EVENT("NewNetworkConnectionHandler",
207 CommandLine::ForCurrentProcess()->HasSwitch(
208 chromeos::switches::kUseNewNetworkConnectionHandler) ?
209 "enabled" : "disabled");
210 if (state == LoginState::LOGGED_IN_ACTIVE) { 188 if (state == LoginState::LOGGED_IN_ACTIVE) {
211 logged_in_ = true; 189 logged_in_ = true;
212 NET_LOG_EVENT("Logged In", ""); 190 NET_LOG_EVENT("Logged In", "");
213 } 191 }
214 } 192 }
215 193
216 void NetworkConnectionHandler::OnCertificatesLoaded( 194 void NetworkConnectionHandler::OnCertificatesLoaded(
217 const net::CertificateList& cert_list, 195 const net::CertificateList& cert_list,
218 bool initial_load) { 196 bool initial_load) {
219 certificates_loaded_ = true; 197 certificates_loaded_ = true;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 InvokeErrorCallback(service_path, error_callback, kErrorNotFound); 287 InvokeErrorCallback(service_path, error_callback, kErrorNotFound);
310 return; 288 return;
311 } 289 }
312 if (!network->IsConnectedState()) { 290 if (!network->IsConnectedState()) {
313 InvokeErrorCallback(service_path, error_callback, kErrorNotConnected); 291 InvokeErrorCallback(service_path, error_callback, kErrorNotConnected);
314 return; 292 return;
315 } 293 }
316 CallShillDisconnect(service_path, success_callback, error_callback); 294 CallShillDisconnect(service_path, success_callback, error_callback);
317 } 295 }
318 296
297 void NetworkConnectionHandler::ActivateNetwork(
298 const std::string& service_path,
299 const std::string& carrier,
300 const base::Closure& success_callback,
301 const network_handler::ErrorCallback& error_callback) {
302 NET_LOG_USER("DisconnectNetwork", service_path);
303 const NetworkState* network =
304 network_state_handler_->GetNetworkState(service_path);
305 if (!network) {
306 InvokeErrorCallback(service_path, error_callback, kErrorNotFound);
307 return;
308 }
309 CallShillActivate(service_path, carrier, success_callback, error_callback);
310 }
311
319 bool NetworkConnectionHandler::HasConnectingNetwork( 312 bool NetworkConnectionHandler::HasConnectingNetwork(
320 const std::string& service_path) { 313 const std::string& service_path) {
321 return pending_requests_.count(service_path) != 0; 314 return pending_requests_.count(service_path) != 0;
322 } 315 }
323 316
324 void NetworkConnectionHandler::NetworkListChanged() { 317 void NetworkConnectionHandler::NetworkListChanged() {
325 CheckAllPendingRequests(); 318 CheckAllPendingRequests();
326 } 319 }
327 320
328 void NetworkConnectionHandler::NetworkPropertiesUpdated( 321 void NetworkConnectionHandler::NetworkPropertiesUpdated(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 // If 'passphrase_required' is still true, then the 'Passphrase' property 367 // If 'passphrase_required' is still true, then the 'Passphrase' property
375 // has not been set to a minimum length value. 368 // has not been set to a minimum length value.
376 bool passphrase_required = false; 369 bool passphrase_required = false;
377 service_properties.GetBooleanWithoutPathExpansion( 370 service_properties.GetBooleanWithoutPathExpansion(
378 flimflam::kPassphraseRequiredProperty, &passphrase_required); 371 flimflam::kPassphraseRequiredProperty, &passphrase_required);
379 if (passphrase_required) { 372 if (passphrase_required) {
380 ErrorCallbackForPendingRequest(service_path, kErrorPassphraseRequired); 373 ErrorCallbackForPendingRequest(service_path, kErrorPassphraseRequired);
381 return; 374 return;
382 } 375 }
383 376
384 // VPN requires a host and username to be set. 377 // Get VPN provider type and host (required for configuration) and ensure
385 if (type == flimflam::kTypeVPN && 378 // that required VPN non-cert properties are set.
386 !VPNIsConfigured(service_path, service_properties)) { 379 std::string vpn_provider_type, vpn_provider_host;
387 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired); 380 if (type == flimflam::kTypeVPN) {
388 return; 381 // VPN Provider values are read from the "Provider" dictionary, not the
382 // "Provider.Type", etc keys (which are used only to set the values).
383 const base::DictionaryValue* provider_properties;
384 if (service_properties.GetDictionaryWithoutPathExpansion(
385 flimflam::kProviderProperty, &provider_properties)) {
386 provider_properties->GetStringWithoutPathExpansion(
387 flimflam::kTypeProperty, &vpn_provider_type);
388 provider_properties->GetStringWithoutPathExpansion(
389 flimflam::kHostProperty, &vpn_provider_host);
390 }
391 if (vpn_provider_type.empty() || vpn_provider_host.empty()) {
392 ErrorCallbackForPendingRequest(service_path, kErrorMissingProvider);
393 return;
394 }
395 // VPN requires a host and username to be set.
396 if (!VPNIsConfigured(
397 service_path, vpn_provider_type, *provider_properties)) {
398 NET_LOG_ERROR("VPN Not Configured", service_path);
399 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired);
400 return;
401 }
389 } 402 }
390 403
391 // Check certificate properties in kUIDataProperty. 404 // These will be set if they need to be configured, otherwise they will
405 // be left empty and the properties will not be set.
406 std::string pkcs11_id, tpm_slot, tpm_pin;
407
408 // Check certificate properties in kUIDataProperty if configured.
409 // Note: Wifi/VPNConfigView set these properties explicitly.
392 scoped_ptr<NetworkUIData> ui_data = 410 scoped_ptr<NetworkUIData> ui_data =
393 ManagedNetworkConfigurationHandler::GetUIData(service_properties); 411 ManagedNetworkConfigurationHandler::GetUIData(service_properties);
394 if (ui_data && ui_data->certificate_type() == CLIENT_CERT_TYPE_PATTERN) { 412 if (ui_data && ui_data->certificate_type() == CLIENT_CERT_TYPE_PATTERN) {
395 // User must be logged in to connect to a network requiring a certificate. 413 // User must be logged in to connect to a network requiring a certificate.
396 if (!logged_in_ || !cert_loader_) { 414 if (!logged_in_ || !cert_loader_) {
397 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); 415 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired);
398 return; 416 return;
399 } 417 }
418
400 // If certificates have not been loaded yet, queue the connect request. 419 // If certificates have not been loaded yet, queue the connect request.
401 if (!certificates_loaded_) { 420 if (!certificates_loaded_) {
402 ConnectRequest* request = pending_request(service_path); 421 ConnectRequest* request = pending_request(service_path);
403 DCHECK(request); 422 DCHECK(request);
404 NET_LOG_EVENT("Connect Request Queued", service_path); 423 NET_LOG_EVENT("Connect Request Queued", service_path);
405 queued_connect_.reset(new ConnectRequest( 424 queued_connect_.reset(new ConnectRequest(
406 service_path, request->success_callback, request->error_callback)); 425 service_path, request->success_callback, request->error_callback));
407 pending_requests_.erase(service_path); 426 pending_requests_.erase(service_path);
408 return; 427 return;
409 } 428 }
410 429
411 // Ensure the certificate is available. 430 // Ensure the certificate is available and configured.
412 std::string pkcs11_id;
413 if (!CertificateIsConfigured(ui_data.get(), &pkcs11_id)) { 431 if (!CertificateIsConfigured(ui_data.get(), &pkcs11_id)) {
414 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired); 432 ErrorCallbackForPendingRequest(service_path, kErrorCertificateRequired);
415 return; 433 return;
416 } 434 }
435 }
417 436
418 // The network may not be 'Connectable' because the certificate data is 437 // The network may not be 'Connectable' because the TPM properties are
419 // not set up, so configure tpm slot/pin and pkcs11_id before connecting. 438 // not set up, so configure tpm slot/pin before connecting.
420 // TODO(stevenjb): Remove this code once NetworkConfigurationHandler 439 if (cert_loader_) {
421 // handles this. 440 tpm_slot = cert_loader_->tpm_token_slot();
441 tpm_pin = cert_loader_->tpm_user_pin();
442 }
443
444 base::DictionaryValue config_properties;
445
446 if (type == flimflam::kTypeVPN) {
447 if (vpn_provider_type == flimflam::kProviderOpenVpn) {
448 if (!pkcs11_id.empty()) {
449 config_properties.SetStringWithoutPathExpansion(
450 flimflam::kOpenVPNClientCertIdProperty, pkcs11_id);
451 }
452 if (!tpm_pin.empty()) {
453 config_properties.SetStringWithoutPathExpansion(
454 flimflam::kOpenVPNPinProperty, tpm_pin);
455 }
456 } else {
457 if (!pkcs11_id.empty()) {
458 config_properties.SetStringWithoutPathExpansion(
459 flimflam::kL2tpIpsecClientCertIdProperty, pkcs11_id);
460 }
461 if (!tpm_slot.empty()) {
462 config_properties.SetStringWithoutPathExpansion(
463 flimflam::kL2tpIpsecClientCertSlotProperty, tpm_slot);
464 }
465 if (!tpm_pin.empty()) {
466 config_properties.SetStringWithoutPathExpansion(
467 flimflam::kL2tpIpsecPinProperty, tpm_pin);
468 }
469 }
470 } else if (type == flimflam::kTypeWifi) {
471 if (!pkcs11_id.empty()) {
472 config_properties.SetStringWithoutPathExpansion(
473 flimflam::kEapCertIdProperty, pkcs11_id);
474 config_properties.SetStringWithoutPathExpansion(
475 flimflam::kEapKeyIdProperty, pkcs11_id);
476 }
477 if (!tpm_pin.empty()) {
478 config_properties.SetStringWithoutPathExpansion(
479 flimflam::kEapPinProperty, tpm_pin);
480 }
481 }
482
483 if (!config_properties.empty()) {
422 NET_LOG_EVENT("Configuring Network", service_path); 484 NET_LOG_EVENT("Configuring Network", service_path);
423 const std::string& tpm_slot = cert_loader_->tpm_token_slot(); 485
424 const std::string& tpm_pin = cert_loader_->tpm_user_pin();
425 base::DictionaryValue config_properties;
426 // Set configuration properties required by Shill to identify the network. 486 // Set configuration properties required by Shill to identify the network.
427 config_properties.SetStringWithoutPathExpansion( 487 config_properties.SetStringWithoutPathExpansion(
428 flimflam::kTypeProperty, type); 488 flimflam::kTypeProperty, type);
429 CopyStringFromDictionary(service_properties, flimflam::kNameProperty, 489 CopyStringFromDictionary(service_properties, flimflam::kNameProperty,
430 &config_properties); 490 &config_properties);
431 CopyStringFromDictionary(service_properties, flimflam::kSecurityProperty,
432 &config_properties);
433 CopyStringFromDictionary(service_properties, flimflam::kGuidProperty, 491 CopyStringFromDictionary(service_properties, flimflam::kGuidProperty,
434 &config_properties); 492 &config_properties);
493 if (type == flimflam::kTypeVPN) {
494 config_properties.SetStringWithoutPathExpansion(
495 flimflam::kProviderTypeProperty, vpn_provider_type);
496 config_properties.SetStringWithoutPathExpansion(
497 flimflam::kProviderHostProperty, vpn_provider_host);
498 } else if (type == flimflam::kTypeWifi) {
499 CopyStringFromDictionary(service_properties, flimflam::kSecurityProperty,
500 &config_properties);
501 }
435 502
436 if (type == flimflam::kTypeVPN) {
437 // VPN Provider values are read from the "Provider" dictionary, not the
438 // "Provider.Type", etc keys (which are used only to set the values).
439 std::string provider_type;
440 const base::DictionaryValue* provider_properties;
441 if (service_properties.GetDictionaryWithoutPathExpansion(
442 flimflam::kProviderProperty, &provider_properties)) {
443 provider_properties->GetStringWithoutPathExpansion(
444 flimflam::kTypeProperty, &provider_type);
445 }
446 if (provider_type.empty()) {
447 ErrorCallbackForPendingRequest(service_path, kErrorMissingProviderType);
448 return;
449 }
450 if (provider_type == flimflam::kProviderOpenVpn) {
451 config_properties.SetStringWithoutPathExpansion(
452 flimflam::kOpenVPNClientCertSlotProperty, tpm_slot);
453 config_properties.SetStringWithoutPathExpansion(
454 flimflam::kOpenVPNPinProperty, tpm_pin);
455 config_properties.SetStringWithoutPathExpansion(
456 flimflam::kOpenVPNClientCertIdProperty, pkcs11_id);
457 } else {
458 config_properties.SetStringWithoutPathExpansion(
459 flimflam::kL2tpIpsecClientCertSlotProperty, tpm_slot);
460 config_properties.SetStringWithoutPathExpansion(
461 flimflam::kL2tpIpsecPinProperty, tpm_pin);
462 config_properties.SetStringWithoutPathExpansion(
463 flimflam::kL2tpIpsecClientCertIdProperty, pkcs11_id);
464 }
465 } else if (type == flimflam::kTypeWifi) {
466 config_properties.SetStringWithoutPathExpansion(
467 flimflam::kEapPinProperty, cert_loader_->tpm_user_pin());
468 config_properties.SetStringWithoutPathExpansion(
469 flimflam::kEapCertIdProperty, pkcs11_id);
470 config_properties.SetStringWithoutPathExpansion(
471 flimflam::kEapKeyIdProperty, pkcs11_id);
472 }
473 network_configuration_handler_->SetProperties( 503 network_configuration_handler_->SetProperties(
474 service_path, 504 service_path,
475 config_properties, 505 config_properties,
476 base::Bind(&NetworkConnectionHandler::CallShillConnect, 506 base::Bind(&NetworkConnectionHandler::CallShillConnect,
477 AsWeakPtr(), service_path), 507 AsWeakPtr(), service_path),
478 base::Bind(&NetworkConnectionHandler::HandleConfigurationFailure, 508 base::Bind(&NetworkConnectionHandler::HandleConfigurationFailure,
479 AsWeakPtr(), service_path)); 509 AsWeakPtr(), service_path));
480 return; 510 return;
481 } 511 }
482 512
483 // Otherwise, we need to configure the network. 513 // Otherwise, we probably still need to configure the network since
484 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired); 514 // 'Connectable' is false. If |check_error_state| is true, signal an
515 // error, otherwise attempt to connect to possibly gain additional error
516 // state from Shill (or in case 'Connectable' is improperly unset).
517 if (check_error_state)
518 ErrorCallbackForPendingRequest(service_path, kErrorConfigurationRequired);
519 else
520 CallShillConnect(service_path);
485 } 521 }
486 522
487 void NetworkConnectionHandler::CallShillConnect( 523 void NetworkConnectionHandler::CallShillConnect(
488 const std::string& service_path) { 524 const std::string& service_path) {
489 NET_LOG_EVENT("Sending Connect Request to Shill", service_path); 525 NET_LOG_EVENT("Sending Connect Request to Shill", service_path);
490 DBusThreadManager::Get()->GetShillServiceClient()->Connect( 526 DBusThreadManager::Get()->GetShillServiceClient()->Connect(
491 dbus::ObjectPath(service_path), 527 dbus::ObjectPath(service_path),
492 base::Bind(&NetworkConnectionHandler::HandleShillConnectSuccess, 528 base::Bind(&NetworkConnectionHandler::HandleShillConnectSuccess,
493 AsWeakPtr(), service_path), 529 AsWeakPtr(), service_path),
494 base::Bind(&NetworkConnectionHandler::HandleShillConnectFailure, 530 base::Bind(&NetworkConnectionHandler::HandleShillConnectFailure,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 void NetworkConnectionHandler::CallShillDisconnect( 656 void NetworkConnectionHandler::CallShillDisconnect(
621 const std::string& service_path, 657 const std::string& service_path,
622 const base::Closure& success_callback, 658 const base::Closure& success_callback,
623 const network_handler::ErrorCallback& error_callback) { 659 const network_handler::ErrorCallback& error_callback) {
624 NET_LOG_USER("Disconnect Request", service_path); 660 NET_LOG_USER("Disconnect Request", service_path);
625 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect( 661 DBusThreadManager::Get()->GetShillServiceClient()->Disconnect(
626 dbus::ObjectPath(service_path), 662 dbus::ObjectPath(service_path),
627 base::Bind(&NetworkConnectionHandler::HandleShillDisconnectSuccess, 663 base::Bind(&NetworkConnectionHandler::HandleShillDisconnectSuccess,
628 AsWeakPtr(), service_path, success_callback), 664 AsWeakPtr(), service_path, success_callback),
629 base::Bind(&network_handler::ShillErrorCallbackFunction, 665 base::Bind(&network_handler::ShillErrorCallbackFunction,
630 kErrorDisconnectFailed, service_path, error_callback)); 666 kErrorShillError, service_path, error_callback));
631 } 667 }
632 668
633 void NetworkConnectionHandler::HandleShillDisconnectSuccess( 669 void NetworkConnectionHandler::HandleShillDisconnectSuccess(
634 const std::string& service_path, 670 const std::string& service_path,
635 const base::Closure& success_callback) { 671 const base::Closure& success_callback) {
636 NET_LOG_EVENT("Disconnect Request Sent", service_path); 672 NET_LOG_EVENT("Disconnect Request Sent", service_path);
637 if (!success_callback.is_null()) 673 if (!success_callback.is_null())
638 success_callback.Run(); 674 success_callback.Run();
639 } 675 }
640 676
677 // Activate
678
679 void NetworkConnectionHandler::CallShillActivate(
680 const std::string& service_path,
681 const std::string& carrier,
682 const base::Closure& success_callback,
683 const network_handler::ErrorCallback& error_callback) {
684 NET_LOG_USER("Activate Request", service_path + ": '" + carrier + "'");
685 DBusThreadManager::Get()->GetShillServiceClient()->ActivateCellularModem(
686 dbus::ObjectPath(service_path),
687 carrier,
688 base::Bind(&NetworkConnectionHandler::HandleShillActivateSuccess,
689 AsWeakPtr(), service_path, success_callback),
690 base::Bind(&network_handler::ShillErrorCallbackFunction,
691 kErrorShillError, service_path, error_callback));
692 }
693
694 void NetworkConnectionHandler::HandleShillActivateSuccess(
695 const std::string& service_path,
696 const base::Closure& success_callback) {
697 NET_LOG_EVENT("Activate Request Sent", service_path);
698 if (!success_callback.is_null())
699 success_callback.Run();
700 }
701
641 } // namespace chromeos 702 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_connection_handler.h ('k') | chromeos/network/network_profile_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698