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

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

Issue 983823002: Use GUID instead of servicePath in network settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_430115_internet_options_enable_extension_apis
Patch Set: . Created 5 years, 9 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
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 "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 const char kShowCarrierSelectKey[] = "showCarrierSelect"; 64 const char kShowCarrierSelectKey[] = "showCarrierSelect";
65 const char kNetworkDataKey[] = "networkData"; 65 const char kNetworkDataKey[] = "networkData";
66 66
67 // Keys for the network description dictionary passed to the web ui. Make sure 67 // Keys for the network description dictionary passed to the web ui. Make sure
68 // to keep the strings in sync with what the JavaScript side uses. 68 // to keep the strings in sync with what the JavaScript side uses.
69 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; 69 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged";
70 70
71 // Functions we call in JavaScript. 71 // Functions we call in JavaScript.
72 const char kRefreshNetworkDataFunction[] = 72 const char kRefreshNetworkDataFunction[] =
73 "options.network.NetworkList.refreshNetworkData"; 73 "options.network.NetworkList.refreshNetworkData";
74 const char kGetManagedPropertiesResultFunction[] =
75 "options.internet.DetailsInternetPage.getManagedPropertiesResult";
76 const char kUpdateConnectionDataFunction[] = 74 const char kUpdateConnectionDataFunction[] =
77 "options.internet.DetailsInternetPage.updateConnectionData"; 75 "options.internet.DetailsInternetPage.updateConnectionData";
78 const char kUpdateCarrierFunction[] = 76 const char kUpdateCarrierFunction[] =
79 "options.internet.DetailsInternetPage.updateCarrier"; 77 "options.internet.DetailsInternetPage.updateCarrier";
80 78
81 // Setter methods called from JS that still need to be converted to match 79 // Setter methods called from JS that still need to be converted to match
82 // networkingPrivate methods. 80 // networkingPrivate methods.
83 const char kSetCarrierMessage[] = "setCarrier"; 81 const char kSetCarrierMessage[] = "setCarrier";
84 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; 82 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo";
85 const char kSimOperationMessage[] = "simOperation"; 83 const char kSimOperationMessage[] = "simOperation";
86 84
87 // TODO(stevenjb): Replace these with the matching networkingPrivate methods. 85 // TODO(stevenjb): Replace these with the matching networkingPrivate methods.
88 // crbug.com/279351. 86 // crbug.com/279351.
89 const char kGetManagedPropertiesMessage[] = "getManagedProperties";
90 const char kStartConnectMessage[] = "startConnect"; 87 const char kStartConnectMessage[] = "startConnect";
91 const char kSetPropertiesMessage[] = "setProperties";
92 88
93 // TODO(stevenjb): Add these to networkingPrivate. 89 // TODO(stevenjb): Add these to networkingPrivate.
94 const char kRemoveNetworkMessage[] = "removeNetwork"; 90 const char kRemoveNetworkMessage[] = "removeNetwork";
95 91
96 // TODO(stevenjb): Deprecate these and integrate with settings Web UI. 92 // TODO(stevenjb): Deprecate these and integrate with settings Web UI.
97 const char kAddConnectionMessage[] = "addConnection"; 93 const char kAddConnectionMessage[] = "addConnection";
98 const char kConfigureNetworkMessage[] = "configureNetwork"; 94 const char kConfigureNetworkMessage[] = "configureNetwork";
99 const char kActivateNetworkMessage[] = "activateNetwork"; 95 const char kActivateNetworkMessage[] = "activateNetwork";
100 96
101 // These are strings used to communicate with JavaScript. 97 // These are strings used to communicate with JavaScript.
(...skipping 10 matching lines...) Expand all
112 const char kTagSimOpUnlock[] = "unlock"; 108 const char kTagSimOpUnlock[] = "unlock";
113 const char kTagVpnList[] = "vpnList"; 109 const char kTagVpnList[] = "vpnList";
114 const char kTagWifiAvailable[] = "wifiAvailable"; 110 const char kTagWifiAvailable[] = "wifiAvailable";
115 const char kTagWifiEnabled[] = "wifiEnabled"; 111 const char kTagWifiEnabled[] = "wifiEnabled";
116 const char kTagWimaxAvailable[] = "wimaxAvailable"; 112 const char kTagWimaxAvailable[] = "wimaxAvailable";
117 const char kTagWimaxEnabled[] = "wimaxEnabled"; 113 const char kTagWimaxEnabled[] = "wimaxEnabled";
118 const char kTagWiredList[] = "wiredList"; 114 const char kTagWiredList[] = "wiredList";
119 const char kTagWirelessList[] = "wirelessList"; 115 const char kTagWirelessList[] = "wirelessList";
120 116
121 // Pseudo-ONC chrome specific properties appended to the ONC dictionary. 117 // Pseudo-ONC chrome specific properties appended to the ONC dictionary.
122 const char kNetworkInfoKeyServicePath[] = "servicePath";
123 const char kTagErrorMessage[] = "errorMessage";
124 const char kTagShowViewAccountButton[] = "showViewAccountButton"; 118 const char kTagShowViewAccountButton[] = "showViewAccountButton";
125 119
126 void ShillError(const std::string& function, 120 void ShillError(const std::string& function,
127 const std::string& error_name, 121 const std::string& error_name,
128 scoped_ptr<base::DictionaryValue> error_data) { 122 scoped_ptr<base::DictionaryValue> error_data) {
129 // UpdateConnectionData may send requests for stale services; ignore 123 // UpdateConnectionData may send requests for stale services; ignore
130 // these errors. 124 // these errors.
131 if (function == "UpdateConnectionData" && 125 if (function == "UpdateConnectionData" &&
132 error_name == network_handler::kDBusFailedError) 126 error_name == network_handler::kDBusFailedError)
133 return; 127 return;
134 NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name, 128 NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name,
135 function); 129 function);
136 } 130 }
137 131
138 const NetworkState* GetNetworkState(const std::string& service_path) { 132 const NetworkState* GetNetworkState(const std::string& service_path) {
139 return NetworkHandler::Get()->network_state_handler()-> 133 return NetworkHandler::Get()->network_state_handler()->
140 GetNetworkState(service_path); 134 GetNetworkState(service_path);
141 } 135 }
142 136
137 std::string ServicePathFromGuid(const std::string& guid) {
pneubeck (no reviews) 2015/03/12 20:53:58 to consider: should this handle an empty |guid|?
stevenjb 2015/03/13 01:20:14 Do you mean log an error? It will already return a
138 const NetworkState* network =
139 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid(
140 guid);
141 return network ? network->path() : "";
142 }
143
143 // Builds a dictionary with network information for the NetworkList on the 144 // Builds a dictionary with network information for the NetworkList on the
144 // settings page. Ownership of the returned pointer is transferred to the 145 // settings page. Ownership of the returned pointer is transferred to the
145 // caller. TODO(stevenjb): Replace with calls to networkingPrivate.getNetworks. 146 // caller. TODO(stevenjb): Replace with calls to networkingPrivate.getNetworks.
146 base::DictionaryValue* BuildNetworkDictionary( 147 base::DictionaryValue* BuildNetworkDictionary(
147 const NetworkState* network, 148 const NetworkState* network,
148 const PrefService* profile_prefs) { 149 const PrefService* profile_prefs) {
149 scoped_ptr<base::DictionaryValue> network_info = 150 scoped_ptr<base::DictionaryValue> network_info =
150 network_util::TranslateNetworkStateToONC(network); 151 network_util::TranslateNetworkStateToONC(network);
151 152
152 bool has_policy = onc::HasPolicyForNetwork( 153 bool has_policy = onc::HasPolicyForNetwork(
153 profile_prefs, g_browser_process->local_state(), *network); 154 profile_prefs, g_browser_process->local_state(), *network);
154 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy); 155 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy);
155 156
156 network_info->SetString(kNetworkInfoKeyServicePath, network->path());
157
158 return network_info.release(); 157 return network_info.release();
159 } 158 }
160 159
161 bool ShowViewAccountButton(const NetworkState* cellular) { 160 bool ShowViewAccountButton(const NetworkState* cellular) {
162 if (cellular->activation_state() != shill::kActivationStateActivating && 161 if (cellular->activation_state() != shill::kActivationStateActivating &&
163 cellular->activation_state() != shill::kActivationStateActivated) 162 cellular->activation_state() != shill::kActivationStateActivated)
164 return false; 163 return false;
165 164
166 const DeviceState* device = 165 const DeviceState* device =
167 NetworkHandler::Get()->network_state_handler()->GetDeviceState( 166 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback, 256 base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback,
258 base::Unretained(this))); 257 base::Unretained(this)));
259 web_ui()->RegisterMessageCallback(kSetCarrierMessage, 258 web_ui()->RegisterMessageCallback(kSetCarrierMessage,
260 base::Bind(&InternetOptionsHandler::SetCarrierCallback, 259 base::Bind(&InternetOptionsHandler::SetCarrierCallback,
261 base::Unretained(this))); 260 base::Unretained(this)));
262 web_ui()->RegisterMessageCallback(kSimOperationMessage, 261 web_ui()->RegisterMessageCallback(kSimOperationMessage,
263 base::Bind(&InternetOptionsHandler::SimOperationCallback, 262 base::Bind(&InternetOptionsHandler::SimOperationCallback,
264 base::Unretained(this))); 263 base::Unretained(this)));
265 264
266 // networkingPrivate methods 265 // networkingPrivate methods
267 web_ui()->RegisterMessageCallback(kGetManagedPropertiesMessage,
268 base::Bind(&InternetOptionsHandler::GetManagedPropertiesCallback,
269 base::Unretained(this)));
270 web_ui()->RegisterMessageCallback(kStartConnectMessage, 266 web_ui()->RegisterMessageCallback(kStartConnectMessage,
271 base::Bind(&InternetOptionsHandler::StartConnectCallback, 267 base::Bind(&InternetOptionsHandler::StartConnectCallback,
272 base::Unretained(this))); 268 base::Unretained(this)));
273 web_ui()->RegisterMessageCallback(kSetPropertiesMessage,
274 base::Bind(&InternetOptionsHandler::SetPropertiesCallback,
275 base::Unretained(this)));
276 } 269 }
277 270
278 void InternetOptionsHandler::ShowMorePlanInfoCallback( 271 void InternetOptionsHandler::ShowMorePlanInfoCallback(
279 const base::ListValue* args) { 272 const base::ListValue* args) {
280 if (!web_ui()) 273 if (!web_ui())
281 return; 274 return;
282 std::string service_path; 275 std::string guid;
283 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 276 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
284 NOTREACHED(); 277 NOTREACHED();
285 return; 278 return;
286 } 279 }
287 ui::NetworkConnect::Get()->ShowMobileSetup(service_path); 280 std::string service_path = ServicePathFromGuid(guid);
281 if (!service_path.empty())
282 ui::NetworkConnect::Get()->ShowMobileSetup(service_path);
288 } 283 }
289 284
290 void InternetOptionsHandler::CarrierStatusCallback() { 285 void InternetOptionsHandler::CarrierStatusCallback() {
291 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 286 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
292 const DeviceState* device = 287 const DeviceState* device =
293 handler->GetDeviceStateByType(NetworkTypePattern::Cellular()); 288 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
294 if (device && (device->carrier() == shill::kCarrierSprint)) { 289 if (device && (device->carrier() == shill::kCarrierSprint)) {
295 const NetworkState* network = 290 const NetworkState* network =
296 handler->FirstNetworkByType(NetworkTypePattern::Cellular()); 291 handler->FirstNetworkByType(NetworkTypePattern::Cellular());
297 if (network && network->path() == details_path_) { 292 if (network) {
298 ui::NetworkConnect::Get()->ActivateCellular(network->path()); 293 ui::NetworkConnect::Get()->ActivateCellular(network->path());
299 UpdateConnectionData(network->path()); 294 UpdateConnectionData(network->path());
300 } 295 }
301 } 296 }
302 UpdateCarrier(); 297 UpdateCarrier();
303 } 298 }
304 299
305 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 300 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
306 std::string service_path;
307 std::string carrier; 301 std::string carrier;
308 if (args->GetSize() != 2 || 302 if (args->GetSize() != 1 || !args->GetString(1, &carrier)) {
309 !args->GetString(0, &service_path) ||
310 !args->GetString(1, &carrier)) {
311 NOTREACHED(); 303 NOTREACHED();
312 return; 304 return;
313 } 305 }
314 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 306 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
315 GetDeviceStateByType(NetworkTypePattern::Cellular()); 307 GetDeviceStateByType(NetworkTypePattern::Cellular());
316 if (!device) { 308 if (!device) {
317 LOG(WARNING) << "SetCarrierCallback with no cellular device."; 309 LOG(WARNING) << "SetCarrierCallback with no cellular device.";
318 return; 310 return;
319 } 311 }
320 NetworkHandler::Get()->network_device_handler()->SetCarrier( 312 NetworkHandler::Get()->network_device_handler()->SetCarrier(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return; 347 return;
356 } 348 }
357 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); 349 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode);
358 } 350 }
359 351
360 //////////////////////////////////////////////////////////////////////////////// 352 ////////////////////////////////////////////////////////////////////////////////
361 // networkingPrivate implementation methods. TODO(stevenjb): Use the 353 // networkingPrivate implementation methods. TODO(stevenjb): Use the
362 // networkingPrivate API directly in the settings JS and deprecate these 354 // networkingPrivate API directly in the settings JS and deprecate these
363 // methods. crbug.com/279351. 355 // methods. crbug.com/279351.
364 356
365 void InternetOptionsHandler::GetManagedPropertiesCallback( 357 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) {
366 const base::ListValue* args) { 358 std::string guid;
367 std::string service_path; 359 if (!args->GetString(0, &guid)) {
368 if (!args->GetString(0, &service_path)) {
369 NOTREACHED(); 360 NOTREACHED();
370 return; 361 return;
371 } 362 }
372 // This is only ever called to provide properties for the details page, so 363 std::string service_path = ServicePathFromGuid(guid);
373 // set |details_path_| (used by the NetworkState observers) here. 364 if (!service_path.empty())
374 details_path_ = service_path; 365 ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
375 NetworkHandler::Get()
376 ->managed_network_configuration_handler()
377 ->GetManagedProperties(
378 LoginState::Get()->primary_user_hash(), service_path,
379 base::Bind(&InternetOptionsHandler::GetManagedPropertiesResult,
380 weak_factory_.GetWeakPtr(),
381 kGetManagedPropertiesResultFunction),
382 base::Bind(&ShillError, "GetManagedProperties"));
383 }
384
385 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) {
386 std::string service_path;
387 if (!args->GetString(0, &service_path)) {
388 NOTREACHED();
389 return;
390 }
391 ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
392 } 366 }
393 367
394 //////////////////////////////////////////////////////////////////////////////// 368 ////////////////////////////////////////////////////////////////////////////////
395 369
396 void InternetOptionsHandler::RefreshNetworkData() { 370 void InternetOptionsHandler::RefreshNetworkData() {
397 base::DictionaryValue dictionary; 371 base::DictionaryValue dictionary;
398 FillNetworkInfo(&dictionary); 372 FillNetworkInfo(&dictionary);
399 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary); 373 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary);
400 } 374 }
401 375
402 void InternetOptionsHandler::UpdateConnectionData( 376 void InternetOptionsHandler::UpdateConnectionData(
403 const std::string& service_path) { 377 const std::string& service_path) {
404 NetworkHandler::Get() 378 NetworkHandler::Get()
405 ->managed_network_configuration_handler() 379 ->managed_network_configuration_handler()
406 ->GetManagedProperties( 380 ->GetManagedProperties(
407 LoginState::Get()->primary_user_hash(), service_path, 381 LoginState::Get()->primary_user_hash(), service_path,
408 base::Bind(&InternetOptionsHandler::GetManagedPropertiesResult, 382 base::Bind(&InternetOptionsHandler::GetManagedPropertiesResult,
409 weak_factory_.GetWeakPtr(), kUpdateConnectionDataFunction), 383 weak_factory_.GetWeakPtr(), kUpdateConnectionDataFunction),
410 base::Bind(&ShillError, "UpdateConnectionData")); 384 base::Bind(&ShillError, "UpdateConnectionData"));
411 } 385 }
412 386
413 void InternetOptionsHandler::GetManagedPropertiesResult( 387 void InternetOptionsHandler::GetManagedPropertiesResult(
414 const std::string& js_callback_function, 388 const std::string& js_callback_function,
415 const std::string& service_path, 389 const std::string& service_path,
416 const base::DictionaryValue& onc_properties) { 390 const base::DictionaryValue& onc_properties) {
417 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy()); 391 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy());
418 // Add service path for now.
419 dictionary->SetString(kNetworkInfoKeyServicePath, service_path);
420
421 const NetworkState* network = GetNetworkState(service_path); 392 const NetworkState* network = GetNetworkState(service_path);
422 if (network) { 393 if (network) {
423 // Add a Chrome specific translated error message. TODO(stevenjb): Figure
424 // out a more robust way to track errors. Service.Error is transient so we
425 // use NetworkState.error() which accurately tracks the "last" error.
426 dictionary->SetString(kTagErrorMessage,
427 ui::NetworkConnect::Get()->GetShillErrorString(
428 network->error(), service_path));
429 // Add additional non-ONC cellular properties to inform the UI. 394 // Add additional non-ONC cellular properties to inform the UI.
430 if (network->type() == shill::kTypeCellular) { 395 if (network->type() == shill::kTypeCellular) {
431 dictionary->SetBoolean(kTagShowViewAccountButton, 396 dictionary->SetBoolean(kTagShowViewAccountButton,
432 ShowViewAccountButton(network)); 397 ShowViewAccountButton(network));
433 } 398 }
434 } 399 }
435 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary); 400 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary);
436 } 401 }
437 402
438 void InternetOptionsHandler::UpdateCarrier() { 403 void InternetOptionsHandler::UpdateCarrier() {
439 web_ui()->CallJavascriptFunction(kUpdateCarrierFunction); 404 web_ui()->CallJavascriptFunction(kUpdateCarrierFunction);
440 } 405 }
441 406
442 void InternetOptionsHandler::DeviceListChanged() { 407 void InternetOptionsHandler::DeviceListChanged() {
443 if (!web_ui()) 408 if (!web_ui())
444 return; 409 return;
445 RefreshNetworkData(); 410 RefreshNetworkData();
446 } 411 }
447 412
448 void InternetOptionsHandler::NetworkListChanged() { 413 void InternetOptionsHandler::NetworkListChanged() {
449 if (!web_ui()) 414 if (!web_ui())
450 return; 415 return;
451 RefreshNetworkData(); 416 RefreshNetworkData();
452 } 417 }
453 418
454 void InternetOptionsHandler::NetworkConnectionStateChanged( 419 void InternetOptionsHandler::NetworkConnectionStateChanged(
455 const NetworkState* network) { 420 const NetworkState* network) {
456 if (!web_ui()) 421 if (!web_ui())
457 return; 422 return;
pneubeck (no reviews) 2015/03/12 20:53:58 is that such a good idea to send all network prope
stevenjb 2015/03/13 01:20:14 The JS already ignores updates to other networks.
pneubeck (no reviews) 2015/03/13 09:54:20 That's not what the API currently exposes. All eve
stevenjb 2015/03/13 17:01:14 Sure, that's fair, this will send more data than j
458 if (network->path() == details_path_) 423 UpdateConnectionData(network->path());
459 UpdateConnectionData(network->path());
460 } 424 }
461 425
462 void InternetOptionsHandler::NetworkPropertiesUpdated( 426 void InternetOptionsHandler::NetworkPropertiesUpdated(
pneubeck (no reviews) 2015/03/12 20:53:58 this is triggered for every signalStrength change
stevenjb 2015/03/13 01:20:14 Still infrequent as these things go. Previously we
pneubeck (no reviews) 2015/03/13 09:54:20 fair enough.
463 const NetworkState* network) { 427 const NetworkState* network) {
464 if (!web_ui()) 428 if (!web_ui())
465 return; 429 return;
466 RefreshNetworkData(); 430 RefreshNetworkData();
467 if (network->path() == details_path_) 431 UpdateConnectionData(network->path());
468 UpdateConnectionData(network->path());
469 } 432 }
470 433
471 void InternetOptionsHandler::DevicePropertiesUpdated( 434 void InternetOptionsHandler::DevicePropertiesUpdated(
472 const DeviceState* device) { 435 const DeviceState* device) {
473 if (!web_ui()) 436 if (!web_ui())
474 return; 437 return;
475 if (device->type() != shill::kTypeCellular) 438 if (device->type() != shill::kTypeCellular)
476 return; 439 return;
477 const NetworkState* network = 440 const NetworkState* network =
478 NetworkHandler::Get()->network_state_handler()->FirstNetworkByType( 441 NetworkHandler::Get()->network_state_handler()->FirstNetworkByType(
479 NetworkTypePattern::Cellular()); 442 NetworkTypePattern::Cellular());
480 if (network && network->path() == details_path_) 443 UpdateConnectionData(network->path());
481 UpdateConnectionData(network->path());
482 }
483
484 void InternetOptionsHandler::SetPropertiesCallback(
485 const base::ListValue* args) {
486 std::string service_path;
487 const base::DictionaryValue* properties;
488 if (args->GetSize() < 2 ||
489 !args->GetString(0, &service_path) ||
490 !args->GetDictionary(1, &properties)) {
491 NOTREACHED();
492 return;
493 }
494 NetworkHandler::Get()->managed_network_configuration_handler()->SetProperties(
495 service_path, *properties,
496 base::Bind(&base::DoNothing),
497 base::Bind(&ShillError, "SetProperties"));
498 } 444 }
499 445
500 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 446 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
501 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 447 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
502 } 448 }
503 449
504 const PrefService* InternetOptionsHandler::GetPrefs() const { 450 const PrefService* InternetOptionsHandler::GetPrefs() const {
505 return Profile::FromWebUI(web_ui())->GetPrefs(); 451 return Profile::FromWebUI(web_ui())->GetPrefs();
506 } 452 }
507 453
508 void InternetOptionsHandler::AddConnection(const base::ListValue* args) { 454 void InternetOptionsHandler::AddConnection(const base::ListValue* args) {
509 std::string onc_type; 455 std::string onc_type;
510 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { 456 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) {
511 NOTREACHED(); 457 NOTREACHED();
512 return; 458 return;
513 } 459 }
514 if (onc_type == ::onc::network_type::kWiFi) { 460 if (onc_type == ::onc::network_type::kWiFi) {
515 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); 461 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow());
516 } else if (onc_type == ::onc::network_type::kVPN) { 462 } else if (onc_type == ::onc::network_type::kVPN) {
517 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); 463 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow());
518 } else if (onc_type == ::onc::network_type::kCellular) { 464 } else if (onc_type == ::onc::network_type::kCellular) {
519 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 465 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
520 } else { 466 } else {
521 LOG(ERROR) << "Unsupported type for AddConnection"; 467 LOG(ERROR) << "Unsupported type for AddConnection";
522 } 468 }
523 } 469 }
524 470
525 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { 471 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) {
526 std::string service_path; 472 std::string guid;
527 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 473 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
528 NOTREACHED(); 474 NOTREACHED();
529 return; 475 return;
530 } 476 }
531 NetworkConfigView::Show(service_path, GetNativeWindow()); 477 std::string service_path = ServicePathFromGuid(guid);
478 if (!service_path.empty())
479 NetworkConfigView::Show(service_path, GetNativeWindow());
532 } 480 }
533 481
534 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) { 482 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) {
535 std::string service_path; 483 std::string guid;
536 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 484 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
537 NOTREACHED(); 485 NOTREACHED();
538 return; 486 return;
539 } 487 }
540 ui::NetworkConnect::Get()->ActivateCellular(service_path); 488 std::string service_path = ServicePathFromGuid(guid);
489 if (!service_path.empty())
490 ui::NetworkConnect::Get()->ActivateCellular(service_path);
541 } 491 }
542 492
543 void InternetOptionsHandler::RemoveNetwork(const base::ListValue* args) { 493 void InternetOptionsHandler::RemoveNetwork(const base::ListValue* args) {
544 std::string service_path; 494 std::string guid;
545 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 495 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
546 NOTREACHED(); 496 NOTREACHED();
547 return; 497 return;
548 } 498 }
499 std::string service_path = ServicePathFromGuid(guid);
500 if (service_path.empty())
501 return;
549 NetworkHandler::Get() 502 NetworkHandler::Get()
550 ->managed_network_configuration_handler() 503 ->managed_network_configuration_handler()
551 ->RemoveConfiguration(service_path, base::Bind(&base::DoNothing), 504 ->RemoveConfiguration(service_path, base::Bind(&base::DoNothing),
552 base::Bind(&ShillError, "RemoveNetwork")); 505 base::Bind(&ShillError, "RemoveNetwork"));
553 } 506 }
554 507
555 base::ListValue* InternetOptionsHandler::GetWiredList() { 508 base::ListValue* InternetOptionsHandler::GetWiredList() {
556 base::ListValue* list = new base::ListValue(); 509 base::ListValue* list = new base::ListValue();
557 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 510 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
558 FirstNetworkByType(NetworkTypePattern::Ethernet()); 511 FirstNetworkByType(NetworkTypePattern::Ethernet());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 dictionary->SetBoolean( 599 dictionary->SetBoolean(
647 kTagWimaxAvailable, 600 kTagWimaxAvailable,
648 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 601 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
649 dictionary->SetBoolean( 602 dictionary->SetBoolean(
650 kTagWimaxEnabled, 603 kTagWimaxEnabled,
651 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 604 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
652 } 605 }
653 606
654 } // namespace options 607 } // namespace options
655 } // namespace chromeos 608 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698