| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/dom_ui/internet_options_handler.h" | 5 #include "chrome/browser/chromeos/dom_ui/internet_options_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 dictionary.SetBoolean("cellularAvailable", cros->cellular_available()); | 350 dictionary.SetBoolean("cellularAvailable", cros->cellular_available()); |
| 351 dictionary.SetBoolean("cellularEnabled", cros->cellular_enabled()); | 351 dictionary.SetBoolean("cellularEnabled", cros->cellular_enabled()); |
| 352 dom_ui_->CallJavascriptFunction( | 352 dom_ui_->CallJavascriptFunction( |
| 353 L"options.InternetOptions.refreshNetworkData", dictionary); | 353 L"options.InternetOptions.refreshNetworkData", dictionary); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void InternetOptionsHandler::CellularDataPlanChanged( | 356 void InternetOptionsHandler::CellularDataPlanChanged( |
| 357 chromeos::NetworkLibrary* obj) { | 357 chromeos::NetworkLibrary* obj) { |
| 358 if (!dom_ui_) | 358 if (!dom_ui_) |
| 359 return; | 359 return; |
| 360 const chromeos::CellularNetwork cellular = obj->cellular_network(); | 360 chromeos::CellularNetwork* cellular = obj->cellular_network(); |
| 361 const chromeos::CellularDataPlanList& plans = cellular.GetDataPlans(); | 361 if (!cellular) |
| 362 return; |
| 363 const chromeos::CellularDataPlanList& plans = cellular->GetDataPlans(); |
| 362 DictionaryValue connection_plans; | 364 DictionaryValue connection_plans; |
| 363 ListValue* plan_list = new ListValue(); | 365 ListValue* plan_list = new ListValue(); |
| 364 for (chromeos::CellularDataPlanList::const_iterator iter = plans.begin(); | 366 for (chromeos::CellularDataPlanList::const_iterator iter = plans.begin(); |
| 365 iter != plans.end(); | 367 iter != plans.end(); |
| 366 ++iter) { | 368 ++iter) { |
| 367 plan_list->Append(CellularDataPlanToDictionary(*iter)); | 369 plan_list->Append(CellularDataPlanToDictionary(*iter)); |
| 368 } | 370 } |
| 369 connection_plans.SetString("servicePath", cellular.service_path()); | 371 connection_plans.SetString("servicePath", cellular->service_path()); |
| 370 connection_plans.Set("plans", plan_list); | 372 connection_plans.Set("plans", plan_list); |
| 371 dom_ui_->CallJavascriptFunction( | 373 dom_ui_->CallJavascriptFunction( |
| 372 L"options.InternetOptions.updateCellularPlans", connection_plans); | 374 L"options.InternetOptions.updateCellularPlans", connection_plans); |
| 373 } | 375 } |
| 374 | 376 |
| 375 DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary( | 377 DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary( |
| 376 const chromeos::CellularDataPlan& plan) { | 378 const chromeos::CellularDataPlan& plan) { |
| 377 | 379 |
| 378 DictionaryValue* plan_dict = new DictionaryValue(); | 380 DictionaryValue* plan_dict = new DictionaryValue(); |
| 379 plan_dict->SetInteger("plan_type", plan.plan_type); | 381 plan_dict->SetInteger("plan_type", plan.plan_type); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 std::string remember; | 473 std::string remember; |
| 472 | 474 |
| 473 if (args->GetSize() < 2 || | 475 if (args->GetSize() < 2 || |
| 474 !args->GetString(0, &service_path) || | 476 !args->GetString(0, &service_path) || |
| 475 !args->GetString(1, &remember)) { | 477 !args->GetString(1, &remember)) { |
| 476 NOTREACHED(); | 478 NOTREACHED(); |
| 477 return; | 479 return; |
| 478 } | 480 } |
| 479 chromeos::NetworkLibrary* cros = | 481 chromeos::NetworkLibrary* cros = |
| 480 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 482 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 481 chromeos::WifiNetwork network; | 483 chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); |
| 484 if (!network) |
| 485 return; |
| 486 bool changed = false; |
| 487 if (network->encrypted()) { |
| 488 std::string password; |
| 482 | 489 |
| 483 if (cros->FindWifiNetworkByPath(service_path, &network)) { | 490 if (args->GetSize() != 5 || |
| 484 bool changed = false; | 491 !args->GetString(4, &password)) { |
| 485 if (network.encrypted()) { | 492 NOTREACHED(); |
| 486 std::string password; | 493 return; |
| 494 } |
| 495 if (password != network->passphrase()) { |
| 496 network->set_passphrase(password); |
| 497 changed = true; |
| 498 } |
| 487 | 499 |
| 488 if (args->GetSize() != 5 || | 500 if (network->encryption() == chromeos::SECURITY_8021X) { |
| 489 !args->GetString(4, &password)) { | 501 std::string ident; |
| 502 std::string certpath; |
| 503 |
| 504 if (!args->GetString(2, &ident) || |
| 505 !args->GetString(3, &certpath)) { |
| 490 NOTREACHED(); | 506 NOTREACHED(); |
| 491 return; | 507 return; |
| 492 } | 508 } |
| 493 if (password != network.passphrase()) { | 509 if (ident != network->identity()) { |
| 494 network.set_passphrase(password); | 510 network->set_identity(ident); |
| 495 changed = true; | 511 changed = true; |
| 496 } | 512 } |
| 497 | 513 if (certpath != network->cert_path()) { |
| 498 if (network.encryption() == chromeos::SECURITY_8021X) { | 514 network->set_cert_path(certpath); |
| 499 std::string ident; | 515 changed = true; |
| 500 std::string certpath; | |
| 501 | |
| 502 if (!args->GetString(2, &ident) || | |
| 503 !args->GetString(3, &certpath)) { | |
| 504 NOTREACHED(); | |
| 505 return; | |
| 506 } | |
| 507 if (ident != network.identity()) { | |
| 508 network.set_identity(ident); | |
| 509 changed = true; | |
| 510 } | |
| 511 if (certpath != network.cert_path()) { | |
| 512 network.set_cert_path(certpath); | |
| 513 changed = true; | |
| 514 } | |
| 515 } | 516 } |
| 516 } | 517 } |
| 518 } |
| 517 | 519 |
| 518 bool auto_connect = remember == "true"; | 520 bool auto_connect = remember == "true"; |
| 519 if (auto_connect != network.auto_connect()) { | 521 if (auto_connect != network->auto_connect()) { |
| 520 network.set_auto_connect(auto_connect); | 522 network->set_auto_connect(auto_connect); |
| 521 changed = true; | 523 changed = true; |
| 522 } | 524 } |
| 523 | 525 |
| 524 if (changed) | 526 if (changed) |
| 525 cros->SaveWifiNetwork(network); | 527 cros->SaveWifiNetwork(network); |
| 526 } | |
| 527 } | 528 } |
| 528 | 529 |
| 529 // Parse 'path' to determine if the certificate is stored in a pkcs#11 device. | 530 // Parse 'path' to determine if the certificate is stored in a pkcs#11 device. |
| 530 // flimflam recognizes the string "SETTINGS:" to specify authentication | 531 // flimflam recognizes the string "SETTINGS:" to specify authentication |
| 531 // parameters. 'key_id=' indicates that the certificate is stored in a pkcs#11 | 532 // parameters. 'key_id=' indicates that the certificate is stored in a pkcs#11 |
| 532 // device. See src/third_party/flimflam/files/doc/service-api.txt. | 533 // device. See src/third_party/flimflam/files/doc/service-api.txt. |
| 533 bool InternetOptionsHandler::is_certificate_in_pkcs11(const std::string& path) { | 534 bool InternetOptionsHandler::is_certificate_in_pkcs11(const std::string& path) { |
| 534 static const std::string settings_string("SETTINGS:"); | 535 static const std::string settings_string("SETTINGS:"); |
| 535 static const std::string pkcs11_key("key_id"); | 536 static const std::string pkcs11_key("key_id"); |
| 536 if (path.find(settings_string) == 0) { | 537 if (path.find(settings_string) == 0) { |
| 537 std::string::size_type idx = path.find(pkcs11_key); | 538 std::string::size_type idx = path.find(pkcs11_key); |
| 538 if (idx != std::string::npos) | 539 if (idx != std::string::npos) |
| 539 idx = path.find_first_not_of(kWhitespaceASCII, idx + pkcs11_key.length()); | 540 idx = path.find_first_not_of(kWhitespaceASCII, idx + pkcs11_key.length()); |
| 540 if (idx != std::string::npos && path[idx] == '=') | 541 if (idx != std::string::npos && path[idx] == '=') |
| 541 return true; | 542 return true; |
| 542 } | 543 } |
| 543 return false; | 544 return false; |
| 544 } | 545 } |
| 545 | 546 |
| 546 void InternetOptionsHandler::PopulateDictionaryDetails( | 547 void InternetOptionsHandler::PopulateDictionaryDetails( |
| 547 const chromeos::Network& net, chromeos::NetworkLibrary* cros) { | 548 const chromeos::Network* net, chromeos::NetworkLibrary* cros) { |
| 549 DCHECK(net); |
| 548 DictionaryValue dictionary; | 550 DictionaryValue dictionary; |
| 549 chromeos::ConnectionType type = net.type(); | 551 chromeos::ConnectionType type = net->type(); |
| 550 std::string hardware_address; | 552 std::string hardware_address; |
| 551 chromeos::NetworkIPConfigVector ipconfigs = | 553 chromeos::NetworkIPConfigVector ipconfigs = |
| 552 cros->GetIPConfigs(net.device_path(), &hardware_address); | 554 cros->GetIPConfigs(net->device_path(), &hardware_address); |
| 553 scoped_ptr<ListValue> ipconfig_list(new ListValue()); | 555 scoped_ptr<ListValue> ipconfig_list(new ListValue()); |
| 554 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 556 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| 555 it != ipconfigs.end(); ++it) { | 557 it != ipconfigs.end(); ++it) { |
| 556 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); | 558 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); |
| 557 const chromeos::NetworkIPConfig& ipconfig = *it; | 559 const chromeos::NetworkIPConfig& ipconfig = *it; |
| 558 ipconfig_dict->SetString("address", ipconfig.address); | 560 ipconfig_dict->SetString("address", ipconfig.address); |
| 559 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); | 561 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); |
| 560 ipconfig_dict->SetString("gateway", ipconfig.gateway); | 562 ipconfig_dict->SetString("gateway", ipconfig.gateway); |
| 561 ipconfig_dict->SetString("dns", ipconfig.name_servers); | 563 ipconfig_dict->SetString("dns", ipconfig.name_servers); |
| 562 ipconfig_list->Append(ipconfig_dict.release()); | 564 ipconfig_list->Append(ipconfig_dict.release()); |
| 563 } | 565 } |
| 564 dictionary.Set("ipconfigs", ipconfig_list.release()); | 566 dictionary.Set("ipconfigs", ipconfig_list.release()); |
| 565 dictionary.SetInteger("type", type); | 567 dictionary.SetInteger("type", type); |
| 566 dictionary.SetString("servicePath", net.service_path()); | 568 dictionary.SetString("servicePath", net->service_path()); |
| 567 dictionary.SetBoolean("connecting", net.connecting()); | 569 dictionary.SetBoolean("connecting", net->connecting()); |
| 568 dictionary.SetBoolean("connected", net.connected()); | 570 dictionary.SetBoolean("connected", net->connected()); |
| 569 dictionary.SetString("connectionState", net.GetStateString()); | 571 dictionary.SetString("connectionState", net->GetStateString()); |
| 570 if (type == chromeos::TYPE_WIFI) { | 572 if (type == chromeos::TYPE_WIFI) { |
| 571 chromeos::WifiNetwork wireless; | 573 chromeos::WifiNetwork* wireless = |
| 572 if (!cros->FindWifiNetworkByPath(net.service_path(), &wireless)) { | 574 cros->FindWifiNetworkByPath(net->service_path()); |
| 573 LOG(WARNING) << "Cannot find network " << net.service_path(); | 575 if (!wireless) { |
| 576 LOG(WARNING) << "Cannot find network " << net->service_path(); |
| 574 } else { | 577 } else { |
| 575 dictionary.SetString("ssid", wireless.name()); | 578 dictionary.SetString("ssid", wireless->name()); |
| 576 dictionary.SetBoolean("autoConnect",wireless.auto_connect()); | 579 dictionary.SetBoolean("autoConnect",wireless->auto_connect()); |
| 577 if (wireless.encrypted()) { | 580 if (wireless->encrypted()) { |
| 578 dictionary.SetBoolean("encrypted", true); | 581 dictionary.SetBoolean("encrypted", true); |
| 579 if (wireless.encryption() == chromeos::SECURITY_8021X) { | 582 if (wireless->encryption() == chromeos::SECURITY_8021X) { |
| 580 bool certificate_in_pkcs11 = | 583 bool certificate_in_pkcs11 = |
| 581 is_certificate_in_pkcs11(wireless.cert_path()); | 584 is_certificate_in_pkcs11(wireless->cert_path()); |
| 582 if (certificate_in_pkcs11) { | 585 if (certificate_in_pkcs11) { |
| 583 dictionary.SetBoolean("certInPkcs", true); | 586 dictionary.SetBoolean("certInPkcs", true); |
| 584 } else { | 587 } else { |
| 585 dictionary.SetBoolean("certInPkcs", false); | 588 dictionary.SetBoolean("certInPkcs", false); |
| 586 } | 589 } |
| 587 dictionary.SetString("certPath",wireless.cert_path()); | 590 dictionary.SetString("certPath",wireless->cert_path()); |
| 588 dictionary.SetString("ident",wireless.identity()); | 591 dictionary.SetString("ident",wireless->identity()); |
| 589 dictionary.SetBoolean("certNeeded", true); | 592 dictionary.SetBoolean("certNeeded", true); |
| 590 dictionary.SetString("certPass",wireless.passphrase()); | 593 dictionary.SetString("certPass",wireless->passphrase()); |
| 591 } else { | 594 } else { |
| 592 dictionary.SetBoolean("certNeeded", false); | 595 dictionary.SetBoolean("certNeeded", false); |
| 593 dictionary.SetString("pass", wireless.passphrase()); | 596 dictionary.SetString("pass", wireless->passphrase()); |
| 594 } | 597 } |
| 595 } else { | 598 } else { |
| 596 dictionary.SetBoolean("encrypted", false); | 599 dictionary.SetBoolean("encrypted", false); |
| 597 } | 600 } |
| 598 } | 601 } |
| 599 } else if (type == chromeos::TYPE_CELLULAR) { | 602 } else if (type == chromeos::TYPE_CELLULAR) { |
| 600 chromeos::CellularNetwork cellular; | 603 chromeos::CellularNetwork* cellular = |
| 601 if (!cros->FindCellularNetworkByPath(net.service_path(), &cellular)) { | 604 cros->FindCellularNetworkByPath(net->service_path()); |
| 602 LOG(WARNING) << "Cannot find network " << net.service_path(); | 605 if (!cellular) { |
| 606 LOG(WARNING) << "Cannot find network " << net->service_path(); |
| 603 } else { | 607 } else { |
| 604 // Cellular network / connection settings. | 608 // Cellular network / connection settings. |
| 605 dictionary.SetString("serviceName", cellular.service_name()); | 609 dictionary.SetString("serviceName", cellular->service_name()); |
| 606 dictionary.SetString("networkTechnology", | 610 dictionary.SetString("networkTechnology", |
| 607 cellular.GetNetworkTechnologyString()); | 611 cellular->GetNetworkTechnologyString()); |
| 608 dictionary.SetString("operatorName", cellular.operator_name()); | 612 dictionary.SetString("operatorName", cellular->operator_name()); |
| 609 dictionary.SetString("operatorCode", cellular.operator_code()); | 613 dictionary.SetString("operatorCode", cellular->operator_code()); |
| 610 dictionary.SetString("activationState", | 614 dictionary.SetString("activationState", |
| 611 cellular.GetActivationStateString()); | 615 cellular->GetActivationStateString()); |
| 612 dictionary.SetString("roamingState", | 616 dictionary.SetString("roamingState", |
| 613 cellular.GetRoamingStateString()); | 617 cellular->GetRoamingStateString()); |
| 614 dictionary.SetString("restrictedPool", | 618 dictionary.SetString("restrictedPool", |
| 615 cellular.restricted_pool() ? | 619 cellular->restricted_pool() ? |
| 616 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : | 620 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : |
| 617 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); | 621 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); |
| 618 dictionary.SetString("errorState", cellular.GetErrorString()); | 622 dictionary.SetString("errorState", cellular->GetErrorString()); |
| 619 // Device settings. | 623 // Device settings. |
| 620 dictionary.SetString("manufacturer", cellular.manufacturer()); | 624 dictionary.SetString("manufacturer", cellular->manufacturer()); |
| 621 dictionary.SetString("modelId", cellular.model_id()); | 625 dictionary.SetString("modelId", cellular->model_id()); |
| 622 dictionary.SetString("firmwareRevision", cellular.firmware_revision()); | 626 dictionary.SetString("firmwareRevision", cellular->firmware_revision()); |
| 623 dictionary.SetString("hardwareRevision", cellular.hardware_revision()); | 627 dictionary.SetString("hardwareRevision", cellular->hardware_revision()); |
| 624 dictionary.SetString("lastUpdate", cellular.last_update()); | 628 dictionary.SetString("lastUpdate", cellular->last_update()); |
| 625 dictionary.SetString("prlVersion", StringPrintf("%u", | 629 dictionary.SetString("prlVersion", StringPrintf("%u", |
| 626 cellular.prl_version())); | 630 cellular->prl_version())); |
| 627 dictionary.SetString("meid", cellular.meid()); | 631 dictionary.SetString("meid", cellular->meid()); |
| 628 dictionary.SetString("imei", cellular.imei()); | 632 dictionary.SetString("imei", cellular->imei()); |
| 629 dictionary.SetString("mdn", cellular.mdn()); | 633 dictionary.SetString("mdn", cellular->mdn()); |
| 630 dictionary.SetString("imsi", cellular.imsi()); | 634 dictionary.SetString("imsi", cellular->imsi()); |
| 631 dictionary.SetString("esn", cellular.esn()); | 635 dictionary.SetString("esn", cellular->esn()); |
| 632 dictionary.SetString("min", cellular.min()); | 636 dictionary.SetString("min", cellular->min()); |
| 633 | 637 |
| 634 dictionary.SetBoolean("gsm", cellular.is_gsm()); | 638 dictionary.SetBoolean("gsm", cellular->is_gsm()); |
| 635 } | 639 } |
| 636 } | 640 } |
| 637 if (!hardware_address.empty()) { | 641 if (!hardware_address.empty()) { |
| 638 dictionary.SetString("hardwareAddress", | 642 dictionary.SetString("hardwareAddress", |
| 639 FormatHardwareAddress(hardware_address)); | 643 FormatHardwareAddress(hardware_address)); |
| 640 } | 644 } |
| 641 | 645 |
| 642 dom_ui_->CallJavascriptFunction( | 646 dom_ui_->CallJavascriptFunction( |
| 643 L"options.InternetOptions.showDetailedInfo", dictionary); | 647 L"options.InternetOptions.showDetailedInfo", dictionary); |
| 644 } | 648 } |
| 645 | 649 |
| 646 void InternetOptionsHandler::PopupWirelessPassword( | 650 void InternetOptionsHandler::PopupWirelessPassword( |
| 647 const chromeos::WifiNetwork& network) { | 651 const chromeos::WifiNetwork* network) { |
| 648 DictionaryValue dictionary; | 652 DictionaryValue dictionary; |
| 649 dictionary.SetString("servicePath",network.service_path()); | 653 dictionary.SetString("servicePath",network->service_path()); |
| 650 if (network.encryption() == chromeos::SECURITY_8021X) { | 654 if (network->encryption() == chromeos::SECURITY_8021X) { |
| 651 dictionary.SetBoolean("certNeeded", true); | 655 dictionary.SetBoolean("certNeeded", true); |
| 652 dictionary.SetString("ident", network.identity()); | 656 dictionary.SetString("ident", network->identity()); |
| 653 dictionary.SetString("cert", network.cert_path()); | 657 dictionary.SetString("cert", network->cert_path()); |
| 654 } else { | 658 } else { |
| 655 dictionary.SetBoolean("certNeeded", false); | 659 dictionary.SetBoolean("certNeeded", false); |
| 656 dictionary.SetString("pass", network.passphrase()); | 660 dictionary.SetString("pass", network->passphrase()); |
| 657 } | 661 } |
| 658 dom_ui_->CallJavascriptFunction( | 662 dom_ui_->CallJavascriptFunction( |
| 659 L"options.InternetOptions.showPasswordEntry", dictionary); | 663 L"options.InternetOptions.showPasswordEntry", dictionary); |
| 660 } | 664 } |
| 661 | 665 |
| 662 void InternetOptionsHandler::LoginCallback(const ListValue* args) { | 666 void InternetOptionsHandler::LoginCallback(const ListValue* args) { |
| 663 | 667 |
| 664 std::string service_path; | 668 std::string service_path; |
| 665 std::string password; | 669 std::string password; |
| 666 | 670 |
| 667 if (args->GetSize() != 2 || | 671 if (args->GetSize() != 2 || |
| 668 !args->GetString(0, &service_path) || | 672 !args->GetString(0, &service_path) || |
| 669 !args->GetString(1, &password)) { | 673 !args->GetString(1, &password)) { |
| 670 NOTREACHED(); | 674 NOTREACHED(); |
| 671 return; | 675 return; |
| 672 } | 676 } |
| 673 | 677 |
| 674 chromeos::NetworkLibrary* cros = | 678 chromeos::NetworkLibrary* cros = |
| 675 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 679 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 676 chromeos::WifiNetwork network; | 680 chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); |
| 677 | 681 if (network) { |
| 678 if (cros->FindWifiNetworkByPath(service_path, &network)) { | |
| 679 cros->ConnectToWifiNetwork( | 682 cros->ConnectToWifiNetwork( |
| 680 network, password, std::string(), std::string()); | 683 network, password, std::string(), std::string()); |
| 681 } else { | 684 } else { |
| 682 // Must be an "other" login | 685 // Must be an "other" login |
| 683 cros->ConnectToWifiNetwork( | 686 cros->ConnectToWifiNetwork( |
| 684 service_path, password, std::string(), std::string(), true); | 687 service_path, password, std::string(), std::string(), true); |
| 685 } | 688 } |
| 686 } | 689 } |
| 687 | 690 |
| 688 void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { | 691 void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { |
| 689 | 692 |
| 690 std::string service_path; | 693 std::string service_path; |
| 691 std::string identity; | 694 std::string identity; |
| 692 std::string certpath; | 695 std::string certpath; |
| 693 std::string password; | 696 std::string password; |
| 694 | 697 |
| 695 if (args->GetSize() != 4 || | 698 if (args->GetSize() != 4 || |
| 696 !args->GetString(0, &service_path) || | 699 !args->GetString(0, &service_path) || |
| 697 !args->GetString(1, &certpath) || | 700 !args->GetString(1, &certpath) || |
| 698 !args->GetString(2, &identity) || | 701 !args->GetString(2, &identity) || |
| 699 !args->GetString(3, &password)) { | 702 !args->GetString(3, &password)) { |
| 700 NOTREACHED(); | 703 NOTREACHED(); |
| 701 return; | 704 return; |
| 702 } | 705 } |
| 703 chromeos::NetworkLibrary* cros = | 706 chromeos::NetworkLibrary* cros = |
| 704 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 707 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 705 chromeos::WifiNetwork network; | 708 chromeos::WifiNetwork* network = |
| 706 | 709 cros->FindWifiNetworkByPath(service_path); |
| 707 if (cros->FindWifiNetworkByPath(service_path, &network)) { | 710 if (network) { |
| 708 cros->ConnectToWifiNetwork( | 711 cros->ConnectToWifiNetwork( |
| 709 network, password, identity, certpath); | 712 network, password, identity, certpath); |
| 710 } else { | 713 } else { |
| 711 // TODO(dhg): Send error back to UI | 714 // TODO(dhg): Send error back to UI |
| 712 } | 715 } |
| 713 } | 716 } |
| 714 | 717 |
| 715 void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { | 718 void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { |
| 716 std::string ssid; | 719 std::string ssid; |
| 717 std::string password; | 720 std::string password; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 740 !args->GetString(2, &command)) { | 743 !args->GetString(2, &command)) { |
| 741 NOTREACHED(); | 744 NOTREACHED(); |
| 742 return; | 745 return; |
| 743 } | 746 } |
| 744 | 747 |
| 745 int type = atoi(str_type.c_str()); | 748 int type = atoi(str_type.c_str()); |
| 746 chromeos::NetworkLibrary* cros = | 749 chromeos::NetworkLibrary* cros = |
| 747 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 750 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 748 | 751 |
| 749 if (type == chromeos::TYPE_ETHERNET) { | 752 if (type == chromeos::TYPE_ETHERNET) { |
| 750 const chromeos::EthernetNetwork& ether = cros->ethernet_network(); | 753 chromeos::EthernetNetwork* ether = cros->ethernet_network(); |
| 751 PopulateDictionaryDetails(ether, cros); | 754 PopulateDictionaryDetails(ether, cros); |
| 752 } else if (type == chromeos::TYPE_WIFI) { | 755 } else if (type == chromeos::TYPE_WIFI) { |
| 753 chromeos::WifiNetwork network; | 756 chromeos::WifiNetwork* network; |
| 754 if (command == "forget") { | 757 if (command == "forget") { |
| 755 cros->ForgetWirelessNetwork(service_path); | 758 cros->ForgetWifiNetwork(service_path); |
| 756 } else if (cros->FindWifiNetworkByPath(service_path, &network)) { | 759 } else if ((network = cros->FindWifiNetworkByPath(service_path))) { |
| 757 if (command == "connect") { | 760 if (command == "connect") { |
| 758 // Connect to wifi here. Open password page if appropriate. | 761 // Connect to wifi here. Open password page if appropriate. |
| 759 if (network.encrypted() && !network.auto_connect()) { | 762 if (network->encrypted() && !network->auto_connect()) { |
| 760 if (network.encryption() == chromeos::SECURITY_8021X) { | 763 if (network->encryption() == chromeos::SECURITY_8021X) { |
| 761 PopulateDictionaryDetails(network, cros); | 764 PopulateDictionaryDetails(network, cros); |
| 762 } else { | 765 } else { |
| 763 PopupWirelessPassword(network); | 766 PopupWirelessPassword(network); |
| 764 } | 767 } |
| 765 } else { | 768 } else { |
| 766 cros->ConnectToWifiNetwork( | 769 cros->ConnectToWifiNetwork( |
| 767 network, std::string(), std::string(), std::string()); | 770 network, std::string(), std::string(), std::string()); |
| 768 } | 771 } |
| 769 } else if (command == "disconnect") { | 772 } else if (command == "disconnect") { |
| 770 cros->DisconnectFromWirelessNetwork(network); | 773 cros->DisconnectFromWirelessNetwork(network); |
| 771 } else if (command == "options") { | 774 } else if (command == "options") { |
| 772 PopulateDictionaryDetails(network, cros); | 775 PopulateDictionaryDetails(network, cros); |
| 773 } | 776 } |
| 774 } | 777 } |
| 775 } else if (type == chromeos::TYPE_CELLULAR) { | 778 } else if (type == chromeos::TYPE_CELLULAR) { |
| 776 chromeos::CellularNetwork cellular; | 779 chromeos::CellularNetwork* cellular = |
| 777 if (cros->FindCellularNetworkByPath(service_path, &cellular)) { | 780 cros->FindCellularNetworkByPath(service_path); |
| 781 if (cellular) { |
| 778 if (command == "connect") { | 782 if (command == "connect") { |
| 779 cros->ConnectToCellularNetwork(cellular); | 783 cros->ConnectToCellularNetwork(cellular); |
| 780 } else if (command == "disconnect") { | 784 } else if (command == "disconnect") { |
| 781 cros->DisconnectFromWirelessNetwork(cellular); | 785 cros->DisconnectFromWirelessNetwork(cellular); |
| 782 } else if (command == "activate") { | 786 } else if (command == "activate") { |
| 783 Browser* browser = BrowserList::GetLastActive(); | 787 Browser* browser = BrowserList::GetLastActive(); |
| 784 if (browser) | 788 if (browser) |
| 785 browser->OpenMobilePlanTabAndActivate(); | 789 browser->OpenMobilePlanTabAndActivate(); |
| 786 } else if (command == "options") { | 790 } else if (command == "options") { |
| 787 PopulateDictionaryDetails(cellular, cros); | 791 PopulateDictionaryDetails(cellular, cros); |
| 788 } | 792 } |
| 789 } | 793 } |
| 790 } else { | 794 } else { |
| 791 NOTREACHED(); | 795 NOTREACHED(); |
| 792 } | 796 } |
| 793 } | 797 } |
| 794 | 798 |
| 795 void InternetOptionsHandler::RefreshCellularPlanCallback( | 799 void InternetOptionsHandler::RefreshCellularPlanCallback( |
| 796 const ListValue* args) { | 800 const ListValue* args) { |
| 797 std::string service_path; | 801 std::string service_path; |
| 798 if (args->GetSize() != 1 || | 802 if (args->GetSize() != 1 || |
| 799 !args->GetString(0, &service_path)) { | 803 !args->GetString(0, &service_path)) { |
| 800 NOTREACHED(); | 804 NOTREACHED(); |
| 801 return; | 805 return; |
| 802 } | 806 } |
| 803 chromeos::NetworkLibrary* cros = | 807 chromeos::NetworkLibrary* cros = |
| 804 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 808 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 805 chromeos::CellularNetwork cellular; | 809 chromeos::CellularNetwork* cellular = |
| 806 if (cros->FindCellularNetworkByPath(service_path, &cellular)) { | 810 cros->FindCellularNetworkByPath(service_path); |
| 811 if (cellular) |
| 807 cros->RefreshCellularDataPlans(cellular); | 812 cros->RefreshCellularDataPlans(cellular); |
| 808 } else { | |
| 809 NOTREACHED(); | |
| 810 } | |
| 811 } | 813 } |
| 812 | 814 |
| 813 ListValue* InternetOptionsHandler::GetNetwork(const std::string& service_path, | 815 ListValue* InternetOptionsHandler::GetNetwork(const std::string& service_path, |
| 814 const SkBitmap& icon, const std::string& name, bool connecting, | 816 const SkBitmap& icon, const std::string& name, bool connecting, |
| 815 bool connected, chromeos::ConnectionType connection_type, bool remembered, | 817 bool connected, chromeos::ConnectionType connection_type, bool remembered, |
| 816 chromeos::ActivationState activation_state) { | 818 chromeos::ActivationState activation_state) { |
| 817 | 819 |
| 818 ListValue* network = new ListValue(); | 820 ListValue* network = new ListValue(); |
| 819 | 821 |
| 820 int connection_state = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED; | 822 int connection_state = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 } | 855 } |
| 854 | 856 |
| 855 ListValue* InternetOptionsHandler::GetWiredList() { | 857 ListValue* InternetOptionsHandler::GetWiredList() { |
| 856 chromeos::NetworkLibrary* cros = | 858 chromeos::NetworkLibrary* cros = |
| 857 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 859 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 858 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 860 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 859 ListValue* list = new ListValue(); | 861 ListValue* list = new ListValue(); |
| 860 | 862 |
| 861 // If ethernet is not enabled, then don't add anything. | 863 // If ethernet is not enabled, then don't add anything. |
| 862 if (cros->ethernet_enabled()) { | 864 if (cros->ethernet_enabled()) { |
| 863 const chromeos::EthernetNetwork& ethernet_network = | 865 chromeos::EthernetNetwork* ethernet_network = |
| 864 cros->ethernet_network(); | 866 cros->ethernet_network(); |
| 865 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK); | 867 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK); |
| 866 if (!ethernet_network.connecting() && | 868 if (!ethernet_network || (!ethernet_network->connecting() && |
| 867 !ethernet_network.connected()) { | 869 !ethernet_network->connected())) { |
| 868 icon = chromeos::NetworkMenu::IconForDisplay(icon, | 870 icon = chromeos::NetworkMenu::IconForDisplay(icon, |
| 869 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); | 871 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); |
| 870 } | 872 } |
| 871 list->Append(GetNetwork( | 873 if (ethernet_network) { |
| 872 ethernet_network.service_path(), | 874 list->Append(GetNetwork( |
| 873 icon, | 875 ethernet_network->service_path(), |
| 874 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), | 876 icon, |
| 875 ethernet_network.connecting(), | 877 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), |
| 876 ethernet_network.connected(), | 878 ethernet_network->connecting(), |
| 877 chromeos::TYPE_ETHERNET, | 879 ethernet_network->connected(), |
| 878 false, | 880 chromeos::TYPE_ETHERNET, |
| 879 chromeos::ACTIVATION_STATE_UNKNOWN)); | 881 false, |
| 882 chromeos::ACTIVATION_STATE_UNKNOWN)); |
| 883 } |
| 880 } | 884 } |
| 881 return list; | 885 return list; |
| 882 } | 886 } |
| 883 | 887 |
| 884 ListValue* InternetOptionsHandler::GetWirelessList() { | 888 ListValue* InternetOptionsHandler::GetWirelessList() { |
| 885 chromeos::NetworkLibrary* cros = | 889 chromeos::NetworkLibrary* cros = |
| 886 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 890 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 887 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 891 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 888 ListValue* list = new ListValue(); | 892 ListValue* list = new ListValue(); |
| 889 | 893 |
| 890 const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 894 const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| 891 for (chromeos::WifiNetworkVector::const_iterator it = | 895 for (chromeos::WifiNetworkVector::const_iterator it = |
| 892 wifi_networks.begin(); it != wifi_networks.end(); ++it) { | 896 wifi_networks.begin(); it != wifi_networks.end(); ++it) { |
| 893 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength( | 897 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength( |
| 894 it->strength(), true); | 898 (*it)->strength(), true); |
| 895 if (it->encrypted()) { | 899 if ((*it)->encrypted()) { |
| 896 icon = chromeos::NetworkMenu::IconForDisplay(icon, | 900 icon = chromeos::NetworkMenu::IconForDisplay(icon, |
| 897 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | 901 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); |
| 898 } | 902 } |
| 899 list->Append(GetNetwork( | 903 list->Append(GetNetwork( |
| 900 it->service_path(), | 904 (*it)->service_path(), |
| 901 icon, | 905 icon, |
| 902 it->name(), | 906 (*it)->name(), |
| 903 it->connecting(), | 907 (*it)->connecting(), |
| 904 it->connected(), | 908 (*it)->connected(), |
| 905 chromeos::TYPE_WIFI, | 909 chromeos::TYPE_WIFI, |
| 906 false, | 910 false, |
| 907 chromeos::ACTIVATION_STATE_UNKNOWN)); | 911 chromeos::ACTIVATION_STATE_UNKNOWN)); |
| 908 } | 912 } |
| 909 | 913 |
| 910 const chromeos::CellularNetworkVector& cellular_networks = | 914 const chromeos::CellularNetworkVector cellular_networks = |
| 911 cros->cellular_networks(); | 915 cros->cellular_networks(); |
| 912 for (chromeos::CellularNetworkVector::const_iterator it = | 916 for (chromeos::CellularNetworkVector::const_iterator it = |
| 913 cellular_networks.begin(); it != cellular_networks.end(); ++it) { | 917 cellular_networks.begin(); it != cellular_networks.end(); ++it) { |
| 914 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength( | 918 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength( |
| 915 it->strength(), true); | 919 (*it)->strength(), true); |
| 916 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); | 920 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); |
| 917 icon = chromeos::NetworkMenu::IconForDisplay(icon, badge); | 921 icon = chromeos::NetworkMenu::IconForDisplay(icon, badge); |
| 918 list->Append(GetNetwork( | 922 list->Append(GetNetwork( |
| 919 it->service_path(), | 923 (*it)->service_path(), |
| 920 icon, | 924 icon, |
| 921 it->name(), | 925 (*it)->name(), |
| 922 it->connecting(), | 926 (*it)->connecting(), |
| 923 it->connected(), | 927 (*it)->connected(), |
| 924 chromeos::TYPE_CELLULAR, | 928 chromeos::TYPE_CELLULAR, |
| 925 false, | 929 false, |
| 926 it->activation_state())); | 930 (*it)->activation_state())); |
| 927 } | 931 } |
| 928 | 932 |
| 929 // Add "Other..." if wifi is enabled. | 933 // Add "Other..." if wifi is enabled. |
| 930 if (cros->wifi_enabled()) { | 934 if (cros->wifi_enabled()) { |
| 931 list->Append(GetNetwork( | 935 list->Append(GetNetwork( |
| 932 kOtherNetworksFakePath, | 936 kOtherNetworksFakePath, |
| 933 SkBitmap(), | 937 SkBitmap(), |
| 934 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_OTHER_NETWORKS), | 938 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_OTHER_NETWORKS), |
| 935 false, | 939 false, |
| 936 false, | 940 false, |
| 937 chromeos::TYPE_WIFI, | 941 chromeos::TYPE_WIFI, |
| 938 false, | 942 false, |
| 939 chromeos::ACTIVATION_STATE_UNKNOWN)); | 943 chromeos::ACTIVATION_STATE_UNKNOWN)); |
| 940 } | 944 } |
| 941 | 945 |
| 942 return list; | 946 return list; |
| 943 } | 947 } |
| 944 | 948 |
| 945 ListValue* InternetOptionsHandler::GetRememberedList() { | 949 ListValue* InternetOptionsHandler::GetRememberedList() { |
| 946 chromeos::NetworkLibrary* cros = | 950 chromeos::NetworkLibrary* cros = |
| 947 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 951 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 948 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 952 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 949 ListValue* list = new ListValue(); | 953 ListValue* list = new ListValue(); |
| 950 | 954 |
| 951 const chromeos::WifiNetworkVector& wifi_networks = | 955 const chromeos::WifiNetworkVector& wifi_networks = |
| 952 cros->remembered_wifi_networks(); | 956 cros->remembered_wifi_networks(); |
| 953 for (chromeos::WifiNetworkVector::const_iterator it = | 957 for (chromeos::WifiNetworkVector::const_iterator it = |
| 954 wifi_networks.begin(); it != wifi_networks.end(); ++it) { | 958 wifi_networks.begin(); it != wifi_networks.end(); ++it) { |
| 955 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); | 959 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); |
| 956 if (it->encrypted()) { | 960 if ((*it)->encrypted()) { |
| 957 icon = chromeos::NetworkMenu::IconForDisplay(icon, | 961 icon = chromeos::NetworkMenu::IconForDisplay(icon, |
| 958 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | 962 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); |
| 959 } | 963 } |
| 960 list->Append(GetNetwork( | 964 list->Append(GetNetwork( |
| 961 it->service_path(), | 965 (*it)->service_path(), |
| 962 icon, | 966 icon, |
| 963 it->name(), | 967 (*it)->name(), |
| 964 it->connecting(), | 968 (*it)->connecting(), |
| 965 it->connected(), | 969 (*it)->connected(), |
| 966 chromeos::TYPE_WIFI, | 970 chromeos::TYPE_WIFI, |
| 967 true, | 971 true, |
| 968 chromeos::ACTIVATION_STATE_UNKNOWN)); | 972 chromeos::ACTIVATION_STATE_UNKNOWN)); |
| 969 } | 973 } |
| 970 | |
| 971 const chromeos::CellularNetworkVector& cellular_networks = | |
| 972 cros->remembered_cellular_networks(); | |
| 973 for (chromeos::CellularNetworkVector::const_iterator it = | |
| 974 cellular_networks.begin(); it != cellular_networks.end(); ++it) { | |
| 975 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); | |
| 976 SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G); | |
| 977 icon = chromeos::NetworkMenu::IconForDisplay(icon, badge); | |
| 978 list->Append(GetNetwork( | |
| 979 it->service_path(), | |
| 980 icon, | |
| 981 it->name(), | |
| 982 it->connecting(), | |
| 983 it->connected(), | |
| 984 chromeos::TYPE_CELLULAR, | |
| 985 true, | |
| 986 it->activation_state())); | |
| 987 } | |
| 988 | |
| 989 return list; | 974 return list; |
| 990 } | 975 } |
| OLD | NEW |