Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/webui/internet_options_handler.h" | 5 #include "chrome/browser/chromeos/webui/internet_options_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 926 ListValue* InternetOptionsHandler::GetWiredList() { | 926 ListValue* InternetOptionsHandler::GetWiredList() { |
| 927 chromeos::NetworkLibrary* cros = | 927 chromeos::NetworkLibrary* cros = |
| 928 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 928 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 929 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 929 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 930 ListValue* list = new ListValue(); | 930 ListValue* list = new ListValue(); |
| 931 | 931 |
| 932 // If ethernet is not enabled, then don't add anything. | 932 // If ethernet is not enabled, then don't add anything. |
| 933 if (cros->ethernet_enabled()) { | 933 if (cros->ethernet_enabled()) { |
| 934 const chromeos::EthernetNetwork* ethernet_network = | 934 const chromeos::EthernetNetwork* ethernet_network = |
| 935 cros->ethernet_network(); | 935 cros->ethernet_network(); |
| 936 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK); | 936 SkBitmap* icon = rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK); |
|
stevenjb
2011/02/28 23:02:37
nit: const*
Charlie Lee
2011/02/28 23:54:13
Done.
| |
| 937 if (!ethernet_network || (!ethernet_network->connecting() && | 937 SkBitmap* badge = !ethernet_network || |
|
stevenjb
2011/02/28 23:02:37
nit: const*
Charlie Lee
2011/02/28 23:54:13
Done.
| |
| 938 !ethernet_network->connected())) { | 938 (!ethernet_network->connecting() && !ethernet_network->connected()) ? |
| 939 icon = chromeos::NetworkMenu::IconForDisplay(icon, | 939 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED) : NULL; |
| 940 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED)); | |
| 941 } | |
| 942 if (ethernet_network) { | 940 if (ethernet_network) { |
| 943 list->Append(GetNetwork( | 941 list->Append(GetNetwork( |
| 944 ethernet_network->service_path(), | 942 ethernet_network->service_path(), |
| 945 icon, | 943 chromeos::NetworkMenu::IconForDisplay(icon, badge), |
| 946 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), | 944 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), |
| 947 ethernet_network->connecting(), | 945 ethernet_network->connecting(), |
| 948 ethernet_network->connected(), | 946 ethernet_network->connected(), |
| 949 ethernet_network->connectable(), | 947 ethernet_network->connectable(), |
| 950 chromeos::TYPE_ETHERNET, | 948 chromeos::TYPE_ETHERNET, |
| 951 false, | 949 false, |
| 952 chromeos::ACTIVATION_STATE_UNKNOWN, | 950 chromeos::ACTIVATION_STATE_UNKNOWN, |
| 953 false)); | 951 false)); |
| 954 } | 952 } |
| 955 } | 953 } |
| 956 return list; | 954 return list; |
| 957 } | 955 } |
| 958 | 956 |
| 959 ListValue* InternetOptionsHandler::GetWirelessList() { | 957 ListValue* InternetOptionsHandler::GetWirelessList() { |
| 960 chromeos::NetworkLibrary* cros = | 958 chromeos::NetworkLibrary* cros = |
| 961 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 959 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 962 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 960 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 963 ListValue* list = new ListValue(); | 961 ListValue* list = new ListValue(); |
| 964 | 962 |
| 965 const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 963 const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| 966 for (chromeos::WifiNetworkVector::const_iterator it = | 964 for (chromeos::WifiNetworkVector::const_iterator it = |
| 967 wifi_networks.begin(); it != wifi_networks.end(); ++it) { | 965 wifi_networks.begin(); it != wifi_networks.end(); ++it) { |
| 968 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(*it, true); | 966 const SkBitmap* icon = |
| 969 if ((*it)->encrypted()) { | 967 chromeos::NetworkMenu::IconForNetworkStrength(*it, true); |
| 970 icon = chromeos::NetworkMenu::IconForDisplay(icon, | 968 const SkBitmap* badge = (*it)->encrypted() ? |
| 971 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | 969 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; |
| 972 } | |
| 973 list->Append(GetNetwork( | 970 list->Append(GetNetwork( |
| 974 (*it)->service_path(), | 971 (*it)->service_path(), |
| 975 icon, | 972 chromeos::NetworkMenu::IconForDisplay(icon, badge), |
| 976 (*it)->name(), | 973 (*it)->name(), |
| 977 (*it)->connecting(), | 974 (*it)->connecting(), |
| 978 (*it)->connected(), | 975 (*it)->connected(), |
| 979 (*it)->connectable(), | 976 (*it)->connectable(), |
| 980 chromeos::TYPE_WIFI, | 977 chromeos::TYPE_WIFI, |
| 981 false, | 978 false, |
| 982 chromeos::ACTIVATION_STATE_UNKNOWN, | 979 chromeos::ACTIVATION_STATE_UNKNOWN, |
| 983 false)); | 980 false)); |
| 984 } | 981 } |
| 985 | 982 |
| 986 const chromeos::CellularNetworkVector cellular_networks = | 983 const chromeos::CellularNetworkVector cellular_networks = |
| 987 cros->cellular_networks(); | 984 cros->cellular_networks(); |
| 988 for (chromeos::CellularNetworkVector::const_iterator it = | 985 for (chromeos::CellularNetworkVector::const_iterator it = |
| 989 cellular_networks.begin(); it != cellular_networks.end(); ++it) { | 986 cellular_networks.begin(); it != cellular_networks.end(); ++it) { |
| 990 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(*it, true); | 987 const SkBitmap* icon = |
| 991 SkBitmap badge = chromeos::NetworkMenu::BadgeForNetworkTechnology(*it); | 988 chromeos::NetworkMenu::IconForNetworkStrength(*it, true); |
| 992 icon = chromeos::NetworkMenu::IconForDisplay(icon, badge); | 989 const SkBitmap* badge = |
| 990 chromeos::NetworkMenu::BadgeForNetworkTechnology(*it); | |
| 993 list->Append(GetNetwork( | 991 list->Append(GetNetwork( |
| 994 (*it)->service_path(), | 992 (*it)->service_path(), |
| 995 icon, | 993 chromeos::NetworkMenu::IconForDisplay(icon, badge), |
| 996 (*it)->name(), | 994 (*it)->name(), |
| 997 (*it)->connecting(), | 995 (*it)->connecting(), |
| 998 (*it)->connected(), | 996 (*it)->connected(), |
| 999 (*it)->connectable(), | 997 (*it)->connectable(), |
| 1000 chromeos::TYPE_CELLULAR, | 998 chromeos::TYPE_CELLULAR, |
| 1001 false, | 999 false, |
| 1002 (*it)->activation_state(), | 1000 (*it)->activation_state(), |
| 1003 (*it)->restricted_pool())); | 1001 (*it)->restricted_pool())); |
| 1004 } | 1002 } |
| 1005 | 1003 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 rit != remembered_wifi_networks.end(); ++rit) { | 1049 rit != remembered_wifi_networks.end(); ++rit) { |
| 1052 chromeos::WifiNetwork* wifi = *rit; | 1050 chromeos::WifiNetwork* wifi = *rit; |
| 1053 // Check if this remembered network has a matching detected network. | 1051 // Check if this remembered network has a matching detected network. |
| 1054 std::map<std::string, chromeos::WifiNetwork*>::const_iterator it = | 1052 std::map<std::string, chromeos::WifiNetwork*>::const_iterator it = |
| 1055 wifi_map.find(GetWifiUniqueIdentifier(wifi)); | 1053 wifi_map.find(GetWifiUniqueIdentifier(wifi)); |
| 1056 bool found = it != wifi_map.end(); | 1054 bool found = it != wifi_map.end(); |
| 1057 | 1055 |
| 1058 // Don't show the active network in the remembered list. | 1056 // Don't show the active network in the remembered list. |
| 1059 if (found && (it->second)->connected()) | 1057 if (found && (it->second)->connected()) |
| 1060 continue; | 1058 continue; |
| 1061 SkBitmap icon; | 1059 const SkBitmap* icon = found ? |
| 1062 if (found) | 1060 chromeos::NetworkMenu::IconForNetworkStrength(it->second, true) : |
| 1063 icon = chromeos::NetworkMenu::IconForNetworkStrength(it->second, true); | 1061 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); |
| 1064 else | |
| 1065 icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); | |
| 1066 // Place the secure badge on the icon if the remembered network is | 1062 // Place the secure badge on the icon if the remembered network is |
| 1067 // encrypted (the matching detected network, if any, will have the same | 1063 // encrypted (the matching detected network, if any, will have the same |
| 1068 // encrypted property by definition). | 1064 // encrypted property by definition). |
| 1069 if (wifi->encrypted()) { | 1065 const SkBitmap* badge = wifi->encrypted() ? |
| 1070 icon = chromeos::NetworkMenu::IconForDisplay(icon, | 1066 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; |
| 1071 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE)); | |
| 1072 } | |
| 1073 list->Append(GetNetwork( | 1067 list->Append(GetNetwork( |
| 1074 wifi->service_path(), | 1068 wifi->service_path(), |
| 1075 icon, | 1069 chromeos::NetworkMenu::IconForDisplay(icon, badge), |
| 1076 wifi->name(), | 1070 wifi->name(), |
| 1077 wifi->connecting(), | 1071 wifi->connecting(), |
| 1078 wifi->connected(), | 1072 wifi->connected(), |
| 1079 true, | 1073 true, |
| 1080 chromeos::TYPE_WIFI, | 1074 chromeos::TYPE_WIFI, |
| 1081 true, | 1075 true, |
| 1082 chromeos::ACTIVATION_STATE_UNKNOWN, | 1076 chromeos::ACTIVATION_STATE_UNKNOWN, |
| 1083 false)); | 1077 false)); |
| 1084 } | 1078 } |
| 1085 return list; | 1079 return list; |
| 1086 } | 1080 } |
| 1087 | 1081 |
| 1088 void InternetOptionsHandler::FillNetworkInfo( | 1082 void InternetOptionsHandler::FillNetworkInfo( |
| 1089 DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) { | 1083 DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) { |
| 1090 dictionary->SetBoolean("accessLocked", cros->IsLocked()); | 1084 dictionary->SetBoolean("accessLocked", cros->IsLocked()); |
| 1091 dictionary->Set("wiredList", GetWiredList()); | 1085 dictionary->Set("wiredList", GetWiredList()); |
| 1092 dictionary->Set("wirelessList", GetWirelessList()); | 1086 dictionary->Set("wirelessList", GetWirelessList()); |
| 1093 dictionary->Set("rememberedList", GetRememberedList()); | 1087 dictionary->Set("rememberedList", GetRememberedList()); |
| 1094 dictionary->SetBoolean("wifiAvailable", cros->wifi_available()); | 1088 dictionary->SetBoolean("wifiAvailable", cros->wifi_available()); |
| 1095 dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled()); | 1089 dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled()); |
| 1096 dictionary->SetBoolean("cellularAvailable", cros->cellular_available()); | 1090 dictionary->SetBoolean("cellularAvailable", cros->cellular_available()); |
| 1097 dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled()); | 1091 dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled()); |
| 1098 } | 1092 } |
| OLD | NEW |