| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 l10n_util::GetStringF( | 113 l10n_util::GetStringF( |
| 114 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 114 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, |
| 115 l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); | 115 l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); |
| 116 } else if (cros->wifi_connected()) { | 116 } else if (cros->wifi_connected()) { |
| 117 SetIcon(IconForNetworkStrength( | 117 SetIcon(IconForNetworkStrength( |
| 118 cros->wifi_network().strength(), false)); | 118 cros->wifi_network().strength(), false)); |
| 119 SetTooltipText(l10n_util::GetStringF( | 119 SetTooltipText(l10n_util::GetStringF( |
| 120 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 120 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, |
| 121 UTF8ToWide(cros->wifi_network().name()))); | 121 UTF8ToWide(cros->wifi_network().name()))); |
| 122 } else if (cros->cellular_connected()) { | 122 } else if (cros->cellular_connected()) { |
| 123 const CellularNetwork& cellular = cros->cellular_network(); | 123 SetIcon(IconForNetworkStrength( |
| 124 if (cellular.data_left() == CellularNetwork::DATA_NONE) { | 124 cros->cellular_network().strength(), false)); |
| 125 // If no data, then we show 0 bars. | |
| 126 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | |
| 127 } else { | |
| 128 SetIcon(IconForNetworkStrength(cellular)); | |
| 129 } | |
| 130 SetTooltipText(l10n_util::GetStringF( | 125 SetTooltipText(l10n_util::GetStringF( |
| 131 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, | 126 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, |
| 132 UTF8ToWide(cellular.name()))); | 127 UTF8ToWide(cros->cellular_network().name()))); |
| 133 } else { | 128 } else { |
| 134 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 129 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); |
| 135 SetTooltipText(l10n_util::GetString( | 130 SetTooltipText(l10n_util::GetString( |
| 136 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); | 131 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); |
| 137 } | 132 } |
| 138 } | 133 } |
| 139 | 134 |
| 140 if (!cros->Connected() && !cros->Connecting()) { | 135 if (!cros->Connected() && !cros->Connecting()) { |
| 141 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); | 136 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); |
| 142 } else if (!cros->ethernet_connected() && !cros->wifi_connected() && | 137 } else if (!cros->ethernet_connected() && !cros->wifi_connected() && |
| 143 (cros->cellular_connecting() || cros->cellular_connected())) { | 138 (cros->cellular_connecting() || cros->cellular_connected())) { |
| 144 int id; | 139 // TODO(chocobo): Check cellular network 3g/edge. |
| 145 switch (cros->cellular_network().data_left()) { | 140 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G)); |
| 146 case CellularNetwork::DATA_NONE: | 141 // SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE)); |
| 147 case CellularNetwork::DATA_VERY_LOW: | |
| 148 id = IDR_STATUSBAR_NETWORK_3G_VLOWDATA; | |
| 149 break; | |
| 150 case CellularNetwork::DATA_LOW: | |
| 151 id = IDR_STATUSBAR_NETWORK_3G_LOWDATA; | |
| 152 break; | |
| 153 case CellularNetwork::DATA_NORMAL: | |
| 154 id = IDR_STATUSBAR_NETWORK_3G; | |
| 155 break; | |
| 156 } | |
| 157 SetBadge(*rb.GetBitmapNamed(id)); | |
| 158 } else { | 142 } else { |
| 159 SetBadge(SkBitmap()); | 143 SetBadge(SkBitmap()); |
| 160 } | 144 } |
| 161 } else { | 145 } else { |
| 162 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 146 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); |
| 163 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_WARNING)); | 147 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_WARNING)); |
| 164 SetTooltipText(l10n_util::GetString( | 148 SetTooltipText(l10n_util::GetString( |
| 165 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); | 149 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); |
| 166 } | 150 } |
| 167 | 151 |
| 168 SchedulePaint(); | 152 SchedulePaint(); |
| 169 UpdateMenu(); | 153 UpdateMenu(); |
| 170 } | 154 } |
| 171 | 155 |
| 172 void NetworkMenuButton::CellularDataPlanChanged(NetworkLibrary* cros) { | |
| 173 // Call NetworkChanged which will update the icon. | |
| 174 NetworkChanged(cros); | |
| 175 } | |
| 176 | |
| 177 void NetworkMenuButton::SetBadge(const SkBitmap& badge) { | 156 void NetworkMenuButton::SetBadge(const SkBitmap& badge) { |
| 178 badge_ = badge; | 157 badge_ = badge; |
| 179 } | 158 } |
| 180 | 159 |
| 181 //////////////////////////////////////////////////////////////////////////////// | 160 //////////////////////////////////////////////////////////////////////////////// |
| 182 // NetworkMenuButton, NetworkMenu implementation: | 161 // NetworkMenuButton, NetworkMenu implementation: |
| 183 | 162 |
| 184 bool NetworkMenuButton::IsBrowserMode() const { | 163 bool NetworkMenuButton::IsBrowserMode() const { |
| 185 return host_->IsBrowserMode(); | 164 return host_->IsBrowserMode(); |
| 186 } | 165 } |
| 187 | 166 |
| 188 gfx::NativeWindow NetworkMenuButton::GetNativeWindow() const { | 167 gfx::NativeWindow NetworkMenuButton::GetNativeWindow() const { |
| 189 return host_->GetNativeWindow(); | 168 return host_->GetNativeWindow(); |
| 190 } | 169 } |
| 191 | 170 |
| 192 void NetworkMenuButton::OpenButtonOptions() const { | 171 void NetworkMenuButton::OpenButtonOptions() const { |
| 193 host_->OpenButtonOptions(this); | 172 host_->OpenButtonOptions(this); |
| 194 } | 173 } |
| 195 | 174 |
| 196 bool NetworkMenuButton::ShouldOpenButtonOptions() const { | 175 bool NetworkMenuButton::ShouldOpenButtonOptions() const { |
| 197 return host_->ShouldOpenButtonOptions(this); | 176 return host_->ShouldOpenButtonOptions(this); |
| 198 } | 177 } |
| 199 | 178 |
| 200 } // namespace chromeos | 179 } // namespace chromeos |
| OLD | NEW |