| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 void NetworkMenuButton::NetworkChanged(NetworkLibrary* cros) { | 229 void NetworkMenuButton::NetworkChanged(NetworkLibrary* cros) { |
| 230 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 230 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 231 if (CrosLibrary::Get()->EnsureLoaded()) { | 231 if (CrosLibrary::Get()->EnsureLoaded()) { |
| 232 if (cros->wifi_connecting() || cros->cellular_connecting()) { | 232 if (cros->wifi_connecting() || cros->cellular_connecting()) { |
| 233 // Start the connecting animation if not running. | 233 // Start the connecting animation if not running. |
| 234 if (!animation_connecting_.is_animating()) { | 234 if (!animation_connecting_.is_animating()) { |
| 235 animation_connecting_.Reset(); | 235 animation_connecting_.Reset(); |
| 236 animation_connecting_.StartThrobbing(std::numeric_limits<int>::max()); | 236 animation_connecting_.StartThrobbing(std::numeric_limits<int>::max()); |
| 237 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS1)); | 237 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS1)); |
| 238 } | 238 } |
| 239 std::string network_name = cros->wifi_connecting() ? |
| 240 cros->wifi_name() : cros->cellular_name(); |
| 241 SetTooltipText( |
| 242 l10n_util::GetStringF(IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP, |
| 243 UTF8ToWide(network_name))); |
| 239 } else { | 244 } else { |
| 240 // Stop connecting animation since we are not connecting. | 245 // Stop connecting animation since we are not connecting. |
| 241 animation_connecting_.Stop(); | 246 animation_connecting_.Stop(); |
| 242 | 247 |
| 243 // Always show the higher priority connection first. Ethernet then wifi. | 248 // Always show the higher priority connection first. Ethernet then wifi. |
| 244 if (cros->ethernet_connected()) | 249 if (cros->ethernet_connected()) { |
| 245 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); | 250 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); |
| 246 else if (cros->wifi_connected()) | 251 SetTooltipText( |
| 252 l10n_util::GetStringF( |
| 253 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, |
| 254 l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); |
| 255 } else if (cros->wifi_connected()) { |
| 247 SetIcon(IconForNetworkStrength(cros->wifi_strength(), false)); | 256 SetIcon(IconForNetworkStrength(cros->wifi_strength(), false)); |
| 248 else if (cros->cellular_connected()) | 257 SetTooltipText(l10n_util::GetStringF( |
| 258 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, |
| 259 UTF8ToWide(cros->wifi_name()))); |
| 260 } else if (cros->cellular_connected()) { |
| 249 SetIcon(IconForNetworkStrength(cros->cellular_strength(), false)); | 261 SetIcon(IconForNetworkStrength(cros->cellular_strength(), false)); |
| 250 else | 262 SetTooltipText(l10n_util::GetStringF( |
| 263 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP, |
| 264 UTF8ToWide(cros->cellular_name()))); |
| 265 } else { |
| 251 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 266 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); |
| 267 SetTooltipText(l10n_util::GetString( |
| 268 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); |
| 269 } |
| 252 } | 270 } |
| 253 | 271 |
| 254 if (!cros->Connected() && !cros->Connecting()) { | 272 if (!cros->Connected() && !cros->Connecting()) { |
| 255 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); | 273 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); |
| 256 } else if (!cros->ethernet_connected() && !cros->wifi_connected() && | 274 } else if (!cros->ethernet_connected() && !cros->wifi_connected() && |
| 257 (cros->cellular_connecting() || cros->cellular_connected())) { | 275 (cros->cellular_connecting() || cros->cellular_connected())) { |
| 258 // TODO(chocobo): Check cellular network 3g/edge. | 276 // TODO(chocobo): Check cellular network 3g/edge. |
| 259 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G)); | 277 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G)); |
| 260 // SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE)); | 278 // SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_EDGE)); |
| 261 } else { | 279 } else { |
| 262 SetBadge(SkBitmap()); | 280 SetBadge(SkBitmap()); |
| 263 } | 281 } |
| 264 } else { | 282 } else { |
| 265 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); | 283 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0)); |
| 266 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_WARNING)); | 284 SetBadge(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_WARNING)); |
| 285 SetTooltipText(l10n_util::GetString( |
| 286 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP)); |
| 267 } | 287 } |
| 268 | 288 |
| 269 SchedulePaint(); | 289 SchedulePaint(); |
| 270 } | 290 } |
| 271 | 291 |
| 272 void NetworkMenuButton::SetBadge(const SkBitmap& badge) { | 292 void NetworkMenuButton::SetBadge(const SkBitmap& badge) { |
| 273 badge_ = badge; | 293 badge_ = badge; |
| 274 } | 294 } |
| 275 | 295 |
| 276 // static | 296 // static |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 if (host_->ShouldOpenButtonOptions(this)) { | 475 if (host_->ShouldOpenButtonOptions(this)) { |
| 456 string16 label = | 476 string16 label = |
| 457 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG); | 477 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_OPEN_OPTIONS_DIALOG); |
| 458 menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label, | 478 menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label, |
| 459 SkBitmap(), std::string(), FLAG_OPTIONS)); | 479 SkBitmap(), std::string(), FLAG_OPTIONS)); |
| 460 } | 480 } |
| 461 } | 481 } |
| 462 } | 482 } |
| 463 | 483 |
| 464 } // namespace chromeos | 484 } // namespace chromeos |
| OLD | NEW |