Commit 56e10c47 authored by Abhishek Bhardwaj's avatar Abhishek Bhardwaj Committed by Commit Bot

arc: Update GetNetworks to use the new NetworkConfiguration type

This change deprecates the current GetNetworks function and removes the
old GetNetworksDeprecated function altogether. The new GetNetworks
function uses the NetworkConfiguration type used in other APIs instead
of the old WifiConfiguration type.

BUG=b:63738960
TEST=Compile and boot.

Change-Id: I4c00cf19b55fd90a322422ca91cd787084013d86
Reviewed-on: https://chromium-review.googlesource.com/573111
Commit-Queue: Abhishek Bhardwaj <abhishekbh@google.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarLuis Hector Chavez <lhchavez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#488368}
parent a42eff7d
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// Next MinVersion: 7
module arc.mojom; module arc.mojom;
[Extensible] [Extensible]
...@@ -122,11 +124,13 @@ struct NetworkData { ...@@ -122,11 +124,13 @@ struct NetworkData {
array<WifiConfiguration> networks; array<WifiConfiguration> networks;
}; };
interface NetHost { struct GetNetworksResponseType {
// Sends a request to get configured or visible WiFi networks based on the NetworkResult status;
// |configured_only| and |visible_only| flags. array<NetworkConfiguration> networks;
GetNetworksDeprecated@0(bool configured_only, bool visible_only) => (NetworkData data); };
interface NetHost {
// Sends a request to get enabled / disabled status of WiFi. // Sends a request to get enabled / disabled status of WiFi.
GetWifiEnabledState@1() => (bool is_enabled); GetWifiEnabledState@1() => (bool is_enabled);
...@@ -135,7 +139,7 @@ interface NetHost { ...@@ -135,7 +139,7 @@ interface NetHost {
// Sends a request to get configured or visible WiFi networks based on the // Sends a request to get configured or visible WiFi networks based on the
// request type. // request type.
[MinVersion=2] GetNetworks@3(GetNetworksRequestType type) => (NetworkData data); [MinVersion=2] GetNetworksDeprecated@3(GetNetworksRequestType type) => (NetworkData data);
// Sends a request to enable or disable WiFi. The |result| is true when the // Sends a request to enable or disable WiFi. The |result| is true when the
// the state has been successfully set or WiFi is already in the desired // the state has been successfully set or WiFi is already in the desired
...@@ -161,6 +165,11 @@ interface NetHost { ...@@ -161,6 +165,11 @@ interface NetHost {
[MinVersion=5] GetDefaultNetwork@9() => ( [MinVersion=5] GetDefaultNetwork@9() => (
NetworkConfiguration? logical_default, NetworkConfiguration? logical_default,
NetworkConfiguration? physical_default); NetworkConfiguration? physical_default);
// Sends a request to get configured or visible WiFi networks based on the
// request type.
[MinVersion=6] GetNetworks@10(GetNetworksRequestType type) =>
(GetNetworksResponseType response);
}; };
interface NetInstance { interface NetInstance {
......
...@@ -363,28 +363,9 @@ void ArcNetHostImpl::OnInstanceClosed() { ...@@ -363,28 +363,9 @@ void ArcNetHostImpl::OnInstanceClosed() {
} }
void ArcNetHostImpl::GetNetworksDeprecated( void ArcNetHostImpl::GetNetworksDeprecated(
bool configured_only, mojom::GetNetworksRequestType type,
bool visible_only,
const GetNetworksDeprecatedCallback& callback) { const GetNetworksDeprecatedCallback& callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (configured_only && visible_only) {
VLOG(1) << "Illegal arguments - both configured and visible networks "
"requested.";
return;
}
mojom::GetNetworksRequestType type =
mojom::GetNetworksRequestType::CONFIGURED_ONLY;
if (visible_only) {
type = mojom::GetNetworksRequestType::VISIBLE_ONLY;
}
GetNetworks(type, callback);
}
void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type,
const GetNetworksCallback& callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
mojom::NetworkDataPtr data = mojom::NetworkData::New(); mojom::NetworkDataPtr data = mojom::NetworkData::New();
bool configured_only = true; bool configured_only = true;
...@@ -394,7 +375,7 @@ void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type, ...@@ -394,7 +375,7 @@ void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type,
visible_only = true; visible_only = true;
} }
// Retrieve list of nearby wifi networks // Retrieve list of nearby WiFi networks.
chromeos::NetworkTypePattern network_pattern = chromeos::NetworkTypePattern network_pattern =
chromeos::onc::NetworkTypePatternFromOncType(onc::network_type::kWiFi); chromeos::onc::NetworkTypePatternFromOncType(onc::network_type::kWiFi);
std::unique_ptr<base::ListValue> network_properties_list = std::unique_ptr<base::ListValue> network_properties_list =
...@@ -459,6 +440,31 @@ void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type, ...@@ -459,6 +440,31 @@ void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type,
callback.Run(std::move(data)); callback.Run(std::move(data));
} }
void ArcNetHostImpl::GetNetworks(mojom::GetNetworksRequestType type,
const GetNetworksCallback& callback) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
// Retrieve list of configured or visible WiFi networks.
bool configured_only = type == mojom::GetNetworksRequestType::CONFIGURED_ONLY;
chromeos::NetworkTypePattern network_pattern =
chromeos::onc::NetworkTypePatternFromOncType(onc::network_type::kWiFi);
std::unique_ptr<base::ListValue> network_properties_list =
chromeos::network_util::TranslateNetworkListToONC(
network_pattern, configured_only, !configured_only /* visible_only */,
kGetNetworksListLimit);
std::vector<mojom::NetworkConfigurationPtr> networks;
for (const auto& value : *network_properties_list) {
const base::DictionaryValue* network_dict = nullptr;
value.GetAsDictionary(&network_dict);
DCHECK(network_dict);
networks.push_back(TranslateONCConfiguration(network_dict));
}
callback.Run(mojom::GetNetworksResponseType::New(
arc::mojom::NetworkResult::SUCCESS, std::move(networks)));
}
void ArcNetHostImpl::CreateNetworkSuccessCallback( void ArcNetHostImpl::CreateNetworkSuccessCallback(
const mojom::NetHost::CreateNetworkCallback& mojo_callback, const mojom::NetHost::CreateNetworkCallback& mojo_callback,
const std::string& service_path, const std::string& service_path,
......
...@@ -50,8 +50,7 @@ class ArcNetHostImpl : public KeyedService, ...@@ -50,8 +50,7 @@ class ArcNetHostImpl : public KeyedService,
// ARC -> Chrome calls: // ARC -> Chrome calls:
void GetNetworksDeprecated( void GetNetworksDeprecated(
bool configured_only, mojom::GetNetworksRequestType type,
bool visible_only,
const GetNetworksDeprecatedCallback& callback) override; const GetNetworksDeprecatedCallback& callback) override;
void GetNetworks(mojom::GetNetworksRequestType type, void GetNetworks(mojom::GetNetworksRequestType type,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment