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 ProviderTypeComboboxIndex { |
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 ProviderTypeComboboxIndex ProviderTypeToIndex( | |
68 const std::string& provider_type, | |
69 const std::string& client_cert_id) { | |
70 if (provider_type == flimflam::kProviderL2tpIpsec) { | |
71 if (!client_cert_id.empty()) | |
72 return PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT; | |
73 else | |
74 return PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK; | |
75 } else { | |
76 DCHECK(provider_type == flimflam::kProviderOpenVpn); | |
77 return PROVIDER_TYPE_INDEX_OPEN_VPN; | |
78 } | |
79 } | |
80 | |
56 // Translates the provider type to the name of the respective ONC dictionary | 81 // Translates the provider type to the name of the respective ONC dictionary |
57 // containing configuration data for the type. | 82 // containing configuration data for the type. |
58 std::string ProviderTypeToONCDictKey(chromeos::ProviderType type) { | 83 std::string ProviderTypeToONCDictKey(const std::string& provider_type) { |
59 switch (type) { | 84 if (provider_type == flimflam::kProviderL2tpIpsec) |
60 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK: | 85 return chromeos::onc::vpn::kIPsec; |
61 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: | 86 if (provider_type == flimflam::kProviderOpenVpn) |
62 return chromeos::onc::vpn::kIPsec; | 87 return chromeos::onc::vpn::kOpenVPN; |
63 case chromeos::PROVIDER_TYPE_OPEN_VPN: | 88 NOTREACHED() << "Unhandled provider type " << provider_type; |
64 return chromeos::onc::vpn::kOpenVPN; | 89 return std::string(); |
65 case chromeos::PROVIDER_TYPE_MAX: | 90 } |
66 break; | |
67 } | |
68 | 91 |
69 NOTREACHED() << "Unhandled provider type " << type; | 92 void ShillError(const std::string& function, |
70 return std::string(); | 93 const std::string& error_name, |
94 scoped_ptr<base::DictionaryValue> error_data) { | |
95 NET_LOG_ERROR("Shill Error from VpnConfigView: " + error_name, function); | |
71 } | 96 } |
72 | 97 |
73 } // namespace | 98 } // namespace |
74 | 99 |
75 namespace chromeos { | 100 namespace chromeos { |
76 | 101 |
77 namespace internal { | 102 namespace internal { |
78 | 103 |
79 class ProviderTypeComboboxModel : public ui::ComboboxModel { | 104 class ProviderTypeComboboxModel : public ui::ComboboxModel { |
80 public: | 105 public: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 | 142 |
118 // ProviderTypeComboboxModel --------------------------------------------------- | 143 // ProviderTypeComboboxModel --------------------------------------------------- |
119 | 144 |
120 ProviderTypeComboboxModel::ProviderTypeComboboxModel() { | 145 ProviderTypeComboboxModel::ProviderTypeComboboxModel() { |
121 } | 146 } |
122 | 147 |
123 ProviderTypeComboboxModel::~ProviderTypeComboboxModel() { | 148 ProviderTypeComboboxModel::~ProviderTypeComboboxModel() { |
124 } | 149 } |
125 | 150 |
126 int ProviderTypeComboboxModel::GetItemCount() const { | 151 int ProviderTypeComboboxModel::GetItemCount() const { |
127 return PROVIDER_TYPE_MAX; | 152 return PROVIDER_TYPE_INDEX_MAX; |
128 } | 153 } |
129 | 154 |
130 string16 ProviderTypeComboboxModel::GetItemAt(int index) { | 155 string16 ProviderTypeComboboxModel::GetItemAt(int index) { |
131 ProviderType type = static_cast<ProviderType>(index); | 156 return ProviderTypeIndexToString(index); |
132 return ProviderTypeToString(type); | |
133 } | 157 } |
134 | 158 |
135 // VpnServerCACertComboboxModel ------------------------------------------------ | 159 // VpnServerCACertComboboxModel ------------------------------------------------ |
136 | 160 |
137 VpnServerCACertComboboxModel::VpnServerCACertComboboxModel() { | 161 VpnServerCACertComboboxModel::VpnServerCACertComboboxModel() { |
138 } | 162 } |
139 | 163 |
140 VpnServerCACertComboboxModel::~VpnServerCACertComboboxModel() { | 164 VpnServerCACertComboboxModel::~VpnServerCACertComboboxModel() { |
141 } | 165 } |
142 | 166 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) { | 210 if (CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) == 0) { |
187 return l10n_util::GetStringUTF16( | 211 return l10n_util::GetStringUTF16( |
188 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); | 212 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_USER_CERT_NONE_INSTALLED); |
189 } | 213 } |
190 return CertLibrary::Get()->GetCertDisplayStringAt( | 214 return CertLibrary::Get()->GetCertDisplayStringAt( |
191 CertLibrary::CERT_TYPE_USER, index); | 215 CertLibrary::CERT_TYPE_USER, index); |
192 } | 216 } |
193 | 217 |
194 } // namespace internal | 218 } // namespace internal |
195 | 219 |
196 VPNConfigView::VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn) | 220 VPNConfigView::VPNConfigView(NetworkConfigView* parent, |
197 : ChildNetworkConfigView(parent, vpn), | 221 const std::string& service_path) |
198 title_(0) { | 222 : ChildNetworkConfigView(parent, service_path), |
199 Init(vpn); | 223 service_text_modified_(false), |
200 } | 224 enable_psk_passphrase_(false), |
201 | 225 enable_user_cert_(false), |
202 VPNConfigView::VPNConfigView(NetworkConfigView* parent) | 226 enable_server_ca_cert_(false), |
203 : ChildNetworkConfigView(parent), | 227 enable_otp_(false), |
204 title_(0) { | 228 enable_group_name_(false), |
205 Init(NULL); | 229 title_(0), |
230 layout_(NULL), | |
231 server_textfield_(NULL), | |
232 service_text_(NULL), | |
233 service_textfield_(NULL), | |
234 provider_type_combobox_(NULL), | |
235 provider_type_text_label_(NULL), | |
236 psk_passphrase_label_(NULL), | |
237 psk_passphrase_textfield_(NULL), | |
238 user_cert_label_(NULL), | |
239 user_cert_combobox_(NULL), | |
240 server_ca_cert_label_(NULL), | |
241 server_ca_cert_combobox_(NULL), | |
242 username_textfield_(NULL), | |
243 user_passphrase_textfield_(NULL), | |
244 otp_label_(NULL), | |
245 otp_textfield_(NULL), | |
246 group_name_label_(NULL), | |
247 group_name_textfield_(NULL), | |
248 save_credentials_checkbox_(NULL), | |
249 error_label_(NULL) { | |
250 Init(); | |
206 } | 251 } |
207 | 252 |
208 VPNConfigView::~VPNConfigView() { | 253 VPNConfigView::~VPNConfigView() { |
209 CertLibrary::Get()->RemoveObserver(this); | 254 CertLibrary::Get()->RemoveObserver(this); |
210 } | 255 } |
211 | 256 |
212 string16 VPNConfigView::GetTitle() const { | 257 string16 VPNConfigView::GetTitle() const { |
213 DCHECK_NE(title_, 0); | 258 DCHECK_NE(title_, 0); |
214 return l10n_util::GetStringUTF16(title_); | 259 return l10n_util::GetStringUTF16(title_); |
215 } | 260 } |
(...skipping 10 matching lines...) Expand all Loading... | |
226 return psk_passphrase_textfield_; | 271 return psk_passphrase_textfield_; |
227 else if (user_cert_combobox_ && user_cert_combobox_->enabled()) | 272 else if (user_cert_combobox_ && user_cert_combobox_->enabled()) |
228 return user_cert_combobox_; | 273 return user_cert_combobox_; |
229 else if (server_ca_cert_combobox_ && server_ca_cert_combobox_->enabled()) | 274 else if (server_ca_cert_combobox_ && server_ca_cert_combobox_->enabled()) |
230 return server_ca_cert_combobox_; | 275 return server_ca_cert_combobox_; |
231 else | 276 else |
232 return NULL; | 277 return NULL; |
233 } | 278 } |
234 | 279 |
235 bool VPNConfigView::CanLogin() { | 280 bool VPNConfigView::CanLogin() { |
281 int provider_type_index = GetProviderTypeIndex(); | |
282 | |
236 // Username is always required. | 283 // Username is always required. |
237 if (GetUsername().empty()) | 284 if (GetUsername().empty()) |
238 return false; | 285 return false; |
239 | 286 |
240 // TODO(stevenjb): min kMinPassphraseLen length? | 287 // TODO(stevenjb): min kMinPassphraseLen length? |
241 if (service_path_.empty() && | 288 if (service_path_.empty() && |
242 (GetService().empty() || GetServer().empty())) | 289 (GetService().empty() || GetServer().empty())) |
243 return false; | 290 return false; |
244 | 291 |
245 // Block login if certs are required but user has none. | 292 // Block login if certs are required but user has none. |
246 if (UserCertRequired() && (!HaveUserCerts() || !IsUserCertValid())) | 293 bool cert_required = |
294 provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT; | |
295 if (cert_required && (!HaveUserCerts() || !IsUserCertValid())) | |
247 return false; | 296 return false; |
248 | 297 |
249 return true; | 298 return true; |
250 } | 299 } |
251 | 300 |
252 void VPNConfigView::ContentsChanged(views::Textfield* sender, | 301 void VPNConfigView::ContentsChanged(views::Textfield* sender, |
253 const string16& new_contents) { | 302 const string16& new_contents) { |
254 if (sender == server_textfield_ && !service_text_modified_) { | 303 if (sender == server_textfield_ && !service_text_modified_) { |
255 // Set the service name to the server name up to '.', unless it has | 304 // Set the service name to the server name up to '.', unless it has |
256 // been explicitly set by the user. | 305 // been explicitly set by the user. |
(...skipping 19 matching lines...) Expand all Loading... | |
276 parent_->GetDialogClientView()->AcceptWindow(); | 325 parent_->GetDialogClientView()->AcceptWindow(); |
277 } | 326 } |
278 return false; | 327 return false; |
279 } | 328 } |
280 | 329 |
281 void VPNConfigView::ButtonPressed(views::Button* sender, | 330 void VPNConfigView::ButtonPressed(views::Button* sender, |
282 const ui::Event& event) { | 331 const ui::Event& event) { |
283 } | 332 } |
284 | 333 |
285 void VPNConfigView::OnSelectedIndexChanged(views::Combobox* combobox) { | 334 void VPNConfigView::OnSelectedIndexChanged(views::Combobox* combobox) { |
286 if (combobox == provider_type_combobox_) { | 335 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(); | 336 UpdateErrorLabel(); |
296 UpdateCanLogin(); | 337 UpdateCanLogin(); |
297 } | 338 } |
298 | 339 |
299 void VPNConfigView::OnCertificatesLoaded(bool initial_load) { | 340 void VPNConfigView::OnCertificatesLoaded(bool initial_load) { |
300 Refresh(); | 341 Refresh(); |
301 } | 342 } |
302 | 343 |
303 bool VPNConfigView::Login() { | 344 bool VPNConfigView::Login() { |
304 NetworkLibrary* cros = NetworkLibrary::Get(); | |
305 if (service_path_.empty()) { | 345 if (service_path_.empty()) { |
306 NetworkLibrary::VPNConfigData config_data; | 346 base::DictionaryValue properties; |
307 switch (provider_type_) { | 347 // Identifying properties |
308 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | 348 properties.SetStringWithoutPathExpansion( |
309 config_data.psk = GetPSKPassphrase(); | 349 flimflam::kTypeProperty, flimflam::kTypeVPN); |
310 config_data.username = GetUsername(); | 350 properties.SetStringWithoutPathExpansion( |
311 config_data.user_passphrase = GetUserPassphrase(); | 351 flimflam::kNameProperty, GetService()); |
312 config_data.group_name = GetGroupName(); | 352 properties.SetStringWithoutPathExpansion( |
313 break; | 353 flimflam::kProviderHostProperty, GetServer()); |
314 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: { | 354 properties.SetStringWithoutPathExpansion( |
315 config_data.server_ca_cert_pem = GetServerCACertPEM(); | 355 flimflam::kProviderTypeProperty, GetProviderTypeString()); |
316 config_data.client_cert_pkcs11_id = GetUserCertID(); | 356 |
317 config_data.username = GetUsername(); | 357 SetCredentials(&properties); |
318 config_data.user_passphrase = GetUserPassphrase(); | 358 ash::network_connect::CreateConfigurationAndConnect( |
319 config_data.group_name = GetGroupName(); | 359 &properties, false /* shared */); |
320 break; | 360 } else { |
321 } | 361 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
322 case PROVIDER_TYPE_OPEN_VPN: | 362 GetNetworkState(service_path_); |
323 config_data.server_ca_cert_pem = GetServerCACertPEM(); | 363 if (!vpn) { |
324 config_data.client_cert_pkcs11_id = GetUserCertID(); | 364 // Shill no longer knows about this network (edge case). |
325 config_data.username = GetUsername(); | 365 // TODO(stevenjb): Add notification for this. |
326 config_data.user_passphrase = GetUserPassphrase(); | 366 NET_LOG_ERROR("Network not found", service_path_); |
327 config_data.otp = GetOTP(); | 367 return true; // Close dialog |
328 break; | |
329 case PROVIDER_TYPE_MAX: | |
330 break; | |
331 } | 368 } |
332 config_data.save_credentials = GetSaveCredentials(); | 369 base::DictionaryValue properties; |
333 cros->ConnectToUnconfiguredVirtualNetwork( | 370 SetCredentials(&properties); |
334 GetService(), GetServer(), provider_type_, config_data); | 371 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 } | 372 } |
373 // Connection failures are responsible for updating the UI, including | |
374 // reopening dialogs. | |
375 return true; // Close dialog. | 373 return true; // Close dialog. |
376 } | 374 } |
377 | 375 |
378 void VPNConfigView::Cancel() { | 376 void VPNConfigView::Cancel() { |
379 } | 377 } |
380 | 378 |
381 void VPNConfigView::InitFocus() { | 379 void VPNConfigView::InitFocus() { |
382 views::View* view_to_focus = GetInitiallyFocusedView(); | 380 views::View* view_to_focus = GetInitiallyFocusedView(); |
383 if (view_to_focus) | 381 if (view_to_focus) |
384 view_to_focus->RequestFocus(); | 382 view_to_focus->RequestFocus(); |
385 } | 383 } |
386 | 384 |
387 const std::string VPNConfigView::GetService() const { | 385 const std::string VPNConfigView::GetService() const { |
388 if (service_textfield_ != NULL) | 386 if (service_textfield_ != NULL) |
389 return GetTextFromField(service_textfield_, true); | 387 return GetTextFromField(service_textfield_, true); |
390 return service_path_; | 388 return service_path_; |
391 } | 389 } |
392 | 390 |
393 const std::string VPNConfigView::GetServer() const { | 391 const std::string VPNConfigView::GetServer() const { |
394 if (server_textfield_ != NULL) | 392 if (server_textfield_ != NULL) |
395 return GetTextFromField(server_textfield_, true); | 393 return GetTextFromField(server_textfield_, true); |
396 return server_hostname_; | 394 return std::string(); |
397 } | 395 } |
398 | 396 |
399 const std::string VPNConfigView::GetPSKPassphrase() const { | 397 const std::string VPNConfigView::GetPSKPassphrase() const { |
400 if (psk_passphrase_textfield_ && | 398 if (psk_passphrase_textfield_ && |
401 enable_psk_passphrase_ && | 399 enable_psk_passphrase_ && |
402 psk_passphrase_textfield_->visible()) | 400 psk_passphrase_textfield_->visible()) |
403 return GetPassphraseFromField(psk_passphrase_textfield_); | 401 return GetPassphraseFromField(psk_passphrase_textfield_); |
404 return std::string(); | 402 return std::string(); |
405 } | 403 } |
406 | 404 |
(...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; | 439 int index = user_cert_combobox_ ? user_cert_combobox_->selected_index() : 0; |
442 return CertLibrary::Get()->GetCertPkcs11IdAt( | 440 return CertLibrary::Get()->GetCertPkcs11IdAt( |
443 CertLibrary::CERT_TYPE_USER, index); | 441 CertLibrary::CERT_TYPE_USER, index); |
444 } | 442 } |
445 } | 443 } |
446 | 444 |
447 bool VPNConfigView::GetSaveCredentials() const { | 445 bool VPNConfigView::GetSaveCredentials() const { |
448 return save_credentials_checkbox_->checked(); | 446 return save_credentials_checkbox_->checked(); |
449 } | 447 } |
450 | 448 |
451 void VPNConfigView::Init(VirtualNetwork* vpn) { | 449 int VPNConfigView::GetProviderTypeIndex() const { |
452 if (vpn) { | 450 if (!provider_type_.empty()) |
453 ProviderType type = vpn->provider_type(); | 451 return ProviderTypeToIndex(provider_type_, client_cert_id_); |
454 std::string type_dict_name = ProviderTypeToONCDictKey(type); | 452 if (provider_type_combobox_) |
453 return provider_type_combobox_->selected_index(); | |
454 return PROVIDER_TYPE_INDEX_MAX; | |
455 } | |
455 | 456 |
456 if (type == PROVIDER_TYPE_L2TP_IPSEC_PSK) { | 457 std::string VPNConfigView::GetProviderTypeString() const { |
457 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name, | 458 int index = GetProviderTypeIndex(); |
458 onc::ipsec::kServerCARef); | 459 switch (index) { |
459 ParseVPNUIProperty(&psk_passphrase_ui_data_, vpn, type_dict_name, | 460 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK: |
460 onc::ipsec::kPSK); | 461 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: |
461 ParseVPNUIProperty(&group_name_ui_data_, vpn, type_dict_name, | 462 return flimflam::kProviderL2tpIpsec; |
462 onc::ipsec::kGroup); | 463 case PROVIDER_TYPE_INDEX_OPEN_VPN: |
463 } else { // OpenVPN | 464 return flimflam::kProviderOpenVpn; |
464 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name, | 465 } |
465 onc::openvpn::kServerCARef); | 466 NOTREACHED(); |
466 } | 467 return std::string(); |
467 ParseVPNUIProperty(&user_cert_ui_data_, vpn, type_dict_name, | 468 } |
468 onc::vpn::kClientCertRef); | |
469 | 469 |
470 const std::string credentials_dict_name( | 470 void VPNConfigView::Init() { |
471 type == PROVIDER_TYPE_L2TP_IPSEC_PSK ? | 471 const NetworkState* vpn = service_path_.empty() ? NULL : |
472 onc::vpn::kL2TP : type_dict_name); | 472 NetworkHandler::Get()->network_state_handler()-> |
473 ParseVPNUIProperty(&username_ui_data_, vpn, credentials_dict_name, | 473 GetNetworkState(service_path_); |
474 onc::vpn::kUsername); | |
475 ParseVPNUIProperty(&user_passphrase_ui_data_, vpn, credentials_dict_name, | |
476 onc::vpn::kPassword); | |
477 ParseVPNUIProperty(&save_credentials_ui_data_, vpn, credentials_dict_name, | |
478 onc::vpn::kSaveCredentials); | |
479 } | |
480 | 474 |
481 views::GridLayout* layout = views::GridLayout::CreatePanel(this); | 475 layout_ = views::GridLayout::CreatePanel(this); |
482 SetLayoutManager(layout); | 476 SetLayoutManager(layout_); |
483 | 477 |
484 // Observer any changes to the certificate list. | 478 // Observer any changes to the certificate list. |
485 CertLibrary::Get()->AddObserver(this); | 479 CertLibrary::Get()->AddObserver(this); |
486 | 480 |
487 const int column_view_set_id = 0; | 481 views::ColumnSet* column_set = layout_->AddColumnSet(0); |
488 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); | |
489 // Label. | 482 // Label. |
490 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 483 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
491 views::GridLayout::USE_PREF, 0, 0); | 484 views::GridLayout::USE_PREF, 0, 0); |
492 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); | 485 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); |
493 // Textfield, combobox. | 486 // Textfield, combobox. |
494 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 487 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
495 views::GridLayout::USE_PREF, 0, | 488 views::GridLayout::USE_PREF, 0, |
496 ChildNetworkConfigView::kInputFieldMinWidth); | 489 ChildNetworkConfigView::kInputFieldMinWidth); |
497 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); | 490 column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); |
498 // Policy indicator. | 491 // Policy indicator. |
499 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, | 492 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 0, |
500 views::GridLayout::USE_PREF, 0, 0); | 493 views::GridLayout::USE_PREF, 0, 0); |
501 | 494 |
502 // Initialize members. | 495 // Initialize members. |
503 service_text_modified_ = false; | 496 service_text_modified_ = false; |
497 title_ = vpn ? IDS_OPTIONS_SETTINGS_JOIN_VPN : IDS_OPTIONS_SETTINGS_ADD_VPN; | |
498 | |
499 // Set up initial layout. | |
500 InitControls(); | |
501 | |
504 if (vpn) { | 502 if (vpn) { |
505 provider_type_ = vpn->provider_type(); | 503 NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
506 // Sets enable_* based on the provider type which we use to control | 504 service_path_, |
507 // which controls to make visible. | 505 base::Bind(&VPNConfigView::InitFromProperties, AsWeakPtr()), |
508 UpdateControlsToEnable(); | 506 base::Bind(&VPNConfigView::GetPropertiesError, AsWeakPtr())); |
509 } else { | 507 } |
510 // Set the default provider type. | 508 } |
511 provider_type_ = PROVIDER_TYPE_L2TP_IPSEC_PSK; | 509 |
512 // Provider Type is user selectable, so enable all controls during init. | 510 void VPNConfigView::InitControls() { |
513 enable_psk_passphrase_ = true; | 511 // By default enable all controls. |
514 enable_user_cert_ = true; | 512 enable_psk_passphrase_ = true; |
515 enable_server_ca_cert_ = true; | 513 enable_user_cert_ = true; |
516 enable_otp_ = true; | 514 enable_server_ca_cert_ = true; |
517 enable_group_name_ = true; | 515 enable_otp_ = true; |
518 } | 516 enable_group_name_ = true; |
519 | |
520 // Initialize the title string ID used for the dialog. | |
521 title_ = vpn ? IDS_OPTIONS_SETTINGS_JOIN_VPN : IDS_OPTIONS_SETTINGS_ADD_VPN; | |
522 | 517 |
523 // Server label and input. | 518 // Server label and input. |
524 // Only provide Server name when configuring a new VPN. | 519 // Only provide Server name when configuring a new VPN. |
525 if (!vpn) { | 520 if (service_path_.empty()) { |
526 layout->StartRow(0, column_view_set_id); | 521 layout_->StartRow(0, 0); |
527 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 522 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
528 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME))); | 523 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVER_HOSTNAME))); |
529 server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 524 server_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
530 server_textfield_->SetController(this); | 525 server_textfield_->SetController(this); |
531 layout->AddView(server_textfield_); | 526 layout_->AddView(server_textfield_); |
532 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 527 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
533 } else { | 528 } else { |
534 server_textfield_ = NULL; | 529 server_textfield_ = NULL; |
535 } | 530 } |
536 | 531 |
537 // Service label and name or input. | 532 // Service label and name or input. |
538 layout->StartRow(0, column_view_set_id); | 533 layout_->StartRow(0, 0); |
539 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 534 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
540 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME))); | 535 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_SERVICE_NAME))); |
541 if (!vpn) { | 536 if (service_path_.empty()) { |
542 service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 537 service_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
543 service_textfield_->SetController(this); | 538 service_textfield_->SetController(this); |
544 layout->AddView(service_textfield_); | 539 layout_->AddView(service_textfield_); |
545 service_text_ = NULL; | 540 service_text_ = NULL; |
546 } else { | 541 } else { |
547 service_text_ = new views::Label(ASCIIToUTF16(vpn->name())); | 542 service_text_ = new views::Label(); |
548 service_text_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 543 service_text_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
549 layout->AddView(service_text_); | 544 layout_->AddView(service_text_); |
550 service_textfield_ = NULL; | 545 service_textfield_ = NULL; |
551 } | 546 } |
552 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 547 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
553 | 548 |
554 // Provider type label and select. | 549 // Provider type label and select. |
555 layout->StartRow(0, column_view_set_id); | 550 layout_->StartRow(0, 0); |
556 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 551 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
557 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE))); | 552 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PROVIDER_TYPE))); |
558 if (!vpn) { | 553 if (service_path_.empty()) { |
559 provider_type_combobox_model_.reset( | 554 provider_type_combobox_model_.reset( |
560 new internal::ProviderTypeComboboxModel); | 555 new internal::ProviderTypeComboboxModel); |
561 provider_type_combobox_ = new views::Combobox( | 556 provider_type_combobox_ = new views::Combobox( |
562 provider_type_combobox_model_.get()); | 557 provider_type_combobox_model_.get()); |
563 provider_type_combobox_->set_listener(this); | 558 provider_type_combobox_->set_listener(this); |
564 layout->AddView(provider_type_combobox_); | 559 layout_->AddView(provider_type_combobox_); |
565 provider_type_text_label_ = NULL; | 560 provider_type_text_label_ = NULL; |
566 } else { | 561 } else { |
567 provider_type_text_label_ = | 562 provider_type_text_label_ = new views::Label(); |
568 new views::Label(ProviderTypeToString(provider_type_)); | |
569 provider_type_text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 563 provider_type_text_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
570 layout->AddView(provider_type_text_label_); | 564 layout_->AddView(provider_type_text_label_); |
571 provider_type_combobox_ = NULL; | 565 provider_type_combobox_ = NULL; |
572 } | 566 } |
573 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 567 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
574 | 568 |
575 // PSK passphrase label, input and visible button. | 569 // PSK passphrase label, input and visible button. |
576 if (enable_psk_passphrase_) { | 570 layout_->StartRow(0, 0); |
gauravsh
2013/08/03 01:15:54
The enable_psk_passphrase_ isn't needed anymore?
stevenjb
2013/08/06 00:32:48
Because we are asynchronously requesting the prope
| |
577 layout->StartRow(0, column_view_set_id); | 571 psk_passphrase_label_ = new views::Label(l10n_util::GetStringUTF16( |
578 psk_passphrase_label_ = new views::Label(l10n_util::GetStringUTF16( | 572 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE)); |
579 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_PSK_PASSPHRASE)); | 573 layout_->AddView(psk_passphrase_label_); |
580 layout->AddView(psk_passphrase_label_); | 574 psk_passphrase_textfield_ = new PassphraseTextfield(); |
581 bool has_psk_passphrase = vpn && !vpn->IsPSKPassphraseRequired(); | 575 psk_passphrase_textfield_->SetController(this); |
582 psk_passphrase_textfield_ = new PassphraseTextfield(has_psk_passphrase); | 576 layout_->AddView(psk_passphrase_textfield_); |
583 psk_passphrase_textfield_->SetController(this); | 577 layout_->AddView( |
584 layout->AddView(psk_passphrase_textfield_); | 578 new ControlledSettingIndicatorView(psk_passphrase_ui_data_)); |
585 layout->AddView( | 579 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 | 580 |
593 // Server CA certificate | 581 // Server CA certificate |
594 // Only provide Server CA when configuring a new VPN. | 582 layout_->StartRow(0, 0); |
gauravsh
2013/08/03 01:15:54
Why no check for the service_path_.empty() here?
stevenjb
2013/08/06 00:32:48
Hm, I'm not sure actually, good catch, I'll fix th
| |
595 if (!vpn) { | 583 server_ca_cert_label_ = new views::Label(l10n_util::GetStringUTF16( |
596 layout->StartRow(0, column_view_set_id); | 584 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA)); |
597 server_ca_cert_label_ = | 585 layout_->AddView(server_ca_cert_label_); |
598 new views::Label(l10n_util::GetStringUTF16( | 586 server_ca_cert_combobox_model_.reset( |
599 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_SERVER_CA)); | 587 new internal::VpnServerCACertComboboxModel()); |
600 layout->AddView(server_ca_cert_label_); | 588 server_ca_cert_combobox_ = new views::Combobox( |
601 server_ca_cert_combobox_model_.reset( | 589 server_ca_cert_combobox_model_.get()); |
602 new internal::VpnServerCACertComboboxModel()); | 590 layout_->AddView(server_ca_cert_combobox_); |
603 server_ca_cert_combobox_ = new views::Combobox( | 591 layout_->AddView(new ControlledSettingIndicatorView(ca_cert_ui_data_)); |
604 server_ca_cert_combobox_model_.get()); | 592 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
605 layout->AddView(server_ca_cert_combobox_); | |
606 layout->AddView(new ControlledSettingIndicatorView(ca_cert_ui_data_)); | |
607 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
608 } else { | |
609 server_ca_cert_label_ = NULL; | |
610 server_ca_cert_combobox_ = NULL; | |
611 } | |
612 | 593 |
613 // User certificate label and input. | 594 // User certificate label and input. |
614 if (enable_user_cert_) { | 595 layout_->StartRow(0, 0); |
615 layout->StartRow(0, column_view_set_id); | 596 user_cert_label_ = new views::Label(l10n_util::GetStringUTF16( |
616 user_cert_label_ = new views::Label(l10n_util::GetStringUTF16( | 597 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT)); |
617 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_CERT)); | 598 layout_->AddView(user_cert_label_); |
618 layout->AddView(user_cert_label_); | 599 user_cert_combobox_model_.reset( |
619 user_cert_combobox_model_.reset( | 600 new internal::VpnUserCertComboboxModel()); |
620 new internal::VpnUserCertComboboxModel()); | 601 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); |
621 user_cert_combobox_ = new views::Combobox(user_cert_combobox_model_.get()); | 602 user_cert_combobox_->set_listener(this); |
622 user_cert_combobox_->set_listener(this); | 603 layout_->AddView(user_cert_combobox_); |
623 layout->AddView(user_cert_combobox_); | 604 layout_->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_)); |
624 layout->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_)); | 605 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 | 606 |
631 // Username label and input. | 607 // Username label and input. |
632 layout->StartRow(0, column_view_set_id); | 608 layout_->StartRow(0, 0); |
633 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 609 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
634 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME))); | 610 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USERNAME))); |
635 username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 611 username_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
636 username_textfield_->SetController(this); | 612 username_textfield_->SetController(this); |
637 username_textfield_->SetEnabled(username_ui_data_.IsEditable()); | 613 username_textfield_->SetEnabled(username_ui_data_.IsEditable()); |
638 if (vpn && !vpn->username().empty()) | 614 layout_->AddView(username_textfield_); |
gauravsh
2013/08/03 01:15:54
No longer a call to username_textfield_->SetText()
stevenjb
2013/08/06 00:32:48
Yes, that got moved to the bottom of InitFromPrope
| |
639 username_textfield_->SetText(UTF8ToUTF16(vpn->username())); | 615 layout_->AddView(new ControlledSettingIndicatorView(username_ui_data_)); |
640 layout->AddView(username_textfield_); | 616 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
641 layout->AddView(new ControlledSettingIndicatorView(username_ui_data_)); | |
642 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
643 | 617 |
644 // User passphrase label, input and visble button. | 618 // User passphrase label, input and visble button. |
645 layout->StartRow(0, column_view_set_id); | 619 layout_->StartRow(0, 0); |
646 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 620 layout_->AddView(new views::Label(l10n_util::GetStringUTF16( |
647 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE))); | 621 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_USER_PASSPHRASE))); |
648 bool has_user_passphrase = vpn && !vpn->IsUserPassphraseRequired(); | 622 user_passphrase_textfield_ = new PassphraseTextfield(); |
649 user_passphrase_textfield_ = new PassphraseTextfield(has_user_passphrase); | |
650 user_passphrase_textfield_->SetController(this); | 623 user_passphrase_textfield_->SetController(this); |
651 user_passphrase_textfield_->SetEnabled(user_passphrase_ui_data_.IsEditable()); | 624 user_passphrase_textfield_->SetEnabled(user_passphrase_ui_data_.IsEditable()); |
652 layout->AddView(user_passphrase_textfield_); | 625 layout_->AddView(user_passphrase_textfield_); |
653 layout->AddView(new ControlledSettingIndicatorView(user_passphrase_ui_data_)); | 626 layout_->AddView( |
654 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 627 new ControlledSettingIndicatorView(user_passphrase_ui_data_)); |
628 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
655 | 629 |
656 // OTP label and input. | 630 // OTP label and input. |
657 if (enable_otp_) { | 631 layout_->StartRow(0, 0); |
658 layout->StartRow(0, column_view_set_id); | 632 otp_label_ = new views::Label(l10n_util::GetStringUTF16( |
659 otp_label_ = new views::Label(l10n_util::GetStringUTF16( | 633 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP)); |
660 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_OTP)); | 634 layout_->AddView(otp_label_); |
661 layout->AddView(otp_label_); | 635 otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); |
662 otp_textfield_ = new views::Textfield(views::Textfield::STYLE_DEFAULT); | 636 otp_textfield_->SetController(this); |
663 otp_textfield_->SetController(this); | 637 layout_->AddView(otp_textfield_); |
664 layout->AddView(otp_textfield_); | 638 layout_->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
665 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | |
666 } else { | |
667 otp_label_ = NULL; | |
668 otp_textfield_ = NULL; | |
669 } | |
670 | 639 |
671 // Group Name label and input. | 640 // Group Name label and input. |
672 if (enable_group_name_) { | 641 layout_->StartRow(0, 0); |
673 layout->StartRow(0, column_view_set_id); | 642 group_name_label_ = new views::Label(l10n_util::GetStringUTF16( |
674 group_name_label_ = new views::Label(l10n_util::GetStringUTF16( | 643 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME)); |
675 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_VPN_GROUP_NAME)); | 644 layout_->AddView(group_name_label_); |
676 layout->AddView(group_name_label_); | 645 group_name_textfield_ = |
677 group_name_textfield_ = | 646 new views::Textfield(views::Textfield::STYLE_DEFAULT); |
678 new views::Textfield(views::Textfield::STYLE_DEFAULT); | 647 group_name_textfield_->SetController(this); |
679 group_name_textfield_->SetController(this); | 648 layout_->AddView(group_name_textfield_); |
680 if (vpn && !vpn->group_name().empty()) | 649 layout_->AddView(new ControlledSettingIndicatorView(group_name_ui_data_)); |
gauravsh
2013/08/03 01:15:54
Here as well.
stevenjb
2013/08/06 00:32:48
Ditto
| |
681 group_name_textfield_->SetText(UTF8ToUTF16(vpn->group_name())); | 650 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 | 651 |
690 // Save credentials | 652 // Save credentials |
691 layout->StartRow(0, column_view_set_id); | 653 layout_->StartRow(0, 0); |
692 save_credentials_checkbox_ = new views::Checkbox( | 654 save_credentials_checkbox_ = new views::Checkbox( |
693 l10n_util::GetStringUTF16( | 655 l10n_util::GetStringUTF16( |
694 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); | 656 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
695 save_credentials_checkbox_->SetEnabled( | 657 save_credentials_checkbox_->SetEnabled( |
696 save_credentials_ui_data_.IsEditable()); | 658 save_credentials_ui_data_.IsEditable()); |
697 bool save_credentials = vpn ? vpn->save_credentials() : false; | 659 layout_->SkipColumns(1); |
698 save_credentials_checkbox_->SetChecked(save_credentials); | 660 layout_->AddView(save_credentials_checkbox_); |
699 layout->SkipColumns(1); | 661 layout_->AddView( |
700 layout->AddView(save_credentials_checkbox_); | |
701 layout->AddView( | |
702 new ControlledSettingIndicatorView(save_credentials_ui_data_)); | 662 new ControlledSettingIndicatorView(save_credentials_ui_data_)); |
703 | 663 |
704 // Error label. | 664 // Error label. |
705 layout->StartRow(0, column_view_set_id); | 665 layout_->StartRow(0, 0); |
706 layout->SkipColumns(1); | 666 layout_->SkipColumns(1); |
707 error_label_ = new views::Label(); | 667 error_label_ = new views::Label(); |
708 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 668 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
709 error_label_->SetEnabledColor(SK_ColorRED); | 669 error_label_->SetEnabledColor(SK_ColorRED); |
710 layout->AddView(error_label_); | 670 layout_->AddView(error_label_); |
711 | 671 |
712 // Set or hide the UI, update comboboxes and error labels. | 672 // Set or hide the UI, update comboboxes and error labels. |
713 Refresh(); | 673 Refresh(); |
714 } | 674 } |
715 | 675 |
676 void VPNConfigView::InitFromProperties( | |
677 const std::string& service_path, | |
678 const base::DictionaryValue& service_properties) { | |
679 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> | |
680 GetNetworkState(service_path); | |
681 if (!vpn) { | |
gauravsh
2013/08/03 01:15:54
DCHECK the type to make sure it's indeed a kTypeVp
stevenjb
2013/08/06 00:32:48
Added a DCHECK in Init()
| |
682 NET_LOG_ERROR("Shill Error getting properties VpnConfigView", service_path); | |
683 return; | |
684 } | |
685 | |
686 std::string server_hostname, username, group_name; | |
687 bool psk_passphrase_required = false; | |
688 const base::DictionaryValue* provider_properties; | |
689 if (service_properties.GetDictionaryWithoutPathExpansion( | |
690 flimflam::kProviderProperty, &provider_properties)) { | |
691 provider_properties->GetStringWithoutPathExpansion( | |
692 flimflam::kTypeProperty, &provider_type_); | |
693 service_properties.GetStringWithoutPathExpansion( | |
694 flimflam::kHostProperty, &server_hostname); | |
695 } | |
696 if (provider_type_ == flimflam::kProviderL2tpIpsec) { | |
697 service_properties.GetStringWithoutPathExpansion( | |
698 flimflam::kL2tpIpsecClientCertIdProperty, &client_cert_id_); | |
699 service_properties.GetStringWithoutPathExpansion( | |
700 shill::kL2tpIpsecCaCertPemProperty, &ca_cert_pem_); | |
701 service_properties.GetBooleanWithoutPathExpansion( | |
702 flimflam::kL2tpIpsecPskRequiredProperty, &psk_passphrase_required); | |
703 service_properties.GetStringWithoutPathExpansion( | |
704 flimflam::kL2tpIpsecUserProperty, &username); | |
705 service_properties.GetStringWithoutPathExpansion( | |
706 shill::kL2tpIpsecTunnelGroupProperty, &group_name); | |
707 } else if (provider_type_ == flimflam::kProviderOpenVpn) { | |
708 service_properties.GetStringWithoutPathExpansion( | |
709 flimflam::kOpenVPNClientCertIdProperty, &client_cert_id_); | |
710 service_properties.GetStringWithoutPathExpansion( | |
711 shill::kOpenVPNCaCertPemProperty, &ca_cert_pem_); | |
712 service_properties.GetStringWithoutPathExpansion( | |
713 flimflam::kOpenVPNUserProperty, &username); | |
714 } | |
715 bool user_passphrase_required = false; | |
716 service_properties.GetBooleanWithoutPathExpansion( | |
717 flimflam::kPassphraseRequiredProperty, &user_passphrase_required); | |
gauravsh
2013/08/03 01:15:54
Where is user_passphrase_required used?
stevenjb
2013/08/06 00:32:48
It's not any more. I looked at how we were using t
| |
718 bool save_credentials = false; | |
719 service_properties.GetBooleanWithoutPathExpansion( | |
720 flimflam::kSaveCredentialsProperty, &save_credentials); | |
721 | |
722 ProviderTypeComboboxIndex provider_type_index = | |
723 ProviderTypeToIndex(provider_type_, client_cert_id_); | |
724 | |
725 std::string type_dict_name = ProviderTypeToONCDictKey(provider_type_); | |
726 if (provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK) { | |
gauravsh
2013/08/03 01:15:54
To keep this method smaller, this ONC dictionary h
stevenjb
2013/08/06 00:32:48
Added ParseUIProperties()
| |
727 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name, | |
728 onc::ipsec::kServerCARef); | |
729 ParseVPNUIProperty(&psk_passphrase_ui_data_, vpn, type_dict_name, | |
730 onc::ipsec::kPSK); | |
731 ParseVPNUIProperty(&group_name_ui_data_, vpn, type_dict_name, | |
732 onc::ipsec::kGroup); | |
733 } else if (provider_type_index == PROVIDER_TYPE_INDEX_OPEN_VPN) { | |
734 ParseVPNUIProperty(&ca_cert_ui_data_, vpn, type_dict_name, | |
735 onc::openvpn::kServerCARef); | |
736 } | |
737 ParseVPNUIProperty(&user_cert_ui_data_, vpn, type_dict_name, | |
738 onc::vpn::kClientCertRef); | |
739 | |
740 const std::string credentials_dict_name( | |
741 provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK ? | |
742 onc::vpn::kL2TP : type_dict_name); | |
743 ParseVPNUIProperty(&username_ui_data_, vpn, credentials_dict_name, | |
744 onc::vpn::kUsername); | |
745 ParseVPNUIProperty(&user_passphrase_ui_data_, vpn, credentials_dict_name, | |
746 onc::vpn::kPassword); | |
747 ParseVPNUIProperty(&save_credentials_ui_data_, vpn, credentials_dict_name, | |
748 onc::vpn::kSaveCredentials); | |
749 | |
750 if (service_text_) | |
751 service_text_->SetText(ASCIIToUTF16(vpn->name())); | |
752 if (provider_type_text_label_) | |
753 provider_type_text_label_->SetText( | |
754 ProviderTypeIndexToString(provider_type_index)); | |
755 | |
756 if (server_textfield_ && !server_hostname.empty()) | |
757 server_textfield_->SetText(UTF8ToUTF16(server_hostname)); | |
758 if (username_textfield_ && !username.empty()) | |
759 username_textfield_->SetText(UTF8ToUTF16(username)); | |
760 if (group_name_textfield_ && !group_name.empty()) | |
761 group_name_textfield_->SetText(UTF8ToUTF16(group_name)); | |
762 if (psk_passphrase_textfield_) | |
763 psk_passphrase_textfield_->SetShowFake(!psk_passphrase_required); | |
764 if (save_credentials_checkbox_) | |
765 save_credentials_checkbox_->SetChecked(save_credentials); | |
766 } | |
767 | |
768 void VPNConfigView::GetPropertiesError( | |
769 const std::string& error_name, | |
770 scoped_ptr<base::DictionaryValue> error_data) { | |
771 NET_LOG_ERROR("Shill Error from VpnConfigView: " + error_name, ""); | |
772 } | |
773 | |
774 void VPNConfigView::SetCredentials(base::DictionaryValue* properties) { | |
775 int provider_type_index = GetProviderTypeIndex(); | |
776 std::string user_passphrase = GetUserPassphrase(); | |
777 std::string user_name = GetUsername(); | |
778 std::string group_name = GetGroupName(); | |
779 switch (provider_type_index) { | |
780 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK: { | |
781 std::string psk_passphrase = GetPSKPassphrase(); | |
782 if (!psk_passphrase.empty()) { | |
783 properties->SetStringWithoutPathExpansion( | |
784 flimflam::kL2tpIpsecPskProperty, GetPSKPassphrase()); | |
785 } | |
786 if (!group_name.empty()) { | |
787 properties->SetStringWithoutPathExpansion( | |
788 shill::kL2tpIpsecTunnelGroupProperty, group_name); | |
789 } | |
790 if (!user_name.empty()) { | |
791 properties->SetStringWithoutPathExpansion( | |
792 flimflam::kL2tpIpsecUserProperty, user_name); | |
793 } | |
794 if (!user_passphrase.empty()) { | |
795 properties->SetStringWithoutPathExpansion( | |
796 flimflam::kL2tpIpsecPasswordProperty, user_passphrase); | |
797 } | |
798 break; | |
799 } | |
800 case PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT: { | |
801 std::string ca_cert_pem = GetServerCACertPEM(); | |
802 if (!ca_cert_pem.empty()) { | |
803 properties->SetStringWithoutPathExpansion( | |
804 shill::kL2tpIpsecCaCertPemProperty, ca_cert_pem); | |
805 } | |
806 properties->SetStringWithoutPathExpansion( | |
807 flimflam::kL2tpIpsecClientCertIdProperty, GetUserCertID()); | |
808 if (!group_name.empty()) { | |
809 properties->SetStringWithoutPathExpansion( | |
810 shill::kL2tpIpsecTunnelGroupProperty, GetGroupName()); | |
811 } | |
812 if (!user_name.empty()) { | |
813 properties->SetStringWithoutPathExpansion( | |
814 flimflam::kL2tpIpsecUserProperty, user_name); | |
815 } | |
816 if (!user_passphrase.empty()) { | |
817 properties->SetStringWithoutPathExpansion( | |
818 flimflam::kL2tpIpsecPasswordProperty, user_passphrase); | |
819 } | |
820 break; | |
821 } | |
822 case PROVIDER_TYPE_INDEX_OPEN_VPN: { | |
823 std::string ca_cert_pem = GetServerCACertPEM(); | |
824 if (!ca_cert_pem.empty()) { | |
825 base::ListValue* pem_list = new base::ListValue; | |
826 pem_list->AppendString(GetServerCACertPEM()); | |
827 properties->SetWithoutPathExpansion( | |
828 shill::kOpenVPNCaCertPemProperty, pem_list); | |
829 } | |
830 properties->SetStringWithoutPathExpansion( | |
831 flimflam::kOpenVPNClientCertIdProperty, GetUserCertID()); | |
832 properties->SetStringWithoutPathExpansion( | |
833 flimflam::kOpenVPNUserProperty, GetUsername()); | |
834 if (!user_passphrase.empty()) { | |
835 properties->SetStringWithoutPathExpansion( | |
836 flimflam::kOpenVPNPasswordProperty, user_passphrase); | |
837 } | |
838 std::string otp = GetOTP(); | |
839 if (!otp.empty()) { | |
840 properties->SetStringWithoutPathExpansion( | |
841 flimflam::kOpenVPNOTPProperty, otp); | |
842 } | |
843 break; | |
844 } | |
845 case PROVIDER_TYPE_INDEX_MAX: | |
846 NOTREACHED(); | |
847 break; | |
848 } | |
849 properties->SetBooleanWithoutPathExpansion( | |
850 flimflam::kSaveCredentialsProperty, GetSaveCredentials()); | |
851 } | |
852 | |
716 void VPNConfigView::Refresh() { | 853 void VPNConfigView::Refresh() { |
717 NetworkLibrary* cros = NetworkLibrary::Get(); | |
718 | |
719 UpdateControls(); | 854 UpdateControls(); |
720 | 855 |
721 // Set certificate combo boxes. | 856 // Set certificate combo boxes. |
722 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | |
723 if (server_ca_cert_combobox_) { | 857 if (server_ca_cert_combobox_) { |
724 server_ca_cert_combobox_->ModelChanged(); | 858 server_ca_cert_combobox_->ModelChanged(); |
725 if (enable_server_ca_cert_ && | 859 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. | 860 // Select the current server CA certificate in the combobox. |
728 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( | 861 int cert_index = CertLibrary::Get()->GetCertIndexByPEM( |
729 CertLibrary::CERT_TYPE_SERVER_CA, vpn->ca_cert_pem()); | 862 CertLibrary::CERT_TYPE_SERVER_CA, ca_cert_pem_); |
730 if (cert_index >= 0) { | 863 if (cert_index >= 0) { |
731 // Skip item for "Default" | 864 // Skip item for "Default" |
732 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); | 865 server_ca_cert_combobox_->SetSelectedIndex(1 + cert_index); |
733 } else { | 866 } else { |
734 server_ca_cert_combobox_->SetSelectedIndex(0); | 867 server_ca_cert_combobox_->SetSelectedIndex(0); |
735 } | 868 } |
736 } else { | 869 } else { |
737 server_ca_cert_combobox_->SetSelectedIndex(0); | 870 server_ca_cert_combobox_->SetSelectedIndex(0); |
738 } | 871 } |
739 } | 872 } |
740 | 873 |
741 if (user_cert_combobox_) { | 874 if (user_cert_combobox_) { |
742 user_cert_combobox_->ModelChanged(); | 875 user_cert_combobox_->ModelChanged(); |
743 if (enable_user_cert_ && | 876 if (enable_user_cert_ && !client_cert_id_.empty()) { |
744 (vpn && !vpn->client_cert_id().empty())) { | |
745 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( | 877 int cert_index = CertLibrary::Get()->GetCertIndexByPkcs11Id( |
746 CertLibrary::CERT_TYPE_USER, vpn->client_cert_id()); | 878 CertLibrary::CERT_TYPE_USER, client_cert_id_); |
747 if (cert_index >= 0) | 879 if (cert_index >= 0) |
748 user_cert_combobox_->SetSelectedIndex(cert_index); | 880 user_cert_combobox_->SetSelectedIndex(cert_index); |
749 else | 881 else |
750 user_cert_combobox_->SetSelectedIndex(0); | 882 user_cert_combobox_->SetSelectedIndex(0); |
751 } else { | 883 } else { |
752 user_cert_combobox_->SetSelectedIndex(0); | 884 user_cert_combobox_->SetSelectedIndex(0); |
753 } | 885 } |
754 } | 886 } |
755 | 887 |
756 UpdateErrorLabel(); | 888 UpdateErrorLabel(); |
757 } | 889 } |
758 | 890 |
759 void VPNConfigView::UpdateControlsToEnable() { | 891 void VPNConfigView::UpdateControlsToEnable() { |
760 // Set which controls are enabled. | |
761 enable_psk_passphrase_ = false; | 892 enable_psk_passphrase_ = false; |
762 enable_user_cert_ = false; | 893 enable_user_cert_ = false; |
763 enable_server_ca_cert_ = false; | 894 enable_server_ca_cert_ = false; |
764 enable_otp_ = false; | 895 enable_otp_ = false; |
765 enable_group_name_ = false; | 896 enable_group_name_ = false; |
766 switch (provider_type_) { | 897 int provider_type_index = GetProviderTypeIndex(); |
767 case PROVIDER_TYPE_L2TP_IPSEC_PSK: | 898 if (provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_PSK) { |
768 enable_psk_passphrase_ = true; | 899 enable_psk_passphrase_ = true; |
769 enable_group_name_ = true; | 900 enable_group_name_ = true; |
770 break; | 901 } else if (provider_type_index == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT) { |
771 case PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: | 902 enable_server_ca_cert_ = true; |
772 enable_server_ca_cert_ = true; | 903 enable_user_cert_ = HaveUserCerts(); |
773 enable_user_cert_ = HaveUserCerts(); | 904 enable_group_name_ = true; |
774 enable_group_name_ = true; | 905 } else { // PROVIDER_TYPE_INDEX_OPEN_VPN (default) |
775 break; | 906 enable_server_ca_cert_ = true; |
776 case PROVIDER_TYPE_OPEN_VPN: | 907 enable_user_cert_ = HaveUserCerts(); |
777 enable_server_ca_cert_ = true; | 908 enable_otp_ = true; |
778 enable_user_cert_ = HaveUserCerts(); | |
779 enable_otp_ = true; | |
780 break; | |
781 default: | |
782 NOTREACHED(); | |
783 break; | |
784 } | 909 } |
785 } | 910 } |
786 | 911 |
787 void VPNConfigView::UpdateControls() { | 912 void VPNConfigView::UpdateControls() { |
788 UpdateControlsToEnable(); | 913 UpdateControlsToEnable(); |
789 | 914 |
790 if (psk_passphrase_label_) | 915 if (psk_passphrase_label_) |
791 psk_passphrase_label_->SetEnabled(enable_psk_passphrase_); | 916 psk_passphrase_label_->SetEnabled(enable_psk_passphrase_); |
792 if (psk_passphrase_textfield_) | 917 if (psk_passphrase_textfield_) |
793 psk_passphrase_textfield_->SetEnabled(enable_psk_passphrase_ && | 918 psk_passphrase_textfield_->SetEnabled(enable_psk_passphrase_ && |
(...skipping 17 matching lines...) Expand all Loading... | |
811 otp_textfield_->SetEnabled(enable_otp_); | 936 otp_textfield_->SetEnabled(enable_otp_); |
812 | 937 |
813 if (group_name_label_) | 938 if (group_name_label_) |
814 group_name_label_->SetEnabled(enable_group_name_); | 939 group_name_label_->SetEnabled(enable_group_name_); |
815 if (group_name_textfield_) | 940 if (group_name_textfield_) |
816 group_name_textfield_->SetEnabled(enable_group_name_ && | 941 group_name_textfield_->SetEnabled(enable_group_name_ && |
817 group_name_ui_data_.IsEditable()); | 942 group_name_ui_data_.IsEditable()); |
818 } | 943 } |
819 | 944 |
820 void VPNConfigView::UpdateErrorLabel() { | 945 void VPNConfigView::UpdateErrorLabel() { |
821 NetworkLibrary* cros = NetworkLibrary::Get(); | |
822 | |
823 // Error message. | 946 // Error message. |
824 std::string error_msg; | 947 string16 error_msg; |
825 if (UserCertRequired() && CertLibrary::Get()->CertificatesLoaded()) { | 948 bool cert_required = |
949 GetProviderTypeIndex() == PROVIDER_TYPE_INDEX_L2TP_IPSEC_USER_CERT; | |
950 if (cert_required && CertLibrary::Get()->CertificatesLoaded()) { | |
826 if (!HaveUserCerts()) { | 951 if (!HaveUserCerts()) { |
827 error_msg = l10n_util::GetStringUTF8( | 952 error_msg = l10n_util::GetStringUTF16( |
828 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); | 953 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PLEASE_INSTALL_USER_CERT); |
829 } else if (!IsUserCertValid()) { | 954 } else if (!IsUserCertValid()) { |
830 error_msg = l10n_util::GetStringUTF8( | 955 error_msg = l10n_util::GetStringUTF16( |
831 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); | 956 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); |
832 } | 957 } |
833 } | 958 } |
834 if (error_msg.empty() && !service_path_.empty()) { | 959 if (error_msg.empty() && !service_path_.empty()) { |
835 // TODO(kuan): differentiate between bad psk and user passphrases. | 960 // TODO(kuan): differentiate between bad psk and user passphrases. |
836 VirtualNetwork* vpn = cros->FindVirtualNetworkByPath(service_path_); | 961 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
837 if (vpn && vpn->failed()) { | 962 GetNetworkState(service_path_); |
838 if (vpn->error() == ERROR_BAD_PASSPHRASE) { | 963 if (vpn && vpn->connection_state() == flimflam::kStateFailure) |
839 error_msg = l10n_util::GetStringUTF8( | 964 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 } | 965 } |
846 if (!error_msg.empty()) { | 966 if (!error_msg.empty()) { |
847 error_label_->SetText(UTF8ToUTF16(error_msg)); | 967 error_label_->SetText(error_msg); |
848 error_label_->SetVisible(true); | 968 error_label_->SetVisible(true); |
849 } else { | 969 } else { |
850 error_label_->SetVisible(false); | 970 error_label_->SetVisible(false); |
851 } | 971 } |
852 } | 972 } |
853 | 973 |
854 void VPNConfigView::UpdateCanLogin() { | 974 void VPNConfigView::UpdateCanLogin() { |
855 parent_->GetDialogClientView()->UpdateDialogButtons(); | 975 parent_->GetDialogClientView()->UpdateDialogButtons(); |
856 } | 976 } |
857 | 977 |
858 bool VPNConfigView::UserCertRequired() const { | |
859 return provider_type_ == PROVIDER_TYPE_L2TP_IPSEC_USER_CERT; | |
860 } | |
861 | |
862 bool VPNConfigView::HaveUserCerts() const { | 978 bool VPNConfigView::HaveUserCerts() const { |
863 return CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) > 0; | 979 return CertLibrary::Get()->NumCertificates(CertLibrary::CERT_TYPE_USER) > 0; |
864 } | 980 } |
865 | 981 |
866 bool VPNConfigView::IsUserCertValid() const { | 982 bool VPNConfigView::IsUserCertValid() const { |
867 if (!user_cert_combobox_ || !enable_user_cert_) | 983 if (!user_cert_combobox_ || !enable_user_cert_) |
868 return false; | 984 return false; |
869 int index = user_cert_combobox_->selected_index(); | 985 int index = user_cert_combobox_->selected_index(); |
870 if (index < 0) | 986 if (index < 0) |
871 return false; | 987 return false; |
(...skipping 17 matching lines...) Expand all Loading... | |
889 return result; | 1005 return result; |
890 } | 1006 } |
891 | 1007 |
892 const std::string VPNConfigView::GetPassphraseFromField( | 1008 const std::string VPNConfigView::GetPassphraseFromField( |
893 PassphraseTextfield* textfield) const { | 1009 PassphraseTextfield* textfield) const { |
894 if (!textfield) | 1010 if (!textfield) |
895 return std::string(); | 1011 return std::string(); |
896 return textfield->GetPassphrase(); | 1012 return textfield->GetPassphrase(); |
897 } | 1013 } |
898 | 1014 |
899 void VPNConfigView::ParseVPNUIProperty(NetworkPropertyUIData* property_ui_data, | 1015 void VPNConfigView::ParseVPNUIProperty(NetworkPropertyUIData* property_ui_data, |
gauravsh
2013/08/03 01:15:54
Since property_ui_data is an output parameter, let
stevenjb
2013/08/06 00:32:48
Done.
| |
900 Network* network, | 1016 const NetworkState* network, |
901 const std::string& dict_key, | 1017 const std::string& dict_key, |
902 const std::string& key) { | 1018 const std::string& key) { |
903 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; | 1019 onc::ONCSource onc_source = onc::ONC_SOURCE_NONE; |
904 const base::DictionaryValue* onc = | 1020 const base::DictionaryValue* onc = |
905 NetworkConfigView::FindPolicyForActiveUser(network, &onc_source); | 1021 network_connect::FindPolicyForActiveUser(network, &onc_source); |
906 | 1022 |
907 VLOG_IF(1, !onc) << "No ONC found for VPN network " << network->unique_id(); | 1023 VLOG_IF(1, !onc) << "No ONC found for VPN network " << network->guid(); |
908 property_ui_data->ParseOncProperty( | 1024 property_ui_data->ParseOncProperty( |
909 onc_source, | 1025 onc_source, |
910 onc, | 1026 onc, |
911 base::StringPrintf("%s.%s.%s", | 1027 base::StringPrintf("%s.%s.%s", |
912 onc::network_config::kVPN, | 1028 onc::network_config::kVPN, |
913 dict_key.c_str(), | 1029 dict_key.c_str(), |
914 key.c_str())); | 1030 key.c_str())); |
915 } | 1031 } |
916 | 1032 |
917 } // namespace chromeos | 1033 } // namespace chromeos |
OLD | NEW |