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

Side by Side Diff: chromeos/network/network_util.cc

Issue 289383004: Merge FavoriteState into NetworkState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chromeos/network/network_util.h ('k') | chromeos/network/shill_property_handler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/network/network_util.h" 5 #include "chromeos/network/network_util.h"
6 6
7 #include "base/strings/string_tokenizer.h" 7 #include "base/strings/string_tokenizer.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chromeos/network/favorite_state.h"
11 #include "chromeos/network/network_state.h" 10 #include "chromeos/network/network_state.h"
12 #include "chromeos/network/network_state_handler.h" 11 #include "chromeos/network/network_state_handler.h"
13 #include "chromeos/network/onc/onc_signature.h" 12 #include "chromeos/network/onc/onc_signature.h"
14 #include "chromeos/network/onc/onc_translator.h" 13 #include "chromeos/network/onc/onc_translator.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 14 #include "third_party/cros_system_api/dbus/service_constants.h"
16 15
17 namespace chromeos { 16 namespace chromeos {
18 17
19 WifiAccessPoint::WifiAccessPoint() 18 WifiAccessPoint::WifiAccessPoint()
20 : signal_strength(0), 19 : signal_strength(0),
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 &scan_result.long_name); 132 &scan_result.long_name);
134 dict->GetStringWithoutPathExpansion(shill::kShortNameProperty, 133 dict->GetStringWithoutPathExpansion(shill::kShortNameProperty,
135 &scan_result.short_name); 134 &scan_result.short_name);
136 dict->GetStringWithoutPathExpansion(shill::kTechnologyProperty, 135 dict->GetStringWithoutPathExpansion(shill::kTechnologyProperty,
137 &scan_result.technology); 136 &scan_result.technology);
138 scan_results->push_back(scan_result); 137 scan_results->push_back(scan_result);
139 } 138 }
140 return true; 139 return true;
141 } 140 }
142 141
143 scoped_ptr<base::DictionaryValue> TranslateFavoriteStateToONC( 142 scoped_ptr<base::DictionaryValue> TranslateNetworkStateToONC(
144 const FavoriteState* favorite) { 143 const NetworkState* network) {
145 // Get the properties from the FavoriteState. 144 // Get the properties from the NetworkState.
146 base::DictionaryValue shill_dictionary; 145 base::DictionaryValue shill_dictionary;
147 favorite->GetStateProperties(&shill_dictionary); 146 network->GetStateProperties(&shill_dictionary);
148
149 // If a corresponding NetworkState exists, merge its State properties.
150 const NetworkState* network_state =
151 NetworkHandler::Get()->network_state_handler()->GetNetworkState(
152 favorite->path());
153 if (network_state) {
154 base::DictionaryValue shill_network_dictionary;
155 network_state->GetStateProperties(&shill_network_dictionary);
156 shill_dictionary.MergeDictionary(&shill_network_dictionary);
157 }
158 147
159 scoped_ptr<base::DictionaryValue> onc_dictionary = 148 scoped_ptr<base::DictionaryValue> onc_dictionary =
160 TranslateShillServiceToONCPart( 149 TranslateShillServiceToONCPart(
161 shill_dictionary, &onc::kNetworkWithStateSignature); 150 shill_dictionary, &onc::kNetworkWithStateSignature);
162 return onc_dictionary.Pass(); 151 return onc_dictionary.Pass();
163 } 152 }
164 153
165 scoped_ptr<base::ListValue> TranslateNetworkListToONC( 154 scoped_ptr<base::ListValue> TranslateNetworkListToONC(
166 NetworkTypePattern pattern, 155 NetworkTypePattern pattern,
167 bool configured_only, 156 bool configured_only,
168 bool visible_only, 157 bool visible_only,
169 int limit, 158 int limit,
170 bool debugging_properties) { 159 bool debugging_properties) {
171 NetworkStateHandler::FavoriteStateList favorite_states; 160 NetworkStateHandler::NetworkStateList network_states;
172 NetworkHandler::Get()->network_state_handler()->GetFavoriteListByType( 161 NetworkHandler::Get()->network_state_handler()->GetNetworkListByType(
173 pattern, configured_only, visible_only, limit, &favorite_states); 162 pattern, configured_only, visible_only, limit, &network_states);
174 163
175 scoped_ptr<base::ListValue> network_properties_list(new base::ListValue); 164 scoped_ptr<base::ListValue> network_properties_list(new base::ListValue);
176 for (NetworkStateHandler::FavoriteStateList::iterator it = 165 for (NetworkStateHandler::NetworkStateList::iterator it =
177 favorite_states.begin(); 166 network_states.begin();
178 it != favorite_states.end(); 167 it != network_states.end();
179 ++it) { 168 ++it) {
180 scoped_ptr<base::DictionaryValue> onc_dictionary = 169 scoped_ptr<base::DictionaryValue> onc_dictionary =
181 TranslateFavoriteStateToONC(*it); 170 TranslateNetworkStateToONC(*it);
182 171
183 if (debugging_properties) { 172 if (debugging_properties) {
173 onc_dictionary->SetBoolean("visible", (*it)->visible());
184 onc_dictionary->SetString("profile_path", (*it)->profile_path()); 174 onc_dictionary->SetString("profile_path", (*it)->profile_path());
185 std::string onc_source = (*it)->ui_data().GetONCSourceAsString(); 175 std::string onc_source = (*it)->ui_data().GetONCSourceAsString();
186 if (!onc_source.empty()) 176 if (!onc_source.empty())
187 onc_dictionary->SetString("onc_source", onc_source); 177 onc_dictionary->SetString("onc_source", onc_source);
188 } 178 }
189 179
190 network_properties_list->Append(onc_dictionary.release()); 180 network_properties_list->Append(onc_dictionary.release());
191 } 181 }
192 return network_properties_list.Pass(); 182 return network_properties_list.Pass();
193 } 183 }
194 184
195 } // namespace network_util 185 } // namespace network_util
196 } // namespace chromeos 186 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_util.h ('k') | chromeos/network/shill_property_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698