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

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: Fix Bookmark and Global error unittests Created 3 years, 9 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" 14 #include "chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h"
15 #include "chrome/browser/ui/views/layout_utils.h" 15 #include "chrome/browser/ui/views/layout_utils.h"
16 #include "chrome/grit/generated_resources.h" 16 #include "chrome/grit/generated_resources.h"
17 #include "chrome/grit/theme_resources.h" 17 #include "chrome/grit/theme_resources.h"
18 #include "chromeos/login/login_state.h" 18 #include "chromeos/login/login_state.h"
19 #include "chromeos/network/network_configuration_handler.h" 19 #include "chromeos/network/network_configuration_handler.h"
20 #include "chromeos/network/network_connect.h" 20 #include "chromeos/network/network_connect.h"
21 #include "chromeos/network/network_event_log.h" 21 #include "chromeos/network/network_event_log.h"
22 #include "chromeos/network/network_profile.h" 22 #include "chromeos/network/network_profile.h"
23 #include "chromeos/network/network_profile_handler.h" 23 #include "chromeos/network/network_profile_handler.h"
24 #include "chromeos/network/network_state.h" 24 #include "chromeos/network/network_state.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 DCHECK(wimax && wimax->type() == shill::kTypeWimax); 204 DCHECK(wimax && wimax->type() == shill::kTypeWimax);
205 205
206 WifiConfigView::ParseEAPUIProperty( 206 WifiConfigView::ParseEAPUIProperty(
207 &save_credentials_ui_data_, wimax, ::onc::eap::kSaveCredentials); 207 &save_credentials_ui_data_, wimax, ::onc::eap::kSaveCredentials);
208 WifiConfigView::ParseEAPUIProperty( 208 WifiConfigView::ParseEAPUIProperty(
209 &identity_ui_data_, wimax, ::onc::eap::kIdentity); 209 &identity_ui_data_, wimax, ::onc::eap::kIdentity);
210 WifiConfigView::ParseUIProperty( 210 WifiConfigView::ParseUIProperty(
211 &passphrase_ui_data_, wimax, ::onc::wifi::kPassphrase); 211 &passphrase_ui_data_, wimax, ::onc::wifi::kPassphrase);
212 212
213 views::GridLayout* layout = layout_utils::CreatePanelLayout(this); 213 views::GridLayout* layout = layout_utils::CreatePanelLayout(this);
214 LayoutDelegate* delegate = LayoutDelegate::Get(); 214 ChromeViewsLayoutDelegate* delegate = ChromeViewsLayoutDelegate::Get();
215 215
216 const int column_view_set_id = 0; 216 const int column_view_set_id = 0;
217 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id); 217 views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id);
218 const int kPasswordVisibleWidth = 20; 218 const int kPasswordVisibleWidth = 20;
219 // Label 219 // Label
220 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, 220 column_set->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1,
221 views::GridLayout::USE_PREF, 0, 0); 221 views::GridLayout::USE_PREF, 0, 0);
222 column_set->AddPaddingColumn( 222 column_set->AddPaddingColumn(
223 0, delegate->GetMetric( 223 0, delegate->GetDistanceMetric(
224 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); 224 ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
225 // Textfield, combobox. 225 // Textfield, combobox.
226 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 226 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
227 views::GridLayout::USE_PREF, 0, 227 views::GridLayout::USE_PREF, 0,
228 ChildNetworkConfigView::kInputFieldMinWidth); 228 ChildNetworkConfigView::kInputFieldMinWidth);
229 column_set->AddPaddingColumn( 229 column_set->AddPaddingColumn(
230 0, delegate->GetMetric( 230 0, delegate->GetDistanceMetric(
231 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)); 231 ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
232 // Password visible button / policy indicator. 232 // Password visible button / policy indicator.
233 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, 233 column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1,
234 views::GridLayout::USE_PREF, 0, kPasswordVisibleWidth); 234 views::GridLayout::USE_PREF, 0, kPasswordVisibleWidth);
235 235
236 // Network name 236 // Network name
237 layout->StartRow(0, column_view_set_id); 237 layout->StartRow(0, column_view_set_id);
238 layout->AddView(new views::Label(l10n_util::GetStringUTF16( 238 layout->AddView(new views::Label(l10n_util::GetStringUTF16(
239 IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK))); 239 IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK)));
240 views::Label* label = new views::Label(base::UTF8ToUTF16(wimax->name())); 240 views::Label* label = new views::Label(base::UTF8ToUTF16(wimax->name()));
241 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 241 label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
242 layout->AddView(label); 242 layout->AddView(label);
243 layout->AddPaddingRow( 243 layout->AddPaddingRow(0, delegate->GetDistanceMetric(
244 0, delegate->GetMetric( 244 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
245 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
246 245
247 // Identity 246 // Identity
248 layout->StartRow(0, column_view_set_id); 247 layout->StartRow(0, column_view_set_id);
249 base::string16 identity_label_text = l10n_util::GetStringUTF16( 248 base::string16 identity_label_text = l10n_util::GetStringUTF16(
250 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); 249 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY);
251 identity_label_ = new views::Label(identity_label_text); 250 identity_label_ = new views::Label(identity_label_text);
252 layout->AddView(identity_label_); 251 layout->AddView(identity_label_);
253 identity_textfield_ = new views::Textfield(); 252 identity_textfield_ = new views::Textfield();
254 identity_textfield_->SetAccessibleName(identity_label_text); 253 identity_textfield_->SetAccessibleName(identity_label_text);
255 identity_textfield_->set_controller(this); 254 identity_textfield_->set_controller(this);
256 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); 255 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable());
257 layout->AddView(identity_textfield_); 256 layout->AddView(identity_textfield_);
258 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); 257 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_));
259 layout->AddPaddingRow( 258 layout->AddPaddingRow(0, delegate->GetDistanceMetric(
260 0, delegate->GetMetric( 259 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
261 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
262 260
263 // Passphrase input 261 // Passphrase input
264 layout->StartRow(0, column_view_set_id); 262 layout->StartRow(0, column_view_set_id);
265 base::string16 passphrase_label_text = l10n_util::GetStringUTF16( 263 base::string16 passphrase_label_text = l10n_util::GetStringUTF16(
266 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE); 264 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE);
267 passphrase_label_ = new views::Label(passphrase_label_text); 265 passphrase_label_ = new views::Label(passphrase_label_text);
268 layout->AddView(passphrase_label_); 266 layout->AddView(passphrase_label_);
269 passphrase_textfield_ = new views::Textfield(); 267 passphrase_textfield_ = new views::Textfield();
270 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 268 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
271 passphrase_textfield_->set_controller(this); 269 passphrase_textfield_->set_controller(this);
(...skipping 29 matching lines...) Expand all
301 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD)); 299 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD));
302 passphrase_visible_button_->SetToggledImage( 300 passphrase_visible_button_->SetToggledImage(
303 views::ImageButton::STATE_HOVERED, 301 views::ImageButton::STATE_HOVERED,
304 ResourceBundle::GetSharedInstance(). 302 ResourceBundle::GetSharedInstance().
305 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER)); 303 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER));
306 passphrase_visible_button_->SetImageAlignment( 304 passphrase_visible_button_->SetImageAlignment(
307 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); 305 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE);
308 layout->AddView(passphrase_visible_button_); 306 layout->AddView(passphrase_visible_button_);
309 } 307 }
310 308
311 layout->AddPaddingRow( 309 layout->AddPaddingRow(0, delegate->GetDistanceMetric(
312 0, delegate->GetMetric( 310 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
313 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
314 311
315 // Checkboxes. 312 // Checkboxes.
316 313
317 if (LoginState::Get()->IsUserAuthenticated()) { 314 if (LoginState::Get()->IsUserAuthenticated()) {
318 // Save credentials 315 // Save credentials
319 layout->StartRow(0, column_view_set_id); 316 layout->StartRow(0, column_view_set_id);
320 save_credentials_checkbox_ = new views::Checkbox( 317 save_credentials_checkbox_ = new views::Checkbox(
321 l10n_util::GetStringUTF16( 318 l10n_util::GetStringUTF16(
322 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); 319 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS));
323 save_credentials_checkbox_->SetEnabled( 320 save_credentials_checkbox_->SetEnabled(
(...skipping 16 matching lines...) Expand all
340 ChildNetworkConfigView::GetShareStateForLoginState( 337 ChildNetworkConfigView::GetShareStateForLoginState(
341 &share_network_checkbox_value, 338 &share_network_checkbox_value,
342 &share_network_checkbox_enabled); 339 &share_network_checkbox_enabled);
343 340
344 share_network_checkbox_->SetChecked(share_network_checkbox_value); 341 share_network_checkbox_->SetChecked(share_network_checkbox_value);
345 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled); 342 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled);
346 343
347 layout->SkipColumns(1); 344 layout->SkipColumns(1);
348 layout->AddView(share_network_checkbox_); 345 layout->AddView(share_network_checkbox_);
349 } 346 }
350 layout->AddPaddingRow( 347 layout->AddPaddingRow(0, delegate->GetDistanceMetric(
351 0, delegate->GetMetric( 348 ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
352 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
353 349
354 // Create an error label. 350 // Create an error label.
355 layout->StartRow(0, column_view_set_id); 351 layout->StartRow(0, column_view_set_id);
356 layout->SkipColumns(1); 352 layout->SkipColumns(1);
357 error_label_ = new views::Label(); 353 error_label_ = new views::Label();
358 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 354 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
359 error_label_->SetEnabledColor(SK_ColorRED); 355 error_label_->SetEnabledColor(SK_ColorRED);
360 layout->AddView(error_label_); 356 layout->AddView(error_label_);
361 357
362 UpdateErrorLabel(); 358 UpdateErrorLabel();
(...skipping 24 matching lines...) Expand all
387 } 383 }
388 } 384 }
389 385
390 void WimaxConfigView::InitFocus() { 386 void WimaxConfigView::InitFocus() {
391 views::View* view_to_focus = GetInitiallyFocusedView(); 387 views::View* view_to_focus = GetInitiallyFocusedView();
392 if (view_to_focus) 388 if (view_to_focus)
393 view_to_focus->RequestFocus(); 389 view_to_focus->RequestFocus();
394 } 390 }
395 391
396 } // namespace chromeos 392 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698