| Index: chrome/browser/extensions/api/dial/dial_api.cc
|
| diff --git a/chrome/browser/extensions/api/dial/dial_api.cc b/chrome/browser/extensions/api/dial/dial_api.cc
|
| index e97f90fa0b260780ad189b0ce32a5c585dd4c248..6b59f29df083377b7a12061143e5f69b45d23708 100644
|
| --- a/chrome/browser/extensions/api/dial/dial_api.cc
|
| +++ b/chrome/browser/extensions/api/dial/dial_api.cc
|
| @@ -261,4 +261,29 @@ void DialFetchDeviceDescriptionFunction::OnFetchError(
|
| SendResponse(false);
|
| }
|
|
|
| +DialGetNetworkIdFunction::DialGetNetworkIdFunction() {}
|
| +
|
| +DialGetNetworkIdFunction::~DialGetNetworkIdFunction() {}
|
| +
|
| +bool DialGetNetworkIdFunction::RunAsync() {
|
| + auto* network_monitor = DiscoveryNetworkMonitor::GetInstance();
|
| + // If we are the first to call the DiscoveryNetworkMonitor, it will have no
|
| + // network state. Force a refresh to be sure the network ID is populated.
|
| + network_monitor->ForceNetworkInfoRefresh(
|
| + base::Bind(&DialGetNetworkIdFunction::NetworkIdCallback, this));
|
| + return true;
|
| +}
|
| +
|
| +void DialGetNetworkIdFunction::NetworkIdCallback() {
|
| + const auto* network_monitor = DiscoveryNetworkMonitor::GetInstance();
|
| + std::string network_id(network_monitor->GetNetworkId());
|
| + if (network_id.size() == 0) {
|
| + SetResult(base::MakeUnique<base::Value>(std::string("unknown")));
|
| + SendResponse(true);
|
| + return;
|
| + }
|
| + SetResult(base::MakeUnique<base::Value>(network_id));
|
| + SendResponse(true);
|
| +}
|
| +
|
| } // namespace extensions
|
|
|