#include "chrome/browser/chromeos/options/vpn_config_view.h"
#include "ash/system/chromeos/network/network_connect.h"
+#include "base/bind.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
PROVIDER_TYPE_INDEX_MAX = 3,
};
-string16 ProviderTypeIndexToString(int index) {
+base::string16 ProviderTypeIndexToString(int index) {
switch (index) {
case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK:
return l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN);
}
NOTREACHED();
- return string16();
+ return base::string16();
}
int ProviderTypeToIndex(const std::string& provider_type,
return pem;
}
-void ShillError(const std::string& function,
- const std::string& error_name,
- scoped_ptr<base::DictionaryValue> error_data) {
- NET_LOG_ERROR("Shill Error from VpnConfigView: " + error_name, function);
-}
-
} // namespace
namespace chromeos {
// Overridden from ui::ComboboxModel:
virtual int GetItemCount() const OVERRIDE;
- virtual string16 GetItemAt(int index) OVERRIDE;
+ virtual base::string16 GetItemAt(int index) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(ProviderTypeComboboxModel);
// Overridden from ui::ComboboxModel:
virtual int GetItemCount() const OVERRIDE;
- virtual string16 GetItemAt(int index) OVERRIDE;
+ virtual base::string16 GetItemAt(int index) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(VpnServerCACertComboboxModel);
// Overridden from ui::ComboboxModel:
virtual int GetItemCount() const OVERRIDE;
- virtual string16 GetItemAt(int index) OVERRIDE;
+ virtual base::string16 GetItemAt(int index) OVERRIDE;
private:
DISALLOW_COPY_AND_ASSIGN(VpnUserCertComboboxModel);
return PROVIDER_TYPE_INDEX_MAX;
}
-string16 ProviderTypeComboboxModel::GetItemAt(int index) {
+base::string16 ProviderTypeComboboxModel::GetItemAt(int index) {
return ProviderTypeIndexToString(index);
}
CertLibrary::CERT_TYPE_SERVER_CA) + 1;
}
-string16 VpnServerCACertComboboxModel::GetItemAt(int index) {
+base::string16 VpnServerCACertComboboxModel::GetItemAt(int index) {
if (CertLibrary::Get()->CertificatesLoading())
return l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
return num_certs;
}
-string16 VpnUserCertComboboxModel::GetItemAt(int index) {
+base::string16 VpnUserCertComboboxModel::GetItemAt(int index) {
if (CertLibrary::Get()->CertificatesLoading()) {
return l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_LOADING);
CertLibrary::Get()->RemoveObserver(this);
}
-string16 VPNConfigView::GetTitle() const {
+base::string16 VPNConfigView::GetTitle() const {
DCHECK_NE(title_, 0);
return l10n_util::GetStringUTF16(title_);
}
}
void VPNConfigView::ContentsChanged(views::Textfield* sender,
- const string16& new_contents) {
+ const base::string16& new_contents) {
if (sender == server_textfield_ && !service_text_modified_) {
// Set the service name to the server name up to '.', unless it has
// been explicitly set by the user.
- string16 server = server_textfield_->text();
- string16::size_type n = server.find_first_of(L'.');
+ base::string16 server = server_textfield_->text();
+ base::string16::size_type n = server.find_first_of(L'.');
service_name_from_server_ = server.substr(0, n);
service_textfield_->SetText(service_name_from_server_);
}
const ui::Event& event) {
}
-void VPNConfigView::OnSelectedIndexChanged(views::Combobox* combobox) {
+void VPNConfigView::OnPerformAction(views::Combobox* combobox) {
UpdateControls();
UpdateErrorLabel();
UpdateCanLogin();
shill::kProviderTypeProperty, GetProviderTypeString());
SetConfigProperties(&properties);
- bool shared = !LoginState::Get()->IsUserAuthenticated();
+ bool shared = false;
+ bool modifiable = false;
+ ChildNetworkConfigView::GetShareStateForLoginState(&shared, &modifiable);
bool only_policy_autoconnect =
onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!shared);
return std::string();
} else {
int cert_index = index - 1;
- return CertLibrary::Get()->GetCertPEMAt(
- CertLibrary::CERT_TYPE_SERVER_CA, cert_index);
+ return CertLibrary::Get()->GetServerCACertPEMAt(cert_index);
}
}
} else {
// Certificates are listed in the order they appear in the model.
int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0;
- return CertLibrary::Get()->GetCertPkcs11IdAt(
- CertLibrary::CERT_TYPE_USER, index);
+ return CertLibrary::Get()->GetUserCertPkcs11IdAt(index);
}
}
new views::Label(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME));
layout_->AddView(server_label);
- server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
- server_textfield_->SetController(this);
+ server_textfield_ = new views::Textfield();
+ server_textfield_->set_controller(this);
layout_->AddView(server_textfield_);
layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
if (!service_path_.empty()) {
layout_->AddView(new views::Label(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME)));
if (service_path_.empty()) {
- service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
- service_textfield_->SetController(this);
+ service_textfield_ = new views::Textfield();
+ service_textfield_->set_controller(this);
layout_->AddView(service_textfield_);
service_text_ = NULL;
} else {
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE));
layout_->AddView(psk_passphrase_label_);
psk_passphrase_textfield_ = new PassphraseTextfield();
- psk_passphrase_textfield_->SetController(this);
+ psk_passphrase_textfield_->set_controller(this);
layout_->AddView(psk_passphrase_textfield_);
layout_->AddView(
new ControlledSettingIndicatorView(psk_passphrase_ui_data_));
layout_->StartRow(0, 0);
layout_->AddView(new views::Label(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME)));
- username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
- username_textfield_->SetController(this);
+ username_textfield_ = new views::Textfield();
+ username_textfield_->set_controller(this);
username_textfield_->SetEnabled(username_ui_data_.IsEditable());
layout_->AddView(username_textfield_);
layout_->AddView(new ControlledSettingIndicatorView(username_ui_data_));
layout_->AddView(new views::Label(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE)));
user_passphrase_textfield_ = new PassphraseTextfield();
- user_passphrase_textfield_->SetController(this);
+ user_passphrase_textfield_->set_controller(this);
user_passphrase_textfield_->SetEnabled(user_passphrase_ui_data_.IsEditable());
layout_->AddView(user_passphrase_textfield_);
layout_->AddView(
otp_label_ = new views::Label(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP));
layout_->AddView(otp_label_);
- otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT);
- otp_textfield_->SetController(this);
+ otp_textfield_ = new views::Textfield();
+ otp_textfield_->set_controller(this);
layout_->AddView(otp_textfield_);
layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME));
layout_->AddView(group_name_label_);
group_name_textfield_ =
- new views::Textfield(views::Textfield::STYLE_DEFAULT);
- group_name_textfield_->SetController(this);
+ new views::Textfield();
+ group_name_textfield_->set_controller(this);
layout_->AddView(group_name_textfield_);
layout_->AddView(new ControlledSettingIndicatorView(group_name_ui_data_));
layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
provider_type_index_ = ProviderTypeToIndex(provider_type, client_cert_id_);
if (service_text_)
- service_text_->SetText(ASCIIToUTF16(vpn->name()));
+ service_text_->SetText(base::ASCIIToUTF16(vpn->name()));
if (provider_type_text_label_)
provider_type_text_label_->SetText(
ProviderTypeIndexToString(provider_type_index_));
if (server_textfield_ && !server_hostname.empty())
- server_textfield_->SetText(UTF8ToUTF16(server_hostname));
+ server_textfield_->SetText(base::UTF8ToUTF16(server_hostname));
if (username_textfield_ && !username.empty())
- username_textfield_->SetText(UTF8ToUTF16(username));
+ username_textfield_->SetText(base::UTF8ToUTF16(username));
if (group_name_textfield_ && !group_name.empty())
- group_name_textfield_->SetText(UTF8ToUTF16(group_name));
+ group_name_textfield_->SetText(base::UTF8ToUTF16(group_name));
if (psk_passphrase_textfield_)
psk_passphrase_textfield_->SetShowFake(!psk_passphrase_required);
if (save_credentials_checkbox_)
server_ca_cert_combobox_->ModelChanged();
if (enable_server_ca_cert_ && !ca_cert_pem_.empty()) {
// Select the current server CA certificate in the combobox.
- int cert_index = CertLibrary::Get()->GetCertIndexByPEM(
- CertLibrary::CERT_TYPE_SERVER_CA, ca_cert_pem_);
+ int cert_index =
+ CertLibrary::Get()->GetServerCACertIndexByPEM(ca_cert_pem_);
if (cert_index >= 0) {
// Skip item for "Default"
server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index);
if (user_cert_combobox_) {
user_cert_combobox_->ModelChanged();
if (enable_user_cert_ && !client_cert_id_.empty()) {
- int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id(
- CertLibrary::CERT_TYPE_USER, client_cert_id_);
+ int cert_index =
+ CertLibrary::Get()->GetUserCertIndexByPkcs11Id(client_cert_id_);
if (cert_index >= 0)
user_cert_combobox_->SetSelectedIndex(cert_index);
else
void VPNConfigView::UpdateErrorLabel() {
// Error message.
- string16 error_msg;
+ base::string16 error_msg;
bool cert_required =
GetProviderTypeIndex() == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT;
if (cert_required && CertLibrary::Get()->CertificatesLoaded()) {
const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()->
GetNetworkState(service_path_);
if (vpn && vpn->connection_state() == shill::kStateFailure)
- error_msg = ash::network_connect::ErrorString(vpn->error(), vpn->path());
+ error_msg = ash::network_connect::ErrorString(
+ vpn->last_error(), vpn->path());
}
if (!error_msg.empty()) {
error_label_->SetText(error_msg);
bool trim_whitespace) const {
if (!textfield)
return std::string();
- std::string untrimmed = UTF16ToUTF8(textfield->text());
+ std::string untrimmed = base::UTF16ToUTF8(textfield->text());
if (!trim_whitespace)
return untrimmed;
std::string result;
- TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result);
+ base::TrimWhitespaceASCII(untrimmed, base::TRIM_ALL, &result);
return result;
}