| 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..8ea37887213b339d6630b2d2680654ed5c347b4e 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),
|
| @@ -41,8 +60,9 @@ WimaxConfigView::WimaxConfigView(NetworkConfigView* parent, WimaxNetwork* wimax)
|
| passphrase_label_(NULL),
|
| passphrase_textfield_(NULL),
|
| passphrase_visible_button_(NULL),
|
| - error_label_(NULL) {
|
| - Init(wimax);
|
| + error_label_(NULL),
|
| + weak_ptr_factory_(this) {
|
| + Init();
|
| }
|
|
|
| WimaxConfigView::~WimaxConfigView() {
|
| @@ -76,33 +96,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_);
|
| + 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 +139,26 @@ 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
|
| }
|
| - 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.
|
| + base::DictionaryValue properties;
|
| + properties.SetStringWithoutPathExpansion(
|
| + flimflam::kEapIdentityProperty, GetEapIdentity());
|
| + properties.SetStringWithoutPathExpansion(
|
| + flimflam::kEapPasswordProperty, GetEapPassphrase());
|
| + properties.SetBooleanWithoutPathExpansion(
|
| + flimflam::kSaveCredentialsProperty, GetSaveCredentials());
|
| +
|
| + const bool share_default = true;
|
| + bool share_network = GetShareNetwork(share_default);
|
| + ash::network_connect::ConfigureNetworkAndConnect(
|
| + service_path_, properties, share_network);
|
| return true; // dialog will be closed
|
| }
|
|
|
| @@ -183,8 +185,11 @@ bool WimaxConfigView::GetShareNetwork(bool share_default) const {
|
| void WimaxConfigView::Cancel() {
|
| }
|
|
|
| -void WimaxConfigView::Init(WimaxNetwork* wimax) {
|
| - DCHECK(wimax);
|
| +void WimaxConfigView::Init() {
|
| + const NetworkState* wimax = NetworkHandler::Get()->network_state_handler()->
|
| + GetNetworkState(service_path_);
|
| + DCHECK(wimax && wimax->type() == flimflam::kTypeWimax);
|
| +
|
| WifiConfigView::ParseWiFiEAPUIProperty(
|
| &save_credentials_ui_data_, wimax, onc::eap::kSaveCredentials);
|
| WifiConfigView::ParseWiFiEAPUIProperty(
|
| @@ -230,8 +235,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_));
|
| @@ -288,7 +291,7 @@ void WimaxConfigView::Init(WimaxNetwork* wimax) {
|
|
|
| // Checkboxes.
|
|
|
| - if (LoginState::Get()->IsUserLoggedIn()) {
|
| + if (LoginState::Get()->IsUserAuthenticated()) {
|
| // Save credentials
|
| layout->StartRow(0, column_view_set_id);
|
| save_credentials_checkbox_ = new views::Checkbox(
|
| @@ -296,23 +299,28 @@ 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()) {
|
| - 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
|
| + if (wimax->profile_path().empty()) {
|
| + layout->StartRow(0, column_view_set_id);
|
| + share_network_checkbox_ = new views::Checkbox(
|
| + l10n_util::GetStringUTF16(
|
| + IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHARE_NETWORK));
|
| + if (LoginState::Get()->IsUserAuthenticated()) {
|
| + share_network_checkbox_->SetChecked(false); // Default to unshared
|
| share_network_checkbox_->SetEnabled(true);
|
| - share_network_checkbox_->SetChecked(false); // Default to unshared.
|
| - layout->SkipColumns(1);
|
| - layout->AddView(share_network_checkbox_);
|
| + } else {
|
| + // Not logged in, must be shared
|
| + share_network_checkbox_->SetChecked(true);
|
| + share_network_checkbox_->SetEnabled(false);
|
| }
|
| + layout->SkipColumns(1);
|
| + layout->AddView(share_network_checkbox_);
|
| }
|
| layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
|
|
| @@ -325,6 +333,32 @@ void WimaxConfigView::Init(WimaxNetwork* wimax) {
|
| layout->AddView(error_label_);
|
|
|
| UpdateErrorLabel();
|
| +
|
| + if (wimax) {
|
| + NetworkHandler::Get()->network_configuration_handler()->GetProperties(
|
| + service_path_,
|
| + base::Bind(&WimaxConfigView::InitFromProperties,
|
| + weak_ptr_factory_.GetWeakPtr()),
|
| + 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() {
|
|
|