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

Unified Diff: chrome/browser/chromeos/options/wifi_config_view.cc

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Fix various unit-tests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/options/wifi_config_view.cc
diff --git a/chrome/browser/chromeos/options/wifi_config_view.cc b/chrome/browser/chromeos/options/wifi_config_view.cc
index 412127826b32b07ebe599e6ee639fba25e4d372b..6fc0caf3f7eb6fe35fb1eb4009f9ad9b6a7caf8c 100644
--- a/chrome/browser/chromeos/options/wifi_config_view.cc
+++ b/chrome/browser/chromeos/options/wifi_config_view.cc
@@ -14,7 +14,7 @@
#include "chrome/browser/chromeos/net/shill_error.h"
#include "chrome/browser/chromeos/options/passphrase_textfield.h"
#include "chrome/browser/profiles/profile_manager.h"
-#include "chrome/browser/ui/views/harmony/layout_delegate.h"
+#include "chrome/browser/ui/views/harmony/chrome_views_layout_delegate.h"
#include "chrome/browser/ui/views/layout_utils.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
@@ -32,7 +32,6 @@
#include "components/onc/onc_constants.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
#include "ui/base/l10n/l10n_util.h"
-#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/events/event.h"
#include "ui/views/controls/button/checkbox.h"
@@ -937,13 +936,13 @@ void WifiConfigView::Init(bool show_8021x) {
}
views::GridLayout* layout = layout_utils::CreatePanelLayout(this);
- LayoutDelegate* delegate = LayoutDelegate::Get();
+ ChromeViewsLayoutDelegate* delegate = ChromeViewsLayoutDelegate::Get();
const int column_view_set_id = 0;
views::ColumnSet* column_set = layout->AddColumnSet(column_view_set_id);
const int kPasswordVisibleWidth = 20;
// Label
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
// This constant ensures the minimum width of the label column and ensures
// the width of the Wifi dialog equals 512.
const int kLabelMinWidth = 158;
@@ -954,15 +953,15 @@ void WifiConfigView::Init(bool show_8021x) {
1, views::GridLayout::USE_PREF, 0, 0);
}
column_set->AddPaddingColumn(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING));
+ 0, delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
// Textfield, combobox.
column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
views::GridLayout::USE_PREF, 0,
ChildNetworkConfigView::kInputFieldMinWidth);
column_set->AddPaddingColumn(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING));
+ 0, delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_HORIZONTAL));
// Password visible button / policy indicator.
column_set->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 0,
views::GridLayout::FIXED, kPasswordVisibleWidth, 0);
@@ -977,7 +976,7 @@ void WifiConfigView::Init(bool show_8021x) {
ssid_textfield_->set_controller(this);
ssid_textfield_->SetAccessibleName(l10n_util::GetStringUTF16(
IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID));
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(ssid_textfield_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -990,9 +989,9 @@ void WifiConfigView::Init(bool show_8021x) {
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->AddView(label);
}
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
}
// Security select
@@ -1005,7 +1004,7 @@ void WifiConfigView::Init(bool show_8021x) {
security_combobox_ = new views::Combobox(security_combobox_model_.get());
security_combobox_->SetAccessibleName(label_text);
security_combobox_->set_listener(this);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(security_combobox_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1013,9 +1012,9 @@ void WifiConfigView::Init(bool show_8021x) {
layout->AddView(security_combobox_);
}
layout->AddView(security_combobox_);
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
}
// Only enumerate certificates in the data model for 802.1X networks.
@@ -1034,7 +1033,7 @@ void WifiConfigView::Init(bool show_8021x) {
eap_method_combobox_->SetAccessibleName(eap_label_text);
eap_method_combobox_->set_listener(this);
eap_method_combobox_->SetEnabled(eap_method_ui_data_.IsEditable());
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(eap_method_combobox_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1042,9 +1041,9 @@ void WifiConfigView::Init(bool show_8021x) {
layout->AddView(eap_method_combobox_);
}
layout->AddView(new ControlledSettingIndicatorView(eap_method_ui_data_));
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
// Phase 2 authentication
layout->StartRow(0, column_view_set_id);
@@ -1060,7 +1059,7 @@ void WifiConfigView::Init(bool show_8021x) {
phase_2_auth_label_->SetEnabled(false);
phase_2_auth_combobox_->SetEnabled(false);
phase_2_auth_combobox_->set_listener(this);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(phase_2_auth_combobox_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1068,9 +1067,9 @@ void WifiConfigView::Init(bool show_8021x) {
layout->AddView(phase_2_auth_combobox_);
}
layout->AddView(new ControlledSettingIndicatorView(phase_2_auth_ui_data_));
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
// Server CA certificate
layout->StartRow(0, column_view_set_id);
@@ -1087,7 +1086,7 @@ void WifiConfigView::Init(bool show_8021x) {
server_ca_cert_label_->SetEnabled(false);
server_ca_cert_combobox_->SetEnabled(false);
server_ca_cert_combobox_->set_listener(this);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(server_ca_cert_combobox_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1096,9 +1095,9 @@ void WifiConfigView::Init(bool show_8021x) {
}
layout->AddView(
new ControlledSettingIndicatorView(server_ca_cert_ui_data_));
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
// Subject Match
layout->StartRow(0, column_view_set_id);
@@ -1109,16 +1108,16 @@ void WifiConfigView::Init(bool show_8021x) {
subject_match_textfield_ = new views::Textfield();
subject_match_textfield_->SetAccessibleName(subject_match_label_text);
subject_match_textfield_->set_controller(this);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(subject_match_textfield_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
} else {
layout->AddView(subject_match_textfield_);
}
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
// User certificate
layout->StartRow(0, column_view_set_id);
@@ -1132,7 +1131,7 @@ void WifiConfigView::Init(bool show_8021x) {
user_cert_label_->SetEnabled(false);
user_cert_combobox_->SetEnabled(false);
user_cert_combobox_->set_listener(this);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(user_cert_combobox_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1140,9 +1139,9 @@ void WifiConfigView::Init(bool show_8021x) {
layout->AddView(user_cert_combobox_);
}
layout->AddView(new ControlledSettingIndicatorView(user_cert_ui_data_));
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
// Identity
layout->StartRow(0, column_view_set_id);
@@ -1154,7 +1153,7 @@ void WifiConfigView::Init(bool show_8021x) {
identity_textfield_->SetAccessibleName(identity_label_text);
identity_textfield_->set_controller(this);
identity_textfield_->SetEnabled(identity_ui_data_.IsEditable());
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(identity_textfield_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1162,9 +1161,9 @@ void WifiConfigView::Init(bool show_8021x) {
layout->AddView(identity_textfield_);
}
layout->AddView(new ControlledSettingIndicatorView(identity_ui_data_));
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
}
// Passphrase input
@@ -1181,7 +1180,7 @@ void WifiConfigView::Init(bool show_8021x) {
passphrase_textfield_->SetEnabled(network &&
passphrase_ui_data_.IsEditable());
passphrase_textfield_->SetAccessibleName(passphrase_label_text);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(passphrase_textfield_, 1, 1, views::GridLayout::FILL,
views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1223,9 +1222,8 @@ void WifiConfigView::Init(bool show_8021x) {
layout->AddView(passphrase_visible_button_);
}
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0, delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
if (show_8021x) {
// Anonymous identity
@@ -1238,7 +1236,7 @@ void WifiConfigView::Init(bool show_8021x) {
identity_anonymous_label_->SetEnabled(false);
identity_anonymous_textfield_->SetEnabled(false);
identity_anonymous_textfield_->set_controller(this);
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
layout->AddView(identity_anonymous_textfield_, 1, 1,
views::GridLayout::FILL, views::GridLayout::FILL, 0,
ChildNetworkConfigView::kInputFieldHeight);
@@ -1247,16 +1245,16 @@ void WifiConfigView::Init(bool show_8021x) {
}
layout->AddView(
new ControlledSettingIndicatorView(identity_anonymous_ui_data_));
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
}
- if (ui::MaterialDesignController::IsSecondaryUiMaterial()) {
+ if (delegate->IsHarmonyMode()) {
// We need a little bit more padding above Checkboxes.
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0,
+ delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
}
// Checkboxes.
@@ -1284,9 +1282,8 @@ void WifiConfigView::Init(bool show_8021x) {
layout->SkipColumns(1);
layout->AddView(share_network_checkbox_);
}
- layout->AddPaddingRow(
- 0, delegate->GetMetric(
- LayoutDelegate::Metric::RELATED_CONTROL_VERTICAL_SPACING));
+ layout->AddPaddingRow(0, delegate->GetDistanceMetric(
+ ChromeDistanceMetric::RELATED_CONTROL_VERTICAL));
// Create an error label.
layout->StartRow(0, column_view_set_id);

Powered by Google App Engine
This is Rietveld 408576698