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

Unified Diff: chromeos/network/network_util.cc

Issue 280023003: Implement networkingPrivate.getNetworks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 7 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
Index: chromeos/network/network_util.cc
diff --git a/chromeos/network/network_util.cc b/chromeos/network/network_util.cc
index f0d5d6a1f950dc4548c6d85e9fc5ec205052d82a..2b6cc9e4c5900e7f27805db65d94cc8930ac305e 100644
--- a/chromeos/network/network_util.cc
+++ b/chromeos/network/network_util.cc
@@ -6,6 +6,7 @@
#include "base/strings/string_tokenizer.h"
#include "base/strings/stringprintf.h"
+#include "chromeos/network/favorite_state.h"
#include "chromeos/network/network_state.h"
#include "chromeos/network/network_state_handler.h"
#include "chromeos/network/onc/onc_signature.h"
@@ -128,23 +129,41 @@ bool ParseCellularScanResults(const base::ListValue& list,
}
scoped_ptr<base::ListValue> TranslateNetworkListToONC(
- NetworkTypePattern pattern) {
- NetworkStateHandler::NetworkStateList network_states;
- NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
- pattern, &network_states);
+ NetworkTypePattern pattern,
+ bool configured_only,
+ bool visible_only,
+ int limit) {
+ NetworkStateHandler::FavoriteStateList favorite_states;
+ NetworkHandler::Get()->network_state_handler()->GetFavoriteListByType(
+ pattern, configured_only, visible_only, &favorite_states);
+ int count = 0;
scoped_ptr<base::ListValue> network_properties_list(new base::ListValue);
- for (NetworkStateHandler::NetworkStateList::iterator it =
- network_states.begin();
- it != network_states.end();
+ for (NetworkStateHandler::FavoriteStateList::iterator it =
+ favorite_states.begin();
+ it != favorite_states.end();
++it) {
+ // Get the properties from the FavoriteState.
base::DictionaryValue shill_dictionary;
(*it)->GetStateProperties(&shill_dictionary);
+ // If a corresponding NetworkState exists, merge its State properties.
+ const NetworkState* network_state =
+ NetworkHandler::Get()->network_state_handler()->GetNetworkState(
+ (*it)->path());
+ if (network_state) {
+ base::DictionaryValue shill_network_dictionary;
+ network_state->GetStateProperties(&shill_network_dictionary);
+ shill_dictionary.MergeDictionary(&shill_network_dictionary);
+ }
+
scoped_ptr<base::DictionaryValue> onc_network_part =
TranslateShillServiceToONCPart(
shill_dictionary, &onc::kNetworkWithStateSignature);
network_properties_list->Append(onc_network_part.release());
+
+ if (++count >= limit)
+ break;
}
return network_properties_list.Pass();
}

Powered by Google App Engine
This is Rietveld 408576698