| Index: chrome/browser/chromeos/status/network_dropdown_button.cc
|
| ===================================================================
|
| --- chrome/browser/chromeos/status/network_dropdown_button.cc (revision 64888)
|
| +++ chrome/browser/chromeos/status/network_dropdown_button.cc (working copy)
|
| @@ -34,12 +34,12 @@
|
| parent_window_(parent_window) {
|
| animation_connecting_.SetThrobDuration(kThrobDuration);
|
| animation_connecting_.SetTweenType(Tween::LINEAR);
|
| - OnNetworkManagerChanged(CrosLibrary::Get()->GetNetworkLibrary());
|
| - CrosLibrary::Get()->GetNetworkLibrary()->AddNetworkManagerObserver(this);
|
| + NetworkChanged(CrosLibrary::Get()->GetNetworkLibrary());
|
| + CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(this);
|
| }
|
|
|
| NetworkDropdownButton::~NetworkDropdownButton() {
|
| - CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this);
|
| + CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this);
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -62,13 +62,13 @@
|
| }
|
|
|
| void NetworkDropdownButton::Refresh() {
|
| - OnNetworkManagerChanged(CrosLibrary::Get()->GetNetworkLibrary());
|
| + NetworkChanged(CrosLibrary::Get()->GetNetworkLibrary());
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| -// NetworkDropdownButton, NetworkLibrary::NetworkManagerObserver implementation:
|
| +// NetworkDropdownButton, NetworkLibrary::Observer implementation:
|
|
|
| -void NetworkDropdownButton::OnNetworkManagerChanged(NetworkLibrary* cros) {
|
| +void NetworkDropdownButton::NetworkChanged(NetworkLibrary* cros) {
|
| // Show network that we will actually use. It could be another network than
|
| // user selected. For example user selected WiFi network but we have Ethernet
|
| // connection and Chrome OS device will actually use Ethernet.
|
| @@ -78,27 +78,28 @@
|
|
|
| ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| if (CrosLibrary::Get()->EnsureLoaded()) {
|
| - // Always show the active network, if any
|
| - const Network* active_network = cros->active_network();
|
| - const WirelessNetwork* wireless;
|
| - if (active_network != NULL) {
|
| + // Always show the higher priority connection first. Ethernet then wifi.
|
| + if (cros->ethernet_connected()) {
|
| animation_connecting_.Stop();
|
| - if (active_network->type() == TYPE_ETHERNET) {
|
| - SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED));
|
| - SetText(l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
|
| - } else {
|
| - DCHECK(active_network->type() == TYPE_WIFI ||
|
| - active_network->type() == TYPE_CELLULAR);
|
| - wireless = static_cast<const WirelessNetwork*>(active_network);
|
| - SetIcon(IconForNetworkStrength(wireless->strength(), false));
|
| - SetText(ASCIIToWide(wireless->name()));
|
| - }
|
| + SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED));
|
| + SetText(l10n_util::GetString(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
|
| + } else if (cros->wifi_connected()) {
|
| + animation_connecting_.Stop();
|
| + SetIcon(IconForNetworkStrength(
|
| + cros->wifi_network()->strength(), true));
|
| + SetText(ASCIIToWide(cros->wifi_network()->name()));
|
| + } else if (cros->cellular_connected()) {
|
| + animation_connecting_.Stop();
|
| + SetIcon(IconForNetworkStrength(
|
| + cros->cellular_network()->strength(), false));
|
| + SetText(ASCIIToWide(cros->cellular_network()->name()));
|
| } else if (cros->wifi_connecting() || cros->cellular_connecting()) {
|
| if (!animation_connecting_.is_animating()) {
|
| animation_connecting_.Reset();
|
| animation_connecting_.StartThrobbing(-1);
|
| SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS1_BLACK));
|
| }
|
| +
|
| if (cros->wifi_connecting())
|
| SetText(ASCIIToWide(cros->wifi_network()->name()));
|
| else if (cros->cellular_connecting())
|
|
|