| 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 19e4f39fc605f487185b1b17c984a408125d9cf0..3ccf851a0ce16df3e3749c49b8c9df97697cc72a 100644
|
| --- a/ash/common/system/chromeos/network/network_list_md.cc
|
| +++ b/ash/common/system/chromeos/network/network_list_md.cc
|
| @@ -32,6 +32,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"
|
| @@ -47,11 +48,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;
|
| @@ -107,13 +103,6 @@ class NetworkListViewMd::SectionHeaderRowView : public views::View,
|
|
|
| views::View* container() const { return container_; }
|
|
|
| - // 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();
|
| @@ -132,8 +121,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_);
|
| @@ -284,7 +274,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_);
|
| }
|
|
|
| @@ -460,11 +452,10 @@ NetworkListViewMd::UpdateNetworkListEntries() {
|
| 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.
|
| @@ -487,11 +478,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;
|
| @@ -587,10 +577,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();
|
| @@ -599,9 +591,23 @@ void NetworkListViewMd::UpdateSectionHeaderRow(NetworkTypePattern pattern,
|
| else
|
| NOTREACHED();
|
| (*view)->Init(enabled);
|
| +
|
| + // Add or remove a separator above the header. The separator should only be
|
| + // there when the header row is not at the top of the list.
|
| + if (child_index > 0) {
|
| + if (!*separator_view)
|
| + *separator_view = TrayPopupUtils::CreateListHeaderSeparator();
|
| + } else {
|
| + if (*separator_view)
|
| + delete *separator_view;
|
| + *separator_view = nullptr;
|
| + }
|
| }
|
| (*view)->SetEnabled(enabled);
|
| - PlaceViewAtIndex(*view, child_index);
|
| + if (child_index > 0)
|
| + PlaceViewAtIndex(*separator_view, child_index++);
|
| + PlaceViewAtIndex(*view, child_index++);
|
| + return child_index;
|
| }
|
|
|
| void NetworkListViewMd::NetworkIconChanged() {
|
|
|