diff options
Diffstat (limited to 'chrome/browser')
11 files changed, 360 insertions, 197 deletions
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc index 70205bc..ca31edc 100644 --- a/chrome/browser/automation/testing_automation_provider_chromeos.cc +++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc @@ -566,7 +566,64 @@ void TestingAutomationProvider::ConnectToHiddenWifiNetwork( // Set up an observer (it will delete itself). new SSIDConnectObserver(this, reply_message, ssid); - network_library->ConnectToWifiNetwork(ssid, connection_security, password); + const bool shared = true; + const bool save_credentials = false; + + if (connection_security == chromeos::SECURITY_8021X) { + chromeos::NetworkLibrary::EAPConfigData config_data; + std::string eap_method, eap_auth, eap_identity; + if (!args->GetString("eap_method", &eap_method) || + !args->GetString("eap_auth", &eap_auth) || + !args->GetString("eap_identity", &eap_identity)) { + AutomationJSONReply(this, reply_message).SendError( + "Invalid or missing EAP args."); + return; + } + + std::map<std::string, chromeos::EAPMethod> eap_method_map; + eap_method_map["EAP_METHOD_NONE"] = chromeos::EAP_METHOD_UNKNOWN; + eap_method_map["EAP_METHOD_PEAP"] = chromeos::EAP_METHOD_PEAP; + eap_method_map["EAP_METHOD_TLS"] = chromeos::EAP_METHOD_TLS; + eap_method_map["EAP_METHOD_TTLS"] = chromeos::EAP_METHOD_TTLS; + eap_method_map["EAP_METHOD_LEAP"] = chromeos::EAP_METHOD_LEAP; + if (eap_method_map.find(eap_method) == eap_method_map.end()) { + AutomationJSONReply(this, reply_message).SendError( + "Unknown EAP Method type."); + return; + } + config_data.method = eap_method_map[eap_method]; + + std::map<std::string, chromeos::EAPPhase2Auth> eap_auth_map; + eap_auth_map["EAP_PHASE_2_AUTH_AUTO"] = chromeos::EAP_PHASE_2_AUTH_AUTO; + eap_auth_map["EAP_PHASE_2_AUTH_MD5"] = chromeos::EAP_PHASE_2_AUTH_MD5; + eap_auth_map["EAP_PHASE_2_AUTH_MSCHAP"] = + chromeos::EAP_PHASE_2_AUTH_MSCHAP; + eap_auth_map["EAP_PHASE_2_AUTH_MSCHAPV2"] = + chromeos::EAP_PHASE_2_AUTH_MSCHAPV2; + eap_auth_map["EAP_PHASE_2_AUTH_PAP"] = chromeos::EAP_PHASE_2_AUTH_PAP; + eap_auth_map["EAP_PHASE_2_AUTH_CHAP"] = chromeos::EAP_PHASE_2_AUTH_CHAP; + if (eap_auth_map.find(eap_auth) == eap_auth_map.end()) { + AutomationJSONReply(this, reply_message).SendError( + "Unknown EAP Phase2 Auth type."); + return; + } + config_data.auth = eap_auth_map[eap_auth]; + + config_data.identity = eap_identity; + + // TODO(stevenjb): Parse cert values? + config_data.server_ca_cert_nss_nickname = ""; + config_data.use_system_cas = false; + config_data.client_cert_pkcs11_id = ""; + + network_library->ConnectToUnconfiguredWifiNetwork( + ssid, chromeos::SECURITY_8021X, password, &config_data, + save_credentials, shared); + } else { + network_library->ConnectToUnconfiguredWifiNetwork( + ssid, connection_security, password, NULL, + save_credentials, shared); + } } void TestingAutomationProvider::DisconnectFromWifiNetwork( diff --git a/chrome/browser/chromeos/cros/mock_network_library.h b/chrome/browser/chromeos/cros/mock_network_library.h index 7b58f20..147a42f 100644 --- a/chrome/browser/chromeos/cros/mock_network_library.h +++ b/chrome/browser/chromeos/cros/mock_network_library.h @@ -99,19 +99,14 @@ class MockNetworkLibrary : public NetworkLibrary { MOCK_METHOD1(GetWifiAccessPoints, bool(WifiAccessPointVector*)); MOCK_CONST_METHOD1(CanConnectToNetwork, bool(const Network*)); MOCK_METHOD1(ConnectToWifiNetwork, void(WifiNetwork*)); - MOCK_METHOD3(ConnectToWifiNetwork, void(const std::string&, - ConnectionSecurity security, - const std::string&)); - MOCK_METHOD10(ConnectToWifiNetwork8021x, void(const std::string&, - EAPMethod, - EAPPhase2Auth, - const std::string&, - bool, - const std::string&, - const std::string&, - const std::string&, - const std::string&, - bool)); + MOCK_METHOD2(ConnectToWifiNetwork, void(WifiNetwork*, bool)); + MOCK_METHOD6(ConnectToUnconfiguredWifiNetwork, + void(const std::string&, + ConnectionSecurity, + const std::string&, + const EAPConfigData*, + bool, + bool)); MOCK_METHOD1(ConnectToCellularNetwork, void(CellularNetwork*)); MOCK_METHOD1(ConnectToVirtualNetwork, void(VirtualNetwork*)); MOCK_METHOD5(ConnectToVirtualNetworkPSK, void(const std::string&, diff --git a/chrome/browser/chromeos/cros/network_library.cc b/chrome/browser/chromeos/cros/network_library.cc index d74e91c..14d8a17 100644 --- a/chrome/browser/chromeos/cros/network_library.cc +++ b/chrome/browser/chromeos/cros/network_library.cc @@ -104,6 +104,9 @@ const int kDefaultSimUnlockRetriesCount = 999; // Format of the Carrier ID: <carrier name> (<carrier country>). const char kCarrierIdFormat[] = "%s (%s)"; +// Path of the default (shared) flimflam profile. +const char kSharedProfilePath[] = "/profile/default"; + // Type of a pending SIM operation. enum SimOperationType { SIM_OPERATION_NONE = 0, @@ -2639,25 +2642,18 @@ class NetworkLibraryImplBase : public NetworkLibrary { // Connect to an existing network. virtual void ConnectToWifiNetwork(WifiNetwork* wifi) OVERRIDE; + virtual void ConnectToWifiNetwork(WifiNetwork* wifi, bool shared) OVERRIDE; virtual void ConnectToCellularNetwork(CellularNetwork* cellular) OVERRIDE; virtual void ConnectToVirtualNetwork(VirtualNetwork* vpn) OVERRIDE; // Request a network and connect to it. - virtual void ConnectToWifiNetwork( + virtual void ConnectToUnconfiguredWifiNetwork( const std::string& ssid, ConnectionSecurity security, - const std::string& passphrase) OVERRIDE; - virtual void ConnectToWifiNetwork8021x( - const std::string& ssid, - EAPMethod eap_method, - EAPPhase2Auth eap_auth, - const std::string& eap_server_ca_cert_nss_nickname, - bool eap_use_system_cas, - const std::string& eap_client_cert_pkcs11_id, - const std::string& eap_identity, - const std::string& eap_anonymous_identity, const std::string& passphrase, - bool save_credentials) OVERRIDE; + const EAPConfigData* eap_config, + bool save_credentials, + bool shared) OVERRIDE; virtual void ConnectToVirtualNetworkPSK( const std::string& service_name, const std::string& server_hostname, @@ -2705,6 +2701,13 @@ class NetworkLibraryImplBase : public NetworkLibrary { typedef std::list<NetworkProfile> NetworkProfileList; struct ConnectData { + ConnectData() : + security(SECURITY_NONE), + eap_method(EAP_METHOD_UNKNOWN), + eap_auth(EAP_PHASE_2_AUTH_AUTO), + eap_use_system_cas(false), + save_credentials(false), + profile_type(PROFILE_NONE) {} ConnectionSecurity security; std::string service_name; // For example, SSID. std::string passphrase; @@ -2719,6 +2722,7 @@ class NetworkLibraryImplBase : public NetworkLibrary { std::string psk_key; std::string psk_username; bool save_credentials; + NetworkProfileType profile_type; }; enum NetworkConnectStatus { @@ -2728,7 +2732,10 @@ class NetworkLibraryImplBase : public NetworkLibrary { }; // Called from ConnectTo*Network. - void NetworkConnectStart(Network* network); + void NetworkConnectStartWifi( + WifiNetwork* network, NetworkProfileType profile_type); + void NetworkConnectStartVPN(VirtualNetwork* network); + void NetworkConnectStart(Network* network, NetworkProfileType profile_type); // Called from CallConnectToNetwork. void NetworkConnectCompleted(Network* network, NetworkConnectStatus status); @@ -2806,6 +2813,9 @@ class NetworkLibraryImplBase : public NetworkLibrary { // List of profiles. NetworkProfileList profile_list_; + // List of networks to move to the user profile once logged in. + std::list<std::string> user_networks_; + // A service path based map of all Networks. NetworkMap network_map_; @@ -3416,7 +3426,31 @@ bool NetworkLibraryImplBase::CanConnectToNetwork(const Network* network) const { } // 1. Request a connection to an existing wifi network. +// Use |shared| to pass along the desired profile type. +void NetworkLibraryImplBase::ConnectToWifiNetwork( + WifiNetwork* wifi, bool shared) { + NetworkConnectStartWifi(wifi, shared ? PROFILE_SHARED : PROFILE_USER); +} + +// 1. Request a connection to an existing wifi network. void NetworkLibraryImplBase::ConnectToWifiNetwork(WifiNetwork* wifi) { + NetworkConnectStartWifi(wifi, PROFILE_NONE); +} + +// 1. Connect to a cellular network. +void NetworkLibraryImplBase::ConnectToCellularNetwork( + CellularNetwork* cellular) { + NetworkConnectStart(cellular, PROFILE_NONE); +} + +// 1. Connect to an existing virtual network. +void NetworkLibraryImplBase::ConnectToVirtualNetwork(VirtualNetwork* vpn) { + NetworkConnectStartVPN(vpn); +} + +// 2. Start the connection. +void NetworkLibraryImplBase::NetworkConnectStartWifi( + WifiNetwork* wifi, NetworkProfileType profile_type) { // This will happen if a network resets, gets out of range or is forgotten. if (wifi->user_passphrase_ != wifi->passphrase_ || wifi->passphrase_required()) @@ -3426,39 +3460,46 @@ void NetworkLibraryImplBase::ConnectToWifiNetwork(WifiNetwork* wifi) { // ignores it otherwise. if (wifi->encryption() == SECURITY_8021X) wifi->SetCertificatePin(GetTpmPin()); - NetworkConnectStart(wifi); -} -// 1. Connect to a cellular network. -void NetworkLibraryImplBase::ConnectToCellularNetwork( - CellularNetwork* cellular) { - NetworkConnectStart(cellular); + NetworkConnectStart(wifi, profile_type); } -// 1. Connect to an existing virtual network. -void NetworkLibraryImplBase::ConnectToVirtualNetwork(VirtualNetwork* vpn) { +void NetworkLibraryImplBase::NetworkConnectStartVPN(VirtualNetwork* vpn) { // flimflam needs the TPM PIN for some VPN networks to access client // certificates, and ignores the PIN if it doesn't need them. vpn->SetCertificateSlotAndPin(GetTpmSlot(), GetTpmPin()); - NetworkConnectStart(vpn); + NetworkConnectStart(vpn, PROFILE_NONE); } -// 2. Start the connection. -void NetworkLibraryImplBase::NetworkConnectStart(Network* network) { +void NetworkLibraryImplBase::NetworkConnectStart( + Network* network, NetworkProfileType profile_type) { DCHECK(network); // In order to be certain to trigger any notifications, set the connecting // state locally and notify observers. Otherwise there might be a state // change without a forced notify. network->set_connecting(true); NotifyNetworkManagerChanged(true); // Forced update. - VLOG(1) << "Requesting connect to network: " << network->service_path(); - if (network->profile_path().empty()) { - // Specify the correct profile for the network if it does not already - // have one specified (i.e. is not remembered). - std::string profile_path = GetProfilePath( - network->RequiresUserProfile() ? PROFILE_USER : PROFILE_SHARED); - if (!profile_path.empty()) - network->SetProfilePath(profile_path); + VLOG(1) << "Requesting connect to network: " << network->service_path() + << " profile type: " << profile_type; + // Specify the correct profile for wifi networks (if specified or unset). + if (network->type() == TYPE_WIFI && + (profile_type != PROFILE_NONE || + network->profile_type() == PROFILE_NONE)) { + if (network->RequiresUserProfile()) + profile_type = PROFILE_USER; // Networks with certs can not be shared. + else if (profile_type == PROFILE_NONE) + profile_type = PROFILE_SHARED; // Other networks are shared by default. + std::string profile_path = GetProfilePath(profile_type); + if (!profile_path.empty()) { + if (profile_path != network->profile_path()) + network->SetProfilePath(profile_path); + } else if (profile_type == PROFILE_USER) { + // The user profile was specified but is not available (i.e. pre-login). + // Add this network to the list of networks to move to the user profile + // when it becomes available. + VLOG(1) << "Queuing: " << network->name() << " to user_networks list."; + user_networks_.push_back(network->service_path()); + } } CallConnectToNetwork(network); } @@ -3510,46 +3551,37 @@ void NetworkLibraryImplBase::NetworkConnectCompleted( ///////////////////////////////////////////////////////////////////////////// // Request a network and connect to it. -// 1. Connect to an unlisted wifi network. +// 1. Connect to an unconfigured or unlisted wifi network. // This needs to request information about the named service. // The connection attempt will occur in the callback. -void NetworkLibraryImplBase::ConnectToWifiNetwork( +void NetworkLibraryImplBase::ConnectToUnconfiguredWifiNetwork( const std::string& ssid, ConnectionSecurity security, - const std::string& passphrase) { - DCHECK_NE(security, SECURITY_8021X); + const std::string& passphrase, + const EAPConfigData* eap_config, + bool save_credentials, + bool shared) { // Store the connection data to be used by the callback. connect_data_.security = security; connect_data_.service_name = ssid; connect_data_.passphrase = passphrase; - CallRequestWifiNetworkAndConnect(ssid, security); -} - -// 1. Connect to an unlisted 802.1X EAP network. -void NetworkLibraryImplBase::ConnectToWifiNetwork8021x( - const std::string& ssid, - EAPMethod eap_method, - EAPPhase2Auth eap_auth, - const std::string& eap_server_ca_cert_nss_nickname, - bool eap_use_system_cas, - const std::string& eap_client_cert_pkcs11_id, - const std::string& eap_identity, - const std::string& eap_anonymous_identity, - const std::string& passphrase, - bool save_credentials) { - connect_data_.security = SECURITY_8021X; - connect_data_.service_name = ssid; - connect_data_.eap_method = eap_method; - connect_data_.eap_auth = eap_auth; - connect_data_.server_ca_cert_nss_nickname = - eap_server_ca_cert_nss_nickname; - connect_data_.eap_use_system_cas = eap_use_system_cas; - connect_data_.client_cert_pkcs11_id = eap_client_cert_pkcs11_id; - connect_data_.eap_identity = eap_identity; - connect_data_.eap_anonymous_identity = eap_anonymous_identity; - connect_data_.passphrase = passphrase; connect_data_.save_credentials = save_credentials; - CallRequestWifiNetworkAndConnect(ssid, SECURITY_8021X); + connect_data_.profile_type = shared ? PROFILE_SHARED : PROFILE_USER; + if (security == SECURITY_8021X) { + DCHECK(eap_config); + connect_data_.service_name = ssid; + connect_data_.eap_method = eap_config->method; + connect_data_.eap_auth = eap_config->auth; + connect_data_.server_ca_cert_nss_nickname = + eap_config->server_ca_cert_nss_nickname; + connect_data_.eap_use_system_cas = eap_config->use_system_cas; + connect_data_.client_cert_pkcs11_id = + eap_config->client_cert_pkcs11_id; + connect_data_.eap_identity = eap_config->identity; + connect_data_.eap_anonymous_identity = eap_config->anonymous_identity; + } + + CallRequestWifiNetworkAndConnect(ssid, security); } // 1. Connect to a virtual network with a PSK. @@ -3603,7 +3635,7 @@ void NetworkLibraryImplBase::ConnectToVirtualNetworkCert( // VirtualNetwork::ProviderType provider_type) = 0; // 3. Sets network properties stored in ConnectData and calls -// ConnectToWifiNetwork. +// NetworkConnectStart. void NetworkLibraryImplBase::ConnectToWifiNetworkUsingConnectData( WifiNetwork* wifi) { ConnectData& data = connect_data_; @@ -3629,7 +3661,7 @@ void NetworkLibraryImplBase::ConnectToWifiNetworkUsingConnectData( wifi->SetPassphrase(data.passphrase); } - ConnectToWifiNetwork(wifi); + NetworkConnectStartWifi(wifi, data.profile_type); } // 3. Sets network properties stored in ConnectData and calls @@ -3652,7 +3684,7 @@ void NetworkLibraryImplBase::ConnectToVirtualNetworkUsingConnectData( vpn->SetUsername(data.psk_username); vpn->SetUserPassphrase(data.passphrase); - ConnectToVirtualNetwork(vpn); + NetworkConnectStartVPN(vpn); } ///////////////////////////////////////////////////////////////////////////// @@ -3797,7 +3829,7 @@ void NetworkLibraryImplBase::AddRememberedNetwork(Network* network) { network->set_profile_path(profile.path); network->set_profile_type(profile.type); VLOG(1) << "AddRememberedNetwork: " << network->service_path() - << " Profile: " << profile.path; + << " profile: " << profile.path; break; } } @@ -4123,7 +4155,6 @@ void NetworkLibraryImplBase::FlipSimPinRequiredStateIfNeeded() { //////////////////////////////////////////////////////////////////////////// - class NetworkLibraryImplCros : public NetworkLibraryImplBase { public: NetworkLibraryImplCros(); @@ -5194,8 +5225,8 @@ Network* NetworkLibraryImplCros::ParseNetwork( } VLOG(1) << "ParseNetwork: " << network->name() - << " Path: " << network->service_path() - << " Profile: " << network->profile_path_; + << " path: " << network->service_path() + << " profile: " << network->profile_path_; NotifyNetworkManagerChanged(false); // Not forced. return network; } @@ -5216,11 +5247,24 @@ void NetworkLibraryImplCros::UpdateRememberedNetworks( continue; } NetworkProfileType profile_type; - if (profile_path == active_profile_path_) - profile_type = PROFILE_USER; - else + if (profile_path == kSharedProfilePath) profile_type = PROFILE_SHARED; + else + profile_type = PROFILE_USER; profile_list_.push_back(NetworkProfile(profile_path, profile_type)); + // Check to see if we connected to any networks before a user profile was + // available (i.e. before login), but unchecked the "Share" option (i.e. + // the desired pofile is the user profile). Move these networks to the + // user profile when it becomes available. + if (profile_type == PROFILE_USER && !user_networks_.empty()) { + for (std::list<std::string>::iterator iter2 = user_networks_.begin(); + iter2 != user_networks_.end(); ++iter2) { + Network* network = FindNetworkByPath(*iter2); + if (network && network->profile_path() != profile_path) + network->SetProfilePath(profile_path); + } + user_networks_.clear(); + } } } @@ -5340,8 +5384,8 @@ Network* NetworkLibraryImplCros::ParseRememberedNetwork( SetProfileTypeFromPath(remembered); VLOG(1) << "ParseRememberedNetwork: " << remembered->name() - << " Path: " << remembered->service_path() - << " Profile: " << remembered->profile_path_; + << " path: " << remembered->service_path() + << " profile: " << remembered->profile_path_; NotifyNetworkManagerChanged(false); // Not forced. if (remembered->type() == TYPE_VPN) { diff --git a/chrome/browser/chromeos/cros/network_library.h b/chrome/browser/chromeos/cros/network_library.h index 7cd2e06..643cb01 100644 --- a/chrome/browser/chromeos/cros/network_library.h +++ b/chrome/browser/chromeos/cros/network_library.h @@ -1207,23 +1207,9 @@ class NetworkLibrary { // Connect to the specified wireless network. virtual void ConnectToWifiNetwork(WifiNetwork* network) = 0; - // Connect to a hidden network with given SSID, security, and passphrase. - virtual void ConnectToWifiNetwork(const std::string& ssid, - ConnectionSecurity security, - const std::string& passphrase) = 0; - - // Connect to a hidden 802.1X network. - virtual void ConnectToWifiNetwork8021x( - const std::string& ssid, - EAPMethod method, - EAPPhase2Auth auth, - const std::string& server_ca_cert_nss_nickname, - bool use_system_cas, - const std::string& client_cert_pkcs11_id, - const std::string& identity, - const std::string& anonymous_identity, - const std::string& passphrase, - bool save_credentials) = 0; + // Connect to the specified wireless network and set its profile + // to SHARED if |shared| is true, otherwise to USER. + virtual void ConnectToWifiNetwork(WifiNetwork* network, bool shared) = 0; // Connect to the specified cellular network. virtual void ConnectToCellularNetwork(CellularNetwork* network) = 0; @@ -1231,6 +1217,31 @@ class NetworkLibrary { // Connect to the specified virtual network. virtual void ConnectToVirtualNetwork(VirtualNetwork* network) = 0; + // Connect to an unconfigured network with given SSID, security, passphrase, + // and optional EAP configuration. If |security| is SECURITY_8021X, + // |eap_config| must be provided. + struct EAPConfigData { + EAPConfigData() + : method(EAP_METHOD_UNKNOWN), + auth(EAP_PHASE_2_AUTH_AUTO), + use_system_cas(true) {} + ~EAPConfigData() {} + EAPMethod method; + EAPPhase2Auth auth; + std::string server_ca_cert_nss_nickname; + bool use_system_cas; + std::string client_cert_pkcs11_id; + std::string identity; + std::string anonymous_identity; + }; + virtual void ConnectToUnconfiguredWifiNetwork( + const std::string& ssid, + ConnectionSecurity security, + const std::string& passphrase, + const EAPConfigData* eap_config, + bool save_credentials, + bool shared) = 0; + // Connect to the specified virtual network with service name, // server hostname, provider_type, PSK passphrase, username and passphrase. virtual void ConnectToVirtualNetworkPSK( diff --git a/chrome/browser/chromeos/options/vpn_config_view.cc b/chrome/browser/chromeos/options/vpn_config_view.cc index 144d3d7..200430a 100644 --- a/chrome/browser/chromeos/options/vpn_config_view.cc +++ b/chrome/browser/chromeos/options/vpn_config_view.cc @@ -385,9 +385,6 @@ void VPNConfigView::Init(VirtualNetwork* vpn) { views::GridLayout::USE_PREF, 0, ChildNetworkConfigView::kPassphraseWidth); column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); - // Passphrase visible button. - column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, - views::GridLayout::USE_PREF, 0, 0); // Initialize members. service_text_modified_ = false; diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc index d39be7b..5c726d8 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.cc +++ b/chrome/browser/chromeos/options/wifi_config_view.cc @@ -255,6 +255,8 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi) identity_anonymous_label_(NULL), identity_anonymous_textfield_(NULL), save_credentials_checkbox_(NULL), + share_network_checkbox_(NULL), + shared_network_label_(NULL), security_combobox_(NULL), passphrase_label_(NULL), passphrase_textfield_(NULL), @@ -279,6 +281,8 @@ WifiConfigView::WifiConfigView(NetworkConfigView* parent, bool show_8021x) identity_anonymous_label_(NULL), identity_anonymous_textfield_(NULL), save_credentials_checkbox_(NULL), + share_network_checkbox_(NULL), + shared_network_label_(NULL), security_combobox_(NULL), passphrase_label_(NULL), passphrase_textfield_(NULL), @@ -381,6 +385,32 @@ void WifiConfigView::RefreshEapFields() { identity_anonymous_textfield_->IsEnabled()); if (!identity_anonymous_textfield_->IsEnabled()) identity_anonymous_textfield_->SetText(string16()); + + RefreshShareCheckbox(); +} + +void WifiConfigView::RefreshShareCheckbox() { + if (!share_network_checkbox_) + return; + + if (security_combobox_ && + security_combobox_->selected_item() == SECURITY_INDEX_NONE) { + share_network_checkbox_->SetEnabled(false); + share_network_checkbox_->SetChecked(true); + } else if (eap_method_combobox_ && + (eap_method_combobox_->selected_item() == EAP_METHOD_INDEX_TLS || + user_cert_combobox_->selected_item() != 0)) { + // Can not share TLS network (requires certificate), or any network where + // user certificates are enabled. + share_network_checkbox_->SetEnabled(false); + share_network_checkbox_->SetChecked(false); + } else { + share_network_checkbox_->SetEnabled(true); + if (UserManager::Get()->user_is_logged_in()) + share_network_checkbox_->SetChecked(false); // Default to unshared. + else + share_network_checkbox_->SetChecked(true); // Default to shared. + } } void WifiConfigView::UpdateErrorLabel() { @@ -467,6 +497,7 @@ void WifiConfigView::ItemChanged(views::Combobox* combo_box, passphrase_label_->SetEnabled(true); passphrase_textfield_->SetEnabled(true); } + RefreshShareCheckbox(); } else if (combo_box == eap_method_combobox_) { RefreshEapFields(); UpdateErrorLabel(); @@ -484,27 +515,42 @@ bool WifiConfigView::Login() { if (service_path_.empty()) { if (!eap_method_combobox_) { // Hidden ordinary Wi-Fi connection. - ConnectionSecurity sec = SECURITY_UNKNOWN; + ConnectionSecurity security = SECURITY_UNKNOWN; switch (security_combobox_->selected_item()) { case SECURITY_INDEX_NONE: - sec = SECURITY_NONE; + security = SECURITY_NONE; break; case SECURITY_INDEX_WEP: - sec = SECURITY_WEP; + security = SECURITY_WEP; break; case SECURITY_INDEX_PSK: - sec = SECURITY_PSK; + security = SECURITY_PSK; break; } - cros->ConnectToWifiNetwork(GetSsid(), sec, GetPassphrase()); + cros->ConnectToUnconfiguredWifiNetwork( + GetSsid(), + security, + GetPassphrase(), + NULL, + GetSaveCredentials(), + GetShareNetwork()); } else { // Hidden 802.1X EAP Wi-Fi connection. - cros->ConnectToWifiNetwork8021x( - GetSsid(), GetEapMethod(), GetEapPhase2Auth(), - GetEapServerCaCertNssNickname(), GetEapUseSystemCas(), - GetEapClientCertPkcs11Id(), GetEapIdentity(), - GetEapAnonymousIdentity(), GetPassphrase(), - GetSaveCredentials()); + chromeos::NetworkLibrary::EAPConfigData config_data; + config_data.method = GetEapMethod(); + config_data.auth = GetEapPhase2Auth(); + config_data.server_ca_cert_nss_nickname = GetEapServerCaCertNssNickname(); + config_data.use_system_cas = GetEapUseSystemCas(); + config_data.client_cert_pkcs11_id = GetEapClientCertPkcs11Id(); + config_data.identity = GetEapIdentity(); + config_data.anonymous_identity = GetEapAnonymousIdentity(); + cros->ConnectToUnconfiguredWifiNetwork( + GetSsid(), + SECURITY_8021X, + GetPassphrase(), + &config_data, + GetSaveCredentials(), + GetShareNetwork()); } } else { WifiNetwork* wifi = cros->FindWifiNetworkByPath(service_path_); @@ -534,13 +580,41 @@ bool WifiConfigView::Login() { wifi->SetPassphrase(passphrase); } - cros->ConnectToWifiNetwork(wifi); + cros->ConnectToWifiNetwork(wifi, GetShareNetwork()); // Connection failures are responsible for updating the UI, including // reopening dialogs. } return true; // dialog will be closed } +std::string WifiConfigView::GetSsid() const { + std::string result; + if (ssid_textfield_ != NULL) { + std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); + TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); + } + return result; +} + +std::string WifiConfigView::GetPassphrase() const { + std::string result; + if (passphrase_textfield_ != NULL) + result = UTF16ToUTF8(passphrase_textfield_->text()); + return result; +} + +bool WifiConfigView::GetSaveCredentials() const { + if (!save_credentials_checkbox_) + return true; // share networks by default (e.g. non 8021x). + return save_credentials_checkbox_->checked(); +} + +bool WifiConfigView::GetShareNetwork() const { + if (!share_network_checkbox_) + return true; // share networks by default (e.g. non secure network). + return share_network_checkbox_->checked(); +} + EAPMethod WifiConfigView::GetEapMethod() const { DCHECK(eap_method_combobox_); switch (eap_method_combobox_->selected_item()) { @@ -625,30 +699,9 @@ std::string WifiConfigView::GetEapAnonymousIdentity() const { return UTF16ToUTF8(identity_anonymous_textfield_->text()); } -bool WifiConfigView::GetSaveCredentials() const { - DCHECK(save_credentials_checkbox_); - return save_credentials_checkbox_->checked(); -} - void WifiConfigView::Cancel() { } -std::string WifiConfigView::GetSsid() const { - std::string result; - if (ssid_textfield_ != NULL) { - std::string untrimmed = UTF16ToUTF8(ssid_textfield_->text()); - TrimWhitespaceASCII(untrimmed, TRIM_ALL, &result); - } - return result; -} - -std::string WifiConfigView::GetPassphrase() const { - std::string result; - if (passphrase_textfield_ != NULL) - result = UTF16ToUTF8(passphrase_textfield_->text()); - return result; -} - // This will initialize the view depending on if we have a wifi network or not. // And if we are doing simple password encryption or the more complicated // 802.1x encryption. @@ -661,16 +714,19 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { int column_view_set_id = 0; views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); + const int kPasswordVisibleWidth = 20; // Label column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, views::GridLayout::USE_PREF, 0, 0); - // Textfield + column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); + // Textfield, combobox. column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, views::GridLayout::USE_PREF, 0, ChildNetworkConfigView::kPassphraseWidth); + column_set->AddPaddingColumn(0, views::kRelatedControlSmallHorizontalSpacing); // Password visible button column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, - views::GridLayout::USE_PREF, 0, 0); + views::GridLayout::USE_PREF, 0, kPasswordVisibleWidth); // SSID input layout->StartRow(0, column_view_set_id); @@ -817,17 +873,36 @@ void WifiConfigView::Init(WifiNetwork* wifi, bool show_8021x) { identity_anonymous_textfield_->SetController(this); layout->AddView(identity_anonymous_textfield_); layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); + } - // Save credentials + // Checkboxes. + + // Save credentials + if (show_8021x) { layout->StartRow(0, column_view_set_id); save_credentials_checkbox_ = new views::Checkbox( UTF16ToWide(l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS))); layout->SkipColumns(1); layout->AddView(save_credentials_checkbox_); - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); } + // Share network + if (!wifi || + (wifi->profile_type() == PROFILE_NONE && + wifi->IsPassphraseRequired() && + !wifi->RequiresUserProfile())) { + layout->StartRow(0, column_view_set_id); + share_network_checkbox_ = new views::Checkbox( + UTF16ToWide(l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK))); + layout->SkipColumns(1); + layout->AddView(share_network_checkbox_); + } + layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); + + RefreshShareCheckbox(); + // After creating the fields, we set the values. Fields need to be created // first because RefreshEapFields() will enable/disable them as appropriate. if (show_8021x) { diff --git a/chrome/browser/chromeos/options/wifi_config_view.h b/chrome/browser/chromeos/options/wifi_config_view.h index 6f21e45..52be0c3 100644 --- a/chrome/browser/chromeos/options/wifi_config_view.h +++ b/chrome/browser/chromeos/options/wifi_config_view.h @@ -70,11 +70,11 @@ class WifiConfigView : public ChildNetworkConfigView, // Initializes UI. If |show_8021x| includes 802.1x config options. void Init(WifiNetwork* wifi, bool show_8021x); - // Get the typed in SSID. + // Get input values. std::string GetSsid() const; - - // Get the typed in passphrase. std::string GetPassphrase() const; + bool GetSaveCredentials() const; + bool GetShareNetwork() const; // Get various 802.1X EAP values from the widgets. EAPMethod GetEapMethod() const; @@ -84,7 +84,6 @@ class WifiConfigView : public ChildNetworkConfigView, std::string GetEapClientCertPkcs11Id() const; std::string GetEapIdentity() const; std::string GetEapAnonymousIdentity() const; - bool GetSaveCredentials() const; // Returns true if the EAP method requires a user certificate. bool UserCertRequired(); @@ -95,6 +94,9 @@ class WifiConfigView : public ChildNetworkConfigView, // Enable/Disable EAP fields as appropriate based on selected EAP method. void RefreshEapFields(); + // Enable/Disable "share this network" checkbox. + void RefreshShareCheckbox(); + // Updates the error text label. void UpdateErrorLabel(); @@ -113,6 +115,8 @@ class WifiConfigView : public ChildNetworkConfigView, views::Label* identity_anonymous_label_; views::Textfield* identity_anonymous_textfield_; views::Checkbox* save_credentials_checkbox_; + views::Checkbox* share_network_checkbox_; + views::Label* shared_network_label_; views::Combobox* security_combobox_; views::Label* passphrase_label_; views::Textfield* passphrase_textfield_; diff --git a/chrome/browser/resources/options/chromeos/internet_detail.html b/chrome/browser/resources/options/chromeos/internet_detail.html index bd92bfc..ad4ebec 100644 --- a/chrome/browser/resources/options/chromeos/internet_detail.html +++ b/chrome/browser/resources/options/chromeos/internet_detail.html @@ -45,11 +45,15 @@ </div> <div id="wifiNetworkTab" class="subpages-tab-contents wifi-details"> <section> - <table class="option-control-table"> + <table class="ssid-table"> <tr> <td class="option-name" i18n-content="inetSsid"></td> <td id="inetSsid" class="option-value"></td> </tr> + </table> + </section> + <section> + <table class="option-control-table"> <tr> <td colspan="2"> <div class="checkbox"> @@ -77,15 +81,12 @@ <tr> <td class="option-name" i18n-content="inetPassProtected"></td> </tr> + </table> + </section> + <section id="sharedNetwork" class="shared-network"> + <table class="option-control-table"> <tr> - <td colspan="2"> - <div class="checkbox"> - <label> - <input id="sharedNetwork" type="checkbox"> - <span i18n-content="inetSharedNetwork"></span> - </label> - </div> - </td> + <td class="option-name" i18n-content="inetNetworkShared"></td> </tr> </table> </section> diff --git a/chrome/browser/resources/options/chromeos/internet_detail.js b/chrome/browser/resources/options/chromeos/internet_detail.js index 0426879..c722e53 100644 --- a/chrome/browser/resources/options/chromeos/internet_detail.js +++ b/chrome/browser/resources/options/chromeos/internet_detail.js @@ -63,7 +63,7 @@ cr.define('options.internet', function() { cr.doc.querySelectorAll('#detailsInternetPage .vpn-details'), !this.vpn); - // Cell plan related + // Cell plan related. $('planList').hidden = this.cellplanloading; updateHidden( cr.doc.querySelectorAll('#detailsInternetPage .no-plan-info'), @@ -87,9 +87,13 @@ cr.define('options.internet', function() { cr.doc.querySelectorAll('#detailsInternetPage .apn-details-view'), true); + // Password and shared. updateHidden( cr.doc.querySelectorAll('#detailsInternetPage .password-details'), !this.wireless || !this.password); + updateHidden( + cr.doc.querySelectorAll('#detailsInternetPage .shared-network'), + !this.shared); } }; @@ -110,6 +114,14 @@ cr.define('options.internet', function() { DetailsInternetPage.prototype.updateControls_); /** + * Whether the underlying network shared wifi. Only used for display purpose. + * @type {boolean} + */ + cr.defineProperty(DetailsInternetPage, 'shared', + cr.PropertyKind.JS, + DetailsInternetPage.prototype.updateControls_); + + /** * Whether the underlying network is a vpn. Only used for display purpose. * @type {boolean} */ diff --git a/chrome/browser/resources/options/chromeos/internet_options.js b/chrome/browser/resources/options/chromeos/internet_options.js index ece5c59..f98368d 100644 --- a/chrome/browser/resources/options/chromeos/internet_options.js +++ b/chrome/browser/resources/options/chromeos/internet_options.js @@ -308,8 +308,6 @@ cr.define('options', function() { [String(servicePath), $('autoConnectNetworkCellular').checked ? "true" : "false"]); } - chrome.send('setShared',[String(servicePath), - $('sharedNetwork').checked ? "true" : "false"]); var ipConfigList = $('ipConfigList'); chrome.send('setIPConfig',[String(servicePath), @@ -523,13 +521,12 @@ cr.define('options', function() { detailsPage.ethernet = false; detailsPage.cellular = false; detailsPage.gsm = false; + detailsPage.shared = data.shared; $('inetSsid').textContent = data.ssid; $('preferNetworkWifi').checked = data.preferred; $('preferNetworkWifi').disabled = !data.remembered; $('autoConnectNetworkWifi').checked = data.autoConnect; $('autoConnectNetworkWifi').disabled = !data.remembered; - $('sharedNetwork').checked = data.shared; - $('sharedNetwork').disabled = !data.remembered || !data.shareable; detailsPage.password = data.encrypted; } else if(data.type == options.internet.Constants.TYPE_CELLULAR) { if (!data.gsm) diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc index 41b3835..fc04894 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -176,15 +176,15 @@ void InternetOptionsHandler::GetLocalizedValues( localized_strings->SetString("inetPassProtected", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NET_PROTECTED)); + localized_strings->SetString("inetNetworkShared", + l10n_util::GetStringUTF16( + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_SHARED)); localized_strings->SetString("inetPreferredNetwork", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PREFER_NETWORK)); localized_strings->SetString("inetAutoConnectNetwork", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); - localized_strings->SetString("inetSharedNetwork", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); localized_strings->SetString("inetLogin", l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN)); @@ -366,8 +366,6 @@ void InternetOptionsHandler::RegisterMessages() { NewCallback(this, &InternetOptionsHandler::SetPreferNetworkCallback)); web_ui_->RegisterMessageCallback("setAutoConnect", NewCallback(this, &InternetOptionsHandler::SetAutoConnectCallback)); - web_ui_->RegisterMessageCallback("setShared", - NewCallback(this, &InternetOptionsHandler::SetSharedCallback)); web_ui_->RegisterMessageCallback("setIPConfig", NewCallback(this, &InternetOptionsHandler::SetIPConfigCallback)); web_ui_->RegisterMessageCallback("enableWifi", @@ -626,30 +624,6 @@ void InternetOptionsHandler::SetAutoConnectCallback(const ListValue* args) { network->SetAutoConnect(auto_connect); } -void InternetOptionsHandler::SetSharedCallback(const ListValue* args) { - std::string service_path; - std::string shared_str; - - if (args->GetSize() < 2 || - !args->GetString(0, &service_path) || - !args->GetString(1, &shared_str)) { - NOTREACHED(); - return; - } - - chromeos::Network* network = cros_->FindNetworkByPath(service_path); - if (!network) - return; - - if (cros_->HasProfileType(chromeos::PROFILE_USER)) { - bool shared = shared_str == "true"; - if (network->profile_type() == chromeos::PROFILE_SHARED && !shared) - cros_->SetNetworkProfile(service_path, chromeos::PROFILE_USER); - else if (network->profile_type() == chromeos::PROFILE_USER && shared) - cros_->SetNetworkProfile(service_path, chromeos::PROFILE_SHARED); - } -} - void InternetOptionsHandler::SetIPConfigCallback(const ListValue* args) { std::string service_path; std::string dhcp_str; @@ -788,10 +762,6 @@ void InternetOptionsHandler::PopulateWifiDetails( dictionary->SetBoolean("encrypted", wifi->encrypted()); bool shared = wifi->profile_type() == chromeos::PROFILE_SHARED; dictionary->SetBoolean("shared", shared); - bool shareable = - cros_->HasProfileType(chromeos::PROFILE_USER) && - !wifi->RequiresUserProfile(); - dictionary->SetBoolean("shareable", shareable); } DictionaryValue* InternetOptionsHandler::CreateDictionaryFromCellularApn( |