Index: chromeos/components/tether/network_configuration_remover.cc |
diff --git a/chromeos/components/tether/network_configuration_remover.cc b/chromeos/components/tether/network_configuration_remover.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..671e1a8d5ad2dc0fbc8bd16137e6714dabb18254 |
--- /dev/null |
+++ b/chromeos/components/tether/network_configuration_remover.cc |
@@ -0,0 +1,57 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chromeos/components/tether/network_configuration_remover.h" |
+ |
+#include "base/bind.h" |
+#include "base/bind_helpers.h" |
+#include "base/macros.h" |
+#include "base/memory/ptr_util.h" |
+#include "chromeos/network/managed_network_configuration_handler.h" |
+#include "chromeos/network/network_handler.h" |
+#include "chromeos/network/network_state.h" |
+#include "components/proximity_auth/logging/logging.h" |
+ |
+namespace { |
+ |
+void RemoveConfigurationSuccessCallback(const std::string& guid) { |
+ PA_LOG(INFO) << "Successfully removed Wi-Fi network with GUID " << guid |
+ << "."; |
+} |
+ |
+void RemoveConfigurationFailureCallback( |
+ const std::string& guid, |
+ const std::string& error_name, |
+ std::unique_ptr<base::DictionaryValue> error_data) { |
+ PA_LOG(WARNING) << "Failed to remove Wi-Fi network with GUID " << guid |
+ << ". Error:" << error_name << "."; |
+} |
+ |
+} // namespace |
+ |
+namespace chromeos { |
+ |
+namespace tether { |
+ |
+NetworkConfigurationRemover::NetworkConfigurationRemover( |
+ NetworkStateHandler* network_state_handler, |
+ ManagedNetworkConfigurationHandler* managed_network_configuration_handler) |
+ : network_state_handler_(network_state_handler), |
+ managed_network_configuration_handler_( |
+ managed_network_configuration_handler) {} |
+ |
+NetworkConfigurationRemover::~NetworkConfigurationRemover() {} |
+ |
+void NetworkConfigurationRemover::RemoveNetworkConfiguration( |
+ const std::string& wifi_network_guid) { |
+ managed_network_configuration_handler_->RemoveConfiguration( |
+ network_state_handler_->GetNetworkStateFromGuid(wifi_network_guid) |
+ ->path(), |
+ base::Bind(RemoveConfigurationSuccessCallback, wifi_network_guid), |
+ base::Bind(RemoveConfigurationFailureCallback, wifi_network_guid)); |
+} |
+ |
+} // namespace tether |
+ |
+} // namespace chromeos |