| OLD | NEW |
| 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/vpn_config_view.h" | 5 #include "chrome/browser/chromeos/options/vpn_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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 namespace chromeos { | 53 namespace chromeos { |
| 54 | 54 |
| 55 class ProviderTypeComboboxModel : public ui::ComboboxModel { | 55 class ProviderTypeComboboxModel : public ui::ComboboxModel { |
| 56 public: | 56 public: |
| 57 ProviderTypeComboboxModel() {} | 57 ProviderTypeComboboxModel() {} |
| 58 virtual ~ProviderTypeComboboxModel() {} | 58 virtual ~ProviderTypeComboboxModel() {} |
| 59 virtual int GetItemCount() { | 59 |
| 60 // Overridden from ui::ComboboxModel: |
| 61 virtual int GetItemCount() const OVERRIDE { |
| 60 return chromeos::PROVIDER_TYPE_MAX; | 62 return chromeos::PROVIDER_TYPE_MAX; |
| 61 } | 63 } |
| 62 virtual string16 GetItemAt(int index) { | 64 virtual string16 GetItemAt(int index) OVERRIDE { |
| 63 ProviderType type = static_cast<ProviderType>(index); | 65 ProviderType type = static_cast<ProviderType>(index); |
| 64 return ProviderTypeToString(type); | 66 return ProviderTypeToString(type); |
| 65 } | 67 } |
| 68 |
| 66 private: | 69 private: |
| 67 DISALLOW_COPY_AND_ASSIGN(ProviderTypeComboboxModel); | 70 DISALLOW_COPY_AND_ASSIGN(ProviderTypeComboboxModel); |
| 68 }; | 71 }; |
| 69 | 72 |
| 70 class ServerCACertComboboxModel : public ui::ComboboxModel { | 73 class ServerCACertComboboxModel : public ui::ComboboxModel { |
| 71 public: | 74 public: |
| 72 explicit ServerCACertComboboxModel(CertLibrary* cert_library) | 75 explicit ServerCACertComboboxModel(CertLibrary* cert_library) |
| 73 : cert_library_(cert_library) { | 76 : cert_library_(cert_library) { |
| 74 } | 77 } |
| 75 virtual ~ServerCACertComboboxModel() {} | 78 virtual ~ServerCACertComboboxModel() {} |
| 76 virtual int GetItemCount() { | 79 |
| 80 // Overridden from ui::ComboboxModel: |
| 81 virtual int GetItemCount() const OVERRIDE { |
| 77 if (cert_library_->CertificatesLoading()) | 82 if (cert_library_->CertificatesLoading()) |
| 78 return 1; // "Loading" | 83 return 1; // "Loading" |
| 79 // "Default" + certs. | 84 // "Default" + certs. |
| 80 return cert_library_->GetCACertificates().Size() + 1; | 85 return cert_library_->GetCACertificates().Size() + 1; |
| 81 } | 86 } |
| 82 virtual string16 GetItemAt(int combo_index) { | 87 virtual string16 GetItemAt(int index) OVERRIDE { |
| 83 if (cert_library_->CertificatesLoading()) | 88 if (cert_library_->CertificatesLoading()) |
| 84 return l10n_util::GetStringUTF16( | 89 return l10n_util::GetStringUTF16( |
| 85 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 90 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
| 86 if (combo_index == 0) | 91 if (index == 0) |
| 87 return l10n_util::GetStringUTF16( | 92 return l10n_util::GetStringUTF16( |
| 88 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); | 93 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT); |
| 89 int cert_index = combo_index - 1; | 94 int cert_index = index - 1; |
| 90 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); | 95 return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index); |
| 91 } | 96 } |
| 92 | 97 |
| 93 private: | 98 private: |
| 94 CertLibrary* cert_library_; | 99 CertLibrary* cert_library_; |
| 100 |
| 95 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); | 101 DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel); |
| 96 }; | 102 }; |
| 97 | 103 |
| 98 class UserCertComboboxModel : public ui::ComboboxModel { | 104 class UserCertComboboxModel : public ui::ComboboxModel { |
| 99 public: | 105 public: |
| 100 explicit UserCertComboboxModel(CertLibrary* cert_library) | 106 explicit UserCertComboboxModel(CertLibrary* cert_library) |
| 101 : cert_library_(cert_library) { | 107 : cert_library_(cert_library) { |
| 102 } | 108 } |
| 103 virtual ~UserCertComboboxModel() {} | 109 virtual ~UserCertComboboxModel() {} |
| 104 virtual int GetItemCount() { | 110 |
| 111 // Overridden from ui::ComboboxModel: |
| 112 virtual int GetItemCount() const OVERRIDE { |
| 105 if (cert_library_->CertificatesLoading()) | 113 if (cert_library_->CertificatesLoading()) |
| 106 return 1; // "Loading" | 114 return 1; // "Loading" |
| 107 int num_certs = cert_library_->GetUserCertificates().Size(); | 115 int num_certs = cert_library_->GetUserCertificates().Size(); |
| 108 if (num_certs == 0) | 116 if (num_certs == 0) |
| 109 return 1; // "None installed" | 117 return 1; // "None installed" |
| 110 return num_certs; | 118 return num_certs; |
| 111 } | 119 } |
| 112 virtual string16 GetItemAt(int combo_index) { | 120 virtual string16 GetItemAt(int index) OVERRIDE { |
| 113 if (cert_library_->CertificatesLoading()) { | 121 if (cert_library_->CertificatesLoading()) { |
| 114 return l10n_util::GetStringUTF16( | 122 return l10n_util::GetStringUTF16( |
| 115 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); | 123 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING); |
| 116 } | 124 } |
| 117 if (cert_library_->GetUserCertificates().Size() == 0) { | 125 if (cert_library_->GetUserCertificates().Size() == 0) { |
| 118 return l10n_util::GetStringUTF16( | 126 return l10n_util::GetStringUTF16( |
| 119 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 127 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
| 120 } | 128 } |
| 121 return cert_library_->GetUserCertificates().GetDisplayStringAt(combo_index); | 129 return cert_library_->GetUserCertificates().GetDisplayStringAt(index); |
| 122 } | 130 } |
| 123 | 131 |
| 124 private: | 132 private: |
| 125 CertLibrary* cert_library_; | 133 CertLibrary* cert_library_; |
| 126 DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel); | 134 DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel); |
| 127 }; | 135 }; |
| 128 | 136 |
| 129 VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn) | 137 VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn) |
| 130 : ChildNetworkConfigView(parent, vpn), | 138 : ChildNetworkConfigView(parent, vpn), |
| 131 cert_library_(NULL) { | 139 cert_library_(NULL) { |
| (...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 std::string vpn_type; | 818 std::string vpn_type; |
| 811 if (!vpn_dict || !vpn_dict->GetString(onc::kType, &vpn_type)) | 819 if (!vpn_dict || !vpn_dict->GetString(onc::kType, &vpn_type)) |
| 812 return; | 820 return; |
| 813 | 821 |
| 814 property_ui_data->ParseOncProperty( | 822 property_ui_data->ParseOncProperty( |
| 815 network->ui_data(), onc, | 823 network->ui_data(), onc, |
| 816 base::StringPrintf("%s.%s.%s", onc::kVPN, vpn_type.c_str(), key.c_str())); | 824 base::StringPrintf("%s.%s.%s", onc::kVPN, vpn_type.c_str(), key.c_str())); |
| 817 } | 825 } |
| 818 | 826 |
| 819 } // namespace chromeos | 827 } // namespace chromeos |
| OLD | NEW |