Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Side by Side Diff: chrome/browser/chromeos/webui/internet_options_handler.cc

Issue 6591017: Cache network connecting bitmaps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 914 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 ListValue* InternetOptionsHandler::GetWiredList() { 925 ListValue* InternetOptionsHandler::GetWiredList() {
926 chromeos::NetworkLibrary* cros = 926 chromeos::NetworkLibrary* cros =
927 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 927 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
928 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 928 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
929 ListValue* list = new ListValue(); 929 ListValue* list = new ListValue();
930 930
931 // If ethernet is not enabled, then don't add anything. 931 // If ethernet is not enabled, then don't add anything.
932 if (cros->ethernet_enabled()) { 932 if (cros->ethernet_enabled()) {
933 const chromeos::EthernetNetwork* ethernet_network = 933 const chromeos::EthernetNetwork* ethernet_network =
934 cros->ethernet_network(); 934 cros->ethernet_network();
935 SkBitmap icon = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK); 935 SkBitmap* icon = rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK);
936 if (!ethernet_network || (!ethernet_network->connecting() && 936 SkBitmap* badge = !ethernet_network ||
937 !ethernet_network->connected())) { 937 (!ethernet_network->connecting() && !ethernet_network->connected()) ?
938 icon = chromeos::NetworkMenu::IconForDisplay(icon, 938 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED) : NULL;
939 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED));
940 }
941 if (ethernet_network) { 939 if (ethernet_network) {
942 list->Append(GetNetwork( 940 list->Append(GetNetwork(
943 ethernet_network->service_path(), 941 ethernet_network->service_path(),
944 icon, 942 chromeos::NetworkMenu::IconForDisplay(icon, badge),
945 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), 943 l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET),
946 ethernet_network->connecting(), 944 ethernet_network->connecting(),
947 ethernet_network->connected(), 945 ethernet_network->connected(),
948 ethernet_network->connectable(), 946 ethernet_network->connectable(),
949 chromeos::TYPE_ETHERNET, 947 chromeos::TYPE_ETHERNET,
950 false, 948 false,
951 chromeos::ACTIVATION_STATE_UNKNOWN, 949 chromeos::ACTIVATION_STATE_UNKNOWN,
952 false)); 950 false));
953 } 951 }
954 } 952 }
955 return list; 953 return list;
956 } 954 }
957 955
958 ListValue* InternetOptionsHandler::GetWirelessList() { 956 ListValue* InternetOptionsHandler::GetWirelessList() {
959 chromeos::NetworkLibrary* cros = 957 chromeos::NetworkLibrary* cros =
960 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); 958 chromeos::CrosLibrary::Get()->GetNetworkLibrary();
961 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 959 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
962 ListValue* list = new ListValue(); 960 ListValue* list = new ListValue();
963 961
964 const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); 962 const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks();
965 for (chromeos::WifiNetworkVector::const_iterator it = 963 for (chromeos::WifiNetworkVector::const_iterator it =
966 wifi_networks.begin(); it != wifi_networks.end(); ++it) { 964 wifi_networks.begin(); it != wifi_networks.end(); ++it) {
967 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(*it, true); 965 SkBitmap* icon = chromeos::NetworkMenu::IconForNetworkStrength(*it, true);
968 if ((*it)->encrypted()) { 966 SkBitmap* badge = (*it)->encrypted() ?
969 icon = chromeos::NetworkMenu::IconForDisplay(icon, 967 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL;
970 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE));
971 }
972 list->Append(GetNetwork( 968 list->Append(GetNetwork(
973 (*it)->service_path(), 969 (*it)->service_path(),
974 icon, 970 chromeos::NetworkMenu::IconForDisplay(icon, badge),
975 (*it)->name(), 971 (*it)->name(),
976 (*it)->connecting(), 972 (*it)->connecting(),
977 (*it)->connected(), 973 (*it)->connected(),
978 (*it)->connectable(), 974 (*it)->connectable(),
979 chromeos::TYPE_WIFI, 975 chromeos::TYPE_WIFI,
980 false, 976 false,
981 chromeos::ACTIVATION_STATE_UNKNOWN, 977 chromeos::ACTIVATION_STATE_UNKNOWN,
982 false)); 978 false));
983 } 979 }
984 980
985 const chromeos::CellularNetworkVector cellular_networks = 981 const chromeos::CellularNetworkVector cellular_networks =
986 cros->cellular_networks(); 982 cros->cellular_networks();
987 for (chromeos::CellularNetworkVector::const_iterator it = 983 for (chromeos::CellularNetworkVector::const_iterator it =
988 cellular_networks.begin(); it != cellular_networks.end(); ++it) { 984 cellular_networks.begin(); it != cellular_networks.end(); ++it) {
989 SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(*it, true); 985 SkBitmap* icon = chromeos::NetworkMenu::IconForNetworkStrength(*it, true);
990 SkBitmap badge = chromeos::NetworkMenu::BadgeForNetworkTechnology(*it); 986 SkBitmap* badge = chromeos::NetworkMenu::BadgeForNetworkTechnology(*it);
991 icon = chromeos::NetworkMenu::IconForDisplay(icon, badge);
992 list->Append(GetNetwork( 987 list->Append(GetNetwork(
993 (*it)->service_path(), 988 (*it)->service_path(),
994 icon, 989 chromeos::NetworkMenu::IconForDisplay(icon, badge),
995 (*it)->name(), 990 (*it)->name(),
996 (*it)->connecting(), 991 (*it)->connecting(),
997 (*it)->connected(), 992 (*it)->connected(),
998 (*it)->connectable(), 993 (*it)->connectable(),
999 chromeos::TYPE_CELLULAR, 994 chromeos::TYPE_CELLULAR,
1000 false, 995 false,
1001 (*it)->activation_state(), 996 (*it)->activation_state(),
1002 (*it)->restricted_pool())); 997 (*it)->restricted_pool()));
1003 } 998 }
1004 999
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 rit != remembered_wifi_networks.end(); ++rit) { 1045 rit != remembered_wifi_networks.end(); ++rit) {
1051 chromeos::WifiNetwork* wifi = *rit; 1046 chromeos::WifiNetwork* wifi = *rit;
1052 // Check if this remembered network has a matching detected network. 1047 // Check if this remembered network has a matching detected network.
1053 std::map<std::string, chromeos::WifiNetwork*>::const_iterator it = 1048 std::map<std::string, chromeos::WifiNetwork*>::const_iterator it =
1054 wifi_map.find(GetWifiUniqueIdentifier(wifi)); 1049 wifi_map.find(GetWifiUniqueIdentifier(wifi));
1055 bool found = it != wifi_map.end(); 1050 bool found = it != wifi_map.end();
1056 1051
1057 // Don't show the active network in the remembered list. 1052 // Don't show the active network in the remembered list.
1058 if (found && (it->second)->connected()) 1053 if (found && (it->second)->connected())
1059 continue; 1054 continue;
1060 SkBitmap icon; 1055 SkBitmap* icon = found ?
1061 if (found) 1056 chromeos::NetworkMenu::IconForNetworkStrength(it->second, true) :
1062 icon = chromeos::NetworkMenu::IconForNetworkStrength(it->second, true); 1057 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK);
1063 else
1064 icon = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK);
1065 // Place the secure badge on the icon if the remembered network is 1058 // Place the secure badge on the icon if the remembered network is
1066 // encrypted (the matching detected network, if any, will have the same 1059 // encrypted (the matching detected network, if any, will have the same
1067 // encrypted property by definition). 1060 // encrypted property by definition).
1068 if (wifi->encrypted()) { 1061 SkBitmap* badge = wifi->encrypted() ?
1069 icon = chromeos::NetworkMenu::IconForDisplay(icon, 1062 rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL;
1070 *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE));
1071 }
1072 list->Append(GetNetwork( 1063 list->Append(GetNetwork(
1073 wifi->service_path(), 1064 wifi->service_path(),
1074 icon, 1065 chromeos::NetworkMenu::IconForDisplay(icon, badge),
1075 wifi->name(), 1066 wifi->name(),
1076 wifi->connecting(), 1067 wifi->connecting(),
1077 wifi->connected(), 1068 wifi->connected(),
1078 true, 1069 true,
1079 chromeos::TYPE_WIFI, 1070 chromeos::TYPE_WIFI,
1080 true, 1071 true,
1081 chromeos::ACTIVATION_STATE_UNKNOWN, 1072 chromeos::ACTIVATION_STATE_UNKNOWN,
1082 false)); 1073 false));
1083 } 1074 }
1084 return list; 1075 return list;
1085 } 1076 }
1086 1077
1087 void InternetOptionsHandler::FillNetworkInfo( 1078 void InternetOptionsHandler::FillNetworkInfo(
1088 DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) { 1079 DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) {
1089 dictionary->SetBoolean("accessLocked", cros->IsLocked()); 1080 dictionary->SetBoolean("accessLocked", cros->IsLocked());
1090 dictionary->Set("wiredList", GetWiredList()); 1081 dictionary->Set("wiredList", GetWiredList());
1091 dictionary->Set("wirelessList", GetWirelessList()); 1082 dictionary->Set("wirelessList", GetWirelessList());
1092 dictionary->Set("rememberedList", GetRememberedList()); 1083 dictionary->Set("rememberedList", GetRememberedList());
1093 dictionary->SetBoolean("wifiAvailable", cros->wifi_available()); 1084 dictionary->SetBoolean("wifiAvailable", cros->wifi_available());
1094 dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled()); 1085 dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled());
1095 dictionary->SetBoolean("cellularAvailable", cros->cellular_available()); 1086 dictionary->SetBoolean("cellularAvailable", cros->cellular_available());
1096 dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled()); 1087 dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled());
1097 } 1088 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698