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 c5a5bfbb4cdda6c4bfd8d277d733274f08e20412..c64d573e8f31ace2287a8b9587f7413df207630f 100644 |
--- a/ash/common/system/chromeos/network/network_list_md.cc |
+++ b/ash/common/system/chromeos/network/network_list_md.cc |
@@ -10,7 +10,10 @@ |
#include "ash/common/system/chromeos/network/network_icon_animation.h" |
#include "ash/common/system/chromeos/network/network_info.h" |
#include "ash/common/system/chromeos/network/network_list_delegate.h" |
+#include "ash/common/system/tray/header_list_scroll_view.h" |
+#include "ash/common/system/tray/tray_constants.h" |
#include "base/memory/ptr_util.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
#include "chromeos/dbus/power_manager_client.h" |
@@ -27,6 +30,7 @@ |
#include "ui/gfx/font.h" |
#include "ui/gfx/paint_vector_icon.h" |
#include "ui/gfx/vector_icons_public.h" |
+#include "ui/views/background.h" |
#include "ui/views/border.h" |
#include "ui/views/controls/button/image_button.h" |
#include "ui/views/controls/button/toggle_button.h" |
@@ -46,16 +50,14 @@ namespace ash { |
namespace { |
+const int kWiFiGroupId = 1; |
const int kWiFiButtonSize = 48; |
const int kWifiRowVerticalInset = 4; |
const int kWifiRowLeftInset = 18; |
const int kWifiRowRightInset = 14; |
-const int kWifiRowSeparatorThickness = 1; |
const int kWifiRowChildSpacing = 14; |
const int kFocusBorderInset = 1; |
-const SkColor kWifiRowSeparatorColor = SkColorSetA(SK_ColorBLACK, 0x1F); |
- |
bool IsProhibitedByPolicy(const chromeos::NetworkState* network) { |
if (!NetworkTypePattern::WiFi().MatchesType(network->type())) |
return false; |
@@ -116,11 +118,12 @@ class NetworkListViewMd::WifiHeaderRowView : public views::View { |
return GetPreferredSize().height(); |
} |
+ const char* GetClassName() const override { return "WifiHeaderRowView"; } |
+ |
private: |
void Init() { |
+ set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
// TODO(tdanderson): Need to unify this with the generic menu row class. |
- SetBorder(views::Border::CreateSolidSidedBorder( |
- kWifiRowSeparatorThickness, 0, 0, 0, kWifiRowSeparatorColor)); |
views::View* container = new views::View; |
container->SetBorder(views::Border::CreateEmptyBorder( |
0, kWifiRowLeftInset, 0, kWifiRowRightInset)); |
@@ -377,6 +380,7 @@ NetworkListViewMd::UpdateNetworkListEntries() { |
handler->IsTechnologyEnabled(NetworkTypePattern::WiFi()), index, |
&wifi_header_view_); |
++index; |
+ wifi_header_view_->SetGroup(kWiFiGroupId); |
// "Wifi Enabled / Disabled". |
int message_id = 0; |
@@ -388,6 +392,8 @@ NetworkListViewMd::UpdateNetworkListEntries() { |
UpdateInfoLabel(message_id, index, &no_wifi_networks_view_); |
if (message_id) |
++index; |
+ if (no_wifi_networks_view_) |
+ no_wifi_networks_view_->SetGroup(kWiFiGroupId); |
// Add Wi-Fi networks. |
std::unique_ptr<std::set<std::string>> new_wifi_service_paths = |
@@ -409,6 +415,7 @@ NetworkListViewMd::UpdateNetworkListEntries() { |
std::unique_ptr<std::set<std::string>> NetworkListViewMd::UpdateNetworkChildren( |
bool is_wifi, |
int index) { |
+ int group_id = is_wifi ? kWiFiGroupId : -1; |
std::unique_ptr<std::set<std::string>> new_service_paths( |
new std::set<std::string>); |
for (const auto& info : network_list_) { |
@@ -416,6 +423,17 @@ std::unique_ptr<std::set<std::string>> NetworkListViewMd::UpdateNetworkChildren( |
continue; |
UpdateNetworkChild(index++, info.get()); |
new_service_paths->insert(info->service_path); |
+ |
+ // TODO(varkha) Demo code - remove before committing! |
+ views::View* network_view = service_path_map_[info->service_path]; |
+ if (info->label == base::UTF8ToUTF16("wifi12") || |
+ info->label == base::UTF8ToUTF16("wifi15") || |
+ info->label == base::UTF8ToUTF16("wifi20")) { |
+ network_view->set_background( |
+ views::Background::CreateSolidBackground(kBackgroundColor)); |
+ ++group_id; |
+ } |
+ network_view->SetGroup(group_id); |
} |
return new_service_paths; |
} |
@@ -433,16 +451,23 @@ void NetworkListViewMd::UpdateNetworkChild(int index, const NetworkInfo* info) { |
network_view->Layout(); |
network_view->SchedulePaint(); |
} |
- PlaceViewAtIndex(network_view, index); |
+ bool is_header = (info->label == base::UTF8ToUTF16("wifi12") || |
+ info->label == base::UTF8ToUTF16("wifi15") || |
+ info->label == base::UTF8ToUTF16("wifi20")); |
+ PlaceViewAtIndex(network_view, index, is_header); |
if (info->disable) |
network_view->SetEnabled(false); |
network_map_[network_view] = info->service_path; |
service_path_map_[info->service_path] = network_view; |
} |
-void NetworkListViewMd::PlaceViewAtIndex(views::View* view, int index) { |
+void NetworkListViewMd::PlaceViewAtIndex(views::View* view, |
+ int index, |
+ bool is_header) { |
if (view->parent() != container()) { |
container()->AddChildViewAt(view, index); |
+ if (is_header) |
+ container()->SetHeaderView(view); |
} else { |
if (container()->child_at(index) == view) |
return; |
@@ -468,7 +493,7 @@ void NetworkListViewMd::UpdateInfoLabel(int message_id, |
if (!label) |
label = delegate_->CreateInfoLabel(); |
label->SetText(text); |
- PlaceViewAtIndex(label, insertion_index); |
+ PlaceViewAtIndex(label, insertion_index, false /* is_header */); |
*label_ptr = label; |
} |
@@ -478,7 +503,7 @@ void NetworkListViewMd::UpdateWifiHeaderRow(bool enabled, |
if (!*view) |
*view = new WifiHeaderRowView(this, enabled); |
(*view)->SetWifiEnabled(enabled); |
- PlaceViewAtIndex(*view, child_index); |
+ PlaceViewAtIndex(*view, child_index, true /* is_header */); |
} |
void NetworkListViewMd::NetworkIconChanged() { |