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/cros/network_library.h" | 10 #include "chrome/browser/chromeos/cros/network_library.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 DISALLOW_COPY_AND_ASSIGN(ComboboxWithWidth); | 180 DISALLOW_COPY_AND_ASSIGN(ComboboxWithWidth); |
181 }; | 181 }; |
182 | 182 |
183 class ServerCACertComboboxModel : public ui::ComboboxModel { | 183 class ServerCACertComboboxModel : public ui::ComboboxModel { |
184 public: | 184 public: |
185 explicit ServerCACertComboboxModel(CertLibrary* cert_library) | 185 explicit ServerCACertComboboxModel(CertLibrary* cert_library) |
186 : cert_library_(cert_library) { | 186 : cert_library_(cert_library) { |
187 DCHECK(cert_library); | 187 DCHECK(cert_library); |
188 } | 188 } |
189 virtual ~ServerCACertComboboxModel() {} | 189 virtual ~ServerCACertComboboxModel() {} |
190 virtual int GetItemCount() { | 190 virtual int GetItemCount() { |
zel
2011/12/02 00:07:23
if (!UserManager::Get()->user_is_logged_in())
re
| |
191 if (!cert_library_->CertificatesLoaded()) | 191 // First "Default", then the certs (if any), then "Do not check". |
192 return 1; // "Loading" | |
193 // First "Default", then the certs, then "Do not check". | |
194 return cert_library_->GetCACertificates().Size() + 2; | 192 return cert_library_->GetCACertificates().Size() + 2; |
195 } | 193 } |
196 virtual string16 GetItemAt(int combo_index) { | 194 virtual string16 GetItemAt(int combo_index) { |
197 if (!cert_library_->CertificatesLoaded()) | |
198 return l10n_util::GetStringUTF16( | |
199 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | |
200 if (combo_index == 0) | 195 if (combo_index == 0) |
201 return l10n_util::GetStringUTF16( | 196 return l10n_util::GetStringUTF16( |
202 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); | 197 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); |
203 if (combo_index == GetItemCount() - 1) | 198 if (combo_index == GetItemCount() - 1) |
204 return l10n_util::GetStringUTF16( | 199 return l10n_util::GetStringUTF16( |
205 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DO_NOT_CHECK); | 200 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DO_NOT_CHECK); |
206 int cert_index = combo_index - 1; | 201 int cert_index = combo_index - 1; |
207 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); | 202 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); |
208 } | 203 } |
209 | 204 |
210 private: | 205 private: |
211 CertLibrary* cert_library_; | 206 CertLibrary* cert_library_; |
212 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); | 207 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); |
213 }; | 208 }; |
214 | 209 |
215 class UserCertComboboxModel : public ui::ComboboxModel { | 210 class UserCertComboboxModel : public ui::ComboboxModel { |
216 public: | 211 public: |
217 explicit UserCertComboboxModel(CertLibrary* cert_library) | 212 explicit UserCertComboboxModel(CertLibrary* cert_library) |
218 : cert_library_(cert_library) { | 213 : cert_library_(cert_library) { |
219 DCHECK(cert_library); | 214 DCHECK(cert_library); |
220 } | 215 } |
221 virtual ~UserCertComboboxModel() {} | 216 virtual ~UserCertComboboxModel() {} |
222 virtual int GetItemCount() { | 217 virtual int GetItemCount() { |
zel
2011/12/02 00:07:23
if (!UserManager::Get()->user_is_logged_in())
re
stevenjb
2011/12/02 01:26:33
This should now return "None installed" when not l
| |
223 if (!cert_library_->CertificatesLoaded()) | 218 if (!cert_library_->CertificatesLoaded()) |
224 return 1; // "Loading" | 219 return 1; // "Loading" |
225 int num_certs = cert_library_->GetUserCertificates().Size(); | 220 int num_certs = cert_library_->GetUserCertificates().Size(); |
226 if (num_certs == 0) | 221 if (num_certs == 0) |
227 return 1; // "None installed" | 222 return 1; // "None installed" |
228 return num_certs; | 223 return num_certs; |
229 } | 224 } |
230 virtual string16 GetItemAt(int combo_index) { | 225 virtual string16 GetItemAt(int combo_index) { |
231 if (!cert_library_->CertificatesLoaded()) | 226 if (!cert_library_->CertificatesLoaded()) |
232 return l10n_util::GetStringUTF16( | 227 return l10n_util::GetStringUTF16( |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 passphrase_ui_data_.editable()); | 377 passphrase_ui_data_.editable()); |
383 passphrase_label_->SetEnabled(passphrase_textfield_->IsEnabled()); | 378 passphrase_label_->SetEnabled(passphrase_textfield_->IsEnabled()); |
384 if (!passphrase_textfield_->IsEnabled()) | 379 if (!passphrase_textfield_->IsEnabled()) |
385 passphrase_textfield_->SetText(string16()); | 380 passphrase_textfield_->SetText(string16()); |
386 | 381 |
387 // User certs only for EAP-TLS | 382 // User certs only for EAP-TLS |
388 bool certs_loading = !cert_library_->CertificatesLoaded(); | 383 bool certs_loading = !cert_library_->CertificatesLoaded(); |
389 bool user_cert_enabled = (selected == EAP_METHOD_INDEX_TLS); | 384 bool user_cert_enabled = (selected == EAP_METHOD_INDEX_TLS); |
390 user_cert_label_->SetEnabled(user_cert_enabled); | 385 user_cert_label_->SetEnabled(user_cert_enabled); |
391 bool have_user_certs = !certs_loading && HaveUserCerts(); | 386 bool have_user_certs = !certs_loading && HaveUserCerts(); |
392 user_cert_combobox_->SetEnabled(user_cert_enabled && | 387 user_cert_combobox_->SetEnabled(user_cert_enabled && |
zel
2011/12/02 00:07:23
disable this if user is not logged in by adding co
stevenjb
2011/12/02 01:26:33
HaveUserCerts() will now return false, so this wil
| |
393 have_user_certs && | 388 have_user_certs && |
394 user_cert_ui_data_.editable()); | 389 user_cert_ui_data_.editable()); |
395 user_cert_combobox_->ModelChanged(); | 390 user_cert_combobox_->ModelChanged(); |
396 user_cert_combobox_->SetSelectedItem(0); | 391 user_cert_combobox_->SetSelectedItem(0); |
397 | 392 |
398 // No server CA certs for LEAP | 393 // No server CA certs for LEAP |
399 bool ca_cert_enabled = | 394 bool ca_cert_enabled = |
400 (selected != EAP_METHOD_INDEX_NONE && selected != EAP_METHOD_INDEX_LEAP); | 395 (selected != EAP_METHOD_INDEX_NONE && selected != EAP_METHOD_INDEX_LEAP); |
401 server_ca_cert_label_->SetEnabled(ca_cert_enabled); | 396 server_ca_cert_label_->SetEnabled(ca_cert_enabled); |
402 server_ca_cert_combobox_->SetEnabled(ca_cert_enabled && | 397 server_ca_cert_combobox_->SetEnabled(ca_cert_enabled && |
zel
2011/12/02 00:07:23
disable this if user is not logged in by adding co
stevenjb
2011/12/02 01:26:33
We should probably leave this enabled in case user
| |
403 !certs_loading && | |
404 server_ca_cert_ui_data_.editable()); | 398 server_ca_cert_ui_data_.editable()); |
405 server_ca_cert_combobox_->ModelChanged(); | 399 server_ca_cert_combobox_->ModelChanged(); |
406 server_ca_cert_combobox_->SetSelectedItem(0); | 400 server_ca_cert_combobox_->SetSelectedItem(0); |
407 | 401 |
408 // No anonymous identity if no phase 2 auth. | 402 // No anonymous identity if no phase 2 auth. |
409 identity_anonymous_textfield_->SetEnabled( | 403 identity_anonymous_textfield_->SetEnabled( |
410 phase_2_auth_combobox_->IsEnabled() && | 404 phase_2_auth_combobox_->IsEnabled() && |
411 identity_anonymous_ui_data_.editable()); | 405 identity_anonymous_ui_data_.editable()); |
412 identity_anonymous_label_->SetEnabled( | 406 identity_anonymous_label_->SetEnabled( |
413 identity_anonymous_textfield_->IsEnabled()); | 407 identity_anonymous_textfield_->IsEnabled()); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1129 // Set focus to a reasonable widget, depending on what we're showing. | 1123 // Set focus to a reasonable widget, depending on what we're showing. |
1130 if (ssid_textfield_) | 1124 if (ssid_textfield_) |
1131 ssid_textfield_->RequestFocus(); | 1125 ssid_textfield_->RequestFocus(); |
1132 else if (eap_method_combobox_) | 1126 else if (eap_method_combobox_) |
1133 eap_method_combobox_->RequestFocus(); | 1127 eap_method_combobox_->RequestFocus(); |
1134 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) | 1128 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) |
1135 passphrase_textfield_->RequestFocus(); | 1129 passphrase_textfield_->RequestFocus(); |
1136 } | 1130 } |
1137 | 1131 |
1138 } // namespace chromeos | 1132 } // namespace chromeos |
OLD | NEW |