| OLD | NEW |
| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 const char kTagCarrierUrl[] = "carrierUrl"; | 138 const char kTagCarrierUrl[] = "carrierUrl"; |
| 139 const char kTagCellularAvailable[] = "cellularAvailable"; | 139 const char kTagCellularAvailable[] = "cellularAvailable"; |
| 140 const char kTagCellularEnabled[] = "cellularEnabled"; | 140 const char kTagCellularEnabled[] = "cellularEnabled"; |
| 141 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; | 141 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; |
| 142 const char kTagConfigure[] = "configure"; | 142 const char kTagConfigure[] = "configure"; |
| 143 const char kTagConnect[] = "connect"; | 143 const char kTagConnect[] = "connect"; |
| 144 const char kTagControlledBy[] = "controlledBy"; | 144 const char kTagControlledBy[] = "controlledBy"; |
| 145 const char kTagDeviceConnected[] = "deviceConnected"; | 145 const char kTagDeviceConnected[] = "deviceConnected"; |
| 146 const char kTagDisconnect[] = "disconnect"; | 146 const char kTagDisconnect[] = "disconnect"; |
| 147 const char kTagErrorState[] = "errorState"; | 147 const char kTagErrorState[] = "errorState"; |
| 148 const char kTagEsn[] = "esn"; | |
| 149 const char kTagFirmwareRevision[] = "firmwareRevision"; | |
| 150 const char kTagForget[] = "forget"; | 148 const char kTagForget[] = "forget"; |
| 151 const char kTagGsm[] = "gsm"; | |
| 152 const char kTagHardwareRevision[] = "hardwareRevision"; | |
| 153 const char kTagIdentity[] = "identity"; | 149 const char kTagIdentity[] = "identity"; |
| 154 const char kTagIccid[] = "iccid"; | |
| 155 const char kTagImei[] = "imei"; | |
| 156 const char kTagImsi[] = "imsi"; | |
| 157 const char kTagLanguage[] = "language"; | 150 const char kTagLanguage[] = "language"; |
| 158 const char kTagLastGoodApn[] = "lastGoodApn"; | 151 const char kTagLastGoodApn[] = "lastGoodApn"; |
| 159 const char kTagLocalizedName[] = "localizedName"; | 152 const char kTagLocalizedName[] = "localizedName"; |
| 160 const char kTagCellularManufacturer[] = "cellularManufacturer"; | |
| 161 const char kTagMdn[] = "mdn"; | |
| 162 const char kTagMeid[] = "meid"; | |
| 163 const char kTagMin[] = "min"; | |
| 164 const char kTagModelId[] = "modelId"; | |
| 165 const char kTagName[] = "name"; | 153 const char kTagName[] = "name"; |
| 166 const char kTagNameServersGoogle[] = "nameServersGoogle"; | 154 const char kTagNameServersGoogle[] = "nameServersGoogle"; |
| 167 const char kTagNameServerType[] = "nameServerType"; | 155 const char kTagNameServerType[] = "nameServerType"; |
| 168 const char kTagNetworkId[] = "networkId"; | 156 const char kTagNetworkId[] = "networkId"; |
| 169 const char kTagNetworkTechnology[] = "networkTechnology"; | |
| 170 const char kTagOperatorCode[] = "operatorCode"; | |
| 171 const char kTagOperatorName[] = "operatorName"; | |
| 172 const char kTagOptions[] = "options"; | 157 const char kTagOptions[] = "options"; |
| 173 const char kTagPassword[] = "password"; | 158 const char kTagPassword[] = "password"; |
| 174 const char kTagPolicy[] = "policy"; | 159 const char kTagPolicy[] = "policy"; |
| 175 const char kTagPreferred[] = "preferred"; | 160 const char kTagPreferred[] = "preferred"; |
| 176 const char kTagPrlVersion[] = "prlVersion"; | |
| 177 const char kTagProviderType[] = "providerType"; | 161 const char kTagProviderType[] = "providerType"; |
| 178 const char kTagProviderApnList[] = "providerApnList"; | 162 const char kTagProviderApnList[] = "providerApnList"; |
| 179 const char kTagRecommended[] = "recommended"; | 163 const char kTagRecommended[] = "recommended"; |
| 180 const char kTagRecommendedValue[] = "recommendedValue"; | 164 const char kTagRecommendedValue[] = "recommendedValue"; |
| 181 const char kTagRemembered[] = "remembered"; | 165 const char kTagRemembered[] = "remembered"; |
| 182 const char kTagRememberedList[] = "rememberedList"; | 166 const char kTagRememberedList[] = "rememberedList"; |
| 183 const char kTagRestrictedPool[] = "restrictedPool"; | 167 const char kTagRestrictedPool[] = "restrictedPool"; |
| 184 const char kTagRoamingState[] = "roamingState"; | 168 const char kTagRoamingState[] = "roamingState"; |
| 185 const char kTagServerHostname[] = "serverHostname"; | 169 const char kTagServerHostname[] = "serverHostname"; |
| 186 const char kTagCarriers[] = "carriers"; | 170 const char kTagCarriers[] = "carriers"; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 std::string name_servers; | 326 std::string name_servers; |
| 343 if (shill_properties.GetStringWithoutPathExpansion( | 327 if (shill_properties.GetStringWithoutPathExpansion( |
| 344 name_servers_key, &name_servers)) { | 328 name_servers_key, &name_servers)) { |
| 345 ip_info_dict->SetString(kIpConfigNameServers, name_servers); | 329 ip_info_dict->SetString(kIpConfigNameServers, name_servers); |
| 346 VLOG(2) << "Found " << name_servers_key << ": " << name_servers; | 330 VLOG(2) << "Found " << name_servers_key << ": " << name_servers; |
| 347 } | 331 } |
| 348 | 332 |
| 349 return ip_info_dict.release(); | 333 return ip_info_dict.release(); |
| 350 } | 334 } |
| 351 | 335 |
| 352 bool CanForgetNetworkType(const std::string& type) { | |
| 353 return type == shill::kTypeWifi || | |
| 354 type == shill::kTypeWimax || | |
| 355 type == shill::kTypeVPN; | |
| 356 } | |
| 357 | |
| 358 bool CanAddNetworkType(const std::string& type) { | |
| 359 return type == shill::kTypeWifi || | |
| 360 type == shill::kTypeVPN || | |
| 361 type == shill::kTypeCellular; | |
| 362 } | |
| 363 | |
| 364 // Decorate dictionary |value_dict| with policy information from |ui_data|. | 336 // Decorate dictionary |value_dict| with policy information from |ui_data|. |
| 365 void DecorateValueDictionary(const NetworkPropertyUIData& ui_data, | 337 void DecorateValueDictionary(const NetworkPropertyUIData& ui_data, |
| 366 const base::Value& value, | 338 const base::Value& value, |
| 367 base::DictionaryValue* value_dict) { | 339 base::DictionaryValue* value_dict) { |
| 368 const base::Value* recommended_value = ui_data.default_value(); | 340 const base::Value* recommended_value = ui_data.default_value(); |
| 369 if (ui_data.IsManaged()) | 341 if (ui_data.IsManaged()) |
| 370 value_dict->SetString(kTagControlledBy, kTagPolicy); | 342 value_dict->SetString(kTagControlledBy, kTagPolicy); |
| 371 else if (recommended_value && recommended_value->Equals(&value)) | 343 else if (recommended_value && recommended_value->Equals(&value)) |
| 372 value_dict->SetString(kTagControlledBy, kTagRecommended); | 344 value_dict->SetString(kTagControlledBy, kTagRecommended); |
| 373 | 345 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 std::string CopyStringFromDictionary(const base::DictionaryValue& source, | 389 std::string CopyStringFromDictionary(const base::DictionaryValue& source, |
| 418 const std::string& src_key, | 390 const std::string& src_key, |
| 419 const std::string& dest_key, | 391 const std::string& dest_key, |
| 420 base::DictionaryValue* dest) { | 392 base::DictionaryValue* dest) { |
| 421 std::string string_value; | 393 std::string string_value; |
| 422 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) | 394 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) |
| 423 dest->SetStringWithoutPathExpansion(dest_key, string_value); | 395 dest->SetStringWithoutPathExpansion(dest_key, string_value); |
| 424 return string_value; | 396 return string_value; |
| 425 } | 397 } |
| 426 | 398 |
| 427 void CopyIntegerFromDictionary(const base::DictionaryValue& source, | |
| 428 const std::string& src_key, | |
| 429 const std::string& dest_key, | |
| 430 bool as_string, | |
| 431 base::DictionaryValue* dest) { | |
| 432 int int_value; | |
| 433 if (!source.GetIntegerWithoutPathExpansion(src_key, &int_value)) | |
| 434 return; | |
| 435 if (as_string) { | |
| 436 dest->SetStringWithoutPathExpansion(dest_key, base::IntToString(int_value)); | |
| 437 } else { | |
| 438 dest->SetIntegerWithoutPathExpansion(dest_key, int_value); | |
| 439 } | |
| 440 } | |
| 441 | |
| 442 // Fills |dictionary| with the configuration details of |vpn|. |onc| is required | 399 // Fills |dictionary| with the configuration details of |vpn|. |onc| is required |
| 443 // for augmenting the policy-managed information. | 400 // for augmenting the policy-managed information. |
| 444 void PopulateVPNDetails(const NetworkState* vpn, | 401 void PopulateVPNDetails(const NetworkState* vpn, |
| 445 const base::DictionaryValue& shill_properties, | 402 const base::DictionaryValue& shill_properties, |
| 446 base::DictionaryValue* dictionary) { | 403 base::DictionaryValue* dictionary) { |
| 447 // Name and Remembered are set in PopulateConnectionDetails(). | 404 // Name and Remembered are set in PopulateConnectionDetails(). |
| 448 // Provider properties are stored in the "Provider" dictionary. | 405 // Provider properties are stored in the "Provider" dictionary. |
| 449 const base::DictionaryValue* provider_properties = NULL; | 406 const base::DictionaryValue* provider_properties = NULL; |
| 450 if (!shill_properties.GetDictionaryWithoutPathExpansion( | 407 if (!shill_properties.GetDictionaryWithoutPathExpansion( |
| 451 shill::kProviderProperty, &provider_properties)) { | 408 shill::kProviderProperty, &provider_properties)) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 *apn, shill::kApnLanguageProperty, kTagLanguage, dictionary); | 491 *apn, shill::kApnLanguageProperty, kTagLanguage, dictionary); |
| 535 } | 492 } |
| 536 | 493 |
| 537 void PopulateCellularDetails(const NetworkState* cellular, | 494 void PopulateCellularDetails(const NetworkState* cellular, |
| 538 const base::DictionaryValue& shill_properties, | 495 const base::DictionaryValue& shill_properties, |
| 539 base::DictionaryValue* dictionary) { | 496 base::DictionaryValue* dictionary) { |
| 540 dictionary->SetBoolean(kTagCarrierSelectFlag, | 497 dictionary->SetBoolean(kTagCarrierSelectFlag, |
| 541 CommandLine::ForCurrentProcess()->HasSwitch( | 498 CommandLine::ForCurrentProcess()->HasSwitch( |
| 542 chromeos::switches::kEnableCarrierSwitching)); | 499 chromeos::switches::kEnableCarrierSwitching)); |
| 543 // Cellular network / connection settings. | 500 // Cellular network / connection settings. |
| 544 dictionary->SetString(kTagNetworkTechnology, cellular->network_technology()); | |
| 545 dictionary->SetString(kTagActivationState, | 501 dictionary->SetString(kTagActivationState, |
| 546 internet_options_strings::ActivationStateString( | 502 internet_options_strings::ActivationStateString( |
| 547 cellular->activation_state())); | 503 cellular->activation_state())); |
| 548 dictionary->SetString(kTagRoamingState, | 504 dictionary->SetString(kTagRoamingState, |
| 549 internet_options_strings::RoamingStateString( | 505 internet_options_strings::RoamingStateString( |
| 550 cellular->roaming())); | 506 cellular->roaming())); |
| 551 dictionary->SetString( | 507 dictionary->SetString(kTagRestrictedPool, |
| 552 kTagRestrictedPool, | 508 internet_options_strings::RestrictedStateString( |
| 553 internet_options_strings::RestrictedStateString( | 509 cellular->connection_state())); |
| 554 cellular->connection_state())); | |
| 555 | |
| 556 const base::DictionaryValue* serving_operator = NULL; | |
| 557 if (shill_properties.GetDictionaryWithoutPathExpansion( | |
| 558 shill::kServingOperatorProperty, &serving_operator)) { | |
| 559 CopyStringFromDictionary(*serving_operator, | |
| 560 shill::kOperatorNameKey, | |
| 561 kTagOperatorName, | |
| 562 dictionary); | |
| 563 CopyStringFromDictionary(*serving_operator, | |
| 564 shill::kOperatorCodeKey, | |
| 565 kTagOperatorCode, | |
| 566 dictionary); | |
| 567 } | |
| 568 | 510 |
| 569 const base::DictionaryValue* olp = NULL; | 511 const base::DictionaryValue* olp = NULL; |
| 570 if (shill_properties.GetDictionaryWithoutPathExpansion( | 512 if (shill_properties.GetDictionaryWithoutPathExpansion( |
| 571 shill::kPaymentPortalProperty, &olp)) { | 513 shill::kPaymentPortalProperty, &olp)) { |
| 572 std::string url; | 514 std::string url; |
| 573 olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, &url); | 515 olp->GetStringWithoutPathExpansion(shill::kPaymentPortalURL, &url); |
| 574 dictionary->SetString(kTagSupportUrl, url); | 516 dictionary->SetString(kTagSupportUrl, url); |
| 575 } | 517 } |
| 576 | 518 |
| 577 base::DictionaryValue* apn = new base::DictionaryValue; | 519 base::DictionaryValue* apn = new base::DictionaryValue; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 591 | 533 |
| 592 // These default to empty and are only set if device != NULL. | 534 // These default to empty and are only set if device != NULL. |
| 593 std::string carrier_id; | 535 std::string carrier_id; |
| 594 std::string mdn; | 536 std::string mdn; |
| 595 | 537 |
| 596 // Device settings. | 538 // Device settings. |
| 597 const DeviceState* device = | 539 const DeviceState* device = |
| 598 NetworkHandler::Get()->network_state_handler()->GetDeviceState( | 540 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
| 599 cellular->device_path()); | 541 cellular->device_path()); |
| 600 if (device) { | 542 if (device) { |
| 601 // TODO(stevenjb): Add NetworkDeviceHandler::GetProperties() and use that | |
| 602 // to retrieve the complete dictionary of device properties, instead of | |
| 603 // caching them (will be done for the new UI). | |
| 604 const base::DictionaryValue& device_properties = device->properties(); | 543 const base::DictionaryValue& device_properties = device->properties(); |
| 605 const NetworkPropertyUIData cellular_property_ui_data( | 544 const NetworkPropertyUIData cellular_property_ui_data( |
| 606 cellular->ui_data().onc_source()); | 545 cellular->ui_data().onc_source()); |
| 607 CopyStringFromDictionary(device_properties, | |
| 608 shill::kManufacturerProperty, | |
| 609 kTagCellularManufacturer, | |
| 610 dictionary); | |
| 611 CopyStringFromDictionary( | |
| 612 device_properties, shill::kModelIDProperty, kTagModelId, dictionary); | |
| 613 CopyStringFromDictionary(device_properties, | |
| 614 shill::kFirmwareRevisionProperty, | |
| 615 kTagFirmwareRevision, | |
| 616 dictionary); | |
| 617 CopyStringFromDictionary(device_properties, | |
| 618 shill::kHardwareRevisionProperty, | |
| 619 kTagHardwareRevision, | |
| 620 dictionary); | |
| 621 CopyIntegerFromDictionary(device_properties, | |
| 622 shill::kPRLVersionProperty, | |
| 623 kTagPrlVersion, | |
| 624 true, | |
| 625 dictionary); | |
| 626 CopyStringFromDictionary( | |
| 627 device_properties, shill::kMeidProperty, kTagMeid, dictionary); | |
| 628 CopyStringFromDictionary( | |
| 629 device_properties, shill::kIccidProperty, kTagIccid, dictionary); | |
| 630 CopyStringFromDictionary( | |
| 631 device_properties, shill::kImeiProperty, kTagImei, dictionary); | |
| 632 mdn = CopyStringFromDictionary( | |
| 633 device_properties, shill::kMdnProperty, kTagMdn, dictionary); | |
| 634 CopyStringFromDictionary( | |
| 635 device_properties, shill::kImsiProperty, kTagImsi, dictionary); | |
| 636 CopyStringFromDictionary( | |
| 637 device_properties, shill::kEsnProperty, kTagEsn, dictionary); | |
| 638 CopyStringFromDictionary( | |
| 639 device_properties, shill::kMinProperty, kTagMin, dictionary); | |
| 640 std::string family; | |
| 641 device_properties.GetStringWithoutPathExpansion( | |
| 642 shill::kTechnologyFamilyProperty, &family); | |
| 643 dictionary->SetBoolean(kTagGsm, family == shill::kNetworkTechnologyGsm); | |
| 644 | |
| 645 SetValueDictionary(dictionary, | 546 SetValueDictionary(dictionary, |
| 646 kTagSimCardLockEnabled, | 547 kTagSimCardLockEnabled, |
| 647 new base::FundamentalValue(device->sim_lock_enabled()), | 548 new base::FundamentalValue(device->sim_lock_enabled()), |
| 648 cellular_property_ui_data); | 549 cellular_property_ui_data); |
| 649 | 550 |
| 650 carrier_id = device->home_provider_id(); | 551 carrier_id = device->home_provider_id(); |
| 552 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); |
| 651 | 553 |
| 652 MobileConfig* config = MobileConfig::GetInstance(); | 554 MobileConfig* config = MobileConfig::GetInstance(); |
| 653 if (config->IsReady()) { | 555 if (config->IsReady()) { |
| 654 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); | 556 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); |
| 655 if (carrier && !carrier->top_up_url().empty()) | 557 if (carrier && !carrier->top_up_url().empty()) |
| 656 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); | 558 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); |
| 657 } | 559 } |
| 658 | 560 |
| 659 base::ListValue* apn_list_value = new base::ListValue(); | 561 base::ListValue* apn_list_value = new base::ListValue(); |
| 660 const base::ListValue* apn_list; | 562 const base::ListValue* apn_list; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 // carrier specific portal. | 642 // carrier specific portal. |
| 741 if (cellular->IsConnectedState() || force_show_view_account_button) | 643 if (cellular->IsConnectedState() || force_show_view_account_button) |
| 742 dictionary->SetBoolean(kTagShowViewAccountButton, true); | 644 dictionary->SetBoolean(kTagShowViewAccountButton, true); |
| 743 } | 645 } |
| 744 } | 646 } |
| 745 } | 647 } |
| 746 | 648 |
| 747 scoped_ptr<base::DictionaryValue> PopulateConnectionDetails( | 649 scoped_ptr<base::DictionaryValue> PopulateConnectionDetails( |
| 748 const NetworkState* network, | 650 const NetworkState* network, |
| 749 const base::DictionaryValue& shill_properties) { | 651 const base::DictionaryValue& shill_properties) { |
| 652 // TODO(stevenjb): Once we eliminate all references to Shill properties, |
| 653 // we can switch to using managed_network_configuration_handler which |
| 654 // includes Device properties for Cellular (and skip the call to |
| 655 // onc::TranslateShillServiceToONCPart). For now we copy them over here. |
| 656 scoped_ptr<base::DictionaryValue> shill_properties_with_device( |
| 657 shill_properties.DeepCopy()); |
| 658 const DeviceState* device = |
| 659 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
| 660 network->device_path()); |
| 661 if (device) { |
| 662 shill_properties_with_device->Set(shill::kDeviceProperty, |
| 663 device->properties().DeepCopy()); |
| 664 } |
| 750 scoped_ptr<base::DictionaryValue> dictionary = | 665 scoped_ptr<base::DictionaryValue> dictionary = |
| 751 onc::TranslateShillServiceToONCPart( | 666 onc::TranslateShillServiceToONCPart( |
| 752 shill_properties, &onc::kNetworkWithStateSignature); | 667 *shill_properties_with_device, &onc::kNetworkWithStateSignature); |
| 753 | 668 |
| 754 dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); | 669 dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); |
| 755 dictionary->SetString( | 670 dictionary->SetString( |
| 756 kTagErrorState, | 671 kTagErrorState, |
| 757 ash::network_connect::ErrorString(network->error(), network->path())); | 672 ash::network_connect::ErrorString(network->error(), network->path())); |
| 758 | 673 |
| 759 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); | 674 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); |
| 760 bool shared = !network->IsPrivate(); | 675 bool shared = !network->IsPrivate(); |
| 761 dictionary->SetBoolean(kTagShared, shared); | 676 dictionary->SetBoolean(kTagShared, shared); |
| 762 | 677 |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 gfx::ImageSkia* icon = | 1060 gfx::ImageSkia* icon = |
| 1146 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); | 1061 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); |
| 1147 gfx::ImageSkiaRep image_rep = icon->GetRepresentation( | 1062 gfx::ImageSkiaRep image_rep = icon->GetRepresentation( |
| 1148 web_ui()->GetDeviceScaleFactor()); | 1063 web_ui()->GetDeviceScaleFactor()); |
| 1149 return webui::GetBitmapDataUrl(image_rep.sk_bitmap()); | 1064 return webui::GetBitmapDataUrl(image_rep.sk_bitmap()); |
| 1150 } | 1065 } |
| 1151 | 1066 |
| 1152 void InternetOptionsHandler::RefreshNetworkData() { | 1067 void InternetOptionsHandler::RefreshNetworkData() { |
| 1153 base::DictionaryValue dictionary; | 1068 base::DictionaryValue dictionary; |
| 1154 FillNetworkInfo(&dictionary); | 1069 FillNetworkInfo(&dictionary); |
| 1155 web_ui()->CallJavascriptFunction( | 1070 web_ui()->CallJavascriptFunction(kRefreshNetworkDataFunction, dictionary); |
| 1156 kRefreshNetworkDataFunction, dictionary); | |
| 1157 } | 1071 } |
| 1158 | 1072 |
| 1159 void InternetOptionsHandler::UpdateConnectionData( | 1073 void InternetOptionsHandler::UpdateConnectionData( |
| 1160 const std::string& service_path) { | 1074 const std::string& service_path) { |
| 1161 NetworkHandler::Get()->network_configuration_handler()->GetProperties( | 1075 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 1162 service_path, | 1076 service_path, |
| 1163 base::Bind(&InternetOptionsHandler::UpdateConnectionDataCallback, | 1077 base::Bind(&InternetOptionsHandler::UpdateConnectionDataCallback, |
| 1164 weak_factory_.GetWeakPtr()), | 1078 weak_factory_.GetWeakPtr()), |
| 1165 base::Bind(&ShillError, "UpdateConnectionData")); | 1079 base::Bind(&ShillError, "UpdateConnectionData")); |
| 1166 } | 1080 } |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1533 return; | 1447 return; |
| 1534 } | 1448 } |
| 1535 std::string type; // Shill type | 1449 std::string type; // Shill type |
| 1536 if (!onc_type.empty()) { | 1450 if (!onc_type.empty()) { |
| 1537 type = network_util::TranslateONCTypeToShill(onc_type); | 1451 type = network_util::TranslateONCTypeToShill(onc_type); |
| 1538 if (type.empty()) | 1452 if (type.empty()) |
| 1539 LOG(ERROR) << "Unable to translate ONC type: " << onc_type; | 1453 LOG(ERROR) << "Unable to translate ONC type: " << onc_type; |
| 1540 } | 1454 } |
| 1541 // Process commands that do not require an existing network. | 1455 // Process commands that do not require an existing network. |
| 1542 if (command == kTagAddConnection) { | 1456 if (command == kTagAddConnection) { |
| 1543 if (CanAddNetworkType(type)) | 1457 AddConnection(type); |
| 1544 AddConnection(type); | |
| 1545 } else if (command == kTagForget) { | 1458 } else if (command == kTagForget) { |
| 1546 if (CanForgetNetworkType(type)) { | 1459 NetworkHandler::Get()->network_configuration_handler()-> |
| 1547 NetworkHandler::Get()->network_configuration_handler()-> | 1460 RemoveConfiguration( |
| 1548 RemoveConfiguration( | 1461 service_path, |
| 1549 service_path, | 1462 base::Bind(&base::DoNothing), |
| 1550 base::Bind(&base::DoNothing), | 1463 base::Bind(&ShillError, "NetworkCommand: " + command)); |
| 1551 base::Bind(&ShillError, "NetworkCommand: " + command)); | |
| 1552 } | |
| 1553 } else if (command == kTagOptions) { | 1464 } else if (command == kTagOptions) { |
| 1554 NetworkHandler::Get()->network_configuration_handler()->GetProperties( | 1465 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 1555 service_path, | 1466 service_path, |
| 1556 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, | 1467 base::Bind(&InternetOptionsHandler::PopulateDictionaryDetailsCallback, |
| 1557 weak_factory_.GetWeakPtr()), | 1468 weak_factory_.GetWeakPtr()), |
| 1558 base::Bind(&ShillError, "NetworkCommand: " + command)); | 1469 base::Bind(&ShillError, "NetworkCommand: " + command)); |
| 1559 } else if (command == kTagConnect) { | 1470 } else if (command == kTagConnect) { |
| 1560 const NetworkState* network = GetNetworkState(service_path); | 1471 const NetworkState* network = GetNetworkState(service_path); |
| 1561 if (network && network->type() == shill::kTypeWifi) | 1472 if (network && network->type() == shill::kTypeWifi) |
| 1562 content::RecordAction( | 1473 content::RecordAction( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 content::RecordAction( | 1506 content::RecordAction( |
| 1596 base::UserMetricsAction("Options_NetworkJoinOtherWifi")); | 1507 base::UserMetricsAction("Options_NetworkJoinOtherWifi")); |
| 1597 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); | 1508 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); |
| 1598 } else if (type == shill::kTypeVPN) { | 1509 } else if (type == shill::kTypeVPN) { |
| 1599 content::RecordAction( | 1510 content::RecordAction( |
| 1600 base::UserMetricsAction("Options_NetworkJoinOtherVPN")); | 1511 base::UserMetricsAction("Options_NetworkJoinOtherVPN")); |
| 1601 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); | 1512 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); |
| 1602 } else if (type == shill::kTypeCellular) { | 1513 } else if (type == shill::kTypeCellular) { |
| 1603 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); | 1514 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); |
| 1604 } else { | 1515 } else { |
| 1605 NOTREACHED(); | 1516 LOG(ERROR) << "Unsupported type for AddConnection"; |
| 1606 } | 1517 } |
| 1607 } | 1518 } |
| 1608 | 1519 |
| 1609 base::ListValue* InternetOptionsHandler::GetWiredList() { | 1520 base::ListValue* InternetOptionsHandler::GetWiredList() { |
| 1610 base::ListValue* list = new base::ListValue(); | 1521 base::ListValue* list = new base::ListValue(); |
| 1611 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> | 1522 const NetworkState* network = NetworkHandler::Get()->network_state_handler()-> |
| 1612 FirstNetworkByType(NetworkTypePattern::Ethernet()); | 1523 FirstNetworkByType(NetworkTypePattern::Ethernet()); |
| 1613 if (!network) | 1524 if (!network) |
| 1614 return list; | 1525 return list; |
| 1615 list->Append(BuildNetworkDictionary(network, GetScaleFactor(), GetPrefs())); | 1526 list->Append(BuildNetworkDictionary(network, GetScaleFactor(), GetPrefs())); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 dictionary->SetBoolean( | 1610 dictionary->SetBoolean( |
| 1700 kTagWimaxAvailable, | 1611 kTagWimaxAvailable, |
| 1701 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1612 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1702 dictionary->SetBoolean( | 1613 dictionary->SetBoolean( |
| 1703 kTagWimaxEnabled, | 1614 kTagWimaxEnabled, |
| 1704 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1615 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1705 } | 1616 } |
| 1706 | 1617 |
| 1707 } // namespace options | 1618 } // namespace options |
| 1708 } // namespace chromeos | 1619 } // namespace chromeos |
| OLD | NEW |