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

Unified Diff: components/arc/net/arc_net_host_impl.cc

Issue 1798293002: ARC: Implement SetWifiEnabledState API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made SetWifiEnabled return a bool status. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« components/arc/common/net.mojom ('K') | « components/arc/net/arc_net_host_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/net/arc_net_host_impl.cc
diff --git a/components/arc/net/arc_net_host_impl.cc b/components/arc/net/arc_net_host_impl.cc
index 929b64e89c10e1c20ed1ed1b3ac67e869bd6176f..afaec21d25b077b0468414179e2cd78428405ccf 100644
--- a/components/arc/net/arc_net_host_impl.cc
+++ b/components/arc/net/arc_net_host_impl.cc
@@ -14,6 +14,7 @@
#include "base/time/time.h"
#include "chromeos/network/network_handler.h"
#include "chromeos/network/network_state_handler.h"
+#include "chromeos/network/network_type_pattern.h"
#include "chromeos/network/network_util.h"
#include "chromeos/network/onc/onc_utils.h"
#include "components/arc/arc_bridge_service.h"
@@ -145,10 +146,30 @@ void ArcNetHostImpl::GetWifiEnabledState(
const GetWifiEnabledStateCallback& callback) {
bool is_enabled = GetStateHandler()->IsTechnologyEnabled(
chromeos::NetworkTypePattern::WiFi());
-
callback.Run(is_enabled);
}
+void ArcNetHostImpl::SetWifiEnabledState(
+ bool is_enabled,
+ const SetWifiEnabledStateCallback& callback) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ chromeos::NetworkStateHandler::TechnologyState state =
+ GetStateHandler()->GetTechnologyState(
+ chromeos::NetworkTypePattern::WiFi());
+ // WiFi can't be enabled or disabled in these states.
+ if ((state == chromeos::NetworkStateHandler::TECHNOLOGY_PROHIBITED) ||
+ (state == chromeos::NetworkStateHandler::TECHNOLOGY_UNINITIALIZED) ||
+ (state == chromeos::NetworkStateHandler::TECHNOLOGY_UNAVAILABLE)) {
+ VLOG(1) << "SetWifiEnabledState failed due to WiFi state: " << state;
+ callback.Run(false);
+ } else {
+ GetStateHandler()->SetTechnologyEnabled(
+ chromeos::NetworkTypePattern::WiFi(), is_enabled,
+ chromeos::network_handler::ErrorCallback());
+ callback.Run(true);
+ }
+}
+
void ArcNetHostImpl::StartScan() {
GetStateHandler()->RequestScan();
}
« components/arc/common/net.mojom ('K') | « components/arc/net/arc_net_host_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698