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

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: Use guid instead of service_path for proxy prefs 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"; 88
89 // TODO(stevenjb): Deprecate this once we handle events in the JS.
90 const char kSetNetworkGuidMessage[] = "setNetworkGuid";
92 91
93 // TODO(stevenjb): Add these to networkingPrivate. 92 // TODO(stevenjb): Add these to networkingPrivate.
94 const char kRemoveNetworkMessage[] = "removeNetwork"; 93 const char kRemoveNetworkMessage[] = "removeNetwork";
95 94
96 // TODO(stevenjb): Deprecate these and integrate with settings Web UI. 95 // TODO(stevenjb): Deprecate these and integrate with settings Web UI.
97 const char kAddConnectionMessage[] = "addConnection"; 96 const char kAddConnectionMessage[] = "addConnection";
98 const char kConfigureNetworkMessage[] = "configureNetwork"; 97 const char kConfigureNetworkMessage[] = "configureNetwork";
99 const char kActivateNetworkMessage[] = "activateNetwork"; 98 const char kActivateNetworkMessage[] = "activateNetwork";
100 99
101 // These are strings used to communicate with JavaScript. 100 // These are strings used to communicate with JavaScript.
(...skipping 10 matching lines...) Expand all
112 const char kTagSimOpUnlock[] = "unlock"; 111 const char kTagSimOpUnlock[] = "unlock";
113 const char kTagVpnList[] = "vpnList"; 112 const char kTagVpnList[] = "vpnList";
114 const char kTagWifiAvailable[] = "wifiAvailable"; 113 const char kTagWifiAvailable[] = "wifiAvailable";
115 const char kTagWifiEnabled[] = "wifiEnabled"; 114 const char kTagWifiEnabled[] = "wifiEnabled";
116 const char kTagWimaxAvailable[] = "wimaxAvailable"; 115 const char kTagWimaxAvailable[] = "wimaxAvailable";
117 const char kTagWimaxEnabled[] = "wimaxEnabled"; 116 const char kTagWimaxEnabled[] = "wimaxEnabled";
118 const char kTagWiredList[] = "wiredList"; 117 const char kTagWiredList[] = "wiredList";
119 const char kTagWirelessList[] = "wirelessList"; 118 const char kTagWirelessList[] = "wirelessList";
120 119
121 // Pseudo-ONC chrome specific properties appended to the ONC dictionary. 120 // 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"; 121 const char kTagShowViewAccountButton[] = "showViewAccountButton";
125 122
126 void ShillError(const std::string& function, 123 void ShillError(const std::string& function,
127 const std::string& error_name, 124 const std::string& error_name,
128 scoped_ptr<base::DictionaryValue> error_data) { 125 scoped_ptr<base::DictionaryValue> error_data) {
129 // UpdateConnectionData may send requests for stale services; ignore 126 // UpdateConnectionData may send requests for stale services; ignore
130 // these errors. 127 // these errors.
131 if (function == "UpdateConnectionData" && 128 if (function == "UpdateConnectionData" &&
132 error_name == network_handler::kDBusFailedError) 129 error_name == network_handler::kDBusFailedError)
133 return; 130 return;
134 NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name, 131 NET_LOG_ERROR("Shill Error from InternetOptionsHandler: " + error_name,
135 function); 132 function);
136 } 133 }
137 134
138 const NetworkState* GetNetworkState(const std::string& service_path) { 135 const NetworkState* GetNetworkState(const std::string& service_path) {
139 return NetworkHandler::Get()->network_state_handler()-> 136 return NetworkHandler::Get()->network_state_handler()->
140 GetNetworkState(service_path); 137 GetNetworkState(service_path);
141 } 138 }
142 139
140 std::string ServicePathFromGuid(const std::string& guid) {
141 const NetworkState* network =
142 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid(
143 guid);
144 return network ? network->path() : "";
145 }
146
143 // Builds a dictionary with network information for the NetworkList on the 147 // Builds a dictionary with network information for the NetworkList on the
144 // settings page. Ownership of the returned pointer is transferred to the 148 // settings page. Ownership of the returned pointer is transferred to the
145 // caller. TODO(stevenjb): Replace with calls to networkingPrivate.getNetworks. 149 // caller. TODO(stevenjb): Replace with calls to networkingPrivate.getNetworks.
146 base::DictionaryValue* BuildNetworkDictionary( 150 base::DictionaryValue* BuildNetworkDictionary(
147 const NetworkState* network, 151 const NetworkState* network,
148 const PrefService* profile_prefs) { 152 const PrefService* profile_prefs) {
149 scoped_ptr<base::DictionaryValue> network_info = 153 scoped_ptr<base::DictionaryValue> network_info =
150 network_util::TranslateNetworkStateToONC(network); 154 network_util::TranslateNetworkStateToONC(network);
151 155
152 bool has_policy = onc::HasPolicyForNetwork( 156 bool has_policy = onc::HasPolicyForNetwork(
153 profile_prefs, g_browser_process->local_state(), *network); 157 profile_prefs, g_browser_process->local_state(), *network);
154 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy); 158 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, has_policy);
155 159
156 network_info->SetString(kNetworkInfoKeyServicePath, network->path());
157
158 return network_info.release(); 160 return network_info.release();
159 } 161 }
160 162
161 bool ShowViewAccountButton(const NetworkState* cellular) { 163 bool ShowViewAccountButton(const NetworkState* cellular) {
162 if (cellular->activation_state() != shill::kActivationStateActivating && 164 if (cellular->activation_state() != shill::kActivationStateActivating &&
163 cellular->activation_state() != shill::kActivationStateActivated) 165 cellular->activation_state() != shill::kActivationStateActivated)
164 return false; 166 return false;
165 167
166 const DeviceState* device = 168 const DeviceState* device =
167 NetworkHandler::Get()->network_state_handler()->GetDeviceState( 169 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 web_ui()->RegisterMessageCallback(kShowMorePlanInfoMessage, 258 web_ui()->RegisterMessageCallback(kShowMorePlanInfoMessage,
257 base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback, 259 base::Bind(&InternetOptionsHandler::ShowMorePlanInfoCallback,
258 base::Unretained(this))); 260 base::Unretained(this)));
259 web_ui()->RegisterMessageCallback(kSetCarrierMessage, 261 web_ui()->RegisterMessageCallback(kSetCarrierMessage,
260 base::Bind(&InternetOptionsHandler::SetCarrierCallback, 262 base::Bind(&InternetOptionsHandler::SetCarrierCallback,
261 base::Unretained(this))); 263 base::Unretained(this)));
262 web_ui()->RegisterMessageCallback(kSimOperationMessage, 264 web_ui()->RegisterMessageCallback(kSimOperationMessage,
263 base::Bind(&InternetOptionsHandler::SimOperationCallback, 265 base::Bind(&InternetOptionsHandler::SimOperationCallback,
264 base::Unretained(this))); 266 base::Unretained(this)));
265 267
268 web_ui()->RegisterMessageCallback(kSetNetworkGuidMessage,
269 base::Bind(&InternetOptionsHandler::SetNetworkGuidCallback,
270 base::Unretained(this)));
271
266 // networkingPrivate methods 272 // networkingPrivate methods
267 web_ui()->RegisterMessageCallback(kGetManagedPropertiesMessage,
268 base::Bind(&InternetOptionsHandler::GetManagedPropertiesCallback,
269 base::Unretained(this)));
270 web_ui()->RegisterMessageCallback(kStartConnectMessage, 273 web_ui()->RegisterMessageCallback(kStartConnectMessage,
271 base::Bind(&InternetOptionsHandler::StartConnectCallback, 274 base::Bind(&InternetOptionsHandler::StartConnectCallback,
272 base::Unretained(this))); 275 base::Unretained(this)));
273 web_ui()->RegisterMessageCallback(kSetPropertiesMessage,
274 base::Bind(&InternetOptionsHandler::SetPropertiesCallback,
275 base::Unretained(this)));
276 } 276 }
277 277
278 void InternetOptionsHandler::ShowMorePlanInfoCallback( 278 void InternetOptionsHandler::ShowMorePlanInfoCallback(
279 const base::ListValue* args) { 279 const base::ListValue* args) {
280 if (!web_ui()) 280 if (!web_ui())
281 return; 281 return;
282 std::string service_path; 282 std::string guid;
283 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 283 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
284 NOTREACHED(); 284 NOTREACHED();
285 return; 285 return;
286 } 286 }
287 ui::NetworkConnect::Get()->ShowMobileSetup(service_path); 287 std::string service_path = ServicePathFromGuid(guid);
288 if (!service_path.empty())
289 ui::NetworkConnect::Get()->ShowMobileSetup(service_path);
288 } 290 }
289 291
290 void InternetOptionsHandler::CarrierStatusCallback() { 292 void InternetOptionsHandler::CarrierStatusCallback() {
291 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 293 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
292 const DeviceState* device = 294 const DeviceState* device =
293 handler->GetDeviceStateByType(NetworkTypePattern::Cellular()); 295 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
294 if (device && (device->carrier() == shill::kCarrierSprint)) { 296 if (device && (device->carrier() == shill::kCarrierSprint)) {
295 const NetworkState* network = 297 const NetworkState* network =
296 handler->FirstNetworkByType(NetworkTypePattern::Cellular()); 298 handler->FirstNetworkByType(NetworkTypePattern::Cellular());
297 if (network && network->path() == details_path_) { 299 if (network && network->guid() == details_guid_) {
298 ui::NetworkConnect::Get()->ActivateCellular(network->path()); 300 ui::NetworkConnect::Get()->ActivateCellular(network->path());
299 UpdateConnectionData(network->path()); 301 UpdateConnectionData(network->path());
300 } 302 }
301 } 303 }
302 UpdateCarrier(); 304 UpdateCarrier();
303 } 305 }
304 306
305 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 307 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
306 std::string service_path;
307 std::string carrier; 308 std::string carrier;
308 if (args->GetSize() != 2 || 309 if (args->GetSize() != 1 || !args->GetString(1, &carrier)) {
309 !args->GetString(0, &service_path) ||
310 !args->GetString(1, &carrier)) {
311 NOTREACHED(); 310 NOTREACHED();
312 return; 311 return;
313 } 312 }
314 const DeviceState* device = NetworkHandler::Get()->network_state_handler()-> 313 const DeviceState* device = NetworkHandler::Get()->network_state_handler()->
315 GetDeviceStateByType(NetworkTypePattern::Cellular()); 314 GetDeviceStateByType(NetworkTypePattern::Cellular());
316 if (!device) { 315 if (!device) {
317 LOG(WARNING) << "SetCarrierCallback with no cellular device."; 316 LOG(WARNING) << "SetCarrierCallback with no cellular device.";
318 return; 317 return;
319 } 318 }
320 NetworkHandler::Get()->network_device_handler()->SetCarrier( 319 NetworkHandler::Get()->network_device_handler()->SetCarrier(
(...skipping 30 matching lines...) Expand all
351 } else if (operation == kTagSimOpChangePin) { 350 } else if (operation == kTagSimOpChangePin) {
352 mode = SimDialogDelegate::SIM_DIALOG_CHANGE_PIN; 351 mode = SimDialogDelegate::SIM_DIALOG_CHANGE_PIN;
353 } else { 352 } else {
354 NOTREACHED(); 353 NOTREACHED();
355 return; 354 return;
356 } 355 }
357 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); 356 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode);
358 } 357 }
359 358
360 //////////////////////////////////////////////////////////////////////////////// 359 ////////////////////////////////////////////////////////////////////////////////
360 // TODO(stevenjb): Deprecate this once events are handled in the JS.
361
362 void InternetOptionsHandler::SetNetworkGuidCallback(
363 const base::ListValue* args) {
364 std::string guid;
365 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
366 NOTREACHED();
367 return;
368 }
369 details_guid_ = guid;
370 }
371
372
373 ////////////////////////////////////////////////////////////////////////////////
361 // networkingPrivate implementation methods. TODO(stevenjb): Use the 374 // networkingPrivate implementation methods. TODO(stevenjb): Use the
362 // networkingPrivate API directly in the settings JS and deprecate these 375 // networkingPrivate API directly in the settings JS and deprecate these
363 // methods. crbug.com/279351. 376 // methods. crbug.com/279351.
364 377
365 void InternetOptionsHandler::GetManagedPropertiesCallback( 378 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) {
366 const base::ListValue* args) { 379 std::string guid;
367 std::string service_path; 380 if (!args->GetString(0, &guid)) {
368 if (!args->GetString(0, &service_path)) {
369 NOTREACHED(); 381 NOTREACHED();
370 return; 382 return;
371 } 383 }
372 // This is only ever called to provide properties for the details page, so 384 std::string service_path = ServicePathFromGuid(guid);
373 // set |details_path_| (used by the NetworkState observers) here. 385 if (!service_path.empty())
374 details_path_ = service_path; 386 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 } 387 }
393 388
394 //////////////////////////////////////////////////////////////////////////////// 389 ////////////////////////////////////////////////////////////////////////////////
395 390
396 void InternetOptionsHandler::RefreshNetworkData() { 391 void InternetOptionsHandler::RefreshNetworkData() {
397 base::DictionaryValue dictionary; 392 base::DictionaryValue dictionary;
398 FillNetworkInfo(&dictionary); 393 FillNetworkInfo(&dictionary);
399 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary); 394 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary);
400 } 395 }
401 396
402 void InternetOptionsHandler::UpdateConnectionData( 397 void InternetOptionsHandler::UpdateConnectionData(
403 const std::string& service_path) { 398 const std::string& service_path) {
404 NetworkHandler::Get() 399 NetworkHandler::Get()
405 ->managed_network_configuration_handler() 400 ->managed_network_configuration_handler()
406 ->GetManagedProperties( 401 ->GetManagedProperties(
407 LoginState::Get()->primary_user_hash(), service_path, 402 LoginState::Get()->primary_user_hash(), service_path,
408 base::Bind(&InternetOptionsHandler::GetManagedPropertiesResult, 403 base::Bind(&InternetOptionsHandler::GetManagedPropertiesResult,
409 weak_factory_.GetWeakPtr(), kUpdateConnectionDataFunction), 404 weak_factory_.GetWeakPtr(), kUpdateConnectionDataFunction),
410 base::Bind(&ShillError, "UpdateConnectionData")); 405 base::Bind(&ShillError, "UpdateConnectionData"));
411 } 406 }
412 407
413 void InternetOptionsHandler::GetManagedPropertiesResult( 408 void InternetOptionsHandler::GetManagedPropertiesResult(
414 const std::string& js_callback_function, 409 const std::string& js_callback_function,
415 const std::string& service_path, 410 const std::string& service_path,
416 const base::DictionaryValue& onc_properties) { 411 const base::DictionaryValue& onc_properties) {
417 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy()); 412 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); 413 const NetworkState* network = GetNetworkState(service_path);
422 if (network) { 414 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. 415 // Add additional non-ONC cellular properties to inform the UI.
430 if (network->type() == shill::kTypeCellular) { 416 if (network->type() == shill::kTypeCellular) {
431 dictionary->SetBoolean(kTagShowViewAccountButton, 417 dictionary->SetBoolean(kTagShowViewAccountButton,
432 ShowViewAccountButton(network)); 418 ShowViewAccountButton(network));
433 } 419 }
434 } 420 }
435 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary); 421 web_ui()->CallJavascriptFunction(js_callback_function, *dictionary);
436 } 422 }
437 423
438 void InternetOptionsHandler::UpdateCarrier() { 424 void InternetOptionsHandler::UpdateCarrier() {
439 web_ui()->CallJavascriptFunction(kUpdateCarrierFunction); 425 web_ui()->CallJavascriptFunction(kUpdateCarrierFunction);
440 } 426 }
441 427
442 void InternetOptionsHandler::DeviceListChanged() { 428 void InternetOptionsHandler::DeviceListChanged() {
443 if (!web_ui()) 429 if (!web_ui())
444 return; 430 return;
445 RefreshNetworkData(); 431 RefreshNetworkData();
446 } 432 }
447 433
448 void InternetOptionsHandler::NetworkListChanged() { 434 void InternetOptionsHandler::NetworkListChanged() {
449 if (!web_ui()) 435 if (!web_ui())
450 return; 436 return;
451 RefreshNetworkData(); 437 RefreshNetworkData();
452 } 438 }
453 439
454 void InternetOptionsHandler::NetworkConnectionStateChanged( 440 void InternetOptionsHandler::NetworkConnectionStateChanged(
455 const NetworkState* network) { 441 const NetworkState* network) {
456 if (!web_ui()) 442 if (!web_ui())
457 return; 443 return;
458 if (network->path() == details_path_) 444 if (network->guid() == details_guid_)
459 UpdateConnectionData(network->path()); 445 UpdateConnectionData(network->path());
460 } 446 }
461 447
462 void InternetOptionsHandler::NetworkPropertiesUpdated( 448 void InternetOptionsHandler::NetworkPropertiesUpdated(
463 const NetworkState* network) { 449 const NetworkState* network) {
464 if (!web_ui()) 450 if (!web_ui())
465 return; 451 return;
466 RefreshNetworkData(); 452 RefreshNetworkData();
467 if (network->path() == details_path_) 453 if (network->guid() == details_guid_)
468 UpdateConnectionData(network->path()); 454 UpdateConnectionData(network->path());
469 } 455 }
470 456
471 void InternetOptionsHandler::DevicePropertiesUpdated( 457 void InternetOptionsHandler::DevicePropertiesUpdated(
472 const DeviceState* device) { 458 const DeviceState* device) {
473 if (!web_ui()) 459 if (!web_ui())
474 return; 460 return;
475 if (device->type() != shill::kTypeCellular) 461 if (device->type() != shill::kTypeCellular)
476 return; 462 return;
477 const NetworkState* network = 463 const NetworkState* network =
478 NetworkHandler::Get()->network_state_handler()->FirstNetworkByType( 464 NetworkHandler::Get()->network_state_handler()->FirstNetworkByType(
479 NetworkTypePattern::Cellular()); 465 NetworkTypePattern::Cellular());
480 if (network && network->path() == details_path_) 466 if (network && network->path() == details_guid_)
481 UpdateConnectionData(network->path()); 467 UpdateConnectionData(network->path());
482 } 468 }
483 469
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 }
499
500 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 470 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
501 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 471 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
502 } 472 }
503 473
504 const PrefService* InternetOptionsHandler::GetPrefs() const { 474 const PrefService* InternetOptionsHandler::GetPrefs() const {
505 return Profile::FromWebUI(web_ui())->GetPrefs(); 475 return Profile::FromWebUI(web_ui())->GetPrefs();
506 } 476 }
507 477
508 void InternetOptionsHandler::AddConnection(const base::ListValue* args) { 478 void InternetOptionsHandler::AddConnection(const base::ListValue* args) {
509 std::string onc_type; 479 std::string onc_type;
510 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { 480 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) {
511 NOTREACHED(); 481 NOTREACHED();
512 return; 482 return;
513 } 483 }
514 if (onc_type == ::onc::network_type::kWiFi) { 484 if (onc_type == ::onc::network_type::kWiFi) {
515 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); 485 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow());
516 } else if (onc_type == ::onc::network_type::kVPN) { 486 } else if (onc_type == ::onc::network_type::kVPN) {
517 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); 487 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow());
518 } else if (onc_type == ::onc::network_type::kCellular) { 488 } else if (onc_type == ::onc::network_type::kCellular) {
519 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 489 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
520 } else { 490 } else {
521 LOG(ERROR) << "Unsupported type for AddConnection"; 491 LOG(ERROR) << "Unsupported type for AddConnection";
522 } 492 }
523 } 493 }
524 494
525 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { 495 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) {
526 std::string service_path; 496 std::string guid;
527 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 497 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
528 NOTREACHED(); 498 NOTREACHED();
529 return; 499 return;
530 } 500 }
531 NetworkConfigView::Show(service_path, GetNativeWindow()); 501 std::string service_path = ServicePathFromGuid(guid);
502 if (!service_path.empty())
503 NetworkConfigView::Show(service_path, GetNativeWindow());
532 } 504 }
533 505
534 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) { 506 void InternetOptionsHandler::ActivateNetwork(const base::ListValue* args) {
535 std::string service_path; 507 std::string guid;
536 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 508 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
537 NOTREACHED(); 509 NOTREACHED();
538 return; 510 return;
539 } 511 }
540 ui::NetworkConnect::Get()->ActivateCellular(service_path); 512 std::string service_path = ServicePathFromGuid(guid);
513 if (!service_path.empty())
514 ui::NetworkConnect::Get()->ActivateCellular(service_path);
541 } 515 }
542 516
543 void InternetOptionsHandler::RemoveNetwork(const base::ListValue* args) { 517 void InternetOptionsHandler::RemoveNetwork(const base::ListValue* args) {
544 std::string service_path; 518 std::string guid;
545 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 519 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
546 NOTREACHED(); 520 NOTREACHED();
547 return; 521 return;
548 } 522 }
523 std::string service_path = ServicePathFromGuid(guid);
524 if (service_path.empty())
525 return;
549 NetworkHandler::Get() 526 NetworkHandler::Get()
550 ->managed_network_configuration_handler() 527 ->managed_network_configuration_handler()
551 ->RemoveConfiguration(service_path, base::Bind(&base::DoNothing), 528 ->RemoveConfiguration(service_path, base::Bind(&base::DoNothing),
552 base::Bind(&ShillError, "RemoveNetwork")); 529 base::Bind(&ShillError, "RemoveNetwork"));
553 } 530 }
554 531
555 base::ListValue* InternetOptionsHandler::GetWiredList() { 532 base::ListValue* InternetOptionsHandler::GetWiredList() {
556 base::ListValue* list = new base::ListValue(); 533 base::ListValue* list = new base::ListValue();
557 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> 534 const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
558 FirstNetworkByType(NetworkTypePattern::Ethernet()); 535 FirstNetworkByType(NetworkTypePattern::Ethernet());
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
646 dictionary->SetBoolean( 623 dictionary->SetBoolean(
647 kTagWimaxAvailable, 624 kTagWimaxAvailable,
648 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 625 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
649 dictionary->SetBoolean( 626 dictionary->SetBoolean(
650 kTagWimaxEnabled, 627 kTagWimaxEnabled,
651 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 628 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
652 } 629 }
653 630
654 } // namespace options 631 } // namespace options
655 } // namespace chromeos 632 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698