| 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 "chromeos/network/network_connect.h" | 5 #include "chromeos/network/network_connect.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chromeos/login/login_state.h" | 12 #include "chromeos/login/login_state.h" |
| 13 #include "chromeos/network/device_state.h" | 13 #include "chromeos/network/device_state.h" |
| 14 #include "chromeos/network/network_activation_handler.h" | 14 #include "chromeos/network/network_activation_handler.h" |
| 15 #include "chromeos/network/network_configuration_handler.h" | 15 #include "chromeos/network/network_configuration_handler.h" |
| 16 #include "chromeos/network/network_connection_handler.h" | 16 #include "chromeos/network/network_connection_handler.h" |
| 17 #include "chromeos/network/network_event_log.h" | 17 #include "chromeos/network/network_event_log.h" |
| 18 #include "chromeos/network/network_handler_callbacks.h" | 18 #include "chromeos/network/network_handler_callbacks.h" |
| 19 #include "chromeos/network/network_profile.h" | 19 #include "chromeos/network/network_profile.h" |
| 20 #include "chromeos/network/network_profile_handler.h" | 20 #include "chromeos/network/network_profile_handler.h" |
| 21 #include "chromeos/network/network_state.h" | 21 #include "chromeos/network/network_state.h" |
| 22 #include "chromeos/network/network_state_handler.h" | 22 #include "chromeos/network/network_state_handler.h" |
| 23 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 24 | 24 |
| 25 namespace chromeos { | 25 namespace chromeos { |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 | 28 |
| 29 void IgnoreDisconnectError(const std::string& error_name, |
| 30 std::unique_ptr<base::DictionaryValue> error_data) {} |
| 31 |
| 29 // Returns true for carriers that can be activated through Shill instead of | 32 // Returns true for carriers that can be activated through Shill instead of |
| 30 // through a WebUI dialog. | 33 // through a WebUI dialog. |
| 31 bool IsDirectActivatedCarrier(const std::string& carrier) { | 34 bool IsDirectActivatedCarrier(const std::string& carrier) { |
| 32 if (carrier == shill::kCarrierSprint) | 35 if (carrier == shill::kCarrierSprint) |
| 33 return true; | 36 return true; |
| 34 return false; | 37 return false; |
| 35 } | 38 } |
| 36 | 39 |
| 37 const NetworkState* GetNetworkStateFromId(const std::string& network_id) { | 40 const NetworkState* GetNetworkStateFromId(const std::string& network_id) { |
| 38 // Note: network_id === NetworkState::guid. | 41 // Note: network_id === NetworkState::guid. |
| 39 return NetworkHandler::Get() | 42 return NetworkHandler::Get() |
| 40 ->network_state_handler() | 43 ->network_state_handler() |
| 41 ->GetNetworkStateFromGuid(network_id); | 44 ->GetNetworkStateFromGuid(network_id); |
| 42 } | 45 } |
| 43 | 46 |
| 44 class NetworkConnectImpl : public NetworkConnect { | 47 class NetworkConnectImpl : public NetworkConnect { |
| 45 public: | 48 public: |
| 46 explicit NetworkConnectImpl(Delegate* delegate); | 49 explicit NetworkConnectImpl(Delegate* delegate); |
| 47 ~NetworkConnectImpl() override; | 50 ~NetworkConnectImpl() override; |
| 48 | 51 |
| 49 // NetworkConnect | 52 // NetworkConnect |
| 50 void ConnectToNetworkId(const std::string& network_id) override; | 53 void ConnectToNetworkId(const std::string& network_id) override; |
| 54 void DisconnectFromNetworkId(const std::string& network_id) override; |
| 51 bool MaybeShowConfigureUI(const std::string& network_id, | 55 bool MaybeShowConfigureUI(const std::string& network_id, |
| 52 const std::string& connect_error) override; | 56 const std::string& connect_error) override; |
| 53 void SetTechnologyEnabled(const NetworkTypePattern& technology, | 57 void SetTechnologyEnabled(const NetworkTypePattern& technology, |
| 54 bool enabled_state) override; | 58 bool enabled_state) override; |
| 55 void ShowMobileSetup(const std::string& network_id) override; | 59 void ShowMobileSetup(const std::string& network_id) override; |
| 56 void ConfigureNetworkIdAndConnect( | 60 void ConfigureNetworkIdAndConnect( |
| 57 const std::string& network_id, | 61 const std::string& network_id, |
| 58 const base::DictionaryValue& shill_properties, | 62 const base::DictionaryValue& shill_properties, |
| 59 bool shared) override; | 63 bool shared) override; |
| 60 void CreateConfigurationAndConnect(base::DictionaryValue* shill_properties, | 64 void CreateConfigurationAndConnect(base::DictionaryValue* shill_properties, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 return; | 399 return; |
| 396 } else if (network->RequiresActivation()) { | 400 } else if (network->RequiresActivation()) { |
| 397 ActivateCellular(network_id); | 401 ActivateCellular(network_id); |
| 398 return; | 402 return; |
| 399 } | 403 } |
| 400 } | 404 } |
| 401 const bool check_error_state = true; | 405 const bool check_error_state = true; |
| 402 CallConnectToNetwork(network_id, check_error_state); | 406 CallConnectToNetwork(network_id, check_error_state); |
| 403 } | 407 } |
| 404 | 408 |
| 409 void NetworkConnectImpl::DisconnectFromNetworkId( |
| 410 const std::string& network_id) { |
| 411 NET_LOG_USER("DisconnectFromNetwork", network_id); |
| 412 const NetworkState* network = GetNetworkStateFromId(network_id); |
| 413 if (!network) |
| 414 return; |
| 415 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( |
| 416 network->path(), base::Bind(&base::DoNothing), |
| 417 base::Bind(&IgnoreDisconnectError)); |
| 418 } |
| 419 |
| 405 bool NetworkConnectImpl::MaybeShowConfigureUI( | 420 bool NetworkConnectImpl::MaybeShowConfigureUI( |
| 406 const std::string& network_id, | 421 const std::string& network_id, |
| 407 const std::string& connect_error) { | 422 const std::string& connect_error) { |
| 408 return MaybeShowConfigureUIImpl(network_id, connect_error); | 423 return MaybeShowConfigureUIImpl(network_id, connect_error); |
| 409 } | 424 } |
| 410 | 425 |
| 411 void NetworkConnectImpl::SetTechnologyEnabled( | 426 void NetworkConnectImpl::SetTechnologyEnabled( |
| 412 const NetworkTypePattern& technology, | 427 const NetworkTypePattern& technology, |
| 413 bool enabled_state) { | 428 bool enabled_state) { |
| 414 std::string log_string = base::StringPrintf( | 429 std::string log_string = base::StringPrintf( |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 NetworkConnect* NetworkConnect::Get() { | 592 NetworkConnect* NetworkConnect::Get() { |
| 578 CHECK(g_network_connect); | 593 CHECK(g_network_connect); |
| 579 return g_network_connect; | 594 return g_network_connect; |
| 580 } | 595 } |
| 581 | 596 |
| 582 NetworkConnect::NetworkConnect() {} | 597 NetworkConnect::NetworkConnect() {} |
| 583 | 598 |
| 584 NetworkConnect::~NetworkConnect() {} | 599 NetworkConnect::~NetworkConnect() {} |
| 585 | 600 |
| 586 } // namespace chromeos | 601 } // namespace chromeos |
| OLD | NEW |