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

Side by Side Diff: chrome/browser/ui/webui/chromeos/network_config_message_handler.cc

Issue 540613002: Translate Saved/StaticIPConfig properties from ONC to Shill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 6 years, 3 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
« no previous file with comments | « no previous file | chromeos/network/onc/onc_signature.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/webui/chromeos/network_config_message_handler.h" 5 #include "chrome/browser/ui/webui/chromeos/network_config_message_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 } 145 }
146 146
147 void NetworkConfigMessageHandler::GetPropertiesSuccess( 147 void NetworkConfigMessageHandler::GetPropertiesSuccess(
148 int callback_id, 148 int callback_id,
149 const std::string& service_path, 149 const std::string& service_path,
150 const base::DictionaryValue& dictionary) const { 150 const base::DictionaryValue& dictionary) const {
151 base::ListValue return_arg_list; 151 base::ListValue return_arg_list;
152 return_arg_list.AppendInteger(callback_id); 152 return_arg_list.AppendInteger(callback_id);
153 153
154 base::DictionaryValue* network_properties = dictionary.DeepCopy(); 154 base::DictionaryValue* network_properties = dictionary.DeepCopy();
155 // Set the 'ServicePath' property for debugging.
155 network_properties->SetStringWithoutPathExpansion( 156 network_properties->SetStringWithoutPathExpansion(
156 ::onc::network_config::kGUID, service_path); 157 "ServicePath", service_path);
158
157 return_arg_list.Append(network_properties); 159 return_arg_list.Append(network_properties);
158 InvokeCallback(return_arg_list); 160 InvokeCallback(return_arg_list);
159 } 161 }
160 162
161 void NetworkConfigMessageHandler::GetShillProperties( 163 void NetworkConfigMessageHandler::GetShillProperties(
162 const base::ListValue* arg_list) { 164 const base::ListValue* arg_list) {
163 int callback_id = 0; 165 int callback_id = 0;
164 std::string guid; 166 std::string guid;
165 if (!arg_list->GetInteger(0, &callback_id) || 167 if (!arg_list->GetInteger(0, &callback_id) ||
166 !arg_list->GetString(1, &guid)) { 168 !arg_list->GetString(1, &guid)) {
(...skipping 11 matching lines...) Expand all
178 weak_ptr_factory_.GetWeakPtr(), callback_id), 180 weak_ptr_factory_.GetWeakPtr(), callback_id),
179 base::Bind(&NetworkConfigMessageHandler::ErrorCallback, 181 base::Bind(&NetworkConfigMessageHandler::ErrorCallback,
180 weak_ptr_factory_.GetWeakPtr(), callback_id)); 182 weak_ptr_factory_.GetWeakPtr(), callback_id));
181 } 183 }
182 184
183 void NetworkConfigMessageHandler::GetShillPropertiesSuccess( 185 void NetworkConfigMessageHandler::GetShillPropertiesSuccess(
184 int callback_id, 186 int callback_id,
185 const std::string& service_path, 187 const std::string& service_path,
186 const base::DictionaryValue& dictionary) const { 188 const base::DictionaryValue& dictionary) const {
187 scoped_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy()); 189 scoped_ptr<base::DictionaryValue> dictionary_copy(dictionary.DeepCopy());
190 // Set the 'ServicePath' property for debugging.
191 dictionary_copy->SetStringWithoutPathExpansion("ServicePath", service_path);
188 192
189 // Get the device properties for debugging. 193 // Get the device properties for debugging.
190 std::string device; 194 std::string device;
191 dictionary_copy->GetStringWithoutPathExpansion( 195 dictionary_copy->GetStringWithoutPathExpansion(
192 shill::kDeviceProperty, &device); 196 shill::kDeviceProperty, &device);
193 const DeviceState* device_state = 197 const DeviceState* device_state =
194 NetworkHandler::Get()->network_state_handler()->GetDeviceState(device); 198 NetworkHandler::Get()->network_state_handler()->GetDeviceState(device);
195 if (device_state) { 199 if (device_state) {
196 base::DictionaryValue* device_dictionary = 200 base::DictionaryValue* device_dictionary =
197 device_state->properties().DeepCopy(); 201 device_state->properties().DeepCopy();
198 dictionary_copy->Set(shill::kDeviceProperty, device_dictionary); 202 dictionary_copy->Set(shill::kDeviceProperty, device_dictionary);
203
204 // Convert IPConfig dictionary to a ListValue.
205 base::ListValue* ip_configs = new base::ListValue;
206 for (base::DictionaryValue::Iterator iter(device_state->ip_configs());
207 !iter.IsAtEnd(); iter.Advance()) {
208 ip_configs->Append(iter.value().DeepCopy());
209 }
210 device_dictionary->SetWithoutPathExpansion(
211 shill::kIPConfigsProperty, ip_configs);
199 } 212 }
200 GetPropertiesSuccess(callback_id, service_path, *dictionary_copy); 213
214 base::ListValue return_arg_list;
215 return_arg_list.AppendInteger(callback_id);
216 return_arg_list.Append(dictionary_copy.release());
217 InvokeCallback(return_arg_list);
201 } 218 }
202 219
203 void NetworkConfigMessageHandler::InvokeCallback( 220 void NetworkConfigMessageHandler::InvokeCallback(
204 const base::ListValue& arg_list) const { 221 const base::ListValue& arg_list) const {
205 web_ui()->CallJavascriptFunction( 222 web_ui()->CallJavascriptFunction(
206 "networkConfig.chromeCallbackSuccess", arg_list); 223 "networkConfig.chromeCallbackSuccess", arg_list);
207 } 224 }
208 225
209 void NetworkConfigMessageHandler::ErrorCallback( 226 void NetworkConfigMessageHandler::ErrorCallback(
210 int callback_id, 227 int callback_id,
211 const std::string& error_name, 228 const std::string& error_name,
212 scoped_ptr<base::DictionaryValue> error_data) const { 229 scoped_ptr<base::DictionaryValue> error_data) const {
213 LOG(ERROR) << "NetworkConfigMessageHandler Error: " << error_name; 230 LOG(ERROR) << "NetworkConfigMessageHandler Error: " << error_name;
214 base::ListValue arg_list; 231 base::ListValue arg_list;
215 arg_list.AppendInteger(callback_id); 232 arg_list.AppendInteger(callback_id);
216 arg_list.AppendString(error_name); 233 arg_list.AppendString(error_name);
217 web_ui()->CallJavascriptFunction( 234 web_ui()->CallJavascriptFunction(
218 "networkConfig.chromeCallbackError", arg_list); 235 "networkConfig.chromeCallbackError", arg_list);
219 } 236 }
220 237
221 } // namespace chromeos 238 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/onc/onc_signature.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698