Chromium Code Reviews| Index: ash/system/network/network_list.cc |
| diff --git a/ash/system/network/network_list.cc b/ash/system/network/network_list.cc |
| index cdb1001dda89086349b7613b55b97bd3e73491f1..c0ac1776da4eedf43ed6eb391393a9ca75be05e5 100644 |
| --- a/ash/system/network/network_list.cc |
| +++ b/ash/system/network/network_list.cc |
| @@ -6,14 +6,18 @@ |
| #include <stddef.h> |
| +#include "ash/shell.h" |
| #include "ash/strings/grit/ash_strings.h" |
| #include "ash/system/network/network_icon.h" |
| #include "ash/system/network/network_icon_animation.h" |
| #include "ash/system/network/network_list_delegate.h" |
| +#include "ash/system/networking_config_delegate.h" |
| #include "ash/system/tray/system_menu_button.h" |
| +#include "ash/system/tray/system_tray_delegate.h" |
| #include "ash/system/tray/tray_constants.h" |
| #include "ash/system/tray/tray_popup_item_style.h" |
| #include "ash/system/tray/tray_popup_utils.h" |
| +#include "ash/system/tray/tri_view.h" |
| #include "base/memory/ptr_util.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/power_manager/power_supply_properties.pb.h" |
| @@ -29,7 +33,9 @@ |
| #include "ui/gfx/color_palette.h" |
| #include "ui/gfx/font.h" |
| #include "ui/gfx/paint_vector_icon.h" |
| +#include "ui/views/background.h" |
| #include "ui/views/controls/button/toggle_button.h" |
| +#include "ui/views/controls/image_view.h" |
| #include "ui/views/controls/label.h" |
| #include "ui/views/controls/separator.h" |
| #include "ui/views/layout/box_layout.h" |
| @@ -289,7 +295,8 @@ NetworkListView::NetworkListView(NetworkListDelegate* delegate) |
| wifi_header_view_(nullptr), |
| cellular_separator_view_(nullptr), |
| tether_separator_view_(nullptr), |
| - wifi_separator_view_(nullptr) { |
| + wifi_separator_view_(nullptr), |
| + connection_warning_(nullptr) { |
| CHECK(delegate_); |
| } |
| @@ -480,12 +487,58 @@ std::unique_ptr<std::set<std::string>> |
| NetworkListView::UpdateNetworkListEntries() { |
| NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| + // Keep an index where the next child should be inserted. |
| + int index = 0; |
| + |
| + bool show_connection_warning = |
| + !!NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( |
| + NetworkTypePattern::VPN()); |
| + |
| + NetworkingConfigDelegate* networking_config_delegate = |
| + Shell::Get()->system_tray_delegate()->GetNetworkingConfigDelegate(); |
| + if (networking_config_delegate) { |
| + show_connection_warning = |
| + show_connection_warning || |
| + networking_config_delegate->HasDefaultNetworkProxyConfigured(); |
| + } |
| + |
| + if (show_connection_warning) { |
| + if (!connection_warning_) { |
|
stevenjb
2017/04/20 23:44:55
Move this code to a helper:
connection_warning_ =
sammiequon
2017/04/21 00:05:32
Done.
|
| + // Set up layout and apply sticky row property. |
| + connection_warning_ = TrayPopupUtils::CreateDefaultRowView(); |
| + TrayPopupUtils::ConfigureAsStickyHeader(connection_warning_); |
| + connection_warning_->set_background( |
| + views::Background::CreateSolidBackground(kHeaderBackgroundColor)); |
| + |
| + // Set 'info' icon on left side. |
| + views::ImageView* image_view = TrayPopupUtils::CreateMainImageView(); |
| + image_view->SetImage( |
| + gfx::CreateVectorIcon(kSystemMenuInfoIcon, kMenuIconColor)); |
| + image_view->set_background( |
| + views::Background::CreateSolidBackground(SK_ColorTRANSPARENT)); |
| + connection_warning_->AddView(TriView::Container::START, image_view); |
| + |
| + // Set message label in middle of row. |
| + views::Label* label = TrayPopupUtils::CreateDefaultLabel(); |
| + label->SetText(l10n_util::GetStringUTF16( |
| + IDS_ASH_STATUS_TRAY_NETWORK_MONITORED_WARNING)); |
| + label->set_background( |
| + views::Background::CreateSolidBackground(SK_ColorTRANSPARENT)); |
| + TrayPopupItemStyle style( |
| + TrayPopupItemStyle::FontStyle::DETAILED_VIEW_LABEL); |
| + style.SetupLabel(label); |
| + connection_warning_->AddView(TriView::Container::CENTER, label); |
| + |
| + // Nothing to the right of the text. |
| + connection_warning_->SetContainerVisible(TriView::Container::END, false); |
| + } |
| + PlaceViewAtIndex(connection_warning_, index++); |
| + } |
| + |
| // First add high-priority networks (not Wi-Fi nor cellular). |
| std::unique_ptr<std::set<std::string>> new_guids = |
| - UpdateNetworkChildren(NetworkInfo::Type::UNKNOWN, 0); |
| - |
| - // Keep an index where the next child should be inserted. |
| - int index = new_guids->size(); |
| + UpdateNetworkChildren(NetworkInfo::Type::UNKNOWN, index); |
| + index += new_guids->size(); |
| const NetworkTypePattern pattern = delegate_->GetNetworkTypePattern(); |
| if (pattern.MatchesPattern(NetworkTypePattern::Cellular())) { |