| Index: chrome/browser/chromeos/options/vpn_config_view.cc
|
| diff --git a/chrome/browser/chromeos/options/vpn_config_view.cc b/chrome/browser/chromeos/options/vpn_config_view.cc
|
| index af149baa43784237e072042c0d81dbbe83f9376a..13fd6836d3df2c113e17245e6f5d44193f8cf452 100644
|
| --- a/chrome/browser/chromeos/options/vpn_config_view.cc
|
| +++ b/chrome/browser/chromeos/options/vpn_config_view.cc
|
| @@ -52,21 +52,16 @@ string16 ProviderTypeToString(chromeos::ProviderType type) {
|
|
|
| } // namespace
|
|
|
| -namespace chromeos {
|
| +namespace internal {
|
|
|
| class ProviderTypeComboboxModel : public ui::ComboboxModel {
|
| public:
|
| - ProviderTypeComboboxModel() {}
|
| - virtual ~ProviderTypeComboboxModel() {}
|
| + ProviderTypeComboboxModel();
|
| + virtual ~ProviderTypeComboboxModel();
|
|
|
| // Overridden from ui::ComboboxModel:
|
| - virtual int GetItemCount() const OVERRIDE {
|
| - return chromeos::PROVIDER_TYPE_MAX;
|
| - }
|
| - virtual string16 GetItemAt(int index) OVERRIDE {
|
| - ProviderType type = static_cast<ProviderType>(index);
|
| - return ProviderTypeToString(type);
|
| - }
|
| + virtual int GetItemCount() const OVERRIDE;
|
| + virtual string16 GetItemAt(int index) OVERRIDE;
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ProviderTypeComboboxModel);
|
| @@ -74,68 +69,114 @@ class ProviderTypeComboboxModel : public ui::ComboboxModel {
|
|
|
| class ServerCACertComboboxModel : public ui::ComboboxModel {
|
| public:
|
| - explicit ServerCACertComboboxModel(CertLibrary* cert_library)
|
| - : cert_library_(cert_library) {
|
| - }
|
| - virtual ~ServerCACertComboboxModel() {}
|
| + explicit ServerCACertComboboxModel(chromeos::CertLibrary* cert_library);
|
| + virtual ~ServerCACertComboboxModel();
|
|
|
| // Overridden from ui::ComboboxModel:
|
| - virtual int GetItemCount() const OVERRIDE {
|
| - if (cert_library_->CertificatesLoading())
|
| - return 1; // "Loading"
|
| - // "Default" + certs.
|
| - return cert_library_->GetCACertificates().Size() + 1;
|
| - }
|
| - virtual string16 GetItemAt(int index) OVERRIDE {
|
| - if (cert_library_->CertificatesLoading())
|
| - return l10n_util::GetStringUTF16(
|
| - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
|
| - if (index == 0)
|
| - return l10n_util::GetStringUTF16(
|
| - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT);
|
| - int cert_index = index - 1;
|
| - return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index);
|
| - }
|
| + virtual int GetItemCount() const OVERRIDE;
|
| + virtual string16 GetItemAt(int index) OVERRIDE;
|
|
|
| private:
|
| - CertLibrary* cert_library_;
|
| + chromeos::CertLibrary* cert_library_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ServerCACertComboboxModel);
|
| };
|
|
|
| class UserCertComboboxModel : public ui::ComboboxModel {
|
| public:
|
| - explicit UserCertComboboxModel(CertLibrary* cert_library)
|
| - : cert_library_(cert_library) {
|
| - }
|
| - virtual ~UserCertComboboxModel() {}
|
| + explicit UserCertComboboxModel(chromeos::CertLibrary* cert_library);
|
| + virtual ~UserCertComboboxModel();
|
|
|
| // Overridden from ui::ComboboxModel:
|
| - virtual int GetItemCount() const OVERRIDE {
|
| - if (cert_library_->CertificatesLoading())
|
| - return 1; // "Loading"
|
| - int num_certs = cert_library_->GetUserCertificates().Size();
|
| - if (num_certs == 0)
|
| - return 1; // "None installed"
|
| - return num_certs;
|
| - }
|
| - virtual string16 GetItemAt(int index) OVERRIDE {
|
| - if (cert_library_->CertificatesLoading()) {
|
| - return l10n_util::GetStringUTF16(
|
| - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
|
| - }
|
| - if (cert_library_->GetUserCertificates().Size() == 0) {
|
| - return l10n_util::GetStringUTF16(
|
| - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED);
|
| - }
|
| - return cert_library_->GetUserCertificates().GetDisplayStringAt(index);
|
| - }
|
| + virtual int GetItemCount() const OVERRIDE;
|
| + virtual string16 GetItemAt(int index) OVERRIDE;
|
|
|
| private:
|
| - CertLibrary* cert_library_;
|
| + chromeos::CertLibrary* cert_library_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(UserCertComboboxModel);
|
| };
|
|
|
| +// ProviderTypeComboboxModel ---------------------------------------------------
|
| +
|
| +ProviderTypeComboboxModel::ProviderTypeComboboxModel() {
|
| +}
|
| +
|
| +ProviderTypeComboboxModel::~ProviderTypeComboboxModel() {
|
| +}
|
| +
|
| +int ProviderTypeComboboxModel::GetItemCount() const {
|
| + return chromeos::PROVIDER_TYPE_MAX;
|
| +}
|
| +
|
| +string16 ProviderTypeComboboxModel::GetItemAt(int index) {
|
| + chromeos::ProviderType type = static_cast<chromeos::ProviderType>(index);
|
| + return ProviderTypeToString(type);
|
| +}
|
| +
|
| +// ServerCACertComboboxModel ---------------------------------------------------
|
| +
|
| +ServerCACertComboboxModel::ServerCACertComboboxModel(
|
| + chromeos::CertLibrary* cert_library)
|
| + : cert_library_(cert_library) {
|
| +}
|
| +
|
| +ServerCACertComboboxModel::~ServerCACertComboboxModel() {
|
| +}
|
| +
|
| +int ServerCACertComboboxModel::GetItemCount() const {
|
| + if (cert_library_->CertificatesLoading())
|
| + return 1; // "Loading"
|
| + // "Default" + certs.
|
| + return cert_library_->GetCACertificates().Size() + 1;
|
| +}
|
| +
|
| +string16 ServerCACertComboboxModel::GetItemAt(int index) {
|
| + if (cert_library_->CertificatesLoading())
|
| + return l10n_util::GetStringUTF16(
|
| + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
|
| + if (index == 0)
|
| + return l10n_util::GetStringUTF16(
|
| + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA_DEFAULT);
|
| + int cert_index = index - 1;
|
| + return cert_library_->GetCACertificates().GetDisplayStringAt(cert_index);
|
| +}
|
| +
|
| +// UserCertComboboxModel -------------------------------------------------------
|
| +
|
| +UserCertComboboxModel::UserCertComboboxModel(
|
| + chromeos::CertLibrary* cert_library)
|
| + : cert_library_(cert_library) {
|
| +}
|
| +
|
| +UserCertComboboxModel::~UserCertComboboxModel() {
|
| +}
|
| +
|
| +int UserCertComboboxModel::GetItemCount() const {
|
| + if (cert_library_->CertificatesLoading())
|
| + return 1; // "Loading"
|
| + int num_certs = cert_library_->GetUserCertificates().Size();
|
| + if (num_certs == 0)
|
| + return 1; // "None installed"
|
| + return num_certs;
|
| +}
|
| +
|
| +string16 UserCertComboboxModel::GetItemAt(int index) {
|
| + if (cert_library_->CertificatesLoading()) {
|
| + return l10n_util::GetStringUTF16(
|
| + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
|
| + }
|
| + if (cert_library_->GetUserCertificates().Size() == 0) {
|
| + return l10n_util::GetStringUTF16(
|
| + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED);
|
| + }
|
| + return cert_library_->GetUserCertificates().GetDisplayStringAt(index);
|
| +}
|
| +
|
| +} // namespace internal
|
| +
|
| +namespace chromeos {
|
| +
|
| VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn)
|
| : ChildNetworkConfigView(parent, vpn),
|
| cert_library_(NULL) {
|
| @@ -478,8 +519,10 @@ void VPNConfigView::Init(VirtualNetwork* vpn) {
|
| layout->AddView(new views::Label(l10n_util::GetStringUTF16(
|
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE)));
|
| if (!vpn) {
|
| - provider_type_combobox_ =
|
| - new views::Combobox(new ProviderTypeComboboxModel());
|
| + provider_type_combobox_model_.reset(
|
| + new internal::ProviderTypeComboboxModel);
|
| + provider_type_combobox_ = new views::Combobox(
|
| + provider_type_combobox_model_.get());
|
| provider_type_combobox_->set_listener(this);
|
| layout->AddView(provider_type_combobox_);
|
| provider_type_text_label_ = NULL;
|
| @@ -518,9 +561,10 @@ void VPNConfigView::Init(VirtualNetwork* vpn) {
|
| new views::Label(l10n_util::GetStringUTF16(
|
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA));
|
| layout->AddView(server_ca_cert_label_);
|
| - ServerCACertComboboxModel* server_ca_cert_model =
|
| - new ServerCACertComboboxModel(cert_library_);
|
| - server_ca_cert_combobox_ = new views::Combobox(server_ca_cert_model);
|
| + server_ca_cert_combobox_model_.reset(
|
| + new internal::ServerCACertComboboxModel(cert_library_));
|
| + server_ca_cert_combobox_ = new views::Combobox(
|
| + server_ca_cert_combobox_model_.get());
|
| layout->AddView(server_ca_cert_combobox_);
|
| layout->AddView(new ControlledSettingIndicatorView(ca_cert_ui_data_));
|
| layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| @@ -535,9 +579,9 @@ void VPNConfigView::Init(VirtualNetwork* vpn) {
|
| user_cert_label_ = new views::Label(l10n_util::GetStringUTF16(
|
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT));
|
| layout->AddView(user_cert_label_);
|
| - UserCertComboboxModel* user_cert_model =
|
| - new UserCertComboboxModel(cert_library_);
|
| - user_cert_combobox_ = new views::Combobox(user_cert_model);
|
| + user_cert_combobox_model_.reset(
|
| + new internal::UserCertComboboxModel(cert_library_));
|
| + user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get());
|
| user_cert_combobox_->set_listener(this);
|
| layout->AddView(user_cert_combobox_);
|
| layout->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_));
|
|
|