Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/components/tether/tether_network_disconnection_handler.h" | 5 #include "chromeos/components/tether/tether_network_disconnection_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | |
| 8 #include "base/bind_helpers.h" | |
| 9 #include "base/macros.h" | |
| 7 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "chromeos/network/managed_network_configuration_handler.h" | |
| 8 #include "chromeos/network/network_handler.h" | 12 #include "chromeos/network/network_handler.h" |
| 9 #include "chromeos/network/network_state.h" | 13 #include "chromeos/network/network_state.h" |
| 10 #include "chromeos/network/network_state_handler.h" | 14 #include "chromeos/network/network_state_handler.h" |
| 11 #include "components/proximity_auth/logging/logging.h" | 15 #include "components/proximity_auth/logging/logging.h" |
| 12 | 16 |
| 17 namespace { | |
| 18 | |
| 19 void RemoveConfigurationSuccessCallback() { | |
| 20 PA_LOG(INFO) << "Successfully removed Wi-Fi network."; | |
|
Kyle Horimoto
2017/04/17 20:34:53
Add more information to this log. Since the callba
Ryan Hansberry
2017/04/20 20:57:58
Done.
| |
| 21 } | |
| 22 | |
| 23 void RemoveConfigurationFailureCallback( | |
| 24 const std::string& error_name, | |
| 25 std::unique_ptr<base::DictionaryValue> error_data) { | |
| 26 PA_LOG(WARNING) << "Failed to remove Wi-Fi network: " << error_name; | |
| 27 } | |
| 28 | |
| 29 } // namespace | |
| 30 | |
| 13 namespace chromeos { | 31 namespace chromeos { |
| 14 | 32 |
| 15 namespace tether { | 33 namespace tether { |
| 16 | 34 |
| 17 TetherNetworkDisconnectionHandler::TetherNetworkDisconnectionHandler( | 35 TetherNetworkDisconnectionHandler::TetherNetworkDisconnectionHandler( |
| 18 ActiveHost* active_host) | |
| 19 : TetherNetworkDisconnectionHandler( | |
| 20 active_host, | |
| 21 NetworkHandler::Get()->network_state_handler()) {} | |
| 22 | |
| 23 TetherNetworkDisconnectionHandler::TetherNetworkDisconnectionHandler( | |
| 24 ActiveHost* active_host, | 36 ActiveHost* active_host, |
| 25 NetworkStateHandler* network_state_handler) | 37 NetworkStateHandler* network_state_handler, |
| 26 : active_host_(active_host), network_state_handler_(network_state_handler) { | 38 ManagedNetworkConfigurationHandler* managed_network_configuration_handler) |
| 39 : active_host_(active_host), | |
| 40 network_state_handler_(network_state_handler), | |
| 41 managed_network_configuration_handler_( | |
| 42 managed_network_configuration_handler) { | |
| 27 network_state_handler_->AddObserver(this, FROM_HERE); | 43 network_state_handler_->AddObserver(this, FROM_HERE); |
| 28 } | 44 } |
| 29 | 45 |
| 30 TetherNetworkDisconnectionHandler::~TetherNetworkDisconnectionHandler() { | 46 TetherNetworkDisconnectionHandler::~TetherNetworkDisconnectionHandler() { |
| 31 network_state_handler_->RemoveObserver(this, FROM_HERE); | 47 network_state_handler_->RemoveObserver(this, FROM_HERE); |
| 32 } | 48 } |
| 33 | 49 |
| 34 void TetherNetworkDisconnectionHandler::NetworkConnectionStateChanged( | 50 void TetherNetworkDisconnectionHandler::NetworkConnectionStateChanged( |
| 35 const NetworkState* network) { | 51 const NetworkState* network) { |
| 36 // Note: |active_host_->GetWifiNetworkGuid()| returns "" unless currently | 52 // Note: |active_host_->GetWifiNetworkGuid()| returns "" unless currently |
| 37 // connected, so this if() statement is only entered on disconnections. | 53 // connected, so this if() statement is only entered on disconnections. |
| 38 if (network->guid() == active_host_->GetWifiNetworkGuid() && | 54 if (network->guid() == active_host_->GetWifiNetworkGuid() && |
| 39 !network->IsConnectedState()) { | 55 !network->IsConnectedState()) { |
| 40 PA_LOG(INFO) << "Connection to active host (Wi-Fi network GUID " | 56 PA_LOG(INFO) << "Connection to active host (Wi-Fi network GUID " |
| 41 << network->guid() << ") has been lost."; | 57 << network->guid() << ") has been lost."; |
| 58 | |
| 59 managed_network_configuration_handler_->RemoveConfiguration( | |
|
Kyle Horimoto
2017/04/17 20:34:53
Can you actually move this functionality to a new
stevenjb
2017/04/18 21:03:36
Do we really want to remove the configuration on a
Kyle Horimoto
2017/04/18 21:14:00
Yes, we do want to remove the configuration on any
Ryan Hansberry
2017/04/20 20:57:57
Done.
| |
| 60 network->path(), base::Bind(RemoveConfigurationSuccessCallback), | |
| 61 base::Bind(RemoveConfigurationFailureCallback)); | |
| 62 | |
| 42 active_host_->SetActiveHostDisconnected(); | 63 active_host_->SetActiveHostDisconnected(); |
| 43 | |
| 44 // TODO(hansberry): Remove Wi-Fi network from "known" networks. | |
| 45 } | 64 } |
| 46 } | 65 } |
| 47 | 66 |
| 48 } // namespace tether | 67 } // namespace tether |
| 49 | 68 |
| 50 } // namespace chromeos | 69 } // namespace chromeos |
| OLD | NEW |