| 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" | |
| 8 #include "base/bind.h" | 7 #include "base/bind.h" |
| 9 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 10 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 11 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 13 #include "chrome/browser/chromeos/net/onc_utils.h" | 12 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 14 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 15 #include "chrome/common/net/x509_certificate_model.h" | 14 #include "chrome/common/net/x509_certificate_model.h" |
| 16 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
| 17 #include "chromeos/login/login_state.h" | 16 #include "chromeos/login/login_state.h" |
| 18 #include "chromeos/network/network_configuration_handler.h" | 17 #include "chromeos/network/network_configuration_handler.h" |
| 19 #include "chromeos/network/network_event_log.h" | 18 #include "chromeos/network/network_event_log.h" |
| 20 #include "chromeos/network/network_state.h" | 19 #include "chromeos/network/network_state.h" |
| 21 #include "chromeos/network/network_state_handler.h" | 20 #include "chromeos/network/network_state_handler.h" |
| 22 #include "chromeos/network/network_ui_data.h" | 21 #include "chromeos/network/network_ui_data.h" |
| 23 #include "components/onc/onc_constants.h" | 22 #include "components/onc/onc_constants.h" |
| 24 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/base/models/combobox_model.h" | 25 #include "ui/base/models/combobox_model.h" |
| 26 #include "ui/chromeos/network/network_connect.h" |
| 27 #include "ui/events/event.h" | 27 #include "ui/events/event.h" |
| 28 #include "ui/views/controls/button/checkbox.h" | 28 #include "ui/views/controls/button/checkbox.h" |
| 29 #include "ui/views/controls/combobox/combobox.h" | 29 #include "ui/views/controls/combobox/combobox.h" |
| 30 #include "ui/views/controls/label.h" | 30 #include "ui/views/controls/label.h" |
| 31 #include "ui/views/controls/textfield/textfield.h" | 31 #include "ui/views/controls/textfield/textfield.h" |
| 32 #include "ui/views/layout/grid_layout.h" | 32 #include "ui/views/layout/grid_layout.h" |
| 33 #include "ui/views/layout/layout_constants.h" | 33 #include "ui/views/layout/layout_constants.h" |
| 34 #include "ui/views/widget/widget.h" | 34 #include "ui/views/widget/widget.h" |
| 35 #include "ui/views/window/dialog_client_view.h" | 35 #include "ui/views/window/dialog_client_view.h" |
| 36 | 36 |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 bool modifiable = false; | 367 bool modifiable = false; |
| 368 ChildNetworkConfigView::GetShareStateForLoginState(&shared, &modifiable); | 368 ChildNetworkConfigView::GetShareStateForLoginState(&shared, &modifiable); |
| 369 | 369 |
| 370 bool only_policy_autoconnect = | 370 bool only_policy_autoconnect = |
| 371 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!shared); | 371 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!shared); |
| 372 if (only_policy_autoconnect) { | 372 if (only_policy_autoconnect) { |
| 373 properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, | 373 properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, |
| 374 false); | 374 false); |
| 375 } | 375 } |
| 376 | 376 |
| 377 ash::NetworkConnect::Get()->CreateConfigurationAndConnect(&properties, | 377 ui::NetworkConnect::Get()->CreateConfigurationAndConnect(&properties, |
| 378 shared); | 378 shared); |
| 379 } else { | 379 } else { |
| 380 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> | 380 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
| 381 GetNetworkState(service_path_); | 381 GetNetworkState(service_path_); |
| 382 if (!vpn) { | 382 if (!vpn) { |
| 383 // Shill no longer knows about this network (edge case). | 383 // Shill no longer knows about this network (edge case). |
| 384 // TODO(stevenjb): Add notification for this. | 384 // TODO(stevenjb): Add notification for this. |
| 385 NET_LOG_ERROR("Network not found", service_path_); | 385 NET_LOG_ERROR("Network not found", service_path_); |
| 386 return true; // Close dialog | 386 return true; // Close dialog |
| 387 } | 387 } |
| 388 base::DictionaryValue properties; | 388 base::DictionaryValue properties; |
| 389 SetConfigProperties(&properties); | 389 SetConfigProperties(&properties); |
| 390 ash::NetworkConnect::Get()->ConfigureNetworkAndConnect( | 390 ui::NetworkConnect::Get()->ConfigureNetworkAndConnect( |
| 391 service_path_, properties, false /* not shared */); | 391 service_path_, properties, false /* not shared */); |
| 392 } | 392 } |
| 393 return true; // Close dialog. | 393 return true; // Close dialog. |
| 394 } | 394 } |
| 395 | 395 |
| 396 void VPNConfigView::Cancel() { | 396 void VPNConfigView::Cancel() { |
| 397 } | 397 } |
| 398 | 398 |
| 399 void VPNConfigView::InitFocus() { | 399 void VPNConfigView::InitFocus() { |
| 400 views::View* view_to_focus = GetInitiallyFocusedView(); | 400 views::View* view_to_focus = GetInitiallyFocusedView(); |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 } else if (!IsUserCertValid()) { | 993 } else if (!IsUserCertValid()) { |
| 994 error_msg = l10n_util::GetStringUTF16( | 994 error_msg = l10n_util::GetStringUTF16( |
| 995 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); | 995 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); |
| 996 } | 996 } |
| 997 } | 997 } |
| 998 if (error_msg.empty() && !service_path_.empty()) { | 998 if (error_msg.empty() && !service_path_.empty()) { |
| 999 // TODO(kuan): differentiate between bad psk and user passphrases. | 999 // TODO(kuan): differentiate between bad psk and user passphrases. |
| 1000 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> | 1000 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> |
| 1001 GetNetworkState(service_path_); | 1001 GetNetworkState(service_path_); |
| 1002 if (vpn && vpn->connection_state() == shill::kStateFailure) | 1002 if (vpn && vpn->connection_state() == shill::kStateFailure) |
| 1003 error_msg = ash::NetworkConnect::Get()->GetErrorString( | 1003 error_msg = ui::NetworkConnect::Get()->GetErrorString( |
| 1004 vpn->last_error(), vpn->path()); | 1004 vpn->last_error(), vpn->path()); |
| 1005 } | 1005 } |
| 1006 if (!error_msg.empty()) { | 1006 if (!error_msg.empty()) { |
| 1007 error_label_->SetText(error_msg); | 1007 error_label_->SetText(error_msg); |
| 1008 error_label_->SetVisible(true); | 1008 error_label_->SetVisible(true); |
| 1009 } else { | 1009 } else { |
| 1010 error_label_->SetVisible(false); | 1010 error_label_->SetVisible(false); |
| 1011 } | 1011 } |
| 1012 } | 1012 } |
| 1013 | 1013 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 property_ui_data->ParseOncProperty( | 1065 property_ui_data->ParseOncProperty( |
| 1066 onc_source, | 1066 onc_source, |
| 1067 onc, | 1067 onc, |
| 1068 base::StringPrintf("%s.%s.%s", | 1068 base::StringPrintf("%s.%s.%s", |
| 1069 ::onc::network_config::kVPN, | 1069 ::onc::network_config::kVPN, |
| 1070 dict_key.c_str(), | 1070 dict_key.c_str(), |
| 1071 key.c_str())); | 1071 key.c_str())); |
| 1072 } | 1072 } |
| 1073 | 1073 |
| 1074 } // namespace chromeos | 1074 } // namespace chromeos |
| OLD | NEW |