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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID)); | 136 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID)); |
137 localized_strings->SetString("inetIdent", | 137 localized_strings->SetString("inetIdent", |
138 l10n_util::GetStringUTF16( | 138 l10n_util::GetStringUTF16( |
139 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY)); | 139 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY)); |
140 localized_strings->SetString("inetCert", | 140 localized_strings->SetString("inetCert", |
141 l10n_util::GetStringUTF16( | 141 l10n_util::GetStringUTF16( |
142 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT)); | 142 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT)); |
143 localized_strings->SetString("inetCertPass", | 143 localized_strings->SetString("inetCertPass", |
144 l10n_util::GetStringUTF16( | 144 l10n_util::GetStringUTF16( |
145 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD)); | 145 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD)); |
146 localized_strings->SetString("inetPass", | 146 localized_strings->SetString("inetPassProtected", |
147 l10n_util::GetStringUTF16( | 147 l10n_util::GetStringUTF16( |
148 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE)); | 148 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NET_PROTECTED)); |
149 localized_strings->SetString("inetRememberNetwork", | 149 localized_strings->SetString("inetRememberNetwork", |
150 l10n_util::GetStringUTF16( | 150 l10n_util::GetStringUTF16( |
151 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); | 151 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); |
152 localized_strings->SetString("inetCertPkcs", | 152 localized_strings->SetString("inetCertPkcs", |
153 l10n_util::GetStringUTF16( | 153 l10n_util::GetStringUTF16( |
154 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED)); | 154 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED)); |
155 localized_strings->SetString("inetLogin", | 155 localized_strings->SetString("inetLogin", |
156 l10n_util::GetStringUTF16( | 156 l10n_util::GetStringUTF16( |
157 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN)); | 157 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN)); |
158 localized_strings->SetString("inetShowPass", | 158 localized_strings->SetString("inetShowPass", |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 NOTREACHED(); | 498 NOTREACHED(); |
499 return; | 499 return; |
500 } | 500 } |
501 chromeos::NetworkLibrary* cros = | 501 chromeos::NetworkLibrary* cros = |
502 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 502 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
503 chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); | 503 chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); |
504 if (!network) | 504 if (!network) |
505 return; | 505 return; |
506 bool changed = false; | 506 bool changed = false; |
507 if (network->encrypted()) { | 507 if (network->encrypted()) { |
508 std::string password; | 508 if (network->encrypted() && |
509 | 509 network->encryption() == chromeos::SECURITY_8021X) { |
510 if (args->GetSize() != 5 || | |
511 !args->GetString(4, &password)) { | |
512 NOTREACHED(); | |
513 return; | |
514 } | |
515 if (password != network->passphrase()) { | |
516 network->set_passphrase(password); | |
517 changed = true; | |
518 } | |
519 | |
520 if (network->encryption() == chromeos::SECURITY_8021X) { | |
521 std::string ident; | 510 std::string ident; |
522 std::string certpath; | 511 std::string certpath; |
523 | 512 |
524 if (!args->GetString(2, &ident) || | 513 if (!args->GetString(2, &ident) || |
525 !args->GetString(3, &certpath)) { | 514 !args->GetString(3, &certpath)) { |
526 NOTREACHED(); | 515 NOTREACHED(); |
527 return; | 516 return; |
528 } | 517 } |
529 if (ident != network->identity()) { | 518 if (ident != network->identity()) { |
530 network->set_identity(ident); | 519 network->set_identity(ident); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 dictionary.SetBoolean("certInPkcs", true); | 595 dictionary.SetBoolean("certInPkcs", true); |
607 } else { | 596 } else { |
608 dictionary.SetBoolean("certInPkcs", false); | 597 dictionary.SetBoolean("certInPkcs", false); |
609 } | 598 } |
610 dictionary.SetString("certPath",wireless->cert_path()); | 599 dictionary.SetString("certPath",wireless->cert_path()); |
611 dictionary.SetString("ident",wireless->identity()); | 600 dictionary.SetString("ident",wireless->identity()); |
612 dictionary.SetBoolean("certNeeded", true); | 601 dictionary.SetBoolean("certNeeded", true); |
613 dictionary.SetString("certPass",wireless->passphrase()); | 602 dictionary.SetString("certPass",wireless->passphrase()); |
614 } else { | 603 } else { |
615 dictionary.SetBoolean("certNeeded", false); | 604 dictionary.SetBoolean("certNeeded", false); |
616 dictionary.SetString("pass", wireless->passphrase()); | |
617 } | 605 } |
618 } else { | 606 } else { |
619 dictionary.SetBoolean("encrypted", false); | 607 dictionary.SetBoolean("encrypted", false); |
620 } | 608 } |
621 } | 609 } |
622 } else if (type == chromeos::TYPE_CELLULAR) { | 610 } else if (type == chromeos::TYPE_CELLULAR) { |
623 chromeos::CellularNetwork* cellular = | 611 chromeos::CellularNetwork* cellular = |
624 cros->FindCellularNetworkByPath(net->service_path()); | 612 cros->FindCellularNetworkByPath(net->service_path()); |
625 if (!cellular) { | 613 if (!cellular) { |
626 LOG(WARNING) << "Cannot find network " << net->service_path(); | 614 LOG(WARNING) << "Cannot find network " << net->service_path(); |
627 } else { | 615 } else { |
628 // Cellular network / connection settings. | 616 // Cellular network / connection settings. |
629 dictionary.SetString("serviceName", cellular->service_name()); | 617 dictionary.SetString("serviceName", cellular->service_name()); |
630 dictionary.SetString("networkTechnology", | 618 dictionary.SetString("networkTechnology", |
631 cellular->GetNetworkTechnologyString()); | 619 cellular->GetNetworkTechnologyString()); |
632 dictionary.SetString("operatorName", cellular->operator_name()); | 620 dictionary.SetString("operatorName", cellular->operator_name()); |
633 dictionary.SetString("operatorCode", cellular->operator_code()); | 621 dictionary.SetString("operatorCode", cellular->operator_code()); |
634 dictionary.SetString("activationState", | 622 dictionary.SetString("activationState", |
635 cellular->GetActivationStateString()); | 623 cellular->GetActivationStateString()); |
636 dictionary.SetString("roamingState", | 624 dictionary.SetString("roamingState", |
637 cellular->GetRoamingStateString()); | 625 cellular->GetRoamingStateString()); |
638 dictionary.SetString("restrictedPool", | 626 dictionary.SetString("restrictedPool", |
639 cellular->restricted_pool() ? | 627 cellular->restricted_pool() ? |
640 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : | 628 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : |
641 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); | 629 l10n_util::GetStringUTF8(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); |
642 dictionary.SetString("errorState", cellular->GetErrorString()); | 630 dictionary.SetString("errorState", cellular->GetErrorString()); |
| 631 dictionary.SetString("supportUrl", |
| 632 cellular->payment_url()); |
643 // Device settings. | 633 // Device settings. |
644 dictionary.SetString("manufacturer", cellular->manufacturer()); | 634 dictionary.SetString("manufacturer", cellular->manufacturer()); |
645 dictionary.SetString("modelId", cellular->model_id()); | 635 dictionary.SetString("modelId", cellular->model_id()); |
646 dictionary.SetString("firmwareRevision", cellular->firmware_revision()); | 636 dictionary.SetString("firmwareRevision", cellular->firmware_revision()); |
647 dictionary.SetString("hardwareRevision", cellular->hardware_revision()); | 637 dictionary.SetString("hardwareRevision", cellular->hardware_revision()); |
648 dictionary.SetString("lastUpdate", cellular->last_update()); | 638 dictionary.SetString("lastUpdate", cellular->last_update()); |
649 dictionary.SetString("prlVersion", StringPrintf("%u", | 639 dictionary.SetString("prlVersion", StringPrintf("%u", |
650 cellular->prl_version())); | 640 cellular->prl_version())); |
651 dictionary.SetString("meid", cellular->meid()); | 641 dictionary.SetString("meid", cellular->meid()); |
652 dictionary.SetString("imei", cellular->imei()); | 642 dictionary.SetString("imei", cellular->imei()); |
(...skipping 17 matching lines...) Expand all Loading... |
670 void InternetOptionsHandler::PopupWirelessPassword( | 660 void InternetOptionsHandler::PopupWirelessPassword( |
671 const chromeos::WifiNetwork* network) { | 661 const chromeos::WifiNetwork* network) { |
672 DictionaryValue dictionary; | 662 DictionaryValue dictionary; |
673 dictionary.SetString("servicePath",network->service_path()); | 663 dictionary.SetString("servicePath",network->service_path()); |
674 if (network->encryption() == chromeos::SECURITY_8021X) { | 664 if (network->encryption() == chromeos::SECURITY_8021X) { |
675 dictionary.SetBoolean("certNeeded", true); | 665 dictionary.SetBoolean("certNeeded", true); |
676 dictionary.SetString("ident", network->identity()); | 666 dictionary.SetString("ident", network->identity()); |
677 dictionary.SetString("cert", network->cert_path()); | 667 dictionary.SetString("cert", network->cert_path()); |
678 } else { | 668 } else { |
679 dictionary.SetBoolean("certNeeded", false); | 669 dictionary.SetBoolean("certNeeded", false); |
680 dictionary.SetString("pass", network->passphrase()); | |
681 } | 670 } |
682 dom_ui_->CallJavascriptFunction( | 671 dom_ui_->CallJavascriptFunction( |
683 L"options.InternetOptions.showPasswordEntry", dictionary); | 672 L"options.InternetOptions.showPasswordEntry", dictionary); |
684 } | 673 } |
685 | 674 |
686 void InternetOptionsHandler::LoginCallback(const ListValue* args) { | 675 void InternetOptionsHandler::LoginCallback(const ListValue* args) { |
687 | 676 |
688 std::string service_path; | 677 std::string service_path; |
689 std::string password; | 678 std::string password; |
690 | 679 |
(...skipping 15 matching lines...) Expand all Loading... |
706 // TODO(chocobo): Display error message. | 695 // TODO(chocobo): Display error message. |
707 LOG(WARNING) << "Cannot find network to connect " << service_path; | 696 LOG(WARNING) << "Cannot find network to connect " << service_path; |
708 } | 697 } |
709 } | 698 } |
710 | 699 |
711 void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { | 700 void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { |
712 | 701 |
713 std::string service_path; | 702 std::string service_path; |
714 std::string identity; | 703 std::string identity; |
715 std::string certpath; | 704 std::string certpath; |
716 std::string password; | 705 if (args->GetSize() < 3 || |
717 | |
718 if (args->GetSize() != 4 || | |
719 !args->GetString(0, &service_path) || | 706 !args->GetString(0, &service_path) || |
720 !args->GetString(1, &certpath) || | 707 !args->GetString(1, &certpath) || |
721 !args->GetString(2, &identity) || | 708 !args->GetString(2, &identity)) { |
722 !args->GetString(3, &password)) { | |
723 NOTREACHED(); | |
724 return; | 709 return; |
725 } | 710 } |
726 chromeos::NetworkLibrary* cros = | 711 chromeos::NetworkLibrary* cros = |
727 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 712 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
728 chromeos::WifiNetwork* network = | 713 chromeos::WifiNetwork* network = |
729 cros->FindWifiNetworkByPath(service_path); | 714 cros->FindWifiNetworkByPath(service_path); |
730 if (network) { | 715 if (!network) |
731 cros->ConnectToWifiNetwork( | 716 return; |
732 network, password, identity, certpath); | 717 // If password does not come from the input, use one saved with the |
733 } else { | 718 // network details. |
734 // TODO(dhg): Send error back to UI | 719 std::string password; |
| 720 if (args->GetSize() != 4 || !args->GetString(3, &password)) { |
| 721 password = network->passphrase(); |
735 } | 722 } |
| 723 cros->ConnectToWifiNetwork( |
| 724 network, password, identity, certpath); |
736 } | 725 } |
737 | 726 |
738 void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { | 727 void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { |
739 std::string security; | 728 std::string security; |
740 std::string ssid; | 729 std::string ssid; |
741 std::string password; | 730 std::string password; |
742 | 731 |
743 if (args->GetSize() != 3 || | 732 if (args->GetSize() != 3 || |
744 !args->GetString(0, &security) || | 733 !args->GetString(0, &security) || |
745 !args->GetString(1, &ssid) || | 734 !args->GetString(1, &ssid) || |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 icon, | 988 icon, |
1000 (*it)->name(), | 989 (*it)->name(), |
1001 (*it)->connecting(), | 990 (*it)->connecting(), |
1002 (*it)->connected(), | 991 (*it)->connected(), |
1003 chromeos::TYPE_WIFI, | 992 chromeos::TYPE_WIFI, |
1004 true, | 993 true, |
1005 chromeos::ACTIVATION_STATE_UNKNOWN)); | 994 chromeos::ACTIVATION_STATE_UNKNOWN)); |
1006 } | 995 } |
1007 return list; | 996 return list; |
1008 } | 997 } |
OLD | NEW |