Chromium Code Reviews| Index: ash/system/network/tray_network.cc |
| diff --git a/ash/system/network/tray_network.cc b/ash/system/network/tray_network.cc |
| index 86ee617ffed63baa9f0a86d824c17afafe9710db..142e43225d6346e90450ca29300004512aa93f63 100644 |
| --- a/ash/system/network/tray_network.cc |
| +++ b/ash/system/network/tray_network.cc |
| @@ -705,12 +705,44 @@ class NetworkNotificationView : public TrayNotificationView { |
| DISALLOW_COPY_AND_ASSIGN(NetworkNotificationView); |
| }; |
| +class NetworkWifiDetailedView : public TrayDetailsView { |
| + public: |
| + explicit NetworkWifiDetailedView(bool wifi_enabled) { |
| + SetLayoutManager(new views::BoxLayout(views::BoxLayout::kHorizontal, |
| + kTrayPopupPaddingHorizontal, |
| + 10, |
| + kTrayPopupPaddingBetweenItems)); |
| + |
| + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| + views::ImageView* image = new views::ImageView; |
| + const int image_id = wifi_enabled ? |
| + IDR_AURA_UBER_TRAY_WIFI_ENABLED : IDR_AURA_UBER_TRAY_WIFI_DISABLED; |
| + image->SetImage(bundle.GetImageNamed(image_id).ToImageSkia()); |
| + AddChildView(image); |
| + |
| + const int string_id = wifi_enabled ? |
| + IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED: |
| + IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED; |
| + views::Label* label = |
| + new views::Label(bundle.GetLocalizedString(string_id)); |
| + label->SetMultiLine(true); |
| + label->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |
| + AddChildView(label); |
| + } |
| + |
| + virtual ~NetworkWifiDetailedView() {} |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(NetworkWifiDetailedView); |
| +}; |
| + |
| } // namespace tray |
| TrayNetwork::TrayNetwork() |
| : tray_(NULL), |
| default_(NULL), |
| detailed_(NULL), |
| + wifi_view_(NULL), |
| notification_(NULL), |
| errors_(new tray::NetworkErrors()) { |
| } |
| @@ -731,6 +763,12 @@ views::View* TrayNetwork::CreateDefaultView(user::LoginStatus status) { |
| } |
| views::View* TrayNetwork::CreateDetailedView(user::LoginStatus status) { |
| + if (wifi_view_) { |
| + views::View* returned_view = wifi_view_; |
| + wifi_view_ = NULL; |
| + return returned_view; |
|
stevenjb
2012/08/02 17:47:16
This logic is pretty confusing. I think we would b
mazda
2012/08/02 19:49:16
Done.
|
| + } |
| + |
| CHECK(detailed_ == NULL); |
| detailed_ = new tray::NetworkDetailedView(status); |
| return detailed_; |
| @@ -802,6 +840,13 @@ void TrayNetwork::ClearNetworkError(ErrorType error_type) { |
| ShowNotificationView(); |
| } |
| +void TrayNetwork::OnWifiToggled(bool wifi_enabled) { |
| + if (!detailed_) { |
| + wifi_view_ = new tray::NetworkWifiDetailedView(wifi_enabled); |
| + PopupDetailedView(kTrayPopupAutoCloseDelayForTextInSeconds, false); |
| + } |
| +} |
| + |
| void TrayNetwork::LinkClicked(ErrorType error_type) { |
| tray::NetworkErrors::ErrorMap::const_iterator iter = |
| errors()->messages().find(error_type); |