Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: chrome/browser/chromeos/options/vpn_config_view.cc

Issue 2434683003: Move NetworkStateNotifier and NetworkConnect from src/ui (Closed)
Patch Set: Fix virtuals Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/chromeos/enrollment_dialog_view.h" 14 #include "chrome/browser/chromeos/enrollment_dialog_view.h"
15 #include "chrome/browser/chromeos/net/onc_utils.h" 15 #include "chrome/browser/chromeos/net/onc_utils.h"
16 #include "chrome/browser/chromeos/net/shill_error.h"
16 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/common/net/x509_certificate_model.h" 18 #include "chrome/common/net/x509_certificate_model.h"
18 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
19 #include "chromeos/login/login_state.h" 20 #include "chromeos/login/login_state.h"
20 #include "chromeos/network/network_configuration_handler.h" 21 #include "chromeos/network/network_configuration_handler.h"
22 #include "chromeos/network/network_connect.h"
21 #include "chromeos/network/network_event_log.h" 23 #include "chromeos/network/network_event_log.h"
22 #include "chromeos/network/network_state.h" 24 #include "chromeos/network/network_state.h"
23 #include "chromeos/network/network_state_handler.h" 25 #include "chromeos/network/network_state_handler.h"
24 #include "chromeos/network/network_ui_data.h" 26 #include "chromeos/network/network_ui_data.h"
25 #include "components/onc/onc_constants.h" 27 #include "components/onc/onc_constants.h"
26 #include "third_party/cros_system_api/dbus/service_constants.h" 28 #include "third_party/cros_system_api/dbus/service_constants.h"
27 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
28 #include "ui/base/models/combobox_model.h" 30 #include "ui/base/models/combobox_model.h"
29 #include "ui/chromeos/network/network_connect.h"
30 #include "ui/events/event.h" 31 #include "ui/events/event.h"
31 #include "ui/views/controls/button/checkbox.h" 32 #include "ui/views/controls/button/checkbox.h"
32 #include "ui/views/controls/combobox/combobox.h" 33 #include "ui/views/controls/combobox/combobox.h"
33 #include "ui/views/controls/label.h" 34 #include "ui/views/controls/label.h"
34 #include "ui/views/controls/textfield/textfield.h" 35 #include "ui/views/controls/textfield/textfield.h"
35 #include "ui/views/layout/grid_layout.h" 36 #include "ui/views/layout/grid_layout.h"
36 #include "ui/views/layout/layout_constants.h" 37 #include "ui/views/layout/layout_constants.h"
37 #include "ui/views/widget/widget.h" 38 #include "ui/views/widget/widget.h"
38 #include "ui/views/window/dialog_client_view.h" 39 #include "ui/views/window/dialog_client_view.h"
39 40
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 bool modifiable = false; 373 bool modifiable = false;
373 ChildNetworkConfigView::GetShareStateForLoginState(&shared, &modifiable); 374 ChildNetworkConfigView::GetShareStateForLoginState(&shared, &modifiable);
374 375
375 bool only_policy_autoconnect = 376 bool only_policy_autoconnect =
376 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!shared); 377 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(!shared);
377 if (only_policy_autoconnect) { 378 if (only_policy_autoconnect) {
378 properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty, 379 properties.SetBooleanWithoutPathExpansion(shill::kAutoConnectProperty,
379 false); 380 false);
380 } 381 }
381 382
382 ui::NetworkConnect::Get()->CreateConfigurationAndConnect(&properties, 383 NetworkConnect::Get()->CreateConfigurationAndConnect(&properties, shared);
383 shared);
384 } else { 384 } else {
385 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> 385 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()->
386 GetNetworkState(service_path_); 386 GetNetworkState(service_path_);
387 if (!vpn) { 387 if (!vpn) {
388 // Shill no longer knows about this network (edge case). 388 // Shill no longer knows about this network (edge case).
389 // TODO(stevenjb): Add notification for this. 389 // TODO(stevenjb): Add notification for this.
390 NET_LOG_ERROR("Network not found", service_path_); 390 NET_LOG_ERROR("Network not found", service_path_);
391 return true; // Close dialog 391 return true; // Close dialog
392 } 392 }
393 base::DictionaryValue properties; 393 base::DictionaryValue properties;
394 SetConfigProperties(&properties); 394 SetConfigProperties(&properties);
395 ui::NetworkConnect::Get()->ConfigureNetworkAndConnect( 395 NetworkConnect::Get()->ConfigureNetworkAndConnect(service_path_, properties,
396 service_path_, properties, false /* not shared */); 396 false /* not shared */);
397 } 397 }
398 return true; // Close dialog. 398 return true; // Close dialog.
399 } 399 }
400 400
401 void VPNConfigView::Cancel() { 401 void VPNConfigView::Cancel() {
402 } 402 }
403 403
404 void VPNConfigView::InitFocus() { 404 void VPNConfigView::InitFocus() {
405 views::View* view_to_focus = GetInitiallyFocusedView(); 405 views::View* view_to_focus = GetInitiallyFocusedView();
406 if (view_to_focus) 406 if (view_to_focus)
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 } else if (!IsUserCertValid()) { 997 } else if (!IsUserCertValid()) {
998 error_msg = l10n_util::GetStringUTF16( 998 error_msg = l10n_util::GetStringUTF16(
999 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED); 999 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_REQUIRE_HARDWARE_BACKED);
1000 } 1000 }
1001 } 1001 }
1002 if (error_msg.empty() && !service_path_.empty()) { 1002 if (error_msg.empty() && !service_path_.empty()) {
1003 // TODO(kuan): differentiate between bad psk and user passphrases. 1003 // TODO(kuan): differentiate between bad psk and user passphrases.
1004 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()-> 1004 const NetworkState* vpn = NetworkHandler::Get()->network_state_handler()->
1005 GetNetworkState(service_path_); 1005 GetNetworkState(service_path_);
1006 if (vpn && vpn->connection_state() == shill::kStateFailure) 1006 if (vpn && vpn->connection_state() == shill::kStateFailure)
1007 error_msg = ui::NetworkConnect::Get()->GetShillErrorString( 1007 error_msg =
1008 vpn->last_error(), vpn->path()); 1008 shill_error::GetShillErrorString(vpn->last_error(), vpn->guid());
1009 } 1009 }
1010 if (!error_msg.empty()) { 1010 if (!error_msg.empty()) {
1011 error_label_->SetText(error_msg); 1011 error_label_->SetText(error_msg);
1012 error_label_->SetVisible(true); 1012 error_label_->SetVisible(true);
1013 } else { 1013 } else {
1014 error_label_->SetVisible(false); 1014 error_label_->SetVisible(false);
1015 } 1015 }
1016 } 1016 }
1017 1017
1018 void VPNConfigView::UpdateCanLogin() { 1018 void VPNConfigView::UpdateCanLogin() {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 property_ui_data->ParseOncProperty( 1069 property_ui_data->ParseOncProperty(
1070 onc_source, 1070 onc_source,
1071 onc, 1071 onc,
1072 base::StringPrintf("%s.%s.%s", 1072 base::StringPrintf("%s.%s.%s",
1073 ::onc::network_config::kVPN, 1073 ::onc::network_config::kVPN,
1074 dict_key.c_str(), 1074 dict_key.c_str(),
1075 key.c_str())); 1075 key.c_str()));
1076 } 1076 }
1077 1077
1078 } // namespace chromeos 1078 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/shill_error.cc ('k') | chrome/browser/chromeos/options/wifi_config_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698