| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "chrome/browser/chromeos/status/network_menu_button.h" | 5 #include "chrome/browser/chromeos/status/network_menu_button.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 #include <limits> | 8 #include <limits> | 
| 9 | 9 | 
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" | 
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 78   ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 78   ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 
| 79   if (CrosLibrary::Get()->EnsureLoaded()) { | 79   if (CrosLibrary::Get()->EnsureLoaded()) { | 
| 80     if (cros->wifi_connecting() || cros->cellular_connecting()) { | 80     if (cros->wifi_connecting() || cros->cellular_connecting()) { | 
| 81       // Start the connecting animation if not running. | 81       // Start the connecting animation if not running. | 
| 82       if (!animation_connecting_.is_animating()) { | 82       if (!animation_connecting_.is_animating()) { | 
| 83         animation_connecting_.Reset(); | 83         animation_connecting_.Reset(); | 
| 84         animation_connecting_.StartThrobbing(std::numeric_limits<int>::max()); | 84         animation_connecting_.StartThrobbing(std::numeric_limits<int>::max()); | 
| 85         SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 85         SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 
| 86       } | 86       } | 
| 87       std::string network_name = cros->wifi_connecting() ? | 87       std::string network_name = cros->wifi_connecting() ? | 
| 88           cros->wifi_network().name() : cros->cellular_network().name(); | 88           cros->wifi_network()->name() : cros->cellular_network()->name(); | 
| 89       bool configuring = cros->wifi_connecting() ? | 89       bool configuring = cros->wifi_connecting() ? | 
| 90           cros->wifi_network().configuring() : | 90           cros->wifi_network()->configuring() : | 
| 91           cros->cellular_network().configuring(); | 91           cros->cellular_network()->configuring(); | 
| 92       SetTooltipText( | 92       SetTooltipText( | 
| 93           l10n_util::GetStringF(configuring ? | 93           l10n_util::GetStringF(configuring ? | 
| 94               IDS_STATUSBAR_NETWORK_CONFIGURING_TOOLTIP : | 94               IDS_STATUSBAR_NETWORK_CONFIGURING_TOOLTIP : | 
| 95               IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP, | 95               IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP, | 
| 96               UTF8ToWide(network_name))); | 96               UTF8ToWide(network_name))); | 
| 97     } else { | 97     } else { | 
| 98       // Stop connecting animation since we are not connecting. | 98       // Stop connecting animation since we are not connecting. | 
| 99       animation_connecting_.Stop(); | 99       animation_connecting_.Stop(); | 
| 100 | 100 | 
| 101       // Always show the higher priority connection first. Ethernet then wifi. | 101       // Always show the higher priority connection first. Ethernet then wifi. | 
| 102       if (cros->ethernet_connected()) { | 102       if (cros->ethernet_connected()) { | 
| 103         SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); | 103         SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); | 
| 104         SetTooltipText( | 104         SetTooltipText( | 
| 105             l10n_util::GetStringF( | 105             l10n_util::GetStringF( | 
| 106                 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 106                 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 
| 107                 l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); | 107                 l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); | 
| 108       } else if (cros->wifi_connected()) { | 108       } else if (cros->wifi_connected()) { | 
| 109         SetIcon(IconForNetworkStrength( | 109         SetIcon(IconForNetworkStrength( | 
| 110             cros->wifi_network().strength(), false)); | 110             cros->wifi_network()->strength(), false)); | 
| 111         SetTooltipText(l10n_util::GetStringF( | 111         SetTooltipText(l10n_util::GetStringF( | 
| 112             IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 112             IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 
| 113             UTF8ToWide(cros->wifi_network().name()))); | 113             UTF8ToWide(cros->wifi_network()->name()))); | 
| 114       } else if (cros->cellular_connected()) { | 114       } else if (cros->cellular_connected()) { | 
| 115         const CellularNetwork& cellular = cros->cellular_network(); | 115         const CellularNetwork* cellular = cros->cellular_network(); | 
| 116         if (cellular.data_left() == CellularNetwork::DATA_NONE) { | 116         if (cellular->data_left() == CellularNetwork::DATA_NONE) { | 
| 117           // If no data, then we show 0 bars. | 117           // If no data, then we show 0 bars. | 
| 118           SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 118           SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 
| 119         } else { | 119         } else { | 
| 120           SetIcon(IconForNetworkStrength(cellular)); | 120           SetIcon(IconForNetworkStrength(cellular)); | 
| 121         } | 121         } | 
| 122         SetTooltipText(l10n_util::GetStringF( | 122         SetTooltipText(l10n_util::GetStringF( | 
| 123             IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 123             IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 
| 124             UTF8ToWide(cellular.name()))); | 124             UTF8ToWide(cellular->name()))); | 
| 125       } else { | 125       } else { | 
| 126         SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 126         SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 
| 127         SetTooltipText(l10n_util::GetString( | 127         SetTooltipText(l10n_util::GetString( | 
| 128             IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); | 128             IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); | 
| 129       } | 129       } | 
| 130     } | 130     } | 
| 131 | 131 | 
| 132     // Figure out whether or not to show a badge. | 132     // Figure out whether or not to show a badge. | 
| 133     int id = -1; | 133     int id = -1; | 
| 134     if (cros->Connecting()) { | 134     if (cros->Connecting()) { | 
| 135       if (cros->cellular_connecting()) { | 135       if (cros->cellular_connecting()) { | 
| 136         id = IDR_STATUSBAR_NETWORK_3G; | 136         id = IDR_STATUSBAR_NETWORK_3G; | 
| 137       } | 137       } | 
| 138     } else if (cros->Connected()) { | 138     } else if (cros->Connected()) { | 
| 139       if (!cros->ethernet_connected() && !cros->wifi_connected() && | 139       if (!cros->ethernet_connected() && !cros->wifi_connected() && | 
| 140           cros->cellular_connected()) { | 140           cros->cellular_connected()) { | 
| 141         switch (cros->cellular_network().data_left()) { | 141         switch (cros->cellular_network()->data_left()) { | 
| 142           case CellularNetwork::DATA_NONE: | 142           case CellularNetwork::DATA_NONE: | 
| 143           case CellularNetwork::DATA_VERY_LOW: | 143           case CellularNetwork::DATA_VERY_LOW: | 
| 144             id = IDR_STATUSBAR_NETWORK_3G_ERROR; | 144             id = IDR_STATUSBAR_NETWORK_3G_ERROR; | 
| 145             break; | 145             break; | 
| 146           case CellularNetwork::DATA_LOW: | 146           case CellularNetwork::DATA_LOW: | 
| 147             id = IDR_STATUSBAR_NETWORK_3G_WARN; | 147             id = IDR_STATUSBAR_NETWORK_3G_WARN; | 
| 148             break; | 148             break; | 
| 149           case CellularNetwork::DATA_NORMAL: | 149           case CellularNetwork::DATA_NORMAL: | 
| 150             id = IDR_STATUSBAR_NETWORK_3G; | 150             id = IDR_STATUSBAR_NETWORK_3G; | 
| 151             break; | 151             break; | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 188 | 188 | 
| 189 void NetworkMenuButton::OpenButtonOptions() const { | 189 void NetworkMenuButton::OpenButtonOptions() const { | 
| 190   host_->OpenButtonOptions(this); | 190   host_->OpenButtonOptions(this); | 
| 191 } | 191 } | 
| 192 | 192 | 
| 193 bool NetworkMenuButton::ShouldOpenButtonOptions() const { | 193 bool NetworkMenuButton::ShouldOpenButtonOptions() const { | 
| 194   return host_->ShouldOpenButtonOptions(this); | 194   return host_->ShouldOpenButtonOptions(this); | 
| 195 } | 195 } | 
| 196 | 196 | 
| 197 }  // namespace chromeos | 197 }  // namespace chromeos | 
| OLD | NEW | 
|---|