| 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/wimax_config_view.h" | 5 #include "chrome/browser/chromeos/options/wimax_config_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 10 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 11 #include "chrome/browser/chromeos/login/startup_utils.h" | 11 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 12 #include "chrome/browser/chromeos/net/shill_error.h" | 12 #include "chrome/browser/chromeos/net/shill_error.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/views/harmony/layout_delegate.h" | |
| 15 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 16 #include "chrome/grit/theme_resources.h" | 15 #include "chrome/grit/theme_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_connect.h" | 18 #include "chromeos/network/network_connect.h" |
| 20 #include "chromeos/network/network_event_log.h" | 19 #include "chromeos/network/network_event_log.h" |
| 21 #include "chromeos/network/network_profile.h" | 20 #include "chromeos/network/network_profile.h" |
| 22 #include "chromeos/network/network_profile_handler.h" | 21 #include "chromeos/network/network_profile_handler.h" |
| 23 #include "chromeos/network/network_state.h" | 22 #include "chromeos/network/network_state.h" |
| 24 #include "chromeos/network/network_state_handler.h" | 23 #include "chromeos/network/network_state_handler.h" |
| 25 #include "chromeos/network/onc/onc_utils.h" | 24 #include "chromeos/network/onc/onc_utils.h" |
| 26 #include "components/onc/onc_constants.h" | 25 #include "components/onc/onc_constants.h" |
| 27 #include "third_party/cros_system_api/dbus/service_constants.h" | 26 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 28 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 29 #include "ui/base/resource/resource_bundle.h" | 28 #include "ui/base/resource/resource_bundle.h" |
| 30 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
| 31 #include "ui/views/controls/button/checkbox.h" | 30 #include "ui/views/controls/button/checkbox.h" |
| 32 #include "ui/views/controls/button/image_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
| 33 #include "ui/views/controls/label.h" | 32 #include "ui/views/controls/label.h" |
| 34 #include "ui/views/controls/textfield/textfield.h" | 33 #include "ui/views/controls/textfield/textfield.h" |
| 35 #include "ui/views/layout/grid_layout.h" | 34 #include "ui/views/layout/grid_layout.h" |
| 35 #include "ui/views/layout/layout_provider.h" |
| 36 #include "ui/views/widget/widget.h" | 36 #include "ui/views/widget/widget.h" |
| 37 #include "ui/views/window/dialog_client_view.h" | 37 #include "ui/views/window/dialog_client_view.h" |
| 38 | 38 |
| 39 namespace chromeos { | 39 namespace chromeos { |
| 40 | 40 |
| 41 namespace { | 41 namespace { |
| 42 | 42 |
| 43 void ShillError(const std::string& function, | 43 void ShillError(const std::string& function, |
| 44 const std::string& error_name, | 44 const std::string& error_name, |
| 45 std::unique_ptr<base::DictionaryValue> error_data) { | 45 std::unique_ptr<base::DictionaryValue> error_data) { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 DCHECK(wimax && wimax->type() == shill::kTypeWimax); | 203 DCHECK(wimax && wimax->type() == shill::kTypeWimax); |
| 204 | 204 |
| 205 WifiConfigView::ParseEAPUIProperty( | 205 WifiConfigView::ParseEAPUIProperty( |
| 206 &save_credentials_ui_data_, wimax, ::onc::eap::kSaveCredentials); | 206 &save_credentials_ui_data_, wimax, ::onc::eap::kSaveCredentials); |
| 207 WifiConfigView::ParseEAPUIProperty( | 207 WifiConfigView::ParseEAPUIProperty( |
| 208 &identity_ui_data_, wimax, ::onc::eap::kIdentity); | 208 &identity_ui_data_, wimax, ::onc::eap::kIdentity); |
| 209 WifiConfigView::ParseUIProperty( | 209 WifiConfigView::ParseUIProperty( |
| 210 &passphrase_ui_data_, wimax, ::onc::wifi::kPassphrase); | 210 &passphrase_ui_data_, wimax, ::onc::wifi::kPassphrase); |
| 211 | 211 |
| 212 views::GridLayout* layout = views::GridLayout::CreatePanel(this); | 212 views::GridLayout* layout = views::GridLayout::CreatePanel(this); |
| 213 LayoutDelegate* delegate = LayoutDelegate::Get(); | 213 views::LayoutProvider* provider = views::LayoutProvider::Get(); |
| 214 | 214 |
| 215 const int column_view_set_id = 0; | 215 const int column_view_set_id = 0; |
| 216 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); | 216 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); |
| 217 const int kPasswordVisibleWidth = 20; | 217 const int kPasswordVisibleWidth = 20; |
| 218 // Label | 218 // Label |
| 219 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 219 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
| 220 views::GridLayout::USE_PREF, 0, 0); | 220 views::GridLayout::USE_PREF, 0, 0); |
| 221 column_set->AddPaddingColumn( | 221 column_set->AddPaddingColumn( |
| 222 0, delegate->GetMetric( | 222 0, |
| 223 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); | 223 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL)); |
| 224 // Textfield, combobox. | 224 // Textfield, combobox. |
| 225 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 225 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
| 226 views::GridLayout::USE_PREF, 0, | 226 views::GridLayout::USE_PREF, 0, |
| 227 ChildNetworkConfigView::kInputFieldMinWidth); | 227 ChildNetworkConfigView::kInputFieldMinWidth); |
| 228 column_set->AddPaddingColumn( | 228 column_set->AddPaddingColumn( |
| 229 0, delegate->GetMetric( | 229 0, |
| 230 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); | 230 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL)); |
| 231 // Password visible button / policy indicator. | 231 // Password visible button / policy indicator. |
| 232 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, | 232 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, |
| 233 views::GridLayout::USE_PREF, 0, kPasswordVisibleWidth); | 233 views::GridLayout::USE_PREF, 0, kPasswordVisibleWidth); |
| 234 | 234 |
| 235 // Network name | 235 // Network name |
| 236 layout->StartRow(0, column_view_set_id); | 236 layout->StartRow(0, column_view_set_id); |
| 237 layout->AddView(new views::Label(l10n_util::GetStringUTF16( | 237 layout->AddView(new views::Label(l10n_util::GetStringUTF16( |
| 238 IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK))); | 238 IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK))); |
| 239 views::Label* label = new views::Label(base::UTF8ToUTF16(wimax->name())); | 239 views::Label* label = new views::Label(base::UTF8ToUTF16(wimax->name())); |
| 240 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 240 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 241 layout->AddView(label); | 241 layout->AddView(label); |
| 242 layout->AddPaddingRow( | 242 layout->AddPaddingRow( |
| 243 0, delegate->GetMetric( | 243 0, provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 244 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 245 | 244 |
| 246 // Identity | 245 // Identity |
| 247 layout->StartRow(0, column_view_set_id); | 246 layout->StartRow(0, column_view_set_id); |
| 248 base::string16 identity_label_text = l10n_util::GetStringUTF16( | 247 base::string16 identity_label_text = l10n_util::GetStringUTF16( |
| 249 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); | 248 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); |
| 250 identity_label_ = new views::Label(identity_label_text); | 249 identity_label_ = new views::Label(identity_label_text); |
| 251 layout->AddView(identity_label_); | 250 layout->AddView(identity_label_); |
| 252 identity_textfield_ = new views::Textfield(); | 251 identity_textfield_ = new views::Textfield(); |
| 253 identity_textfield_->SetAccessibleName(identity_label_text); | 252 identity_textfield_->SetAccessibleName(identity_label_text); |
| 254 identity_textfield_->set_controller(this); | 253 identity_textfield_->set_controller(this); |
| 255 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); | 254 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); |
| 256 layout->AddView(identity_textfield_); | 255 layout->AddView(identity_textfield_); |
| 257 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); | 256 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); |
| 258 layout->AddPaddingRow( | 257 layout->AddPaddingRow( |
| 259 0, delegate->GetMetric( | 258 0, provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 260 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 261 | 259 |
| 262 // Passphrase input | 260 // Passphrase input |
| 263 layout->StartRow(0, column_view_set_id); | 261 layout->StartRow(0, column_view_set_id); |
| 264 base::string16 passphrase_label_text = l10n_util::GetStringUTF16( | 262 base::string16 passphrase_label_text = l10n_util::GetStringUTF16( |
| 265 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE); | 263 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE); |
| 266 passphrase_label_ = new views::Label(passphrase_label_text); | 264 passphrase_label_ = new views::Label(passphrase_label_text); |
| 267 layout->AddView(passphrase_label_); | 265 layout->AddView(passphrase_label_); |
| 268 passphrase_textfield_ = new views::Textfield(); | 266 passphrase_textfield_ = new views::Textfield(); |
| 269 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); | 267 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); |
| 270 passphrase_textfield_->set_controller(this); | 268 passphrase_textfield_->set_controller(this); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 301 passphrase_visible_button_->SetToggledImage( | 299 passphrase_visible_button_->SetToggledImage( |
| 302 views::ImageButton::STATE_HOVERED, | 300 views::ImageButton::STATE_HOVERED, |
| 303 ResourceBundle::GetSharedInstance(). | 301 ResourceBundle::GetSharedInstance(). |
| 304 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER)); | 302 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER)); |
| 305 passphrase_visible_button_->SetImageAlignment( | 303 passphrase_visible_button_->SetImageAlignment( |
| 306 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); | 304 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); |
| 307 layout->AddView(passphrase_visible_button_); | 305 layout->AddView(passphrase_visible_button_); |
| 308 } | 306 } |
| 309 | 307 |
| 310 layout->AddPaddingRow( | 308 layout->AddPaddingRow( |
| 311 0, delegate->GetMetric( | 309 0, provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 312 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 313 | 310 |
| 314 // Checkboxes. | 311 // Checkboxes. |
| 315 | 312 |
| 316 if (LoginState::Get()->IsUserAuthenticated()) { | 313 if (LoginState::Get()->IsUserAuthenticated()) { |
| 317 // Save credentials | 314 // Save credentials |
| 318 layout->StartRow(0, column_view_set_id); | 315 layout->StartRow(0, column_view_set_id); |
| 319 save_credentials_checkbox_ = new views::Checkbox( | 316 save_credentials_checkbox_ = new views::Checkbox( |
| 320 l10n_util::GetStringUTF16( | 317 l10n_util::GetStringUTF16( |
| 321 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); | 318 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); |
| 322 save_credentials_checkbox_->SetEnabled( | 319 save_credentials_checkbox_->SetEnabled( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 340 &share_network_checkbox_value, | 337 &share_network_checkbox_value, |
| 341 &share_network_checkbox_enabled); | 338 &share_network_checkbox_enabled); |
| 342 | 339 |
| 343 share_network_checkbox_->SetChecked(share_network_checkbox_value); | 340 share_network_checkbox_->SetChecked(share_network_checkbox_value); |
| 344 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled); | 341 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled); |
| 345 | 342 |
| 346 layout->SkipColumns(1); | 343 layout->SkipColumns(1); |
| 347 layout->AddView(share_network_checkbox_); | 344 layout->AddView(share_network_checkbox_); |
| 348 } | 345 } |
| 349 layout->AddPaddingRow( | 346 layout->AddPaddingRow( |
| 350 0, delegate->GetMetric( | 347 0, provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)); |
| 351 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); | |
| 352 | 348 |
| 353 // Create an error label. | 349 // Create an error label. |
| 354 layout->StartRow(0, column_view_set_id); | 350 layout->StartRow(0, column_view_set_id); |
| 355 layout->SkipColumns(1); | 351 layout->SkipColumns(1); |
| 356 error_label_ = new views::Label(); | 352 error_label_ = new views::Label(); |
| 357 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 353 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 358 error_label_->SetEnabledColor(SK_ColorRED); | 354 error_label_->SetEnabledColor(SK_ColorRED); |
| 359 layout->AddView(error_label_); | 355 layout->AddView(error_label_); |
| 360 | 356 |
| 361 UpdateErrorLabel(); | 357 UpdateErrorLabel(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 386 } | 382 } |
| 387 } | 383 } |
| 388 | 384 |
| 389 void WimaxConfigView::InitFocus() { | 385 void WimaxConfigView::InitFocus() { |
| 390 views::View* view_to_focus = GetInitiallyFocusedView(); | 386 views::View* view_to_focus = GetInitiallyFocusedView(); |
| 391 if (view_to_focus) | 387 if (view_to_focus) |
| 392 view_to_focus->RequestFocus(); | 388 view_to_focus->RequestFocus(); |
| 393 } | 389 } |
| 394 | 390 |
| 395 } // namespace chromeos | 391 } // namespace chromeos |
| OLD | NEW |