diff options
-rw-r--r-- | chrome/app/generated_resources.grd | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library.cc | 21 | ||||
-rw-r--r-- | chrome/browser/chromeos/cros/network_library.h | 16 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/network_screen.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/options/internet_page_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/chromeos/options/network_config_view.cc | 14 | ||||
-rw-r--r-- | chrome/browser/chromeos/options/wifi_config_view.cc | 113 | ||||
-rw-r--r-- | chrome/browser/chromeos/options/wifi_config_view.h | 19 | ||||
-rw-r--r-- | chrome/browser/chromeos/status/network_menu_button.cc | 2 |
9 files changed, 160 insertions, 43 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index ef65d13..1329f1b 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -7403,6 +7403,18 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID" desc="In settings internet options, the label for the ssid."> Network id: </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY" desc="In settings internet options, the user identity for authentication."> + Identity: + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT" desc="In settings internet options, the x509 certificate to use."> + Certificate: + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON" desc="In settings internet options, the prompt on the certificate-selection button."> + Select certificate file + </message> + <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD" desc="In settings internet options, the password protecting the certificate private key."> + Private key password: + </message> <message name="IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE" desc="In settings internet options, the label for the passphrase."> Network key: </message> diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index 79e3596..a26dd61 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -87,23 +87,32 @@ void NetworkLibraryImpl::RequestWifiScan() { } void NetworkLibraryImpl::ConnectToWifiNetwork(WifiNetwork network, - const string16& password) { + const string16& password, + const string16& identity, + const string16& certpath) { if (CrosLibrary::Get()->EnsureLoaded()) { - ConnectToNetwork(network.service_path.c_str(), - password.empty() ? NULL : UTF16ToUTF8(password).c_str()); + ConnectToNetworkWithCertInfo(network.service_path.c_str(), + password.empty() ? NULL : UTF16ToUTF8(password).c_str(), + identity.empty() ? NULL : UTF16ToUTF8(identity).c_str(), + certpath.empty() ? NULL : UTF16ToUTF8(certpath).c_str()); } } void NetworkLibraryImpl::ConnectToWifiNetwork(const string16& ssid, - const string16& password) { + const string16& password, + const string16& identity, + const string16& certpath) { if (CrosLibrary::Get()->EnsureLoaded()) { // First create a service from hidden network. ServiceInfo* service = GetWifiService(UTF16ToUTF8(ssid).c_str(), SECURITY_UNKNOWN); // Now connect to that service. if (service) { - ConnectToNetwork(service->service_path, - password.empty() ? NULL : UTF16ToUTF8(password).c_str()); + ConnectToNetworkWithCertInfo(service->service_path, + password.empty() ? NULL : UTF16ToUTF8(password).c_str(), + identity.empty() ? NULL : UTF16ToUTF8(identity).c_str(), + certpath.empty() ? NULL : UTF16ToUTF8(certpath).c_str()); + // Clean up ServiceInfo object. FreeServiceInfo(service); } else { diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index d689b29..c99b431 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -190,11 +190,15 @@ class NetworkLibrary { // Connect to the specified wireless network with password. virtual void ConnectToWifiNetwork(WifiNetwork network, - const string16& password) = 0; + const string16& password, + const string16& identity, + const string16& certpath) = 0; // Connect to the specified wifi ssid with password. virtual void ConnectToWifiNetwork(const string16& ssid, - const string16& password) = 0; + const string16& password, + const string16& identity, + const string16& certpath) = 0; // Connect to the specified cellular network. virtual void ConnectToCellularNetwork(CellularNetwork network) = 0; @@ -301,11 +305,15 @@ class NetworkLibraryImpl : public NetworkLibrary, // Connect to the specified wireless network with password. virtual void ConnectToWifiNetwork(WifiNetwork network, - const string16& password); + const string16& password, + const string16& identity, + const string16& certpath); // Connect to the specified wifi ssid with password. virtual void ConnectToWifiNetwork(const string16& ssid, - const string16& password); + const string16& password, + const string16& identity, + const string16& certpath); // Forget the passed in wifi network. virtual void ForgetWifiNetwork(const WifiNetwork& network); diff --git a/chrome/browser/chromeos/login/network_screen.cc b/chrome/browser/chromeos/login/network_screen.cc index 7468e70..c0c86bb 100644 --- a/chrome/browser/chromeos/login/network_screen.cc +++ b/chrome/browser/chromeos/login/network_screen.cc @@ -152,7 +152,8 @@ void NetworkScreen::ConnectToNetwork(NetworkList::NetworkType type, return; } else { chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> - ConnectToWifiNetwork(network->wifi_network, string16()); + ConnectToWifiNetwork(network->wifi_network, + string16(), string16(), string16()); } } else if (NetworkList::NETWORK_CELLULAR == network->network_type) { chromeos::CrosLibrary::Get()->GetNetworkLibrary()-> diff --git a/chrome/browser/chromeos/options/internet_page_view.cc b/chrome/browser/chromeos/options/internet_page_view.cc index 5559063..25b957d 100644 --- a/chrome/browser/chromeos/options/internet_page_view.cc +++ b/chrome/browser/chromeos/options/internet_page_view.cc @@ -363,8 +363,7 @@ void WirelessSection::ButtonClicked(int button, int connection_type, int id) { view->SetLoginTextfieldFocus(); } else { CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( - wifi_networks_[id], - string16()); + wifi_networks_[id], string16(), string16(), string16()); } } else if (button == DISCONNECT_BUTTON) { // TODO(chocobo): Disconnect from wifi network diff --git a/chrome/browser/chromeos/options/network_config_view.cc b/chrome/browser/chromeos/options/network_config_view.cc index b8211c5..6b0a93c 100644 --- a/chrome/browser/chromeos/options/network_config_view.cc +++ b/chrome/browser/chromeos/options/network_config_view.cc @@ -6,7 +6,6 @@ #include "app/l10n_util.h" #include "base/string_util.h" -#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/options/ip_config_view.h" #include "chrome/browser/chromeos/options/wifi_config_view.h" #include "grit/chromium_strings.h" @@ -73,17 +72,8 @@ bool NetworkConfigView::Cancel() { } bool NetworkConfigView::Accept() { - if (flags_ & FLAG_LOGIN_ONLY) { - if (flags_ & FLAG_OTHER_NETWORK) { - CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( - wificonfig_view_->GetSSID(), wificonfig_view_->GetPassphrase()); - } else { - CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork(wifi_, - wificonfig_view_->GetPassphrase()); - } - } else { - // TODO(chocobo): Save new ip config data and/or save new passphrase. - } + if (flags_ & FLAG_WIFI) + return wificonfig_view_->Accept(); return true; } diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index ea0739e..e042391 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -7,12 +7,14 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/options/network_config_view.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "grit/theme_resources.h" #include "views/controls/button/image_button.h" +#include "views/controls/button/native_button.h" #include "views/controls/label.h" #include "views/grid_layout.h" #include "views/standard_layout.h" @@ -29,7 +31,11 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork wifi) can_login_(false), wifi_(wifi), ssid_textfield_(NULL), - passphrase_textfield_(NULL) { + identity_textfield_(NULL), + certificate_browse_button_(NULL), + certificate_path_(), + passphrase_textfield_(NULL), + passphrase_visible_button_(NULL) { Init(); } @@ -38,12 +44,15 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent) other_network_(true), can_login_(false), ssid_textfield_(NULL), - passphrase_textfield_(NULL) { + identity_textfield_(NULL), + certificate_browse_button_(NULL), + certificate_path_(), + passphrase_textfield_(NULL), + passphrase_visible_button_(NULL) { Init(); } -void WifiConfigView::ContentsChanged(views::Textfield* sender, - const string16& new_contents) { +void WifiConfigView::UpdateCanLogin(void) { bool can_login = true; if (other_network_) { // Since the user can try to connect to a non-encrypted hidden network, @@ -52,6 +61,9 @@ void WifiConfigView::ContentsChanged(views::Textfield* sender, } else { // Connecting to an encrypted network, so make sure passphrase is non-empty. can_login = !passphrase_textfield_->text().empty(); + if (identity_textfield_ != NULL) + can_login = !identity_textfield_->text().empty() && + !certificate_path_.empty(); } // Update the login button enable/disable state if can_login_ changes. @@ -61,11 +73,50 @@ void WifiConfigView::ContentsChanged(views::Textfield* sender, } } +void WifiConfigView::ContentsChanged(views::Textfield* sender, + const string16& new_contents) { + UpdateCanLogin(); +} + void WifiConfigView::ButtonPressed(views::Button* sender, const views::Event& event) { - // We only have one button to toggle password visible. - if (passphrase_textfield_) - passphrase_textfield_->SetPassword(!passphrase_textfield_->IsPassword()); + if (sender == passphrase_visible_button_) { + if (passphrase_textfield_) + passphrase_textfield_->SetPassword(!passphrase_textfield_->IsPassword()); + } else if (sender == certificate_browse_button_) { + select_file_dialog_ = SelectFileDialog::Create(this); + select_file_dialog_->SelectFile(SelectFileDialog::SELECT_OPEN_FILE, + string16(), FilePath(), NULL, 0, + std::string(), NULL, NULL); + } else { + NOTREACHED(); + } +} + +void WifiConfigView::FileSelected(const FilePath& path, + int index, void* params) { + certificate_path_ = path; + certificate_browse_button_->SetLabel(path.BaseName().ToWStringHack()); + UpdateCanLogin(); // TODO(njw) Check if the passphrase decrypts the key. +} + +bool WifiConfigView::Accept() { + string16 identity_string, certificate_path_string; + + if (identity_textfield_ != NULL) { + identity_string = identity_textfield_->text(); + certificate_path_string = WideToUTF16(certificate_path_.ToWStringHack()); + } + if (other_network_) { + CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( + ssid_textfield_->text(), passphrase_textfield_->text(), + identity_string, certificate_path_string); + } else { + CrosLibrary::Get()->GetNetworkLibrary()->ConnectToWifiNetwork( + wifi_, passphrase_textfield_->text(), + identity_string, certificate_path_string); + } + return true; } const string16& WifiConfigView::GetSSID() const { @@ -79,6 +130,8 @@ const string16& WifiConfigView::GetPassphrase() const { void WifiConfigView::FocusFirstField() { if (ssid_textfield_) ssid_textfield_->RequestFocus(); + else if (identity_textfield_) + identity_textfield_->RequestFocus(); else if (passphrase_textfield_) passphrase_textfield_->RequestFocus(); } @@ -113,11 +166,39 @@ void WifiConfigView::Init() { } layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + // Add ID and cert password if we're using 802.1x + // XXX we're cheating and assuming 802.1x means EAP-TLS - not true + // in general, but very common. WPA Supplicant doesn't report the + // EAP type because it's unknown until the process begins, and we'd + // need some kind of callback. + if (wifi_.encrypted && wifi_.encryption == SECURITY_8021X) { + layout->StartRow(0, column_view_set_id); + layout->AddView(new views::Label(l10n_util::GetString( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY))); + identity_textfield_ = new views::Textfield( + views::Textfield::STYLE_DEFAULT); + identity_textfield_->SetController(this); + layout->AddView(identity_textfield_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + layout->StartRow(0, column_view_set_id); + layout->AddView(new views::Label(l10n_util::GetString( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT))); + certificate_browse_button_ = new views::NativeButton(this, + l10n_util::GetString( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_BUTTON)); + layout->AddView(certificate_browse_button_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + } + // Add passphrase if other_network or wifi is encrypted. if (other_network_ || wifi_.encrypted) { layout->StartRow(0, column_view_set_id); - layout->AddView(new views::Label(l10n_util::GetString( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE))); + int label_text_id; + if (wifi_.encryption == SECURITY_8021X) + label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT; + else + label_text_id = IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE; + layout->AddView(new views::Label(l10n_util::GetString(label_text_id))); passphrase_textfield_ = new views::Textfield( views::Textfield::STYLE_PASSWORD); passphrase_textfield_->SetController(this); @@ -125,13 +206,13 @@ void WifiConfigView::Init() { passphrase_textfield_->SetText(UTF8ToUTF16(wifi_.passphrase)); layout->AddView(passphrase_textfield_); // Password visible button. - views::ImageButton* button = new views::ImageButton(this); - button->SetImage(views::ImageButton::BS_NORMAL, - ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_STATUSBAR_NETWORK_SECURE)); - button->SetImageAlignment(views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_MIDDLE); - layout->AddView(button); + passphrase_visible_button_ = new views::ImageButton(this); + passphrase_visible_button_->SetImage(views::ImageButton::BS_NORMAL, + ResourceBundle::GetSharedInstance(). + GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); + passphrase_visible_button_->SetImageAlignment( + views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); + layout->AddView(passphrase_visible_button_); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); } } diff --git a/chrome/browser/chromeos/options/wifi_config_view.h b/chrome/browser/chromeos/options/wifi_config_view.h index baec65f..4fbd28e 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.h +++ b/chrome/browser/chromeos/options/wifi_config_view.h @@ -7,9 +7,13 @@ #include <string> +#include "base/file_path.h" #include "base/string16.h" #include "chrome/browser/chromeos/cros/network_library.h" +#include "chrome/browser/shell_dialogs.h" #include "views/controls/button/button.h" +#include "views/controls/button/image_button.h" +#include "views/controls/button/native_button.h" #include "views/controls/textfield/textfield.h" #include "views/view.h" @@ -20,7 +24,8 @@ class NetworkConfigView; // A dialog box for showing a password textfield. class WifiConfigView : public views::View, public views::Textfield::Controller, - public views::ButtonListener { + public views::ButtonListener, + public SelectFileDialog::Listener { public: WifiConfigView(NetworkConfigView* parent, WifiNetwork wifi); explicit WifiConfigView(NetworkConfigView* parent); @@ -37,6 +42,11 @@ class WifiConfigView : public views::View, // views::ButtonListener virtual void ButtonPressed(views::Button* sender, const views::Event& event); + // SelectFileDialog::Listener implementation. + virtual void FileSelected(const FilePath& path, int index, void* params); + + virtual bool Accept(); + // Get the typed in ssid. const string16& GetSSID() const; // Get the typed in passphrase. @@ -52,6 +62,8 @@ class WifiConfigView : public views::View, // Initializes UI. void Init(); + void UpdateCanLogin(); + NetworkConfigView* parent_; bool other_network_; @@ -63,7 +75,12 @@ class WifiConfigView : public views::View, WifiNetwork wifi_; views::Textfield* ssid_textfield_; + views::Textfield* identity_textfield_; + views::NativeButton* certificate_browse_button_; + scoped_refptr<SelectFileDialog> select_file_dialog_; + FilePath certificate_path_; views::Textfield* passphrase_textfield_; + views::ImageButton* passphrase_visible_button_; DISALLOW_COPY_AND_ASSIGN(WifiConfigView); }; diff --git a/chrome/browser/chromeos/status/network_menu_button.cc b/chrome/browser/chromeos/status/network_menu_button.cc index 075ef69..8cb7eba 100644 --- a/chrome/browser/chromeos/status/network_menu_button.cc +++ b/chrome/browser/chromeos/status/network_menu_button.cc @@ -130,7 +130,7 @@ void NetworkMenuButton::ActivatedAt(int index) { // If wifi network is not encrypted, then directly connect. // Otherwise, we open password dialog window. if (!wifi.encrypted) { - cros->ConnectToWifiNetwork(wifi, string16()); + cros->ConnectToWifiNetwork(wifi, string16(), string16(), string16()); } else { NetworkConfigView* view = new NetworkConfigView(wifi, true); views::Window* window = views::Window::CreateChromeWindow( |