| Index: ash/common/system/chromeos/network/network_list_md.cc
|
| diff --git a/ash/common/system/chromeos/network/network_list_md.cc b/ash/common/system/chromeos/network/network_list_md.cc
|
| index 7cecb8b2cb5c087af6df0f065270769a7572368c..3f33ba7f64090c147deadf3e717b0e06438a4e40 100644
|
| --- a/ash/common/system/chromeos/network/network_list_md.cc
|
| +++ b/ash/common/system/chromeos/network/network_list_md.cc
|
| @@ -33,6 +33,7 @@
|
| #include "ui/views/border.h"
|
| #include "ui/views/controls/button/toggle_button.h"
|
| #include "ui/views/controls/label.h"
|
| +#include "ui/views/controls/separator.h"
|
| #include "ui/views/layout/box_layout.h"
|
| #include "ui/views/layout/fill_layout.h"
|
| #include "ui/views/painter.h"
|
| @@ -48,11 +49,6 @@ namespace ash {
|
|
|
| namespace {
|
|
|
| -// TODO(varkha): Merge some of those those constants in tray_constants.h
|
| -const int kSectionHeaderRowSize = 48;
|
| -const int kSectionHeaderRowVerticalInset = 4;
|
| -const int kSectionHeaderRowLeftInset = 18;
|
| -
|
| bool IsProhibitedByPolicy(const chromeos::NetworkState* network) {
|
| if (!NetworkTypePattern::WiFi().MatchesType(network->type()))
|
| return false;
|
| @@ -114,13 +110,6 @@ class NetworkListViewMd::SectionHeaderRowView : public views::View,
|
| views::View* container() const { return container_; }
|
| TrayPopupItemStyle* style() const { return style_.get(); }
|
|
|
| - // views::View:
|
| - gfx::Size GetPreferredSize() const override {
|
| - gfx::Size size = views::View::GetPreferredSize();
|
| - size.set_height(kSectionHeaderRowSize + kSectionHeaderRowVerticalInset * 2);
|
| - return size;
|
| - }
|
| -
|
| int GetHeightForWidth(int w) const override {
|
| // Make row height fixed avoiding layout manager adjustments.
|
| return GetPreferredSize().height();
|
| @@ -139,8 +128,9 @@ class NetworkListViewMd::SectionHeaderRowView : public views::View,
|
| // https://crbug.com/614453.
|
| TrayPopupUtils::ConfigureAsStickyHeader(this);
|
| container_ = new views::View;
|
| - container_->SetBorder(
|
| - views::CreateEmptyBorder(0, kSectionHeaderRowLeftInset, 0, 0));
|
| + container_->SetBorder(views::CreateEmptyBorder(
|
| + kMenuSeparatorVerticalPadding, kTrayPopupPaddingHorizontal,
|
| + kMenuSeparatorVerticalPadding, 0));
|
| views::FillLayout* layout = new views::FillLayout;
|
| SetLayoutManager(layout);
|
| AddChildView(container_);
|
| @@ -285,7 +275,9 @@ NetworkListViewMd::NetworkListViewMd(NetworkListDelegate* delegate)
|
| no_wifi_networks_view_(nullptr),
|
| no_cellular_networks_view_(nullptr),
|
| cellular_header_view_(nullptr),
|
| - wifi_header_view_(nullptr) {
|
| + wifi_header_view_(nullptr),
|
| + cellular_separator_view_(nullptr),
|
| + wifi_separator_view_(nullptr) {
|
| CHECK(delegate_);
|
| }
|
|
|
| @@ -455,17 +447,16 @@ NetworkListViewMd::UpdateNetworkListEntries() {
|
| std::unique_ptr<std::set<std::string>> new_service_paths =
|
| UpdateNetworkChildren(NetworkInfo::Type::UNKNOWN, 0);
|
|
|
| - // Keep an index of the last inserted child.
|
| + // Keep an index where the next child should be inserted.
|
| int index = new_service_paths->size();
|
|
|
| const NetworkTypePattern pattern = delegate_->GetNetworkTypePattern();
|
| if (pattern.MatchesPattern(NetworkTypePattern::Cellular())) {
|
| if (handler->IsTechnologyAvailable(NetworkTypePattern::Cellular())) {
|
| - UpdateSectionHeaderRow(
|
| + index = UpdateSectionHeaderRow(
|
| NetworkTypePattern::Cellular(),
|
| handler->IsTechnologyEnabled(NetworkTypePattern::Cellular()), index,
|
| - &cellular_header_view_);
|
| - ++index;
|
| + &cellular_header_view_, &cellular_separator_view_);
|
| }
|
|
|
| // Cellular initializing.
|
| @@ -488,11 +479,10 @@ NetworkListViewMd::UpdateNetworkListEntries() {
|
| }
|
|
|
| if (pattern.MatchesPattern(NetworkTypePattern::WiFi())) {
|
| - UpdateSectionHeaderRow(
|
| + index = UpdateSectionHeaderRow(
|
| NetworkTypePattern::WiFi(),
|
| handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()), index,
|
| - &wifi_header_view_);
|
| - ++index;
|
| + &wifi_header_view_, &wifi_separator_view_);
|
|
|
| // "Wifi Enabled / Disabled".
|
| int message_id = 0;
|
| @@ -588,10 +578,12 @@ void NetworkListViewMd::UpdateInfoLabel(int message_id,
|
| *label_ptr = label;
|
| }
|
|
|
| -void NetworkListViewMd::UpdateSectionHeaderRow(NetworkTypePattern pattern,
|
| - bool enabled,
|
| - int child_index,
|
| - SectionHeaderRowView** view) {
|
| +int NetworkListViewMd::UpdateSectionHeaderRow(
|
| + NetworkTypePattern pattern,
|
| + bool enabled,
|
| + int child_index,
|
| + SectionHeaderRowView** view,
|
| + views::Separator** separator_view) {
|
| if (!*view) {
|
| if (pattern.Equals(NetworkTypePattern::Cellular()))
|
| *view = new CellularHeaderRowView();
|
| @@ -601,8 +593,16 @@ void NetworkListViewMd::UpdateSectionHeaderRow(NetworkTypePattern pattern,
|
| NOTREACHED();
|
| (*view)->Init(enabled);
|
| }
|
| + // Show or hide a separator above the header. The separator should only be
|
| + // visible when the header row is not at the top of the list.
|
| + if (!*separator_view)
|
| + *separator_view = TrayPopupUtils::CreateListSubHeaderSeparator();
|
| + PlaceViewAtIndex(*separator_view, child_index++);
|
| + (*separator_view)->SetVisible(child_index > 0);
|
| +
|
| (*view)->SetEnabled(enabled);
|
| - PlaceViewAtIndex(*view, child_index);
|
| + PlaceViewAtIndex(*view, child_index++);
|
| + return child_index;
|
| }
|
|
|
| void NetworkListViewMd::NetworkIconChanged() {
|
|
|