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 "ash/system/chromeos/network/network_connect.h" |
7 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
8 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chromeos/cros/network_library.h" | |
11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 12 #include "chrome/browser/chromeos/options/network_connect.h" |
12 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
13 #include "chrome/common/net/x509_certificate_model.h" | 14 #include "chrome/common/net/x509_certificate_model.h" |
| 15 #include "chromeos/network/network_configuration_handler.h" |
| 16 #include "chromeos/network/network_event_log.h" |
| 17 #include "chromeos/network/network_state.h" |
| 18 #include "chromeos/network/network_state_handler.h" |
14 #include "chromeos/network/network_ui_data.h" | 19 #include "chromeos/network/network_ui_data.h" |
15 #include "chromeos/network/onc/onc_constants.h" | 20 #include "chromeos/network/onc/onc_constants.h" |
16 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
17 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
18 #include "grit/locale_settings.h" | 23 #include "grit/locale_settings.h" |
19 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "third_party/cros_system_api/dbus/service_constants.h" |
20 #include "ui/base/events/event.h" | 26 #include "ui/base/events/event.h" |
21 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
22 #include "ui/base/models/combobox_model.h" | 28 #include "ui/base/models/combobox_model.h" |
23 #include "ui/base/resource/resource_bundle.h" | 29 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/views/controls/button/checkbox.h" | 30 #include "ui/views/controls/button/checkbox.h" |
25 #include "ui/views/controls/combobox/combobox.h" | 31 #include "ui/views/controls/combobox/combobox.h" |
26 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
27 #include "ui/views/controls/textfield/textfield.h" | 33 #include "ui/views/controls/textfield/textfield.h" |
28 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
29 #include "ui/views/layout/layout_constants.h" | 35 #include "ui/views/layout/layout_constants.h" |
30 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
31 #include "ui/views/window/dialog_client_view.h" | 37 #include "ui/views/window/dialog_client_view.h" |
32 | 38 |
33 namespace { | 39 namespace { |
34 | 40 |
35 // Root CA certificates that are built into Chrome use this token name. | 41 // Root CA certificates that are built into Chrome use this token name. |
36 const char* const kRootCertificateTokenName = "Builtin Object Token"; | 42 const char* const kRootCertificateTokenName = "Builtin Object Token"; |
37 | 43 |
38 string16 ProviderTypeToString(chromeos::ProviderType type) { | 44 enum ProviderTypeIndex { |
39 switch (type) { | 45 PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK = 0, |
40 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK: | 46 PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT = 1, |
| 47 PROVIDER_TYPE_INDEX_OPEN_VPN = 2, |
| 48 PROVIDER_TYPE_INDEX_MAX = 3, |
| 49 }; |
| 50 |
| 51 string16 ProviderTypeIndexToString(int index) { |
| 52 switch (index) { |
| 53 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK: |
41 return l10n_util::GetStringUTF16( | 54 return l10n_util::GetStringUTF16( |
42 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_PSK); | 55 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_PSK); |
43 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: | 56 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: |
44 return l10n_util::GetStringUTF16( | 57 return l10n_util::GetStringUTF16( |
45 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_USER_CERT); | 58 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_L2TP_IPSEC_USER_CERT); |
46 case chromeos::PROVIDER_TYPE_OPEN_VPN: | 59 case PROVIDER_TYPE_INDEX_OPEN_VPN: |
47 return l10n_util::GetStringUTF16( | 60 return l10n_util::GetStringUTF16( |
48 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN); | 61 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_OPEN_VPN); |
49 case chromeos::PROVIDER_TYPE_MAX: | |
50 break; | |
51 } | 62 } |
52 NOTREACHED(); | 63 NOTREACHED(); |
53 return string16(); | 64 return string16(); |
54 } | 65 } |
55 | 66 |
| 67 int ProviderTypeToIndex(const std::string& provider_type, |
| 68 const std::string& client_cert_id) { |
| 69 if (provider_type == flimflam::kProviderL2tpIpsec) { |
| 70 if (!client_cert_id.empty()) |
| 71 return PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT; |
| 72 else |
| 73 return PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK; |
| 74 } else { |
| 75 DCHECK(provider_type == flimflam::kProviderOpenVpn); |
| 76 return PROVIDER_TYPE_INDEX_OPEN_VPN; |
| 77 } |
| 78 } |
| 79 |
56 // Translates the provider type to the name of the respective ONC dictionary | 80 // Translates the provider type to the name of the respective ONC dictionary |
57 // containing configuration data for the type. | 81 // containing configuration data for the type. |
58 std::string ProviderTypeToONCDictKey(chromeos::ProviderType type) { | 82 std::string ProviderTypeIndexToONCDictKey(int provider_type_index) { |
59 switch (type) { | 83 switch (provider_type_index) { |
60 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK: | 84 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK: |
61 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: | 85 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: |
62 return chromeos::onc::vpn::kIPsec; | 86 return chromeos::onc::vpn::kIPsec; |
63 case chromeos::PROVIDER_TYPE_OPEN_VPN: | 87 case PROVIDER_TYPE_INDEX_OPEN_VPN: |
64 return chromeos::onc::vpn::kOpenVPN; | 88 return chromeos::onc::vpn::kOpenVPN; |
65 case chromeos::PROVIDER_TYPE_MAX: | |
66 break; | |
67 } | 89 } |
| 90 NOTREACHED() << "Unhandled provider type index " << provider_type_index; |
| 91 return std::string(); |
| 92 } |
68 | 93 |
69 NOTREACHED() << "Unhandled provider type " << type; | 94 std::string GetPemFromDictionary( |
70 return std::string(); | 95 const base::DictionaryValue* provider_properties, |
| 96 const std::string& key) { |
| 97 const base::ListValue* pems = NULL; |
| 98 if (!provider_properties->GetListWithoutPathExpansion(key, &pems)) |
| 99 return std::string(); |
| 100 std::string pem; |
| 101 pems->GetString(0, &pem); |
| 102 return pem; |
| 103 } |
| 104 |
| 105 void ShillError(const std::string& function, |
| 106 const std::string& error_name, |
| 107 scoped_ptr<base::DictionaryValue> error_data) { |
| 108 NET_LOG_ERROR("Shill Error from VpnConfigView: " + error_name, function); |
71 } | 109 } |
72 | 110 |
73 } // namespace | 111 } // namespace |
74 | 112 |
75 namespace chromeos { | 113 namespace chromeos { |
76 | 114 |
77 namespace internal { | 115 namespace internal { |
78 | 116 |
79 class ProviderTypeComboboxModel : public ui::ComboboxModel { | 117 class ProviderTypeComboboxModel : public ui::ComboboxModel { |
80 public: | 118 public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 155 |
118 // ProviderTypeComboboxModel --------------------------------------------------- | 156 // ProviderTypeComboboxModel --------------------------------------------------- |
119 | 157 |
120 ProviderTypeComboboxModel::ProviderTypeComboboxModel() { | 158 ProviderTypeComboboxModel::ProviderTypeComboboxModel() { |
121 } | 159 } |
122 | 160 |
123 ProviderTypeComboboxModel::~ProviderTypeComboboxModel() { | 161 ProviderTypeComboboxModel::~ProviderTypeComboboxModel() { |
124 } | 162 } |
125 | 163 |
126 int ProviderTypeComboboxModel::GetItemCount() const { | 164 int ProviderTypeComboboxModel::GetItemCount() const { |
127 return PROVIDER_TYPE_MAX; | 165 return PROVIDER_TYPE_INDEX_MAX; |
128 } | 166 } |
129 | 167 |
130 string16 ProviderTypeComboboxModel::GetItemAt(int index) { | 168 string16 ProviderTypeComboboxModel::GetItemAt(int index) { |
131 ProviderType type = static_cast<ProviderType>(index); | 169 return ProviderTypeIndexToString(index); |
132 return ProviderTypeToString(type); | |
133 } | 170 } |
134 | 171 |
135 // VpnServerCACertComboboxModel ------------------------------------------------ | 172 // VpnServerCACertComboboxModel ------------------------------------------------ |
136 | 173 |
137 VpnServerCACertComboboxModel::VpnServerCACertComboboxModel() { | 174 VpnServerCACertComboboxModel::VpnServerCACertComboboxModel() { |
138 } | 175 } |
139 | 176 |
140 VpnServerCACertComboboxModel::~VpnServerCACertComboboxModel() { | 177 VpnServerCACertComboboxModel::~VpnServerCACertComboboxModel() { |
141 } | 178 } |
142 | 179 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) { | 223 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) { |
187 return l10n_util::GetStringUTF16( | 224 return l10n_util::GetStringUTF16( |
188 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 225 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
189 } | 226 } |
190 return CertLibrary::Get()->GetCertDisplayStringAt( | 227 return CertLibrary::Get()->GetCertDisplayStringAt( |
191 CertLibrary::CERT_TYPE_USER, index); | 228 CertLibrary::CERT_TYPE_USER, index); |
192 } | 229 } |
193 | 230 |
194 } // namespace internal | 231 } // namespace internal |
195 | 232 |
196 VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn) | 233 VPNConfigView::VPNConfigView(NetworkConfigView* parent, |
197 : ChildNetworkConfigView(parent, vpn), | 234 const std::string& service_path) |
198 title_(0) { | 235 : ChildNetworkConfigView(parent, service_path), |
199 Init(vpn); | 236 service_text_modified_(false), |
200 } | 237 enable_psk_passphrase_(false), |
201 | 238 enable_user_cert_(false), |
202 VPNConfigView::VPNConfigView(NetworkConfigView* parent) | 239 enable_server_ca_cert_(false), |
203 : ChildNetworkConfigView(parent), | 240 enable_otp_(false), |
204 title_(0) { | 241 enable_group_name_(false), |
205 Init(NULL); | 242 title_(0), |
| 243 layout_(NULL), |
| 244 server_textfield_(NULL), |
| 245 service_text_(NULL), |
| 246 service_textfield_(NULL), |
| 247 provider_type_combobox_(NULL), |
| 248 provider_type_text_label_(NULL), |
| 249 psk_passphrase_label_(NULL), |
| 250 psk_passphrase_textfield_(NULL), |
| 251 user_cert_label_(NULL), |
| 252 user_cert_combobox_(NULL), |
| 253 server_ca_cert_label_(NULL), |
| 254 server_ca_cert_combobox_(NULL), |
| 255 username_textfield_(NULL), |
| 256 user_passphrase_textfield_(NULL), |
| 257 otp_label_(NULL), |
| 258 otp_textfield_(NULL), |
| 259 group_name_label_(NULL), |
| 260 group_name_textfield_(NULL), |
| 261 save_credentials_checkbox_(NULL), |
| 262 error_label_(NULL), |
| 263 provider_type_index_(PROVIDER_TYPE_INDEX_MAX), |
| 264 weak_ptr_factory_(this) { |
| 265 Init(); |
206 } | 266 } |
207 | 267 |
208 VPNConfigView::~VPNConfigView() { | 268 VPNConfigView::~VPNConfigView() { |
209 CertLibrary::Get()->RemoveObserver(this); | 269 CertLibrary::Get()->RemoveObserver(this); |
210 } | 270 } |
211 | 271 |
212 string16 VPNConfigView::GetTitle() const { | 272 string16 VPNConfigView::GetTitle() const { |
213 DCHECK_NE(title_, 0); | 273 DCHECK_NE(title_, 0); |
214 return l10n_util::GetStringUTF16(title_); | 274 return l10n_util::GetStringUTF16(title_); |
215 } | 275 } |
(...skipping 20 matching lines...) Expand all Loading... |
236 // Username is always required. | 296 // Username is always required. |
237 if (GetUsername().empty()) | 297 if (GetUsername().empty()) |
238 return false; | 298 return false; |
239 | 299 |
240 // TODO(stevenjb): min kMinPassphraseLen length? | 300 // TODO(stevenjb): min kMinPassphraseLen length? |
241 if (service_path_.empty() && | 301 if (service_path_.empty() && |
242 (GetService().empty() || GetServer().empty())) | 302 (GetService().empty() || GetServer().empty())) |
243 return false; | 303 return false; |
244 | 304 |
245 // Block login if certs are required but user has none. | 305 // Block login if certs are required but user has none. |
246 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) | 306 bool cert_required = |
| 307 GetProviderTypeIndex() == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT; |
| 308 if (cert_required && (!HaveUserCerts() || !IsUserCertValid())) |
247 return false; | 309 return false; |
248 | 310 |
249 return true; | 311 return true; |
250 } | 312 } |
251 | 313 |
252 void VPNConfigView::ContentsChanged(views::Textfield* sender, | 314 void VPNConfigView::ContentsChanged(views::Textfield* sender, |
253 const string16& new_contents) { | 315 const string16& new_contents) { |
254 if (sender == server_textfield_ && !service_text_modified_) { | 316 if (sender == server_textfield_ && !service_text_modified_) { |
255 // Set the service name to the server name up to '.', unless it has | 317 // Set the service name to the server name up to '.', unless it has |
256 // been explicitly set by the user. | 318 // been explicitly set by the user. |
(...skipping 19 matching lines...) Expand all Loading... |
276 parent_->GetDialogClientView()->AcceptWindow(); | 338 parent_->GetDialogClientView()->AcceptWindow(); |
277 } | 339 } |
278 return false; | 340 return false; |
279 } | 341 } |
280 | 342 |
281 void VPNConfigView::ButtonPressed(views::Button* sender, | 343 void VPNConfigView::ButtonPressed(views::Button* sender, |
282 const ui::Event& event) { | 344 const ui::Event& event) { |
283 } | 345 } |
284 | 346 |
285 void VPNConfigView::OnSelectedIndexChanged(views::Combobox* combobox) { | 347 void VPNConfigView::OnSelectedIndexChanged(views::Combobox* combobox) { |
286 if (combobox == provider_type_combobox_) { | 348 UpdateControls(); |
287 provider_type_ = static_cast<ProviderType>(combobox->selected_index()); | |
288 UpdateControls(); | |
289 } else if (combobox == user_cert_combobox_ || | |
290 combobox == server_ca_cert_combobox_) { | |
291 // Do nothing. | |
292 } else { | |
293 NOTREACHED(); | |
294 } | |
295 UpdateErrorLabel(); | 349 UpdateErrorLabel(); |
296 UpdateCanLogin(); | 350 UpdateCanLogin(); |
297 } | 351 } |
298 | 352 |
299 void VPNConfigView::OnCertificatesLoaded(bool initial_load) { | 353 void VPNConfigView::OnCertificatesLoaded(bool initial_load) { |
300 Refresh(); | 354 Refresh(); |
301 } | 355 } |
302 | 356 |
303 bool VPNConfigView::Login() { | 357 bool VPNConfigView::Login() { |
304 NetworkLibrary* cros = NetworkLibrary::Get(); | |
305 if (service_path_.empty()) { | 358 if (service_path_.empty()) { |
306 NetworkLibrary::VPNConfigData config_data; | 359 base::DictionaryValue properties; |
307 switch (provider_type_) { | 360 // Identifying properties |
308 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | 361 properties.SetStringWithoutPathExpansion( |
309 config_data.psk = GetPSKPassphrase(); | 362 flimflam::kTypeProperty, flimflam::kTypeVPN); |
310 config_data.username = GetUsername(); | 363 properties.SetStringWithoutPathExpansion( |
311 config_data.user_passphrase = GetUserPassphrase(); | 364 flimflam::kNameProperty, GetService()); |
312 config_data.group_name = GetGroupName(); | 365 properties.SetStringWithoutPathExpansion( |
313 break; | 366 flimflam::kProviderHostProperty, GetServer()); |
314 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { | 367 properties.SetStringWithoutPathExpansion( |
315 config_data.server_ca_cert_pem = GetServerCACertPEM(); | 368 flimflam::kProviderTypeProperty, GetProviderTypeString()); |
316 config_data.client_cert_pkcs11_id = GetUserCertID(); | 369 |
317 config_data.username = GetUsername(); | 370 SetConfigProperties(&properties); |
318 config_data.user_passphrase = GetUserPassphrase(); | 371 ash::network_connect::CreateConfigurationAndConnect( |
319 config_data.group_name = GetGroupName(); | 372 &properties, false /* shared */); |
320 break; | 373 } else { |
321 } | 374 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
322 case PROVIDER_TYPE_OPEN_VPN: | 375 GetNetworkState(service_path_); |
323 config_data.server_ca_cert_pem = GetServerCACertPEM(); | 376 if (!vpn) { |
324 config_data.client_cert_pkcs11_id = GetUserCertID(); | 377 // Shill no longer knows about this network (edge case). |
325 config_data.username = GetUsername(); | 378 // TODO(stevenjb): Add notification for this. |
326 config_data.user_passphrase = GetUserPassphrase(); | 379 NET_LOG_ERROR("Network not found", service_path_); |
327 config_data.otp = GetOTP(); | 380 return true; // Close dialog |
328 break; | |
329 case PROVIDER_TYPE_MAX: | |
330 break; | |
331 } | 381 } |
332 config_data.save_credentials = GetSaveCredentials(); | 382 base::DictionaryValue properties; |
333 cros->ConnectToUnconfiguredVirtualNetwork( | 383 SetConfigProperties(&properties); |
334 GetService(), GetServer(), provider_type_, config_data); | 384 ash::network_connect::ConfigureNetworkAndConnect(service_path_, properties); |
335 } else { | |
336 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | |
337 if (!vpn) { | |
338 // TODO(stevenjb): Add notification for this. | |
339 LOG(WARNING) << "VPN no longer exists: " << service_path_; | |
340 return true; // Close dialog. | |
341 } | |
342 switch (provider_type_) { | |
343 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | |
344 vpn->SetL2TPIPsecPSKCredentials(GetPSKPassphrase(), | |
345 GetUsername(), | |
346 GetUserPassphrase(), | |
347 GetGroupName()); | |
348 break; | |
349 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { | |
350 vpn->SetL2TPIPsecCertCredentials(GetUserCertID(), | |
351 GetUsername(), | |
352 GetUserPassphrase(), | |
353 GetGroupName()); | |
354 break; | |
355 } | |
356 case PROVIDER_TYPE_OPEN_VPN: { | |
357 vpn->SetOpenVPNCredentials(GetUserCertID(), | |
358 GetUsername(), | |
359 GetUserPassphrase(), | |
360 GetOTP()); | |
361 break; | |
362 } | |
363 case PROVIDER_TYPE_MAX: | |
364 break; | |
365 } | |
366 vpn->SetEnrollmentDelegate( | |
367 CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(), | |
368 vpn->name(), | |
369 ProfileManager::GetLastUsedProfile())); | |
370 vpn->SetSaveCredentials(GetSaveCredentials()); | |
371 cros->ConnectToVirtualNetwork(vpn); | |
372 } | 385 } |
373 // Connection failures are responsible for updating the UI, including | |
374 // reopening dialogs. | |
375 return true; // Close dialog. | 386 return true; // Close dialog. |
376 } | 387 } |
377 | 388 |
378 void VPNConfigView::Cancel() { | 389 void VPNConfigView::Cancel() { |
379 } | 390 } |
380 | 391 |
381 void VPNConfigView::InitFocus() { | 392 void VPNConfigView::InitFocus() { |
382 views::View* view_to_focus = GetInitiallyFocusedView(); | 393 views::View* view_to_focus = GetInitiallyFocusedView(); |
383 if (view_to_focus) | 394 if (view_to_focus) |
384 view_to_focus->RequestFocus(); | 395 view_to_focus->RequestFocus(); |
385 } | 396 } |
386 | 397 |
387 const std::string VPNConfigView::GetService() const { | 398 const std::string VPNConfigView::GetService() const { |
388 if (service_textfield_ != NULL) | 399 if (service_textfield_ != NULL) |
389 return GetTextFromField(service_textfield_, true); | 400 return GetTextFromField(service_textfield_, true); |
390 return service_path_; | 401 return service_path_; |
391 } | 402 } |
392 | 403 |
393 const std::string VPNConfigView::GetServer() const { | 404 const std::string VPNConfigView::GetServer() const { |
394 if (server_textfield_ != NULL) | 405 if (server_textfield_ != NULL) |
395 return GetTextFromField(server_textfield_, true); | 406 return GetTextFromField(server_textfield_, true); |
396 return server_hostname_; | 407 return std::string(); |
397 } | 408 } |
398 | 409 |
399 const std::string VPNConfigView::GetPSKPassphrase() const { | 410 const std::string VPNConfigView::GetPSKPassphrase() const { |
400 if (psk_passphrase_textfield_ && | 411 if (psk_passphrase_textfield_ && |
401 enable_psk_passphrase_ && | 412 enable_psk_passphrase_ && |
402 psk_passphrase_textfield_->visible()) | 413 psk_passphrase_textfield_->visible()) |
403 return GetPassphraseFromField(psk_passphrase_textfield_); | 414 return GetPassphraseFromField(psk_passphrase_textfield_); |
404 return std::string(); | 415 return std::string(); |
405 } | 416 } |
406 | 417 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; | 452 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; |
442 return CertLibrary::Get()->GetCertPkcs11IdAt( | 453 return CertLibrary::Get()->GetCertPkcs11IdAt( |
443 CertLibrary::CERT_TYPE_USER, index); | 454 CertLibrary::CERT_TYPE_USER, index); |
444 } | 455 } |
445 } | 456 } |
446 | 457 |
447 bool VPNConfigView::GetSaveCredentials() const { | 458 bool VPNConfigView::GetSaveCredentials() const { |
448 return save_credentials_checkbox_->checked(); | 459 return save_credentials_checkbox_->checked(); |
449 } | 460 } |
450 | 461 |
451 void VPNConfigView::Init(VirtualNetwork* vpn) { | 462 int VPNConfigView::GetProviderTypeIndex() const { |
452 if (vpn) { | 463 if (provider_type_combobox_) |
453 ProviderType type = vpn->provider_type(); | 464 return provider_type_combobox_->selected_index(); |
454 std::string type_dict_name = ProviderTypeToONCDictKey(type); | 465 return provider_type_index_; |
| 466 } |
455 | 467 |
456 if (type == PROVIDER_TYPE_L2TP_IPSEC_PSK) { | 468 std::string VPNConfigView::GetProviderTypeString() const { |
457 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name, | 469 int index = GetProviderTypeIndex(); |
458 onc::ipsec::kServerCARef); | 470 switch (index) { |
459 ParseVPNUIProperty(&psk_passphrase_ui_data_, vpn, type_dict_name, | 471 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK: |
460 onc::ipsec::kPSK); | 472 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: |
461 ParseVPNUIProperty(&group_name_ui_data_, vpn, type_dict_name, | 473 return flimflam::kProviderL2tpIpsec; |
462 onc::ipsec::kGroup); | 474 case PROVIDER_TYPE_INDEX_OPEN_VPN: |
463 } else { // OpenVPN | 475 return flimflam::kProviderOpenVpn; |
464 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name, | 476 } |
465 onc::openvpn::kServerCARef); | 477 NOTREACHED(); |
466 } | 478 return std::string(); |
467 ParseVPNUIProperty(&user_cert_ui_data_, vpn, type_dict_name, | 479 } |
468 onc::vpn::kClientCertRef); | |
469 | 480 |
470 const std::string credentials_dict_name( | 481 void VPNConfigView::Init() { |
471 type == PROVIDER_TYPE_L2TP_IPSEC_PSK ? | 482 const NetworkState* vpn = NULL; |
472 onc::vpn::kL2TP : type_dict_name); | 483 if (!service_path_.empty()) { |
473 ParseVPNUIProperty(&username_ui_data_, vpn, credentials_dict_name, | 484 vpn = NetworkHandler::Get()->network_state_handler()-> |
474 onc::vpn::kUsername); | 485 GetNetworkState(service_path_); |
475 ParseVPNUIProperty(&user_passphrase_ui_data_, vpn, credentials_dict_name, | 486 DCHECK(vpn && vpn->type() == flimflam::kTypeVPN); |
476 onc::vpn::kPassword); | |
477 ParseVPNUIProperty(&save_credentials_ui_data_, vpn, credentials_dict_name, | |
478 onc::vpn::kSaveCredentials); | |
479 } | 487 } |
480 | 488 layout_ = views::GridLayout::CreatePanel(this); |
481 views::GridLayout* layout = views::GridLayout::CreatePanel(this); | 489 SetLayoutManager(layout_); |
482 SetLayoutManager(layout); | |
483 | 490 |
484 // Observer any changes to the certificate list. | 491 // Observer any changes to the certificate list. |
485 CertLibrary::Get()->AddObserver(this); | 492 CertLibrary::Get()->AddObserver(this); |
486 | 493 |
487 const int column_view_set_id = 0; | 494 views::ColumnSet* column_set = layout_->AddColumnSet(0); |
488 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); | |
489 // Label. | 495 // Label. |
490 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 496 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
491 views::GridLayout::USE_PREF, 0, 0); | 497 views::GridLayout::USE_PREF, 0, 0); |
492 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); | 498 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); |
493 // Textfield, combobox. | 499 // Textfield, combobox. |
494 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 500 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
495 views::GridLayout::USE_PREF, 0, | 501 views::GridLayout::USE_PREF, 0, |
496 ChildNetworkConfigView::kInputFieldMinWidth); | 502 ChildNetworkConfigView::kInputFieldMinWidth); |
497 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); | 503 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); |
498 // Policy indicator. | 504 // Policy indicator. |
499 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, | 505 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, |
500 views::GridLayout::USE_PREF, 0, 0); | 506 views::GridLayout::USE_PREF, 0, 0); |
501 | 507 |
502 // Initialize members. | 508 // Initialize members. |
503 service_text_modified_ = false; | 509 service_text_modified_ = false; |
504 if (vpn) { | |
505 provider_type_ = vpn->provider_type(); | |
506 // Sets enable_* based on the provider type which we use to control | |
507 // which controls to make visible. | |
508 UpdateControlsToEnable(); | |
509 } else { | |
510 // Set the default provider type. | |
511 provider_type_ = PROVIDER_TYPE_L2TP_IPSEC_PSK; | |
512 // Provider Type is user selectable, so enable all controls during init. | |
513 enable_psk_passphrase_ = true; | |
514 enable_user_cert_ = true; | |
515 enable_server_ca_cert_ = true; | |
516 enable_otp_ = true; | |
517 enable_group_name_ = true; | |
518 } | |
519 | |
520 // Initialize the title string ID used for the dialog. | |
521 title_ = vpn ? IDS_OPTIONS_SETTINGS_JOIN_VPN : IDS_OPTIONS_SETTINGS_ADD_VPN; | 510 title_ = vpn ? IDS_OPTIONS_SETTINGS_JOIN_VPN : IDS_OPTIONS_SETTINGS_ADD_VPN; |
522 | 511 |
| 512 // By default enable all controls. |
| 513 enable_psk_passphrase_ = true; |
| 514 enable_user_cert_ = true; |
| 515 enable_server_ca_cert_ = true; |
| 516 enable_otp_ = true; |
| 517 enable_group_name_ = true; |
| 518 |
523 // Server label and input. | 519 // Server label and input. |
524 // Only provide Server name when configuring a new VPN. | 520 // Only provide Server name when configuring a new VPN. |
525 if (!vpn) { | 521 if (service_path_.empty()) { |
526 layout->StartRow(0, column_view_set_id); | 522 layout_->StartRow(0, 0); |
527 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 523 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
528 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME))); | 524 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME))); |
529 server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 525 server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
530 server_textfield_->SetController(this); | 526 server_textfield_->SetController(this); |
531 layout->AddView(server_textfield_); | 527 layout_->AddView(server_textfield_); |
532 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 528 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
533 } else { | 529 } else { |
534 server_textfield_ = NULL; | 530 server_textfield_ = NULL; |
535 } | 531 } |
536 | 532 |
537 // Service label and name or input. | 533 // Service label and name or input. |
538 layout->StartRow(0, column_view_set_id); | 534 layout_->StartRow(0, 0); |
539 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 535 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
540 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME))); | 536 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME))); |
541 if (!vpn) { | 537 if (service_path_.empty()) { |
542 service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 538 service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
543 service_textfield_->SetController(this); | 539 service_textfield_->SetController(this); |
544 layout->AddView(service_textfield_); | 540 layout_->AddView(service_textfield_); |
545 service_text_ = NULL; | 541 service_text_ = NULL; |
546 } else { | 542 } else { |
547 service_text_ = new views::Label(ASCIIToUTF16(vpn->name())); | 543 service_text_ = new views::Label(); |
548 service_text_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 544 service_text_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
549 layout->AddView(service_text_); | 545 layout_->AddView(service_text_); |
550 service_textfield_ = NULL; | 546 service_textfield_ = NULL; |
551 } | 547 } |
552 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 548 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
553 | 549 |
554 // Provider type label and select. | 550 // Provider type label and select. |
555 layout->StartRow(0, column_view_set_id); | 551 layout_->StartRow(0, 0); |
556 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 552 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
557 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE))); | 553 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE))); |
558 if (!vpn) { | 554 if (service_path_.empty()) { |
559 provider_type_combobox_model_.reset( | 555 provider_type_combobox_model_.reset( |
560 new internal::ProviderTypeComboboxModel); | 556 new internal::ProviderTypeComboboxModel); |
561 provider_type_combobox_ = new views::Combobox( | 557 provider_type_combobox_ = new views::Combobox( |
562 provider_type_combobox_model_.get()); | 558 provider_type_combobox_model_.get()); |
563 provider_type_combobox_->set_listener(this); | 559 provider_type_combobox_->set_listener(this); |
564 layout->AddView(provider_type_combobox_); | 560 layout_->AddView(provider_type_combobox_); |
565 provider_type_text_label_ = NULL; | 561 provider_type_text_label_ = NULL; |
566 } else { | 562 } else { |
567 provider_type_text_label_ = | 563 provider_type_text_label_ = new views::Label(); |
568 new views::Label(ProviderTypeToString(provider_type_)); | |
569 provider_type_text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 564 provider_type_text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
570 layout->AddView(provider_type_text_label_); | 565 layout_->AddView(provider_type_text_label_); |
571 provider_type_combobox_ = NULL; | 566 provider_type_combobox_ = NULL; |
572 } | 567 } |
573 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 568 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
574 | 569 |
575 // PSK passphrase label, input and visible button. | 570 // PSK passphrase label, input and visible button. |
576 if (enable_psk_passphrase_) { | 571 layout_->StartRow(0, 0); |
577 layout->StartRow(0, column_view_set_id); | 572 psk_passphrase_label_ = new views::Label(l10n_util::GetStringUTF16( |
578 psk_passphrase_label_ = new views::Label(l10n_util::GetStringUTF16( | 573 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE)); |
579 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE)); | 574 layout_->AddView(psk_passphrase_label_); |
580 layout->AddView(psk_passphrase_label_); | 575 psk_passphrase_textfield_ = new PassphraseTextfield(); |
581 bool has_psk_passphrase = vpn && !vpn->IsPSKPassphraseRequired(); | 576 psk_passphrase_textfield_->SetController(this); |
582 psk_passphrase_textfield_ = new PassphraseTextfield(has_psk_passphrase); | 577 layout_->AddView(psk_passphrase_textfield_); |
583 psk_passphrase_textfield_->SetController(this); | 578 layout_->AddView( |
584 layout->AddView(psk_passphrase_textfield_); | 579 new ControlledSettingIndicatorView(psk_passphrase_ui_data_)); |
585 layout->AddView( | 580 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
586 new ControlledSettingIndicatorView(psk_passphrase_ui_data_)); | |
587 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
588 } else { | |
589 psk_passphrase_label_ = NULL; | |
590 psk_passphrase_textfield_ = NULL; | |
591 } | |
592 | 581 |
593 // Server CA certificate | 582 // Server CA certificate |
594 // Only provide Server CA when configuring a new VPN. | 583 if (service_path_.empty()) { |
595 if (!vpn) { | 584 layout_->StartRow(0, 0); |
596 layout->StartRow(0, column_view_set_id); | 585 server_ca_cert_label_ = new views::Label(l10n_util::GetStringUTF16( |
597 server_ca_cert_label_ = | 586 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA)); |
598 new views::Label(l10n_util::GetStringUTF16( | 587 layout_->AddView(server_ca_cert_label_); |
599 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA)); | |
600 layout->AddView(server_ca_cert_label_); | |
601 server_ca_cert_combobox_model_.reset( | 588 server_ca_cert_combobox_model_.reset( |
602 new internal::VpnServerCACertComboboxModel()); | 589 new internal::VpnServerCACertComboboxModel()); |
603 server_ca_cert_combobox_ = new views::Combobox( | 590 server_ca_cert_combobox_ = new views::Combobox( |
604 server_ca_cert_combobox_model_.get()); | 591 server_ca_cert_combobox_model_.get()); |
605 layout->AddView(server_ca_cert_combobox_); | 592 layout_->AddView(server_ca_cert_combobox_); |
606 layout->AddView(new ControlledSettingIndicatorView(ca_cert_ui_data_)); | 593 layout_->AddView(new ControlledSettingIndicatorView(ca_cert_ui_data_)); |
607 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 594 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
608 } else { | 595 } else { |
609 server_ca_cert_label_ = NULL; | 596 server_ca_cert_label_ = NULL; |
610 server_ca_cert_combobox_ = NULL; | 597 server_ca_cert_combobox_ = NULL; |
611 } | 598 } |
612 | 599 |
613 // User certificate label and input. | 600 // User certificate label and input. |
614 if (enable_user_cert_) { | 601 layout_->StartRow(0, 0); |
615 layout->StartRow(0, column_view_set_id); | 602 user_cert_label_ = new views::Label(l10n_util::GetStringUTF16( |
616 user_cert_label_ = new views::Label(l10n_util::GetStringUTF16( | 603 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT)); |
617 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT)); | 604 layout_->AddView(user_cert_label_); |
618 layout->AddView(user_cert_label_); | 605 user_cert_combobox_model_.reset( |
619 user_cert_combobox_model_.reset( | 606 new internal::VpnUserCertComboboxModel()); |
620 new internal::VpnUserCertComboboxModel()); | 607 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); |
621 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); | 608 user_cert_combobox_->set_listener(this); |
622 user_cert_combobox_->set_listener(this); | 609 layout_->AddView(user_cert_combobox_); |
623 layout->AddView(user_cert_combobox_); | 610 layout_->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_)); |
624 layout->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_)); | 611 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
625 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
626 } else { | |
627 user_cert_label_ = NULL; | |
628 user_cert_combobox_ = NULL; | |
629 } | |
630 | 612 |
631 // Username label and input. | 613 // Username label and input. |
632 layout->StartRow(0, column_view_set_id); | 614 layout_->StartRow(0, 0); |
633 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 615 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
634 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME))); | 616 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME))); |
635 username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 617 username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
636 username_textfield_->SetController(this); | 618 username_textfield_->SetController(this); |
637 username_textfield_->SetEnabled(username_ui_data_.IsEditable()); | 619 username_textfield_->SetEnabled(username_ui_data_.IsEditable()); |
638 if (vpn && !vpn->username().empty()) | 620 layout_->AddView(username_textfield_); |
639 username_textfield_->SetText(UTF8ToUTF16(vpn->username())); | 621 layout_->AddView(new ControlledSettingIndicatorView(username_ui_data_)); |
640 layout->AddView(username_textfield_); | 622 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
641 layout->AddView(new ControlledSettingIndicatorView(username_ui_data_)); | |
642 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
643 | 623 |
644 // User passphrase label, input and visble button. | 624 // User passphrase label, input and visble button. |
645 layout->StartRow(0, column_view_set_id); | 625 layout_->StartRow(0, 0); |
646 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 626 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
647 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE))); | 627 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE))); |
648 bool has_user_passphrase = vpn && !vpn->IsUserPassphraseRequired(); | 628 user_passphrase_textfield_ = new PassphraseTextfield(); |
649 user_passphrase_textfield_ = new PassphraseTextfield(has_user_passphrase); | |
650 user_passphrase_textfield_->SetController(this); | 629 user_passphrase_textfield_->SetController(this); |
651 user_passphrase_textfield_->SetEnabled(user_passphrase_ui_data_.IsEditable()); | 630 user_passphrase_textfield_->SetEnabled(user_passphrase_ui_data_.IsEditable()); |
652 layout->AddView(user_passphrase_textfield_); | 631 layout_->AddView(user_passphrase_textfield_); |
653 layout->AddView(new ControlledSettingIndicatorView(user_passphrase_ui_data_)); | 632 layout_->AddView( |
654 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 633 new ControlledSettingIndicatorView(user_passphrase_ui_data_)); |
| 634 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
655 | 635 |
656 // OTP label and input. | 636 // OTP label and input. |
657 if (enable_otp_) { | 637 layout_->StartRow(0, 0); |
658 layout->StartRow(0, column_view_set_id); | 638 otp_label_ = new views::Label(l10n_util::GetStringUTF16( |
659 otp_label_ = new views::Label(l10n_util::GetStringUTF16( | 639 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP)); |
660 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP)); | 640 layout_->AddView(otp_label_); |
661 layout->AddView(otp_label_); | 641 otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
662 otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 642 otp_textfield_->SetController(this); |
663 otp_textfield_->SetController(this); | 643 layout_->AddView(otp_textfield_); |
664 layout->AddView(otp_textfield_); | 644 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
665 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
666 } else { | |
667 otp_label_ = NULL; | |
668 otp_textfield_ = NULL; | |
669 } | |
670 | 645 |
671 // Group Name label and input. | 646 // Group Name label and input. |
672 if (enable_group_name_) { | 647 layout_->StartRow(0, 0); |
673 layout->StartRow(0, column_view_set_id); | 648 group_name_label_ = new views::Label(l10n_util::GetStringUTF16( |
674 group_name_label_ = new views::Label(l10n_util::GetStringUTF16( | 649 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME)); |
675 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME)); | 650 layout_->AddView(group_name_label_); |
676 layout->AddView(group_name_label_); | 651 group_name_textfield_ = |
677 group_name_textfield_ = | 652 new views::Textfield(views::Textfield::STYLE_DEFAULT); |
678 new views::Textfield(views::Textfield::STYLE_DEFAULT); | 653 group_name_textfield_->SetController(this); |
679 group_name_textfield_->SetController(this); | 654 layout_->AddView(group_name_textfield_); |
680 if (vpn && !vpn->group_name().empty()) | 655 layout_->AddView(new ControlledSettingIndicatorView(group_name_ui_data_)); |
681 group_name_textfield_->SetText(UTF8ToUTF16(vpn->group_name())); | 656 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
682 layout->AddView(group_name_textfield_); | |
683 layout->AddView(new ControlledSettingIndicatorView(group_name_ui_data_)); | |
684 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
685 } else { | |
686 group_name_label_ = NULL; | |
687 group_name_textfield_ = NULL; | |
688 } | |
689 | 657 |
690 // Save credentials | 658 // Save credentials |
691 layout->StartRow(0, column_view_set_id); | 659 layout_->StartRow(0, 0); |
692 save_credentials_checkbox_ = new views::Checkbox( | 660 save_credentials_checkbox_ = new views::Checkbox( |
693 l10n_util::GetStringUTF16( | 661 l10n_util::GetStringUTF16( |
694 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); | 662 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
695 save_credentials_checkbox_->SetEnabled( | 663 save_credentials_checkbox_->SetEnabled( |
696 save_credentials_ui_data_.IsEditable()); | 664 save_credentials_ui_data_.IsEditable()); |
697 bool save_credentials = vpn ? vpn->save_credentials() : false; | 665 layout_->SkipColumns(1); |
698 save_credentials_checkbox_->SetChecked(save_credentials); | 666 layout_->AddView(save_credentials_checkbox_); |
699 layout->SkipColumns(1); | 667 layout_->AddView( |
700 layout->AddView(save_credentials_checkbox_); | |
701 layout->AddView( | |
702 new ControlledSettingIndicatorView(save_credentials_ui_data_)); | 668 new ControlledSettingIndicatorView(save_credentials_ui_data_)); |
703 | 669 |
704 // Error label. | 670 // Error label. |
705 layout->StartRow(0, column_view_set_id); | 671 layout_->StartRow(0, 0); |
706 layout->SkipColumns(1); | 672 layout_->SkipColumns(1); |
707 error_label_ = new views::Label(); | 673 error_label_ = new views::Label(); |
708 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 674 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
709 error_label_->SetEnabledColor(SK_ColorRED); | 675 error_label_->SetEnabledColor(SK_ColorRED); |
710 layout->AddView(error_label_); | 676 layout_->AddView(error_label_); |
711 | 677 |
712 // Set or hide the UI, update comboboxes and error labels. | 678 // Set or hide the UI, update comboboxes and error labels. |
713 Refresh(); | 679 Refresh(); |
| 680 |
| 681 if (vpn) { |
| 682 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| 683 service_path_, |
| 684 base::Bind(&VPNConfigView::InitFromProperties, |
| 685 weak_ptr_factory_.GetWeakPtr()), |
| 686 base::Bind(&VPNConfigView::GetPropertiesError, |
| 687 weak_ptr_factory_.GetWeakPtr())); |
| 688 } |
| 689 } |
| 690 |
| 691 void VPNConfigView::InitFromProperties( |
| 692 const std::string& service_path, |
| 693 const base::DictionaryValue& service_properties) { |
| 694 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
| 695 GetNetworkState(service_path); |
| 696 if (!vpn) { |
| 697 NET_LOG_ERROR("Shill Error getting properties VpnConfigView", service_path); |
| 698 return; |
| 699 } |
| 700 |
| 701 std::string provider_type, server_hostname, username, group_name; |
| 702 bool psk_passphrase_required = false; |
| 703 const base::DictionaryValue* provider_properties; |
| 704 if (service_properties.GetDictionaryWithoutPathExpansion( |
| 705 flimflam::kProviderProperty, &provider_properties)) { |
| 706 provider_properties->GetStringWithoutPathExpansion( |
| 707 flimflam::kTypeProperty, &provider_type); |
| 708 provider_properties->GetStringWithoutPathExpansion( |
| 709 flimflam::kHostProperty, &server_hostname); |
| 710 } |
| 711 if (provider_type == flimflam::kProviderL2tpIpsec) { |
| 712 provider_properties->GetStringWithoutPathExpansion( |
| 713 flimflam::kL2tpIpsecClientCertIdProperty, &client_cert_id_); |
| 714 ca_cert_pem_ = GetPemFromDictionary( |
| 715 provider_properties, shill::kL2tpIpsecCaCertPemProperty); |
| 716 provider_properties->GetBooleanWithoutPathExpansion( |
| 717 flimflam::kL2tpIpsecPskRequiredProperty, &psk_passphrase_required); |
| 718 provider_properties->GetStringWithoutPathExpansion( |
| 719 flimflam::kL2tpIpsecUserProperty, &username); |
| 720 provider_properties->GetStringWithoutPathExpansion( |
| 721 shill::kL2tpIpsecTunnelGroupProperty, &group_name); |
| 722 } else if (provider_type == flimflam::kProviderOpenVpn) { |
| 723 provider_properties->GetStringWithoutPathExpansion( |
| 724 flimflam::kOpenVPNClientCertIdProperty, &client_cert_id_); |
| 725 ca_cert_pem_ = GetPemFromDictionary( |
| 726 provider_properties, shill::kOpenVPNCaCertPemProperty); |
| 727 provider_properties->GetStringWithoutPathExpansion( |
| 728 flimflam::kOpenVPNUserProperty, &username); |
| 729 } |
| 730 bool save_credentials = false; |
| 731 service_properties.GetBooleanWithoutPathExpansion( |
| 732 flimflam::kSaveCredentialsProperty, &save_credentials); |
| 733 |
| 734 provider_type_index_ = ProviderTypeToIndex(provider_type, client_cert_id_); |
| 735 |
| 736 if (service_text_) |
| 737 service_text_->SetText(ASCIIToUTF16(vpn->name())); |
| 738 if (provider_type_text_label_) |
| 739 provider_type_text_label_->SetText( |
| 740 ProviderTypeIndexToString(provider_type_index_)); |
| 741 |
| 742 if (server_textfield_ && !server_hostname.empty()) |
| 743 server_textfield_->SetText(UTF8ToUTF16(server_hostname)); |
| 744 if (username_textfield_ && !username.empty()) |
| 745 username_textfield_->SetText(UTF8ToUTF16(username)); |
| 746 if (group_name_textfield_ && !group_name.empty()) |
| 747 group_name_textfield_->SetText(UTF8ToUTF16(group_name)); |
| 748 if (psk_passphrase_textfield_) |
| 749 psk_passphrase_textfield_->SetShowFake(!psk_passphrase_required); |
| 750 if (save_credentials_checkbox_) |
| 751 save_credentials_checkbox_->SetChecked(save_credentials); |
| 752 |
| 753 Refresh(); |
| 754 } |
| 755 |
| 756 void VPNConfigView::ParseUIProperties(const NetworkState* vpn) { |
| 757 std::string type_dict_name = |
| 758 ProviderTypeIndexToONCDictKey(provider_type_index_); |
| 759 if (provider_type_index_ == PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK) { |
| 760 ParseVPNUIProperty(vpn, type_dict_name, onc::ipsec::kServerCARef, |
| 761 &ca_cert_ui_data_); |
| 762 ParseVPNUIProperty(vpn, type_dict_name, onc::ipsec::kPSK, |
| 763 &psk_passphrase_ui_data_); |
| 764 ParseVPNUIProperty(vpn, type_dict_name, onc::ipsec::kGroup, |
| 765 &group_name_ui_data_); |
| 766 } else if (provider_type_index_ == PROVIDER_TYPE_INDEX_OPEN_VPN) { |
| 767 ParseVPNUIProperty(vpn, type_dict_name, onc::openvpn::kServerCARef, |
| 768 &ca_cert_ui_data_); |
| 769 } |
| 770 ParseVPNUIProperty(vpn, type_dict_name, onc::vpn::kClientCertRef, |
| 771 &user_cert_ui_data_); |
| 772 |
| 773 const std::string credentials_dict_name( |
| 774 provider_type_index_ == PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK ? |
| 775 onc::vpn::kL2TP : type_dict_name); |
| 776 ParseVPNUIProperty(vpn, credentials_dict_name, onc::vpn::kUsername, |
| 777 &username_ui_data_); |
| 778 ParseVPNUIProperty(vpn, credentials_dict_name, onc::vpn::kPassword, |
| 779 &user_passphrase_ui_data_); |
| 780 ParseVPNUIProperty(vpn, credentials_dict_name, onc::vpn::kSaveCredentials, |
| 781 &save_credentials_ui_data_); |
| 782 } |
| 783 |
| 784 void VPNConfigView::GetPropertiesError( |
| 785 const std::string& error_name, |
| 786 scoped_ptr<base::DictionaryValue> error_data) { |
| 787 NET_LOG_ERROR("Shill Error from VpnConfigView: " + error_name, ""); |
| 788 } |
| 789 |
| 790 void VPNConfigView::SetConfigProperties( |
| 791 base::DictionaryValue* properties) { |
| 792 int provider_type_index = GetProviderTypeIndex(); |
| 793 std::string user_passphrase = GetUserPassphrase(); |
| 794 std::string user_name = GetUsername(); |
| 795 std::string group_name = GetGroupName(); |
| 796 switch (provider_type_index) { |
| 797 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK: { |
| 798 std::string psk_passphrase = GetPSKPassphrase(); |
| 799 if (!psk_passphrase.empty()) { |
| 800 properties->SetStringWithoutPathExpansion( |
| 801 flimflam::kL2tpIpsecPskProperty, GetPSKPassphrase()); |
| 802 } |
| 803 if (!group_name.empty()) { |
| 804 properties->SetStringWithoutPathExpansion( |
| 805 shill::kL2tpIpsecTunnelGroupProperty, group_name); |
| 806 } |
| 807 if (!user_name.empty()) { |
| 808 properties->SetStringWithoutPathExpansion( |
| 809 flimflam::kL2tpIpsecUserProperty, user_name); |
| 810 } |
| 811 if (!user_passphrase.empty()) { |
| 812 properties->SetStringWithoutPathExpansion( |
| 813 flimflam::kL2tpIpsecPasswordProperty, user_passphrase); |
| 814 } |
| 815 break; |
| 816 } |
| 817 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: { |
| 818 std::string ca_cert_pem = GetServerCACertPEM(); |
| 819 if (!ca_cert_pem.empty()) { |
| 820 properties->SetStringWithoutPathExpansion( |
| 821 shill::kL2tpIpsecCaCertPemProperty, ca_cert_pem); |
| 822 } |
| 823 properties->SetStringWithoutPathExpansion( |
| 824 flimflam::kL2tpIpsecClientCertIdProperty, GetUserCertID()); |
| 825 if (!group_name.empty()) { |
| 826 properties->SetStringWithoutPathExpansion( |
| 827 shill::kL2tpIpsecTunnelGroupProperty, GetGroupName()); |
| 828 } |
| 829 if (!user_name.empty()) { |
| 830 properties->SetStringWithoutPathExpansion( |
| 831 flimflam::kL2tpIpsecUserProperty, user_name); |
| 832 } |
| 833 if (!user_passphrase.empty()) { |
| 834 properties->SetStringWithoutPathExpansion( |
| 835 flimflam::kL2tpIpsecPasswordProperty, user_passphrase); |
| 836 } |
| 837 break; |
| 838 } |
| 839 case PROVIDER_TYPE_INDEX_OPEN_VPN: { |
| 840 std::string ca_cert_pem = GetServerCACertPEM(); |
| 841 if (!ca_cert_pem.empty()) { |
| 842 base::ListValue* pem_list = new base::ListValue; |
| 843 pem_list->AppendString(GetServerCACertPEM()); |
| 844 properties->SetWithoutPathExpansion( |
| 845 shill::kOpenVPNCaCertPemProperty, pem_list); |
| 846 } |
| 847 properties->SetStringWithoutPathExpansion( |
| 848 flimflam::kOpenVPNClientCertIdProperty, GetUserCertID()); |
| 849 properties->SetStringWithoutPathExpansion( |
| 850 flimflam::kOpenVPNUserProperty, GetUsername()); |
| 851 if (!user_passphrase.empty()) { |
| 852 properties->SetStringWithoutPathExpansion( |
| 853 flimflam::kOpenVPNPasswordProperty, user_passphrase); |
| 854 } |
| 855 std::string otp = GetOTP(); |
| 856 if (!otp.empty()) { |
| 857 properties->SetStringWithoutPathExpansion( |
| 858 flimflam::kOpenVPNOTPProperty, otp); |
| 859 } |
| 860 break; |
| 861 } |
| 862 case PROVIDER_TYPE_INDEX_MAX: |
| 863 NOTREACHED(); |
| 864 break; |
| 865 } |
| 866 properties->SetBooleanWithoutPathExpansion( |
| 867 flimflam::kSaveCredentialsProperty, GetSaveCredentials()); |
714 } | 868 } |
715 | 869 |
716 void VPNConfigView::Refresh() { | 870 void VPNConfigView::Refresh() { |
717 NetworkLibrary* cros = NetworkLibrary::Get(); | |
718 | |
719 UpdateControls(); | 871 UpdateControls(); |
720 | 872 |
721 // Set certificate combo boxes. | 873 // Set certificate combo boxes. |
722 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | |
723 if (server_ca_cert_combobox_) { | 874 if (server_ca_cert_combobox_) { |
724 server_ca_cert_combobox_->ModelChanged(); | 875 server_ca_cert_combobox_->ModelChanged(); |
725 if (enable_server_ca_cert_ && | 876 if (enable_server_ca_cert_ && !ca_cert_pem_.empty()) { |
726 (vpn && !vpn->ca_cert_pem().empty())) { | |
727 // Select the current server CA certificate in the combobox. | 877 // Select the current server CA certificate in the combobox. |
728 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( | 878 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
729 CertLibrary::CERT_TYPE_SERVER_CA, vpn->ca_cert_pem()); | 879 CertLibrary::CERT_TYPE_SERVER_CA, ca_cert_pem_); |
730 if (cert_index >= 0) { | 880 if (cert_index >= 0) { |
731 // Skip item for "Default" | 881 // Skip item for "Default" |
732 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | 882 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
733 } else { | 883 } else { |
734 server_ca_cert_combobox_->SetSelectedIndex(0); | 884 server_ca_cert_combobox_->SetSelectedIndex(0); |
735 } | 885 } |
736 } else { | 886 } else { |
737 server_ca_cert_combobox_->SetSelectedIndex(0); | 887 server_ca_cert_combobox_->SetSelectedIndex(0); |
738 } | 888 } |
739 } | 889 } |
740 | 890 |
741 if (user_cert_combobox_) { | 891 if (user_cert_combobox_) { |
742 user_cert_combobox_->ModelChanged(); | 892 user_cert_combobox_->ModelChanged(); |
743 if (enable_user_cert_ && | 893 if (enable_user_cert_ && !client_cert_id_.empty()) { |
744 (vpn && !vpn->client_cert_id().empty())) { | |
745 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( | 894 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( |
746 CertLibrary::CERT_TYPE_USER, vpn->client_cert_id()); | 895 CertLibrary::CERT_TYPE_USER, client_cert_id_); |
747 if (cert_index >= 0) | 896 if (cert_index >= 0) |
748 user_cert_combobox_->SetSelectedIndex(cert_index); | 897 user_cert_combobox_->SetSelectedIndex(cert_index); |
749 else | 898 else |
750 user_cert_combobox_->SetSelectedIndex(0); | 899 user_cert_combobox_->SetSelectedIndex(0); |
751 } else { | 900 } else { |
752 user_cert_combobox_->SetSelectedIndex(0); | 901 user_cert_combobox_->SetSelectedIndex(0); |
753 } | 902 } |
754 } | 903 } |
755 | 904 |
756 UpdateErrorLabel(); | 905 UpdateErrorLabel(); |
757 } | 906 } |
758 | 907 |
759 void VPNConfigView::UpdateControlsToEnable() { | 908 void VPNConfigView::UpdateControlsToEnable() { |
760 // Set which controls are enabled. | |
761 enable_psk_passphrase_ = false; | 909 enable_psk_passphrase_ = false; |
762 enable_user_cert_ = false; | 910 enable_user_cert_ = false; |
763 enable_server_ca_cert_ = false; | 911 enable_server_ca_cert_ = false; |
764 enable_otp_ = false; | 912 enable_otp_ = false; |
765 enable_group_name_ = false; | 913 enable_group_name_ = false; |
766 switch (provider_type_) { | 914 int provider_type_index = GetProviderTypeIndex(); |
767 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | 915 if (provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK) { |
768 enable_psk_passphrase_ = true; | 916 enable_psk_passphrase_ = true; |
769 enable_group_name_ = true; | 917 enable_group_name_ = true; |
770 break; | 918 } else if (provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT) { |
771 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: | 919 enable_server_ca_cert_ = true; |
772 enable_server_ca_cert_ = true; | 920 enable_user_cert_ = HaveUserCerts(); |
773 enable_user_cert_ = HaveUserCerts(); | 921 enable_group_name_ = true; |
774 enable_group_name_ = true; | 922 } else { // PROVIDER_TYPE_INDEX_OPEN_VPN (default) |
775 break; | 923 enable_server_ca_cert_ = true; |
776 case PROVIDER_TYPE_OPEN_VPN: | 924 enable_user_cert_ = HaveUserCerts(); |
777 enable_server_ca_cert_ = true; | 925 enable_otp_ = true; |
778 enable_user_cert_ = HaveUserCerts(); | |
779 enable_otp_ = true; | |
780 break; | |
781 default: | |
782 NOTREACHED(); | |
783 break; | |
784 } | 926 } |
785 } | 927 } |
786 | 928 |
787 void VPNConfigView::UpdateControls() { | 929 void VPNConfigView::UpdateControls() { |
788 UpdateControlsToEnable(); | 930 UpdateControlsToEnable(); |
789 | 931 |
790 if (psk_passphrase_label_) | 932 if (psk_passphrase_label_) |
791 psk_passphrase_label_->SetEnabled(enable_psk_passphrase_); | 933 psk_passphrase_label_->SetEnabled(enable_psk_passphrase_); |
792 if (psk_passphrase_textfield_) | 934 if (psk_passphrase_textfield_) |
793 psk_passphrase_textfield_->SetEnabled(enable_psk_passphrase_ && | 935 psk_passphrase_textfield_->SetEnabled(enable_psk_passphrase_ && |
(...skipping 17 matching lines...) Expand all Loading... |
811 otp_textfield_->SetEnabled(enable_otp_); | 953 otp_textfield_->SetEnabled(enable_otp_); |
812 | 954 |
813 if (group_name_label_) | 955 if (group_name_label_) |
814 group_name_label_->SetEnabled(enable_group_name_); | 956 group_name_label_->SetEnabled(enable_group_name_); |
815 if (group_name_textfield_) | 957 if (group_name_textfield_) |
816 group_name_textfield_->SetEnabled(enable_group_name_ && | 958 group_name_textfield_->SetEnabled(enable_group_name_ && |
817 group_name_ui_data_.IsEditable()); | 959 group_name_ui_data_.IsEditable()); |
818 } | 960 } |
819 | 961 |
820 void VPNConfigView::UpdateErrorLabel() { | 962 void VPNConfigView::UpdateErrorLabel() { |
821 NetworkLibrary* cros = NetworkLibrary::Get(); | |
822 | |
823 // Error message. | 963 // Error message. |
824 std::string error_msg; | 964 string16 error_msg; |
825 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { | 965 bool cert_required = |
| 966 GetProviderTypeIndex() == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT; |
| 967 if (cert_required && CertLibrary::Get()->CertificatesLoaded()) { |
826 if (!HaveUserCerts()) { | 968 if (!HaveUserCerts()) { |
827 error_msg = l10n_util::GetStringUTF8( | 969 error_msg = l10n_util::GetStringUTF16( |
828 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); | 970 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); |
829 } else if (!IsUserCertValid()) { | 971 } else if (!IsUserCertValid()) { |
830 error_msg = l10n_util::GetStringUTF8( | 972 error_msg = l10n_util::GetStringUTF16( |
831 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); | 973 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); |
832 } | 974 } |
833 } | 975 } |
834 if (error_msg.empty() && !service_path_.empty()) { | 976 if (error_msg.empty() && !service_path_.empty()) { |
835 // TODO(kuan): differentiate between bad psk and user passphrases. | 977 // TODO(kuan): differentiate between bad psk and user passphrases. |
836 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | 978 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
837 if (vpn && vpn->failed()) { | 979 GetNetworkState(service_path_); |
838 if (vpn->error() == ERROR_BAD_PASSPHRASE) { | 980 if (vpn && vpn->connection_state() == flimflam::kStateFailure) |
839 error_msg = l10n_util::GetStringUTF8( | 981 error_msg = ash::network_connect::ErrorString(vpn->error()); |
840 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); | |
841 } else { | |
842 error_msg = vpn->GetErrorString(); | |
843 } | |
844 } | |
845 } | 982 } |
846 if (!error_msg.empty()) { | 983 if (!error_msg.empty()) { |
847 error_label_->SetText(UTF8ToUTF16(error_msg)); | 984 error_label_->SetText(error_msg); |
848 error_label_->SetVisible(true); | 985 error_label_->SetVisible(true); |
849 } else { | 986 } else { |
850 error_label_->SetVisible(false); | 987 error_label_->SetVisible(false); |
851 } | 988 } |
852 } | 989 } |
853 | 990 |
854 void VPNConfigView::UpdateCanLogin() { | 991 void VPNConfigView::UpdateCanLogin() { |
855 parent_->GetDialogClientView()->UpdateDialogButtons(); | 992 parent_->GetDialogClientView()->UpdateDialogButtons(); |
856 } | 993 } |
857 | 994 |
858 bool VPNConfigView::UserCertRequired() const { | |
859 return provider_type_ == PROVIDER_TYPE_L2TP_IPSEC_USER_CERT; | |
860 } | |
861 | |
862 bool VPNConfigView::HaveUserCerts() const { | 995 bool VPNConfigView::HaveUserCerts() const { |
863 return CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) > 0; | 996 return CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) > 0; |
864 } | 997 } |
865 | 998 |
866 bool VPNConfigView::IsUserCertValid() const { | 999 bool VPNConfigView::IsUserCertValid() const { |
867 if (!user_cert_combobox_ || !enable_user_cert_) | 1000 if (!user_cert_combobox_ || !enable_user_cert_) |
868 return false; | 1001 return false; |
869 int index = user_cert_combobox_->selected_index(); | 1002 int index = user_cert_combobox_->selected_index(); |
870 if (index < 0) | 1003 if (index < 0) |
871 return false; | 1004 return false; |
(...skipping 17 matching lines...) Expand all Loading... |
889 return result; | 1022 return result; |
890 } | 1023 } |
891 | 1024 |
892 const std::string VPNConfigView::GetPassphraseFromField( | 1025 const std::string VPNConfigView::GetPassphraseFromField( |
893 PassphraseTextfield* textfield) const { | 1026 PassphraseTextfield* textfield) const { |
894 if (!textfield) | 1027 if (!textfield) |
895 return std::string(); | 1028 return std::string(); |
896 return textfield->GetPassphrase(); | 1029 return textfield->GetPassphrase(); |
897 } | 1030 } |
898 | 1031 |
899 void VPNConfigView::ParseVPNUIProperty(NetworkPropertyUIData* property_ui_data, | 1032 void VPNConfigView::ParseVPNUIProperty( |
900 Network* network, | 1033 const NetworkState* network, |
901 const std::string& dict_key, | 1034 const std::string& dict_key, |
902 const std::string& key) { | 1035 const std::string& key, |
| 1036 NetworkPropertyUIData* property_ui_data) { |
903 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 1037 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
904 const base::DictionaryValue* onc = | 1038 const base::DictionaryValue* onc = |
905 NetworkConfigView::FindPolicyForActiveUser(network, &onc_source); | 1039 network_connect::FindPolicyForActiveUser(network, &onc_source); |
906 | 1040 |
907 VLOG_IF(1, !onc) << "No ONC found for VPN network " << network->unique_id(); | 1041 VLOG_IF(1, !onc) << "No ONC found for VPN network " << network->guid(); |
908 property_ui_data->ParseOncProperty( | 1042 property_ui_data->ParseOncProperty( |
909 onc_source, | 1043 onc_source, |
910 onc, | 1044 onc, |
911 base::StringPrintf("%s.%s.%s", | 1045 base::StringPrintf("%s.%s.%s", |
912 onc::network_config::kVPN, | 1046 onc::network_config::kVPN, |
913 dict_key.c_str(), | 1047 dict_key.c_str(), |
914 key.c_str())); | 1048 key.c_str())); |
915 } | 1049 } |
916 | 1050 |
917 } // namespace chromeos | 1051 } // namespace chromeos |
OLD | NEW |