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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Addressed Feedback. Renamed ViewsLayoutDelegate to LayoutDelegate and ChromeViewsLayoutDelegate to … Created 3 years, 8 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/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_delegate.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
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::LayoutDelegate* delegate = views::LayoutDelegate::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, delegate->GetDistanceMetric(
223 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); 223 views::DistanceMetric::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, delegate->GetDistanceMetric(
230 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); 230 views::DistanceMetric::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(0,
243 0, delegate->GetMetric( 243 delegate->GetDistanceMetric(
244 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 244 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
245 245
246 // Identity 246 // Identity
247 layout->StartRow(0, column_view_set_id); 247 layout->StartRow(0, column_view_set_id);
248 base::string16 identity_label_text = l10n_util::GetStringUTF16( 248 base::string16 identity_label_text = l10n_util::GetStringUTF16(
249 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); 249 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY);
250 identity_label_ = new views::Label(identity_label_text); 250 identity_label_ = new views::Label(identity_label_text);
251 layout->AddView(identity_label_); 251 layout->AddView(identity_label_);
252 identity_textfield_ = new views::Textfield(); 252 identity_textfield_ = new views::Textfield();
253 identity_textfield_->SetAccessibleName(identity_label_text); 253 identity_textfield_->SetAccessibleName(identity_label_text);
254 identity_textfield_->set_controller(this); 254 identity_textfield_->set_controller(this);
255 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); 255 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable());
256 layout->AddView(identity_textfield_); 256 layout->AddView(identity_textfield_);
257 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); 257 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_));
258 layout->AddPaddingRow( 258 layout->AddPaddingRow(0,
259 0, delegate->GetMetric( 259 delegate->GetDistanceMetric(
260 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 260 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
261 261
262 // Passphrase input 262 // Passphrase input
263 layout->StartRow(0, column_view_set_id); 263 layout->StartRow(0, column_view_set_id);
264 base::string16 passphrase_label_text = l10n_util::GetStringUTF16( 264 base::string16 passphrase_label_text = l10n_util::GetStringUTF16(
265 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE); 265 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE);
266 passphrase_label_ = new views::Label(passphrase_label_text); 266 passphrase_label_ = new views::Label(passphrase_label_text);
267 layout->AddView(passphrase_label_); 267 layout->AddView(passphrase_label_);
268 passphrase_textfield_ = new views::Textfield(); 268 passphrase_textfield_ = new views::Textfield();
269 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 269 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
270 passphrase_textfield_->set_controller(this); 270 passphrase_textfield_->set_controller(this);
(...skipping 29 matching lines...) Expand all
300 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD)); 300 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD));
301 passphrase_visible_button_->SetToggledImage( 301 passphrase_visible_button_->SetToggledImage(
302 views::ImageButton::STATE_HOVERED, 302 views::ImageButton::STATE_HOVERED,
303 ResourceBundle::GetSharedInstance(). 303 ResourceBundle::GetSharedInstance().
304 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER)); 304 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER));
305 passphrase_visible_button_->SetImageAlignment( 305 passphrase_visible_button_->SetImageAlignment(
306 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); 306 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE);
307 layout->AddView(passphrase_visible_button_); 307 layout->AddView(passphrase_visible_button_);
308 } 308 }
309 309
310 layout->AddPaddingRow( 310 layout->AddPaddingRow(0,
311 0, delegate->GetMetric( 311 delegate->GetDistanceMetric(
312 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 312 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
313 313
314 // Checkboxes. 314 // Checkboxes.
315 315
316 if (LoginState::Get()->IsUserAuthenticated()) { 316 if (LoginState::Get()->IsUserAuthenticated()) {
317 // Save credentials 317 // Save credentials
318 layout->StartRow(0, column_view_set_id); 318 layout->StartRow(0, column_view_set_id);
319 save_credentials_checkbox_ = new views::Checkbox( 319 save_credentials_checkbox_ = new views::Checkbox(
320 l10n_util::GetStringUTF16( 320 l10n_util::GetStringUTF16(
321 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); 321 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS));
322 save_credentials_checkbox_->SetEnabled( 322 save_credentials_checkbox_->SetEnabled(
(...skipping 16 matching lines...) Expand all
339 ChildNetworkConfigView::GetShareStateForLoginState( 339 ChildNetworkConfigView::GetShareStateForLoginState(
340 &share_network_checkbox_value, 340 &share_network_checkbox_value,
341 &share_network_checkbox_enabled); 341 &share_network_checkbox_enabled);
342 342
343 share_network_checkbox_->SetChecked(share_network_checkbox_value); 343 share_network_checkbox_->SetChecked(share_network_checkbox_value);
344 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled); 344 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled);
345 345
346 layout->SkipColumns(1); 346 layout->SkipColumns(1);
347 layout->AddView(share_network_checkbox_); 347 layout->AddView(share_network_checkbox_);
348 } 348 }
349 layout->AddPaddingRow( 349 layout->AddPaddingRow(0,
350 0, delegate->GetMetric( 350 delegate->GetDistanceMetric(
351 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 351 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
352 352
353 // Create an error label. 353 // Create an error label.
354 layout->StartRow(0, column_view_set_id); 354 layout->StartRow(0, column_view_set_id);
355 layout->SkipColumns(1); 355 layout->SkipColumns(1);
356 error_label_ = new views::Label(); 356 error_label_ = new views::Label();
357 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 357 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
358 error_label_->SetEnabledColor(SK_ColorRED); 358 error_label_->SetEnabledColor(SK_ColorRED);
359 layout->AddView(error_label_); 359 layout->AddView(error_label_);
360 360
361 UpdateErrorLabel(); 361 UpdateErrorLabel();
(...skipping 24 matching lines...) Expand all
386 } 386 }
387 } 387 }
388 388
389 void WimaxConfigView::InitFocus() { 389 void WimaxConfigView::InitFocus() {
390 views::View* view_to_focus = GetInitiallyFocusedView(); 390 views::View* view_to_focus = GetInitiallyFocusedView();
391 if (view_to_focus) 391 if (view_to_focus)
392 view_to_focus->RequestFocus(); 392 view_to_focus->RequestFocus();
393 } 393 }
394 394
395 } // namespace chromeos 395 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698