Chromium Code Reviews| Index: chrome/browser/chromeos/options/wimax_config_view.cc |
| diff --git a/chrome/browser/chromeos/options/wimax_config_view.cc b/chrome/browser/chromeos/options/wimax_config_view.cc |
| index 5ae075b796b934a95abf9c4ae5bc5d895b0e3624..232c5246e0df00a8d2a5eb9d3bce74e8911cfb2f 100644 |
| --- a/chrome/browser/chromeos/options/wimax_config_view.cc |
| +++ b/chrome/browser/chromeos/options/wimax_config_view.cc |
| @@ -4,19 +4,27 @@ |
| #include "chrome/browser/chromeos/options/wimax_config_view.h" |
| +#include "ash/system/chromeos/network/network_connect.h" |
| #include "base/strings/string_util.h" |
| #include "base/strings/stringprintf.h" |
| #include "base/strings/utf_string_conversions.h" |
| -#include "chrome/browser/chromeos/cros/network_library.h" |
| #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| #include "chrome/browser/chromeos/login/startup_utils.h" |
| +#include "chrome/browser/chromeos/options/network_connect.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chromeos/login/login_state.h" |
| +#include "chromeos/network/network_configuration_handler.h" |
| +#include "chromeos/network/network_event_log.h" |
| +#include "chromeos/network/network_profile.h" |
| +#include "chromeos/network/network_profile_handler.h" |
| +#include "chromeos/network/network_state.h" |
| +#include "chromeos/network/network_state_handler.h" |
| #include "chromeos/network/onc/onc_constants.h" |
| #include "grit/chromium_strings.h" |
| #include "grit/generated_resources.h" |
| #include "grit/locale_settings.h" |
| #include "grit/theme_resources.h" |
| +#include "third_party/cros_system_api/dbus/service_constants.h" |
| #include "ui/base/events/event.h" |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| @@ -31,8 +39,19 @@ |
| namespace chromeos { |
| -WimaxConfigView::WimaxConfigView(NetworkConfigView* parent, WimaxNetwork* wimax) |
| - : ChildNetworkConfigView(parent, wimax), |
| +namespace { |
| + |
| +void ShillError(const std::string& function, |
| + const std::string& error_name, |
| + scoped_ptr<base::DictionaryValue> error_data) { |
| + NET_LOG_ERROR("Shill Error from WimaxConfigView: " + error_name, function); |
| +} |
| + |
| +} // namespace |
| + |
| +WimaxConfigView::WimaxConfigView(NetworkConfigView* parent, |
| + const std::string& service_path) |
| + : ChildNetworkConfigView(parent, service_path), |
| identity_label_(NULL), |
| identity_textfield_(NULL), |
| save_credentials_checkbox_(NULL), |
| @@ -42,7 +61,7 @@ WimaxConfigView::WimaxConfigView(NetworkConfigView* parent, WimaxNetwork* wimax) |
| passphrase_textfield_(NULL), |
| passphrase_visible_button_(NULL), |
| error_label_(NULL) { |
| - Init(wimax); |
| + Init(service_path); |
| } |
| WimaxConfigView::~WimaxConfigView() { |
| @@ -76,33 +95,15 @@ void WimaxConfigView::UpdateDialogButtons() { |
| } |
| void WimaxConfigView::UpdateErrorLabel() { |
| - std::string error_msg; |
| + base::string16 error_msg; |
| if (!service_path_.empty()) { |
| - NetworkLibrary* cros = NetworkLibrary::Get(); |
| - const WimaxNetwork* wimax = cros->FindWimaxNetworkByPath(service_path_); |
| - if (wimax && wimax->failed()) { |
| - bool passphrase_empty = wimax->eap_passphrase().empty(); |
| - switch (wimax->error()) { |
| - case ERROR_BAD_PASSPHRASE: |
| - if (!passphrase_empty) { |
| - error_msg = l10n_util::GetStringUTF8( |
| - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_PASSPHRASE); |
| - } |
| - break; |
| - case ERROR_BAD_WEPKEY: |
| - if (!passphrase_empty) { |
| - error_msg = l10n_util::GetStringUTF8( |
| - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_BAD_WEPKEY); |
| - } |
| - break; |
| - default: |
| - error_msg = wimax->GetErrorString(); |
| - break; |
| - } |
| - } |
| + const NetworkState* wimax = NetworkHandler::Get()->network_state_handler()-> |
| + GetNetworkState(service_path_); |
|
gauravsh
2013/08/03 01:15:54
Add DCHECK to verity this is a kTypeWimax network.
stevenjb
2013/08/06 00:32:48
Added a DCHECK in Init()
|
| + if (wimax && wimax->connection_state() == flimflam::kStateFailure) |
| + error_msg = ash::network_connect::ErrorString(wimax->error()); |
| } |
| if (!error_msg.empty()) { |
| - error_label_->SetText(UTF8ToUTF16(error_msg)); |
| + error_label_->SetText(error_msg); |
| error_label_->SetVisible(true); |
| } else { |
| error_label_->SetVisible(false); |
| @@ -137,26 +138,42 @@ void WimaxConfigView::ButtonPressed(views::Button* sender, |
| } |
| bool WimaxConfigView::Login() { |
| - NetworkLibrary* cros = NetworkLibrary::Get(); |
| - WimaxNetwork* wimax = cros->FindWimaxNetworkByPath(service_path_); |
| + const NetworkState* wimax = NetworkHandler::Get()->network_state_handler()-> |
| + GetNetworkState(service_path_); |
| if (!wimax) { |
| - // Shill no longer knows about this wimax network (edge case). |
| - // TODO(stevenjb): Add a notification (chromium-os13225). |
| - LOG(WARNING) << "Wimax network: " << service_path_ << " no longer exists."; |
| - return true; |
| + // Shill no longer knows about this network (edge case). |
| + // TODO(stevenjb): Add notification for this. |
| + NET_LOG_ERROR("Network not found", service_path_); |
| + return true; // Close dialog |
| + } |
| + base::DictionaryValue properties; |
| + properties.SetStringWithoutPathExpansion( |
| + flimflam::kEapIdentityProperty, GetEapIdentity()); |
| + properties.SetStringWithoutPathExpansion( |
| + flimflam::kEapPasswordProperty, GetEapPassphrase()); |
| + properties.SetBooleanWithoutPathExpansion( |
| + flimflam::kSaveCredentialsProperty, GetSaveCredentials()); |
| + bool wimax_shared = !wimax->IsPrivate(); |
|
gauravsh
2013/08/03 01:15:54
What are lines l156 - l175 doing? (add a comment t
stevenjb
2013/08/06 00:32:48
Comment Added.
|
| + bool share_network = GetShareNetwork(wimax_shared); |
| + if (share_network != wimax_shared) { |
| + std::string profile_path; |
| + if (share_network) { |
| + profile_path = NetworkProfileHandler::kSharedProfilePath; |
| + } else { |
| + const NetworkProfile* profile = |
| + NetworkHandler::Get()->network_profile_handler()-> |
| + GetDefaultUserProfile(); |
| + if (profile) |
| + profile_path = profile->path; |
| + else |
| + NET_LOG_ERROR("Unable to set user profile", service_path_); |
| + } |
| + if (!profile_path.empty()) { |
| + properties.SetStringWithoutPathExpansion( |
| + flimflam::kProfileProperty, profile_path); |
| + } |
| } |
| - wimax->SetEAPIdentity(GetEapIdentity()); |
| - wimax->SetEAPPassphrase(GetEapPassphrase()); |
| - wimax->SetSaveCredentials(GetSaveCredentials()); |
| - bool share_default = (wimax->profile_type() != PROFILE_USER); |
| - bool share = GetShareNetwork(share_default); |
| - wimax->SetEnrollmentDelegate( |
| - CreateEnrollmentDelegate(GetWidget()->GetNativeWindow(), |
| - wimax->name(), |
| - ProfileManager::GetLastUsedProfile())); |
| - cros->ConnectToWimaxNetwork(wimax, share); |
| - // Connection failures are responsible for updating the UI, including |
| - // reopening dialogs. |
| + ash::network_connect::ConfigureNetworkAndConnect(service_path_, properties); |
| return true; // dialog will be closed |
| } |
| @@ -183,7 +200,9 @@ bool WimaxConfigView::GetShareNetwork(bool share_default) const { |
| void WimaxConfigView::Cancel() { |
| } |
| -void WimaxConfigView::Init(WimaxNetwork* wimax) { |
| +void WimaxConfigView::Init(const std::string& service_path) { |
| + const NetworkState* wimax = NetworkHandler::Get()->network_state_handler()-> |
| + GetNetworkState(service_path); |
| DCHECK(wimax); |
| WifiConfigView::ParseWiFiEAPUIProperty( |
| &save_credentials_ui_data_, wimax, onc::eap::kSaveCredentials); |
| @@ -230,8 +249,6 @@ void WimaxConfigView::Init(WimaxNetwork* wimax) { |
| views::Textfield::STYLE_DEFAULT); |
| identity_textfield_->SetAccessibleName(identity_label_text); |
| identity_textfield_->SetController(this); |
| - const std::string& eap_identity = wimax->eap_identity(); |
| - identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); |
| identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); |
| layout->AddView(identity_textfield_); |
| layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); |
| @@ -296,20 +313,19 @@ void WimaxConfigView::Init(WimaxNetwork* wimax) { |
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
| save_credentials_checkbox_->SetEnabled( |
| save_credentials_ui_data_.IsEditable()); |
| - save_credentials_checkbox_->SetChecked(wimax->save_credentials()); |
| layout->SkipColumns(1); |
| layout->AddView(save_credentials_checkbox_); |
| layout->AddView( |
| new ControlledSettingIndicatorView(save_credentials_ui_data_)); |
| // Share network |
| - if (wimax->profile_type() == PROFILE_NONE && wimax->passphrase_required()) { |
| + if (!wimax->IsPrivate()) { |
| layout->StartRow(0, column_view_set_id); |
| share_network_checkbox_ = new views::Checkbox( |
| l10n_util::GetStringUTF16( |
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK)); |
| share_network_checkbox_->SetEnabled(true); |
| - share_network_checkbox_->SetChecked(false); // Default to unshared. |
| + share_network_checkbox_->SetChecked(true); |
| layout->SkipColumns(1); |
| layout->AddView(share_network_checkbox_); |
| } |
| @@ -325,6 +341,31 @@ void WimaxConfigView::Init(WimaxNetwork* wimax) { |
| layout->AddView(error_label_); |
| UpdateErrorLabel(); |
| + |
| + if (wimax) { |
| + NetworkHandler::Get()->network_configuration_handler()->GetProperties( |
| + service_path, |
| + base::Bind(&WimaxConfigView::InitFromProperties, AsWeakPtr()), |
| + base::Bind(&ShillError, "GetProperties")); |
| + } |
| +} |
| + |
| +void WimaxConfigView::InitFromProperties( |
| + const std::string& service_path, |
| + const base::DictionaryValue& properties) { |
| + // EapIdentity |
| + std::string eap_identity; |
| + properties.GetStringWithoutPathExpansion( |
| + flimflam::kEapIdentityProperty, &eap_identity); |
| + identity_textfield_->SetText(UTF8ToUTF16(eap_identity)); |
| + |
| + // Save credentials |
| + if (save_credentials_checkbox_) { |
| + bool save_credentials = false; |
| + properties.GetBooleanWithoutPathExpansion( |
| + flimflam::kSaveCredentialsProperty, &save_credentials); |
| + save_credentials_checkbox_->SetChecked(save_credentials); |
| + } |
| } |
| void WimaxConfigView::InitFocus() { |