Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1399)

Side by Side Diff: chrome/browser/chromeos/options/wifi_config_view.cc

Issue 14522013: Separate cert loading code from CertLibrary and move to src/chromeos (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 virtual string16 GetItemAt(int index) OVERRIDE; 125 virtual string16 GetItemAt(int index) OVERRIDE;
126 126
127 private: 127 private:
128 views::Combobox* eap_method_combobox_; 128 views::Combobox* eap_method_combobox_;
129 129
130 DISALLOW_COPY_AND_ASSIGN(Phase2AuthComboboxModel); 130 DISALLOW_COPY_AND_ASSIGN(Phase2AuthComboboxModel);
131 }; 131 };
132 132
133 class ServerCACertComboboxModel : public ui::ComboboxModel { 133 class ServerCACertComboboxModel : public ui::ComboboxModel {
134 public: 134 public:
135 explicit ServerCACertComboboxModel(CertLibrary* cert_library); 135 ServerCACertComboboxModel();
136 virtual ~ServerCACertComboboxModel(); 136 virtual ~ServerCACertComboboxModel();
137 137
138 // Overridden from ui::ComboboxModel: 138 // Overridden from ui::ComboboxModel:
139 virtual int GetItemCount() const OVERRIDE; 139 virtual int GetItemCount() const OVERRIDE;
140 virtual string16 GetItemAt(int index) OVERRIDE; 140 virtual string16 GetItemAt(int index) OVERRIDE;
141 141
142 private: 142 private:
143 CertLibrary* cert_library_;
144 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); 143 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel);
145 }; 144 };
146 145
147 class UserCertComboboxModel : public ui::ComboboxModel { 146 class UserCertComboboxModel : public ui::ComboboxModel {
148 public: 147 public:
149 explicit UserCertComboboxModel(CertLibrary* cert_library); 148 UserCertComboboxModel();
150 virtual ~UserCertComboboxModel(); 149 virtual ~UserCertComboboxModel();
151 150
152 // Overridden from ui::ComboboxModel: 151 // Overridden from ui::ComboboxModel:
153 virtual int GetItemCount() const OVERRIDE; 152 virtual int GetItemCount() const OVERRIDE;
154 virtual string16 GetItemAt(int index) OVERRIDE; 153 virtual string16 GetItemAt(int index) OVERRIDE;
155 154
156 private: 155 private:
157 CertLibrary* cert_library_;
158
159 DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel); 156 DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel);
160 }; 157 };
161 158
162 // SecurityComboboxModel ------------------------------------------------------- 159 // SecurityComboboxModel -------------------------------------------------------
163 160
164 SecurityComboboxModel::SecurityComboboxModel() { 161 SecurityComboboxModel::SecurityComboboxModel() {
165 } 162 }
166 163
167 SecurityComboboxModel::~SecurityComboboxModel() { 164 SecurityComboboxModel::~SecurityComboboxModel() {
168 } 165 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_PAP); 255 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_PAP);
259 else if (index == PHASE_2_AUTH_INDEX_CHAP) 256 else if (index == PHASE_2_AUTH_INDEX_CHAP)
260 return l10n_util::GetStringUTF16( 257 return l10n_util::GetStringUTF16(
261 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_CHAP); 258 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PHASE_2_AUTH_CHAP);
262 NOTREACHED(); 259 NOTREACHED();
263 return string16(); 260 return string16();
264 } 261 }
265 262
266 // ServerCACertComboboxModel --------------------------------------------------- 263 // ServerCACertComboboxModel ---------------------------------------------------
267 264
268 ServerCACertComboboxModel::ServerCACertComboboxModel(CertLibrary* cert_library) 265 ServerCACertComboboxModel::ServerCACertComboboxModel() {
269 : cert_library_(cert_library) {
270 DCHECK(cert_library);
271 } 266 }
272 267
273 ServerCACertComboboxModel::~ServerCACertComboboxModel() { 268 ServerCACertComboboxModel::~ServerCACertComboboxModel() {
274 } 269 }
275 270
276 int ServerCACertComboboxModel::GetItemCount() const { 271 int ServerCACertComboboxModel::GetItemCount() const {
277 if (cert_library_->CertificatesLoading()) 272 if (CertLibrary::Get()->CertificatesLoading())
278 return 1; // "Loading" 273 return 1; // "Loading"
279 // First "Default", then the certs, then "Do not check". 274 // First "Default", then the certs, then "Do not check".
280 return cert_library_->GetCACertificates().Size() + 2; 275 return CertLibrary::Get()->NumCertificates(
276 CertLibrary::CERT_TYPE_SERVER_CA) + 2;
281 } 277 }
282 278
283 string16 ServerCACertComboboxModel::GetItemAt(int index) { 279 string16 ServerCACertComboboxModel::GetItemAt(int index) {
284 if (cert_library_->CertificatesLoading()) 280 if (CertLibrary::Get()->CertificatesLoading())
285 return l10n_util::GetStringUTF16( 281 return l10n_util::GetStringUTF16(
286 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); 282 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
287 if (index == 0) 283 if (index == 0)
288 return l10n_util::GetStringUTF16( 284 return l10n_util::GetStringUTF16(
289 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); 285 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT);
290 if (index == GetItemCount() - 1) 286 if (index == GetItemCount() - 1)
291 return l10n_util::GetStringUTF16( 287 return l10n_util::GetStringUTF16(
292 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DO_NOT_CHECK); 288 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DO_NOT_CHECK);
293 int cert_index = index - 1; 289 int cert_index = index - 1;
294 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); 290 return CertLibrary::Get()->GetCertDisplayStringAt(
291 CertLibrary::CERT_TYPE_SERVER_CA, cert_index);
295 } 292 }
296 293
297 // UserCertComboboxModel ------------------------------------------------------- 294 // UserCertComboboxModel -------------------------------------------------------
298 295
299 UserCertComboboxModel::UserCertComboboxModel(CertLibrary* cert_library) 296 UserCertComboboxModel::UserCertComboboxModel() {
300 : cert_library_(cert_library) {
301 DCHECK(cert_library);
302 } 297 }
303 298
304 UserCertComboboxModel::~UserCertComboboxModel() { 299 UserCertComboboxModel::~UserCertComboboxModel() {
305 } 300 }
306 301
307 int UserCertComboboxModel::GetItemCount() const { 302 int UserCertComboboxModel::GetItemCount() const {
308 if (cert_library_->CertificatesLoading()) 303 if (CertLibrary::Get()->CertificatesLoading())
309 return 1; // "Loading" 304 return 1; // "Loading"
310 int num_certs = cert_library_->GetUserCertificates().Size(); 305 int num_certs =
306 CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER);
311 if (num_certs == 0) 307 if (num_certs == 0)
312 return 1; // "None installed" 308 return 1; // "None installed"
313 return num_certs; 309 return num_certs;
314 } 310 }
315 311
316 string16 UserCertComboboxModel::GetItemAt(int index) { 312 string16 UserCertComboboxModel::GetItemAt(int index) {
317 if (cert_library_->CertificatesLoading()) 313 if (CertLibrary::Get()->CertificatesLoading())
318 return l10n_util::GetStringUTF16( 314 return l10n_util::GetStringUTF16(
319 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); 315 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
320 if (cert_library_->GetUserCertificates().Size() == 0) 316 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0)
321 return l10n_util::GetStringUTF16( 317 return l10n_util::GetStringUTF16(
322 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); 318 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED);
323 return cert_library_->GetUserCertificates().GetDisplayStringAt(index); 319 return CertLibrary::Get()->GetCertDisplayStringAt(
320 CertLibrary::CERT_TYPE_USER, index);
324 } 321 }
325 322
326 } // namespace internal 323 } // namespace internal
327 324
328 WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi) 325 WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi)
329 : ChildNetworkConfigView(parent, wifi), 326 : ChildNetworkConfigView(parent, wifi),
330 cert_library_(NULL),
331 ssid_textfield_(NULL), 327 ssid_textfield_(NULL),
332 eap_method_combobox_(NULL), 328 eap_method_combobox_(NULL),
333 phase_2_auth_label_(NULL), 329 phase_2_auth_label_(NULL),
334 phase_2_auth_combobox_(NULL), 330 phase_2_auth_combobox_(NULL),
335 user_cert_label_(NULL), 331 user_cert_label_(NULL),
336 user_cert_combobox_(NULL), 332 user_cert_combobox_(NULL),
337 server_ca_cert_label_(NULL), 333 server_ca_cert_label_(NULL),
338 server_ca_cert_combobox_(NULL), 334 server_ca_cert_combobox_(NULL),
339 identity_label_(NULL), 335 identity_label_(NULL),
340 identity_textfield_(NULL), 336 identity_textfield_(NULL),
341 identity_anonymous_label_(NULL), 337 identity_anonymous_label_(NULL),
342 identity_anonymous_textfield_(NULL), 338 identity_anonymous_textfield_(NULL),
343 save_credentials_checkbox_(NULL), 339 save_credentials_checkbox_(NULL),
344 share_network_checkbox_(NULL), 340 share_network_checkbox_(NULL),
345 shared_network_label_(NULL), 341 shared_network_label_(NULL),
346 security_combobox_(NULL), 342 security_combobox_(NULL),
347 passphrase_label_(NULL), 343 passphrase_label_(NULL),
348 passphrase_textfield_(NULL), 344 passphrase_textfield_(NULL),
349 passphrase_visible_button_(NULL), 345 passphrase_visible_button_(NULL),
350 error_label_(NULL) { 346 error_label_(NULL) {
351 Init(wifi, Is8021x(wifi)); 347 Init(wifi, Is8021x(wifi));
352 } 348 }
353 349
354 WifiConfigView::WifiConfigView(NetworkConfigView* parent, bool show_8021x) 350 WifiConfigView::WifiConfigView(NetworkConfigView* parent, bool show_8021x)
355 : ChildNetworkConfigView(parent), 351 : ChildNetworkConfigView(parent),
356 cert_library_(NULL),
357 ssid_textfield_(NULL), 352 ssid_textfield_(NULL),
358 eap_method_combobox_(NULL), 353 eap_method_combobox_(NULL),
359 phase_2_auth_label_(NULL), 354 phase_2_auth_label_(NULL),
360 phase_2_auth_combobox_(NULL), 355 phase_2_auth_combobox_(NULL),
361 user_cert_label_(NULL), 356 user_cert_label_(NULL),
362 user_cert_combobox_(NULL), 357 user_cert_combobox_(NULL),
363 server_ca_cert_label_(NULL), 358 server_ca_cert_label_(NULL),
364 server_ca_cert_combobox_(NULL), 359 server_ca_cert_combobox_(NULL),
365 identity_label_(NULL), 360 identity_label_(NULL),
366 identity_textfield_(NULL), 361 identity_textfield_(NULL),
367 identity_anonymous_label_(NULL), 362 identity_anonymous_label_(NULL),
368 identity_anonymous_textfield_(NULL), 363 identity_anonymous_textfield_(NULL),
369 save_credentials_checkbox_(NULL), 364 save_credentials_checkbox_(NULL),
370 share_network_checkbox_(NULL), 365 share_network_checkbox_(NULL),
371 shared_network_label_(NULL), 366 shared_network_label_(NULL),
372 security_combobox_(NULL), 367 security_combobox_(NULL),
373 passphrase_label_(NULL), 368 passphrase_label_(NULL),
374 passphrase_textfield_(NULL), 369 passphrase_textfield_(NULL),
375 passphrase_visible_button_(NULL), 370 passphrase_visible_button_(NULL),
376 error_label_(NULL) { 371 error_label_(NULL) {
377 Init(NULL, show_8021x); 372 Init(NULL, show_8021x);
378 } 373 }
379 374
380 WifiConfigView::~WifiConfigView() { 375 WifiConfigView::~WifiConfigView() {
381 if (cert_library_) 376 CertLibrary::Get()->RemoveObserver(this);
382 cert_library_->RemoveObserver(this);
383 } 377 }
384 378
385 views::View* WifiConfigView::GetInitiallyFocusedView() { 379 views::View* WifiConfigView::GetInitiallyFocusedView() {
386 // Return a reasonable widget for initial focus, 380 // Return a reasonable widget for initial focus,
387 // depending on what we're showing. 381 // depending on what we're showing.
388 if (ssid_textfield_) 382 if (ssid_textfield_)
389 return ssid_textfield_; 383 return ssid_textfield_;
390 else if (eap_method_combobox_) 384 else if (eap_method_combobox_)
391 return eap_method_combobox_; 385 return eap_method_combobox_;
392 else if (passphrase_textfield_ && passphrase_textfield_->enabled()) 386 else if (passphrase_textfield_ && passphrase_textfield_->enabled())
(...skipping 21 matching lines...) Expand all
414 return false; 408 return false;
415 409
416 // Block login if certs are required but user has none. 410 // Block login if certs are required but user has none.
417 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) 411 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid()))
418 return false; 412 return false;
419 413
420 return true; 414 return true;
421 } 415 }
422 416
423 bool WifiConfigView::UserCertRequired() const { 417 bool WifiConfigView::UserCertRequired() const {
424 if (!cert_library_)
425 return false; // return false until cert_library_ is initialized.
426 return UserCertActive(); 418 return UserCertActive();
427 } 419 }
428 420
429 bool WifiConfigView::HaveUserCerts() const { 421 bool WifiConfigView::HaveUserCerts() const {
430 return cert_library_->GetUserCertificates().Size() > 0; 422 return CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) > 0;
431 } 423 }
432 424
433 bool WifiConfigView::IsUserCertValid() const { 425 bool WifiConfigView::IsUserCertValid() const {
434 if (!UserCertActive()) 426 if (!UserCertActive())
435 return false; 427 return false;
436 int index = user_cert_combobox_->selected_index(); 428 int index = user_cert_combobox_->selected_index();
437 if (index < 0) 429 if (index < 0)
438 return false; 430 return false;
439 // Currently only hardware-backed user certificates are valid. 431 // Currently only hardware-backed user certificates are valid.
440 if (cert_library_->IsHardwareBacked() && 432 if (CertLibrary::Get()->IsHardwareBacked() &&
441 !cert_library_->GetUserCertificates().IsHardwareBackedAt(index)) 433 !CertLibrary::Get()->IsCertHardwareBackedAt(
434 CertLibrary::CERT_TYPE_USER, index))
442 return false; 435 return false;
443 return true; 436 return true;
444 } 437 }
445 438
446 bool WifiConfigView::Phase2AuthActive() const { 439 bool WifiConfigView::Phase2AuthActive() const {
447 if (phase_2_auth_combobox_) 440 if (phase_2_auth_combobox_)
448 return phase_2_auth_combobox_->model()->GetItemCount() > 1; 441 return phase_2_auth_combobox_->model()->GetItemCount() > 1;
449 return false; 442 return false;
450 } 443 }
451 444
(...skipping 23 matching lines...) Expand all
475 return index != EAP_METHOD_INDEX_NONE && index != EAP_METHOD_INDEX_LEAP; 468 return index != EAP_METHOD_INDEX_NONE && index != EAP_METHOD_INDEX_LEAP;
476 } 469 }
477 return false; 470 return false;
478 } 471 }
479 472
480 void WifiConfigView::UpdateDialogButtons() { 473 void WifiConfigView::UpdateDialogButtons() {
481 parent_->GetDialogClientView()->UpdateDialogButtons(); 474 parent_->GetDialogClientView()->UpdateDialogButtons();
482 } 475 }
483 476
484 void WifiConfigView::RefreshEapFields() { 477 void WifiConfigView::RefreshEapFields() {
485 DCHECK(cert_library_);
486
487 // If EAP method changes, the phase 2 auth choices may have changed also. 478 // If EAP method changes, the phase 2 auth choices may have changed also.
488 phase_2_auth_combobox_->ModelChanged(); 479 phase_2_auth_combobox_->ModelChanged();
489 phase_2_auth_combobox_->SetSelectedIndex(0); 480 phase_2_auth_combobox_->SetSelectedIndex(0);
490 bool phase_2_auth_enabled = Phase2AuthActive(); 481 bool phase_2_auth_enabled = Phase2AuthActive();
491 phase_2_auth_combobox_->SetEnabled(phase_2_auth_enabled && 482 phase_2_auth_combobox_->SetEnabled(phase_2_auth_enabled &&
492 phase_2_auth_ui_data_.editable()); 483 phase_2_auth_ui_data_.editable());
493 phase_2_auth_label_->SetEnabled(phase_2_auth_enabled); 484 phase_2_auth_label_->SetEnabled(phase_2_auth_enabled);
494 485
495 // Passphrase. 486 // Passphrase.
496 bool passphrase_enabled = PassphraseActive(); 487 bool passphrase_enabled = PassphraseActive();
497 passphrase_textfield_->SetEnabled(passphrase_enabled && 488 passphrase_textfield_->SetEnabled(passphrase_enabled &&
498 passphrase_ui_data_.editable()); 489 passphrase_ui_data_.editable());
499 passphrase_label_->SetEnabled(passphrase_enabled); 490 passphrase_label_->SetEnabled(passphrase_enabled);
500 if (!passphrase_enabled) 491 if (!passphrase_enabled)
501 passphrase_textfield_->SetText(string16()); 492 passphrase_textfield_->SetText(string16());
502 493
503 // User cert. 494 // User cert.
504 bool certs_loading = cert_library_->CertificatesLoading(); 495 bool certs_loading = CertLibrary::Get()->CertificatesLoading();
505 bool user_cert_enabled = UserCertActive(); 496 bool user_cert_enabled = UserCertActive();
506 user_cert_label_->SetEnabled(user_cert_enabled); 497 user_cert_label_->SetEnabled(user_cert_enabled);
507 bool have_user_certs = !certs_loading && HaveUserCerts(); 498 bool have_user_certs = !certs_loading && HaveUserCerts();
508 user_cert_combobox_->SetEnabled(user_cert_enabled && 499 user_cert_combobox_->SetEnabled(user_cert_enabled &&
509 have_user_certs && 500 have_user_certs &&
510 user_cert_ui_data_.editable()); 501 user_cert_ui_data_.editable());
511 user_cert_combobox_->ModelChanged(); 502 user_cert_combobox_->ModelChanged();
512 user_cert_combobox_->SetSelectedIndex(0); 503 user_cert_combobox_->SetSelectedIndex(0);
513 504
514 // Server CA. 505 // Server CA.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 share_network_checkbox_->SetEnabled(false); 542 share_network_checkbox_->SetEnabled(false);
552 share_network_checkbox_->SetChecked(true); 543 share_network_checkbox_->SetChecked(true);
553 } else { 544 } else {
554 share_network_checkbox_->SetEnabled(true); 545 share_network_checkbox_->SetEnabled(true);
555 share_network_checkbox_->SetChecked(false); // Default to unshared. 546 share_network_checkbox_->SetChecked(false); // Default to unshared.
556 } 547 }
557 } 548 }
558 549
559 void WifiConfigView::UpdateErrorLabel() { 550 void WifiConfigView::UpdateErrorLabel() {
560 std::string error_msg; 551 std::string error_msg;
561 if (UserCertRequired() && cert_library_->CertificatesLoaded()) { 552 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) {
562 if (!HaveUserCerts()) { 553 if (!HaveUserCerts()) {
563 if (!LoginState::Get()->IsUserLoggedIn()) { 554 if (!LoginState::Get()->IsUserLoggedIn()) {
564 error_msg = l10n_util::GetStringUTF8( 555 error_msg = l10n_util::GetStringUTF8(
565 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT); 556 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN_FOR_USER_CERT);
566 } else { 557 } else {
567 error_msg = l10n_util::GetStringUTF8( 558 error_msg = l10n_util::GetStringUTF8(
568 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); 559 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT);
569 } 560 }
570 } else if (!IsUserCertValid()) { 561 } else if (!IsUserCertValid()) {
571 error_msg = l10n_util::GetStringUTF8( 562 error_msg = l10n_util::GetStringUTF8(
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 return EAP_PHASE_2_AUTH_PAP; 789 return EAP_PHASE_2_AUTH_PAP;
799 case PHASE_2_AUTH_INDEX_CHAP: 790 case PHASE_2_AUTH_INDEX_CHAP:
800 return EAP_PHASE_2_AUTH_CHAP; 791 return EAP_PHASE_2_AUTH_CHAP;
801 default: 792 default:
802 return EAP_PHASE_2_AUTH_AUTO; 793 return EAP_PHASE_2_AUTH_AUTO;
803 } 794 }
804 } 795 }
805 796
806 std::string WifiConfigView::GetEapServerCaCertNssNickname() const { 797 std::string WifiConfigView::GetEapServerCaCertNssNickname() const {
807 DCHECK(server_ca_cert_combobox_); 798 DCHECK(server_ca_cert_combobox_);
808 DCHECK(cert_library_);
809 int index = server_ca_cert_combobox_->selected_index(); 799 int index = server_ca_cert_combobox_->selected_index();
810 if (index == 0) { 800 if (index == 0) {
811 // First item is "Default". 801 // First item is "Default".
812 return std::string(); 802 return std::string();
813 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) { 803 } else if (index == server_ca_cert_combobox_->model()->GetItemCount() - 1) {
814 // Last item is "Do not check". 804 // Last item is "Do not check".
815 return std::string(); 805 return std::string();
816 } else { 806 } else {
817 DCHECK(cert_library_);
818 int cert_index = index - 1; 807 int cert_index = index - 1;
819 return cert_library_->GetCACertificates().GetNicknameAt(cert_index); 808 return CertLibrary::Get()->GetCertNicknameAt(
809 CertLibrary::CERT_TYPE_SERVER_CA, cert_index);
820 } 810 }
821 } 811 }
822 812
823 bool WifiConfigView::GetEapUseSystemCas() const { 813 bool WifiConfigView::GetEapUseSystemCas() const {
824 DCHECK(server_ca_cert_combobox_); 814 DCHECK(server_ca_cert_combobox_);
825 // Only use system CAs if the first item ("Default") is selected. 815 // Only use system CAs if the first item ("Default") is selected.
826 return server_ca_cert_combobox_->selected_index() == 0; 816 return server_ca_cert_combobox_->selected_index() == 0;
827 } 817 }
828 818
829 std::string WifiConfigView::GetEapClientCertPkcs11Id() const { 819 std::string WifiConfigView::GetEapClientCertPkcs11Id() const {
830 DCHECK(user_cert_combobox_); 820 DCHECK(user_cert_combobox_);
831 DCHECK(cert_library_);
832 if (!HaveUserCerts()) { 821 if (!HaveUserCerts()) {
833 return std::string(); // "None installed" 822 return std::string(); // "None installed"
834 } else { 823 } else {
835 // Certificates are listed in the order they appear in the model. 824 // Certificates are listed in the order they appear in the model.
836 int index = user_cert_combobox_->selected_index(); 825 int index = user_cert_combobox_->selected_index();
837 return cert_library_->GetUserCertificates().GetPkcs11IdAt(index); 826 return CertLibrary::Get()->GetCertPkcs11IdAt(
827 CertLibrary::CERT_TYPE_USER, index);
838 } 828 }
839 } 829 }
840 830
841 std::string WifiConfigView::GetEapIdentity() const { 831 std::string WifiConfigView::GetEapIdentity() const {
842 DCHECK(identity_textfield_); 832 DCHECK(identity_textfield_);
843 return UTF16ToUTF8(identity_textfield_->text()); 833 return UTF16ToUTF8(identity_textfield_->text());
844 } 834 }
845 835
846 std::string WifiConfigView::GetEapAnonymousIdentity() const { 836 std::string WifiConfigView::GetEapAnonymousIdentity() const {
847 DCHECK(identity_anonymous_textfield_); 837 DCHECK(identity_anonymous_textfield_);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 security_combobox_model_.reset(new internal::SecurityComboboxModel); 923 security_combobox_model_.reset(new internal::SecurityComboboxModel);
934 security_combobox_ = new views::Combobox(security_combobox_model_.get()); 924 security_combobox_ = new views::Combobox(security_combobox_model_.get());
935 security_combobox_->SetAccessibleName(label_text); 925 security_combobox_->SetAccessibleName(label_text);
936 security_combobox_->set_listener(this); 926 security_combobox_->set_listener(this);
937 layout->AddView(security_combobox_); 927 layout->AddView(security_combobox_);
938 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 928 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
939 } 929 }
940 930
941 // Only enumerate certificates in the data model for 802.1X networks. 931 // Only enumerate certificates in the data model for 802.1X networks.
942 if (show_8021x) { 932 if (show_8021x) {
943 // Initialize cert_library_ for 802.1X netoworks.
944 cert_library_ = chromeos::CrosLibrary::Get()->GetCertLibrary();
945 // Setup a callback if certificates are yet to be loaded, 933 // Setup a callback if certificates are yet to be loaded,
946 if (!cert_library_->CertificatesLoaded()) 934 if (!CertLibrary::Get()->CertificatesLoaded())
pneubeck (no reviews) 2013/05/03 09:42:54 same comment as for vpn config...
stevenjb 2013/05/03 17:02:32 Done.
947 cert_library_->AddObserver(this); 935 CertLibrary::Get()->AddObserver(this);
948 936
949 // EAP method 937 // EAP method
950 layout->StartRow(0, column_view_set_id); 938 layout->StartRow(0, column_view_set_id);
951 string16 eap_label_text = l10n_util::GetStringUTF16( 939 string16 eap_label_text = l10n_util::GetStringUTF16(
952 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD); 940 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EAP_METHOD);
953 layout->AddView(new views::Label(eap_label_text)); 941 layout->AddView(new views::Label(eap_label_text));
954 eap_method_combobox_model_.reset(new internal::EAPMethodComboboxModel); 942 eap_method_combobox_model_.reset(new internal::EAPMethodComboboxModel);
955 eap_method_combobox_ = new views::Combobox( 943 eap_method_combobox_ = new views::Combobox(
956 eap_method_combobox_model_.get()); 944 eap_method_combobox_model_.get());
957 eap_method_combobox_->SetAccessibleName(eap_label_text); 945 eap_method_combobox_->SetAccessibleName(eap_label_text);
(...skipping 21 matching lines...) Expand all
979 layout->AddView(new ControlledSettingIndicatorView(phase_2_auth_ui_data_)); 967 layout->AddView(new ControlledSettingIndicatorView(phase_2_auth_ui_data_));
980 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 968 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
981 969
982 // Server CA certificate 970 // Server CA certificate
983 layout->StartRow(0, column_view_set_id); 971 layout->StartRow(0, column_view_set_id);
984 string16 server_ca_cert_label_text = l10n_util::GetStringUTF16( 972 string16 server_ca_cert_label_text = l10n_util::GetStringUTF16(
985 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA); 973 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA);
986 server_ca_cert_label_ = new views::Label(server_ca_cert_label_text); 974 server_ca_cert_label_ = new views::Label(server_ca_cert_label_text);
987 layout->AddView(server_ca_cert_label_); 975 layout->AddView(server_ca_cert_label_);
988 server_ca_cert_combobox_model_.reset( 976 server_ca_cert_combobox_model_.reset(
989 new internal::ServerCACertComboboxModel(cert_library_)); 977 new internal::ServerCACertComboboxModel());
990 server_ca_cert_combobox_ = new ComboboxWithWidth( 978 server_ca_cert_combobox_ = new ComboboxWithWidth(
991 server_ca_cert_combobox_model_.get(), 979 server_ca_cert_combobox_model_.get(),
992 ChildNetworkConfigView::kInputFieldMinWidth); 980 ChildNetworkConfigView::kInputFieldMinWidth);
993 server_ca_cert_combobox_->SetAccessibleName(server_ca_cert_label_text); 981 server_ca_cert_combobox_->SetAccessibleName(server_ca_cert_label_text);
994 server_ca_cert_label_->SetEnabled(false); 982 server_ca_cert_label_->SetEnabled(false);
995 server_ca_cert_combobox_->SetEnabled(false); 983 server_ca_cert_combobox_->SetEnabled(false);
996 server_ca_cert_combobox_->set_listener(this); 984 server_ca_cert_combobox_->set_listener(this);
997 layout->AddView(server_ca_cert_combobox_); 985 layout->AddView(server_ca_cert_combobox_);
998 layout->AddView( 986 layout->AddView(
999 new ControlledSettingIndicatorView(server_ca_cert_ui_data_)); 987 new ControlledSettingIndicatorView(server_ca_cert_ui_data_));
1000 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 988 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1001 989
1002 // User certificate 990 // User certificate
1003 layout->StartRow(0, column_view_set_id); 991 layout->StartRow(0, column_view_set_id);
1004 string16 user_cert_label_text = l10n_util::GetStringUTF16( 992 string16 user_cert_label_text = l10n_util::GetStringUTF16(
1005 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT); 993 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT);
1006 user_cert_label_ = new views::Label(user_cert_label_text); 994 user_cert_label_ = new views::Label(user_cert_label_text);
1007 layout->AddView(user_cert_label_); 995 layout->AddView(user_cert_label_);
1008 user_cert_combobox_model_.reset( 996 user_cert_combobox_model_.reset(new internal::UserCertComboboxModel());
1009 new internal::UserCertComboboxModel(cert_library_));
1010 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); 997 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get());
1011 user_cert_combobox_->SetAccessibleName(user_cert_label_text); 998 user_cert_combobox_->SetAccessibleName(user_cert_label_text);
1012 user_cert_label_->SetEnabled(false); 999 user_cert_label_->SetEnabled(false);
1013 user_cert_combobox_->SetEnabled(false); 1000 user_cert_combobox_->SetEnabled(false);
1014 user_cert_combobox_->set_listener(this); 1001 user_cert_combobox_->set_listener(this);
1015 layout->AddView(user_cert_combobox_); 1002 layout->AddView(user_cert_combobox_);
1016 layout->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_)); 1003 layout->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_));
1017 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1004 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1018 1005
1019 // Identity 1006 // Identity
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 if (wifi->eap_use_system_cas()) { 1191 if (wifi->eap_use_system_cas()) {
1205 // "Default". 1192 // "Default".
1206 server_ca_cert_combobox_->SetSelectedIndex(0); 1193 server_ca_cert_combobox_->SetSelectedIndex(0);
1207 } else { 1194 } else {
1208 // "Do not check". 1195 // "Do not check".
1209 server_ca_cert_combobox_->SetSelectedIndex( 1196 server_ca_cert_combobox_->SetSelectedIndex(
1210 server_ca_cert_combobox_->model()->GetItemCount() - 1); 1197 server_ca_cert_combobox_->model()->GetItemCount() - 1);
1211 } 1198 }
1212 } else { 1199 } else {
1213 // Select the certificate if available. 1200 // Select the certificate if available.
1214 int cert_index = 1201 int cert_index = CertLibrary::Get()->GetCertIndexByNickname(
1215 cert_library_->GetCACertificates().FindCertByNickname(nss_nickname); 1202 CertLibrary::CERT_TYPE_SERVER_CA, nss_nickname);
1216 if (cert_index >= 0) { 1203 if (cert_index >= 0) {
1217 // Skip item for "Default". 1204 // Skip item for "Default".
1218 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); 1205 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index);
1219 } 1206 }
1220 } 1207 }
1221 } 1208 }
1222 1209
1223 // User certificate. 1210 // User certificate.
1224 if (UserCertActive()) { 1211 if (UserCertActive()) {
1225 const std::string& pkcs11_id = 1212 const std::string& pkcs11_id =
1226 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string()); 1213 (wifi ? wifi->eap_client_cert_pkcs11_id() : std::string());
1227 if (!pkcs11_id.empty()) { 1214 if (!pkcs11_id.empty()) {
1228 int cert_index = 1215 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id(
1229 cert_library_->GetUserCertificates().FindCertByPkcs11Id(pkcs11_id); 1216 CertLibrary::CERT_TYPE_USER, pkcs11_id);
1230 if (cert_index >= 0) { 1217 if (cert_index >= 0) {
1231 user_cert_combobox_->SetSelectedIndex(cert_index); 1218 user_cert_combobox_->SetSelectedIndex(cert_index);
1232 } 1219 }
1233 } 1220 }
1234 } 1221 }
1235 1222
1236 // Identity is always active. 1223 // Identity is always active.
1237 const std::string& eap_identity = 1224 const std::string& eap_identity =
1238 (wifi ? wifi->eap_identity() : std::string()); 1225 (wifi ? wifi->eap_identity() : std::string());
1239 identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); 1226 identity_textfield_->SetText(UTF8ToUTF16(eap_identity));
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1276 void WifiConfigView::ParseWiFiEAPUIProperty( 1263 void WifiConfigView::ParseWiFiEAPUIProperty(
1277 NetworkPropertyUIData* property_ui_data, 1264 NetworkPropertyUIData* property_ui_data,
1278 Network* network, 1265 Network* network,
1279 const std::string& key) { 1266 const std::string& key) {
1280 ParseWiFiUIProperty( 1267 ParseWiFiUIProperty(
1281 property_ui_data, network, 1268 property_ui_data, network,
1282 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str())); 1269 base::StringPrintf("%s.%s", onc::wifi::kEAP, key.c_str()));
1283 } 1270 }
1284 1271
1285 } // namespace chromeos 1272 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698