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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() { |
191 if (!cert_library_->CertificatesLoaded()) | 191 if (cert_library_->CertificatesLoading()) |
192 return 1; // "Loading" | 192 return 1; // "Loading" |
193 // First "Default", then the certs, then "Do not check". | 193 // First "Default", then the certs, then "Do not check". |
194 return cert_library_->GetCACertificates().Size() + 2; | 194 return cert_library_->GetCACertificates().Size() + 2; |
195 } | 195 } |
196 virtual string16 GetItemAt(int combo_index) { | 196 virtual string16 GetItemAt(int combo_index) { |
197 if (!cert_library_->CertificatesLoaded()) | 197 if (cert_library_->CertificatesLoading()) |
198 return l10n_util::GetStringUTF16( | 198 return l10n_util::GetStringUTF16( |
199 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 199 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
200 if (combo_index == 0) | 200 if (combo_index == 0) |
201 return l10n_util::GetStringUTF16( | 201 return l10n_util::GetStringUTF16( |
202 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); | 202 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); |
203 if (combo_index == GetItemCount() - 1) | 203 if (combo_index == GetItemCount() - 1) |
204 return l10n_util::GetStringUTF16( | 204 return l10n_util::GetStringUTF16( |
205 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DO_NOT_CHECK); | 205 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DO_NOT_CHECK); |
206 int cert_index = combo_index - 1; | 206 int cert_index = combo_index - 1; |
207 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); | 207 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); |
208 } | 208 } |
209 | 209 |
210 private: | 210 private: |
211 CertLibrary* cert_library_; | 211 CertLibrary* cert_library_; |
212 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); | 212 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); |
213 }; | 213 }; |
214 | 214 |
215 class UserCertComboboxModel : public ui::ComboboxModel { | 215 class UserCertComboboxModel : public ui::ComboboxModel { |
216 public: | 216 public: |
217 explicit UserCertComboboxModel(CertLibrary* cert_library) | 217 explicit UserCertComboboxModel(CertLibrary* cert_library) |
218 : cert_library_(cert_library) { | 218 : cert_library_(cert_library) { |
219 DCHECK(cert_library); | 219 DCHECK(cert_library); |
220 } | 220 } |
221 virtual ~UserCertComboboxModel() {} | 221 virtual ~UserCertComboboxModel() {} |
222 virtual int GetItemCount() { | 222 virtual int GetItemCount() { |
223 if (!cert_library_->CertificatesLoaded()) | 223 if (cert_library_->CertificatesLoading()) |
224 return 1; // "Loading" | 224 return 1; // "Loading" |
225 int num_certs = cert_library_->GetUserCertificates().Size(); | 225 int num_certs = cert_library_->GetUserCertificates().Size(); |
226 if (num_certs == 0) | 226 if (num_certs == 0) |
227 return 1; // "None installed" | 227 return 1; // "None installed" |
228 return num_certs; | 228 return num_certs; |
229 } | 229 } |
230 virtual string16 GetItemAt(int combo_index) { | 230 virtual string16 GetItemAt(int combo_index) { |
231 if (!cert_library_->CertificatesLoaded()) | 231 if (cert_library_->CertificatesLoading()) |
232 return l10n_util::GetStringUTF16( | 232 return l10n_util::GetStringUTF16( |
233 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 233 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
234 if (cert_library_->GetUserCertificates().Size() == 0) | 234 if (cert_library_->GetUserCertificates().Size() == 0) |
235 return l10n_util::GetStringUTF16( | 235 return l10n_util::GetStringUTF16( |
236 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 236 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
237 return cert_library_->GetUserCertificates().GetDisplayStringAt(combo_index); | 237 return cert_library_->GetUserCertificates().GetDisplayStringAt(combo_index); |
238 } | 238 } |
239 | 239 |
240 private: | 240 private: |
241 CertLibrary* cert_library_; | 241 CertLibrary* cert_library_; |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 // No password for EAP-TLS | 379 // No password for EAP-TLS |
380 passphrase_textfield_->SetEnabled(selected != EAP_METHOD_INDEX_NONE && | 380 passphrase_textfield_->SetEnabled(selected != EAP_METHOD_INDEX_NONE && |
381 selected != EAP_METHOD_INDEX_TLS && | 381 selected != EAP_METHOD_INDEX_TLS && |
382 passphrase_ui_data_.editable()); | 382 passphrase_ui_data_.editable()); |
383 passphrase_label_->SetEnabled(passphrase_textfield_->IsEnabled()); | 383 passphrase_label_->SetEnabled(passphrase_textfield_->IsEnabled()); |
384 if (!passphrase_textfield_->IsEnabled()) | 384 if (!passphrase_textfield_->IsEnabled()) |
385 passphrase_textfield_->SetText(string16()); | 385 passphrase_textfield_->SetText(string16()); |
386 | 386 |
387 // User certs only for EAP-TLS | 387 // User certs only for EAP-TLS |
388 bool certs_loading = !cert_library_->CertificatesLoaded(); | 388 bool certs_loading = cert_library_->CertificatesLoading(); |
389 bool user_cert_enabled = (selected == EAP_METHOD_INDEX_TLS); | 389 bool user_cert_enabled = (selected == EAP_METHOD_INDEX_TLS); |
390 user_cert_label_->SetEnabled(user_cert_enabled); | 390 user_cert_label_->SetEnabled(user_cert_enabled); |
391 bool have_user_certs = !certs_loading && HaveUserCerts(); | 391 bool have_user_certs = !certs_loading && HaveUserCerts(); |
392 user_cert_combobox_->SetEnabled(user_cert_enabled && | 392 user_cert_combobox_->SetEnabled(user_cert_enabled && |
393 have_user_certs && | 393 have_user_certs && |
394 user_cert_ui_data_.editable()); | 394 user_cert_ui_data_.editable()); |
395 user_cert_combobox_->ModelChanged(); | 395 user_cert_combobox_->ModelChanged(); |
396 user_cert_combobox_->SetSelectedItem(0); | 396 user_cert_combobox_->SetSelectedItem(0); |
397 | 397 |
398 // No server CA certs for LEAP | 398 // No server CA certs for LEAP |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 // Set focus to a reasonable widget, depending on what we're showing. | 1129 // Set focus to a reasonable widget, depending on what we're showing. |
1130 if (ssid_textfield_) | 1130 if (ssid_textfield_) |
1131 ssid_textfield_->RequestFocus(); | 1131 ssid_textfield_->RequestFocus(); |
1132 else if (eap_method_combobox_) | 1132 else if (eap_method_combobox_) |
1133 eap_method_combobox_->RequestFocus(); | 1133 eap_method_combobox_->RequestFocus(); |
1134 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) | 1134 else if (passphrase_textfield_ && passphrase_textfield_->IsEnabled()) |
1135 passphrase_textfield_->RequestFocus(); | 1135 passphrase_textfield_->RequestFocus(); |
1136 } | 1136 } |
1137 | 1137 |
1138 } // namespace chromeos | 1138 } // namespace chromeos |
OLD | NEW |