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

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: Deleted LayoutDelegate and HarmonyLayoutDelegate. 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/browser/ui/views/layout_utils.h" 14 #include "chrome/browser/ui/views/layout_utils.h"
16 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
17 #include "chrome/grit/theme_resources.h" 16 #include "chrome/grit/theme_resources.h"
18 #include "chromeos/login/login_state.h" 17 #include "chromeos/login/login_state.h"
19 #include "chromeos/network/network_configuration_handler.h" 18 #include "chromeos/network/network_configuration_handler.h"
20 #include "chromeos/network/network_connect.h" 19 #include "chromeos/network/network_connect.h"
21 #include "chromeos/network/network_event_log.h" 20 #include "chromeos/network/network_event_log.h"
22 #include "chromeos/network/network_profile.h" 21 #include "chromeos/network/network_profile.h"
23 #include "chromeos/network/network_profile_handler.h" 22 #include "chromeos/network/network_profile_handler.h"
24 #include "chromeos/network/network_state.h" 23 #include "chromeos/network/network_state.h"
25 #include "chromeos/network/network_state_handler.h" 24 #include "chromeos/network/network_state_handler.h"
26 #include "chromeos/network/onc/onc_utils.h" 25 #include "chromeos/network/onc/onc_utils.h"
27 #include "components/onc/onc_constants.h" 26 #include "components/onc/onc_constants.h"
28 #include "third_party/cros_system_api/dbus/service_constants.h" 27 #include "third_party/cros_system_api/dbus/service_constants.h"
29 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
31 #include "ui/events/event.h" 30 #include "ui/events/event.h"
32 #include "ui/views/controls/button/checkbox.h" 31 #include "ui/views/controls/button/checkbox.h"
33 #include "ui/views/controls/button/image_button.h" 32 #include "ui/views/controls/button/image_button.h"
34 #include "ui/views/controls/label.h" 33 #include "ui/views/controls/label.h"
35 #include "ui/views/controls/textfield/textfield.h" 34 #include "ui/views/controls/textfield/textfield.h"
36 #include "ui/views/layout/grid_layout.h" 35 #include "ui/views/layout/grid_layout.h"
36 #include "ui/views/layout/views_layout_delegate.h"
37 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
38 #include "ui/views/window/dialog_client_view.h" 38 #include "ui/views/window/dialog_client_view.h"
39 39
40 namespace chromeos { 40 namespace chromeos {
41 41
42 namespace { 42 namespace {
43 43
44 void ShillError(const std::string& function, 44 void ShillError(const std::string& function,
45 const std::string& error_name, 45 const std::string& error_name,
46 std::unique_ptr<base::DictionaryValue> error_data) { 46 std::unique_ptr<base::DictionaryValue> error_data) {
(...skipping 157 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 views::ViewsLayoutDelegate* delegate = views::ViewsLayoutDelegate::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 views::DistanceMetric::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 views::DistanceMetric::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,
244 0, delegate->GetMetric( 244 delegate->GetDistanceMetric(
245 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 245 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
246 246
247 // Identity 247 // Identity
248 layout->StartRow(0, column_view_set_id); 248 layout->StartRow(0, column_view_set_id);
249 base::string16 identity_label_text = l10n_util::GetStringUTF16( 249 base::string16 identity_label_text = l10n_util::GetStringUTF16(
250 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY); 250 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY);
251 identity_label_ = new views::Label(identity_label_text); 251 identity_label_ = new views::Label(identity_label_text);
252 layout->AddView(identity_label_); 252 layout->AddView(identity_label_);
253 identity_textfield_ = new views::Textfield(); 253 identity_textfield_ = new views::Textfield();
254 identity_textfield_->SetAccessibleName(identity_label_text); 254 identity_textfield_->SetAccessibleName(identity_label_text);
255 identity_textfield_->set_controller(this); 255 identity_textfield_->set_controller(this);
256 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable()); 256 identity_textfield_->SetEnabled(identity_ui_data_.IsEditable());
257 layout->AddView(identity_textfield_); 257 layout->AddView(identity_textfield_);
258 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_)); 258 layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_));
259 layout->AddPaddingRow( 259 layout->AddPaddingRow(0,
260 0, delegate->GetMetric( 260 delegate->GetDistanceMetric(
261 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 261 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
262 262
263 // Passphrase input 263 // Passphrase input
264 layout->StartRow(0, column_view_set_id); 264 layout->StartRow(0, column_view_set_id);
265 base::string16 passphrase_label_text = l10n_util::GetStringUTF16( 265 base::string16 passphrase_label_text = l10n_util::GetStringUTF16(
266 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE); 266 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSPHRASE);
267 passphrase_label_ = new views::Label(passphrase_label_text); 267 passphrase_label_ = new views::Label(passphrase_label_text);
268 layout->AddView(passphrase_label_); 268 layout->AddView(passphrase_label_);
269 passphrase_textfield_ = new views::Textfield(); 269 passphrase_textfield_ = new views::Textfield();
270 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD); 270 passphrase_textfield_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
271 passphrase_textfield_->set_controller(this); 271 passphrase_textfield_->set_controller(this);
(...skipping 29 matching lines...) Expand all
301 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD)); 301 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD));
302 passphrase_visible_button_->SetToggledImage( 302 passphrase_visible_button_->SetToggledImage(
303 views::ImageButton::STATE_HOVERED, 303 views::ImageButton::STATE_HOVERED,
304 ResourceBundle::GetSharedInstance(). 304 ResourceBundle::GetSharedInstance().
305 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER)); 305 GetImageSkiaNamed(IDR_NETWORK_HIDE_PASSWORD_HOVER));
306 passphrase_visible_button_->SetImageAlignment( 306 passphrase_visible_button_->SetImageAlignment(
307 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE); 307 views::ImageButton::ALIGN_CENTER, views::ImageButton::ALIGN_MIDDLE);
308 layout->AddView(passphrase_visible_button_); 308 layout->AddView(passphrase_visible_button_);
309 } 309 }
310 310
311 layout->AddPaddingRow( 311 layout->AddPaddingRow(0,
312 0, delegate->GetMetric( 312 delegate->GetDistanceMetric(
313 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 313 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
314 314
315 // Checkboxes. 315 // Checkboxes.
316 316
317 if (LoginState::Get()->IsUserAuthenticated()) { 317 if (LoginState::Get()->IsUserAuthenticated()) {
318 // Save credentials 318 // Save credentials
319 layout->StartRow(0, column_view_set_id); 319 layout->StartRow(0, column_view_set_id);
320 save_credentials_checkbox_ = new views::Checkbox( 320 save_credentials_checkbox_ = new views::Checkbox(
321 l10n_util::GetStringUTF16( 321 l10n_util::GetStringUTF16(
322 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS)); 322 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SAVE_CREDENTIALS));
323 save_credentials_checkbox_->SetEnabled( 323 save_credentials_checkbox_->SetEnabled(
(...skipping 16 matching lines...) Expand all
340 ChildNetworkConfigView::GetShareStateForLoginState( 340 ChildNetworkConfigView::GetShareStateForLoginState(
341 &share_network_checkbox_value, 341 &share_network_checkbox_value,
342 &share_network_checkbox_enabled); 342 &share_network_checkbox_enabled);
343 343
344 share_network_checkbox_->SetChecked(share_network_checkbox_value); 344 share_network_checkbox_->SetChecked(share_network_checkbox_value);
345 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled); 345 share_network_checkbox_->SetEnabled(share_network_checkbox_enabled);
346 346
347 layout->SkipColumns(1); 347 layout->SkipColumns(1);
348 layout->AddView(share_network_checkbox_); 348 layout->AddView(share_network_checkbox_);
349 } 349 }
350 layout->AddPaddingRow( 350 layout->AddPaddingRow(0,
351 0, delegate->GetMetric( 351 delegate->GetDistanceMetric(
352 LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING)); 352 views::DistanceMetric::RELATED_CONTROL_VERTICAL));
353 353
354 // Create an error label. 354 // Create an error label.
355 layout->StartRow(0, column_view_set_id); 355 layout->StartRow(0, column_view_set_id);
356 layout->SkipColumns(1); 356 layout->SkipColumns(1);
357 error_label_ = new views::Label(); 357 error_label_ = new views::Label();
358 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 358 error_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
359 error_label_->SetEnabledColor(SK_ColorRED); 359 error_label_->SetEnabledColor(SK_ColorRED);
360 layout->AddView(error_label_); 360 layout->AddView(error_label_);
361 361
362 UpdateErrorLabel(); 362 UpdateErrorLabel();
(...skipping 24 matching lines...) Expand all
387 } 387 }
388 } 388 }
389 389
390 void WimaxConfigView::InitFocus() { 390 void WimaxConfigView::InitFocus() {
391 views::View* view_to_focus = GetInitiallyFocusedView(); 391 views::View* view_to_focus = GetInitiallyFocusedView();
392 if (view_to_focus) 392 if (view_to_focus)
393 view_to_focus->RequestFocus(); 393 view_to_focus->RequestFocus();
394 } 394 }
395 395
396 } // namespace chromeos 396 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698