| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/options/wifi_config_view.h" | 5 #include "chrome/browser/chromeos/options/wifi_config_view.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/chromeos/cros/cros_library.h" | 9 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 10 #include "chrome/browser/chromeos/login/user_manager.h" | 10 #include "chrome/browser/chromeos/login/user_manager.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Returns true if network is known to require 802.1x. | 30 // Returns true if network is known to require 802.1x. |
| 31 bool Is8021x(const WifiNetwork* wifi) { | 31 bool Is8021x(const WifiNetwork* wifi) { |
| 32 return wifi && wifi->encrypted() && wifi->encryption() == SECURITY_8021X; | 32 return wifi && wifi->encrypted() && wifi->encryption() == SECURITY_8021X; |
| 33 } | 33 } |
| 34 | 34 |
| 35 enum SecurityComboboxIndex { | 35 enum SecurityComboboxIndex { |
| 36 SECURITY_INDEX_NONE = 0, | 36 SECURITY_INDEX_NONE = 0, |
| 37 SECURITY_INDEX_WEP = 1, | 37 SECURITY_INDEX_WEP = 1, |
| 38 SECURITY_INDEX_WPA = 2, | 38 SECURITY_INDEX_PSK = 2, |
| 39 SECURITY_INDEX_RSN = 3, | 39 SECURITY_INDEX_COUNT = 3 |
| 40 SECURITY_INDEX_COUNT = 4 | |
| 41 }; | 40 }; |
| 42 | 41 |
| 43 class SecurityComboboxModel : public ui::ComboboxModel { | 42 class SecurityComboboxModel : public ui::ComboboxModel { |
| 44 public: | 43 public: |
| 45 SecurityComboboxModel() {} | 44 SecurityComboboxModel() {} |
| 46 virtual ~SecurityComboboxModel() {} | 45 virtual ~SecurityComboboxModel() {} |
| 47 virtual int GetItemCount() { | 46 virtual int GetItemCount() { |
| 48 return SECURITY_INDEX_COUNT; | 47 return SECURITY_INDEX_COUNT; |
| 49 } | 48 } |
| 50 virtual string16 GetItemAt(int index) { | 49 virtual string16 GetItemAt(int index) { |
| 51 if (index == SECURITY_INDEX_NONE) | 50 if (index == SECURITY_INDEX_NONE) |
| 52 return l10n_util::GetStringUTF16( | 51 return l10n_util::GetStringUTF16( |
| 53 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE); | 52 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE); |
| 54 else if (index == SECURITY_INDEX_WEP) | 53 else if (index == SECURITY_INDEX_WEP) |
| 55 return l10n_util::GetStringUTF16( | 54 return l10n_util::GetStringUTF16( |
| 56 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP); | 55 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP); |
| 57 else if (index == SECURITY_INDEX_WPA) | 56 else if (index == SECURITY_INDEX_PSK) |
| 58 return l10n_util::GetStringUTF16( | 57 return l10n_util::GetStringUTF16( |
| 59 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WPA); | 58 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_PSK); |
| 60 else if (index == SECURITY_INDEX_RSN) | |
| 61 return l10n_util::GetStringUTF16( | |
| 62 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_RSN); | |
| 63 NOTREACHED(); | 59 NOTREACHED(); |
| 64 return string16(); | 60 return string16(); |
| 65 } | 61 } |
| 66 private: | 62 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(SecurityComboboxModel); | 63 DISALLOW_COPY_AND_ASSIGN(SecurityComboboxModel); |
| 68 }; | 64 }; |
| 69 | 65 |
| 70 // Methods in alphabetical order. | 66 // Methods in alphabetical order. |
| 71 enum EAPMethodComboboxIndex { | 67 enum EAPMethodComboboxIndex { |
| 72 EAP_METHOD_INDEX_NONE = 0, | 68 EAP_METHOD_INDEX_NONE = 0, |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 if (!eap_method_combobox_) { | 430 if (!eap_method_combobox_) { |
| 435 // Hidden ordinary Wi-Fi connection. | 431 // Hidden ordinary Wi-Fi connection. |
| 436 ConnectionSecurity sec = SECURITY_UNKNOWN; | 432 ConnectionSecurity sec = SECURITY_UNKNOWN; |
| 437 switch (security_combobox_->selected_item()) { | 433 switch (security_combobox_->selected_item()) { |
| 438 case SECURITY_INDEX_NONE: | 434 case SECURITY_INDEX_NONE: |
| 439 sec = SECURITY_NONE; | 435 sec = SECURITY_NONE; |
| 440 break; | 436 break; |
| 441 case SECURITY_INDEX_WEP: | 437 case SECURITY_INDEX_WEP: |
| 442 sec = SECURITY_WEP; | 438 sec = SECURITY_WEP; |
| 443 break; | 439 break; |
| 444 case SECURITY_INDEX_WPA: | 440 case SECURITY_INDEX_PSK: |
| 445 sec = SECURITY_WPA; | 441 sec = SECURITY_PSK; |
| 446 break; | |
| 447 case SECURITY_INDEX_RSN: | |
| 448 sec = SECURITY_RSN; | |
| 449 break; | 442 break; |
| 450 } | 443 } |
| 451 cros->ConnectToWifiNetwork(GetSsid(), sec, GetPassphrase()); | 444 cros->ConnectToWifiNetwork(GetSsid(), sec, GetPassphrase()); |
| 452 } else { | 445 } else { |
| 453 // Hidden 802.1X EAP Wi-Fi connection. | 446 // Hidden 802.1X EAP Wi-Fi connection. |
| 454 cros->ConnectToWifiNetwork8021x( | 447 cros->ConnectToWifiNetwork8021x( |
| 455 GetSsid(), GetEapMethod(), GetEapPhase2Auth(), | 448 GetSsid(), GetEapMethod(), GetEapPhase2Auth(), |
| 456 GetEapServerCaCertNssNickname(), GetEapUseSystemCas(), | 449 GetEapServerCaCertNssNickname(), GetEapUseSystemCas(), |
| 457 GetEapClientCertPkcs11Id(), GetEapIdentity(), | 450 GetEapClientCertPkcs11Id(), GetEapIdentity(), |
| 458 GetEapAnonymousIdentity(), GetPassphrase(), | 451 GetEapAnonymousIdentity(), GetPassphrase(), |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 // Set focus to a reasonable widget, depending on what we're showing. | 898 // Set focus to a reasonable widget, depending on what we're showing. |
| 906 if (ssid_textfield_) | 899 if (ssid_textfield_) |
| 907 ssid_textfield_->RequestFocus(); | 900 ssid_textfield_->RequestFocus(); |
| 908 else if (eap_method_combobox_) | 901 else if (eap_method_combobox_) |
| 909 eap_method_combobox_->RequestFocus(); | 902 eap_method_combobox_->RequestFocus(); |
| 910 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) | 903 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) |
| 911 passphrase_textfield_->RequestFocus(); | 904 passphrase_textfield_->RequestFocus(); |
| 912 } | 905 } |
| 913 | 906 |
| 914 } // namespace chromeos | 907 } // namespace chromeos |
| OLD | NEW |