| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/network/network_icon.h" | 5 #include "ash/system/network/network_icon.h" |
| 6 | 6 |
| 7 #include "ash/resources/vector_icons/vector_icons.h" | 7 #include "ash/resources/vector_icons/vector_icons.h" |
| 8 #include "ash/strings/grit/ash_strings.h" | 8 #include "ash/strings/grit/ash_strings.h" |
| 9 #include "ash/system/network/network_icon_animation.h" | 9 #include "ash/system/network/network_icon_animation.h" |
| 10 #include "ash/system/network/network_icon_animation_observer.h" | 10 #include "ash/system/network/network_icon_animation_observer.h" |
| (...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 871 } |
| 872 | 872 |
| 873 // Otherwise just show the network name or 'Ethernet'. | 873 // Otherwise just show the network name or 'Ethernet'. |
| 874 if (network->Matches(NetworkTypePattern::Ethernet())) { | 874 if (network->Matches(NetworkTypePattern::Ethernet())) { |
| 875 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ETHERNET); | 875 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ETHERNET); |
| 876 } else { | 876 } else { |
| 877 return base::UTF8ToUTF16(network->name()); | 877 return base::UTF8ToUTF16(network->name()); |
| 878 } | 878 } |
| 879 } | 879 } |
| 880 | 880 |
| 881 int GetCellularUninitializedMsg() { | 881 int GetMobileUninitializedMsg() { |
| 882 static base::Time s_uninitialized_state_time; | 882 static base::Time s_uninitialized_state_time; |
| 883 static int s_uninitialized_msg(0); | 883 static int s_uninitialized_msg(0); |
| 884 | 884 |
| 885 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 885 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
| 886 if (handler->GetTechnologyState(NetworkTypePattern::Mobile()) == | 886 if (handler->GetTechnologyState(NetworkTypePattern::Mobile()) == |
| 887 NetworkStateHandler::TECHNOLOGY_UNINITIALIZED) { | 887 NetworkStateHandler::TECHNOLOGY_UNINITIALIZED) { |
| 888 // TODO (lesliewatkins): Add a more descriptive message (e.g. "Enable |
| 889 // Bluetooth") for Tether technology type. |
| 888 s_uninitialized_msg = IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR; | 890 s_uninitialized_msg = IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR; |
| 889 s_uninitialized_state_time = base::Time::Now(); | 891 s_uninitialized_state_time = base::Time::Now(); |
| 890 return s_uninitialized_msg; | 892 return s_uninitialized_msg; |
| 891 } else if (handler->GetScanningByType(NetworkTypePattern::Mobile())) { | 893 } else if (handler->GetScanningByType(NetworkTypePattern::Mobile())) { |
| 892 s_uninitialized_msg = IDS_ASH_STATUS_TRAY_MOBILE_SCANNING; | 894 s_uninitialized_msg = IDS_ASH_STATUS_TRAY_MOBILE_SCANNING; |
| 893 s_uninitialized_state_time = base::Time::Now(); | 895 s_uninitialized_state_time = base::Time::Now(); |
| 894 return s_uninitialized_msg; | 896 return s_uninitialized_msg; |
| 895 } | 897 } |
| 896 // There can be a delay between leaving the Initializing state and when | 898 // There can be a delay between leaving the Initializing state and when |
| 897 // a Cellular device shows up, so keep showing the initializing | 899 // a Mobile device shows up, so keep showing the initializing |
| 898 // animation for a bit to avoid flashing the disconnect icon. | 900 // animation for a bit to avoid flashing the disconnect icon. |
| 899 const int kInitializingDelaySeconds = 1; | 901 const int kInitializingDelaySeconds = 1; |
| 900 base::TimeDelta dtime = base::Time::Now() - s_uninitialized_state_time; | 902 base::TimeDelta dtime = base::Time::Now() - s_uninitialized_state_time; |
| 901 if (dtime.InSeconds() < kInitializingDelaySeconds) | 903 if (dtime.InSeconds() < kInitializingDelaySeconds) |
| 902 return s_uninitialized_msg; | 904 return s_uninitialized_msg; |
| 903 return 0; | 905 return 0; |
| 904 } | 906 } |
| 905 | 907 |
| 906 void GetDefaultNetworkImageAndLabel(IconType icon_type, | 908 void GetDefaultNetworkImageAndLabel(IconType icon_type, |
| 907 gfx::ImageSkia* image, | 909 gfx::ImageSkia* image, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 if (!network) { | 945 if (!network) { |
| 944 // If no connecting network, check if we are activating a network. | 946 // If no connecting network, check if we are activating a network. |
| 945 const NetworkState* mobile_network = | 947 const NetworkState* mobile_network = |
| 946 state_handler->FirstNetworkByType(NetworkTypePattern::Mobile()); | 948 state_handler->FirstNetworkByType(NetworkTypePattern::Mobile()); |
| 947 if (mobile_network && (mobile_network->activation_state() == | 949 if (mobile_network && (mobile_network->activation_state() == |
| 948 shill::kActivationStateActivating)) { | 950 shill::kActivationStateActivating)) { |
| 949 network = mobile_network; | 951 network = mobile_network; |
| 950 } | 952 } |
| 951 } | 953 } |
| 952 if (!network) { | 954 if (!network) { |
| 953 // If no connecting network, check for cellular initializing. | 955 // If no connecting network, check for mobile initializing. |
| 954 int uninitialized_msg = GetCellularUninitializedMsg(); | 956 int uninitialized_msg = GetMobileUninitializedMsg(); |
| 955 if (uninitialized_msg != 0) { | 957 if (uninitialized_msg != 0) { |
| 956 *image = GetConnectingImage(icon_type, shill::kTypeCellular); | 958 *image = GetConnectingImage(icon_type, shill::kTypeCellular); |
| 957 if (label) | 959 if (label) |
| 958 *label = l10n_util::GetStringUTF16(uninitialized_msg); | 960 *label = l10n_util::GetStringUTF16(uninitialized_msg); |
| 959 *animating = true; | 961 *animating = true; |
| 960 } else { | 962 } else { |
| 961 // Otherwise show a Wi-Fi icon. If Wi-Fi is disabled, show a full icon | 963 // Otherwise show a Wi-Fi icon. If Wi-Fi is disabled, show a full icon |
| 962 // with a strikethrough. If it's enabled then it's disconnected, so show | 964 // with a strikethrough. If it's enabled then it's disconnected, so show |
| 963 // an empty wedge. | 965 // an empty wedge. |
| 964 bool wifi_enabled = | 966 bool wifi_enabled = |
| (...skipping 28 matching lines...) Expand all Loading... |
| 993 network_paths.insert((*iter)->path()); | 995 network_paths.insert((*iter)->path()); |
| 994 } | 996 } |
| 995 PurgeIconMap(ICON_TYPE_TRAY, network_paths); | 997 PurgeIconMap(ICON_TYPE_TRAY, network_paths); |
| 996 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); | 998 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); |
| 997 PurgeIconMap(ICON_TYPE_LIST, network_paths); | 999 PurgeIconMap(ICON_TYPE_LIST, network_paths); |
| 998 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); | 1000 PurgeIconMap(ICON_TYPE_MENU_LIST, network_paths); |
| 999 } | 1001 } |
| 1000 | 1002 |
| 1001 } // namespace network_icon | 1003 } // namespace network_icon |
| 1002 } // namespace ash | 1004 } // namespace ash |
| OLD | NEW |