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/ui/webui/options/chromeos/internet_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 const char kNetworkInfoKeyConnectable[] = "connectable"; | 63 const char kNetworkInfoKeyConnectable[] = "connectable"; |
| 64 const char kNetworkInfoKeyConnected[] = "connected"; | 64 const char kNetworkInfoKeyConnected[] = "connected"; |
| 65 const char kNetworkInfoKeyConnecting[] = "connecting"; | 65 const char kNetworkInfoKeyConnecting[] = "connecting"; |
| 66 const char kNetworkInfoKeyIconURL[] = "iconURL"; | 66 const char kNetworkInfoKeyIconURL[] = "iconURL"; |
| 67 const char kNetworkInfoKeyNeedsNewPlan[] = "needs_new_plan"; | 67 const char kNetworkInfoKeyNeedsNewPlan[] = "needs_new_plan"; |
| 68 const char kNetworkInfoKeyNetworkName[] = "networkName"; | 68 const char kNetworkInfoKeyNetworkName[] = "networkName"; |
| 69 const char kNetworkInfoKeyNetworkStatus[] = "networkStatus"; | 69 const char kNetworkInfoKeyNetworkStatus[] = "networkStatus"; |
| 70 const char kNetworkInfoKeyNetworkType[] = "networkType"; | 70 const char kNetworkInfoKeyNetworkType[] = "networkType"; |
| 71 const char kNetworkInfoKeyRemembered[] = "remembered"; | 71 const char kNetworkInfoKeyRemembered[] = "remembered"; |
| 72 const char kNetworkInfoKeyServicePath[] = "servicePath"; | 72 const char kNetworkInfoKeyServicePath[] = "servicePath"; |
| 73 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; | |
| 73 | 74 |
| 74 // A helper class for building network information dictionaries to be sent to | 75 // A helper class for building network information dictionaries to be sent to |
| 75 // the webui code. | 76 // the webui code. |
| 76 class NetworkInfoDictionary { | 77 class NetworkInfoDictionary { |
| 77 public: | 78 public: |
| 78 // Initializes the dictionary with default values. | 79 // Initializes the dictionary with default values. |
| 79 NetworkInfoDictionary(); | 80 NetworkInfoDictionary(); |
| 80 | 81 |
| 81 // Copies in service path, connect{ing|ed|able} flags and connection type from | 82 // Copies in service path, connect{ing|ed|able} flags and connection type from |
| 82 // the provided network object. Also chooses an appropriate icon based on the | 83 // the provided network object. Also chooses an appropriate icon based on the |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 } | 117 } |
| 117 void set_shared(bool shared) { | 118 void set_shared(bool shared) { |
| 118 shared_ = shared; | 119 shared_ = shared; |
| 119 } | 120 } |
| 120 void set_activation_state(chromeos::ActivationState activation_state) { | 121 void set_activation_state(chromeos::ActivationState activation_state) { |
| 121 activation_state_ = activation_state; | 122 activation_state_ = activation_state; |
| 122 } | 123 } |
| 123 void set_needs_new_plan(bool needs_new_plan) { | 124 void set_needs_new_plan(bool needs_new_plan) { |
| 124 needs_new_plan_ = needs_new_plan; | 125 needs_new_plan_ = needs_new_plan; |
| 125 } | 126 } |
| 127 void set_policy_managed(bool policy_managed) { | |
| 128 policy_managed_ = policy_managed; | |
| 129 } | |
| 126 | 130 |
| 127 // Builds the DictionaryValue representation from the previously set | 131 // Builds the DictionaryValue representation from the previously set |
| 128 // parameters. Ownership of the returned pointer is transferred to the caller. | 132 // parameters. Ownership of the returned pointer is transferred to the caller. |
| 129 DictionaryValue* BuildDictionary(); | 133 DictionaryValue* BuildDictionary(); |
| 130 | 134 |
| 131 private: | 135 private: |
| 132 // Values to be filled into the dictionary. | 136 // Values to be filled into the dictionary. |
| 133 std::string service_path_; | 137 std::string service_path_; |
| 134 std::string icon_url_; | 138 std::string icon_url_; |
| 135 std::string name_; | 139 std::string name_; |
| 136 bool connecting_; | 140 bool connecting_; |
| 137 bool connected_; | 141 bool connected_; |
| 138 bool connectable_; | 142 bool connectable_; |
| 139 chromeos::ConnectionType connection_type_; | 143 chromeos::ConnectionType connection_type_; |
| 140 bool remembered_; | 144 bool remembered_; |
| 141 bool shared_; | 145 bool shared_; |
| 142 chromeos::ActivationState activation_state_; | 146 chromeos::ActivationState activation_state_; |
| 143 bool needs_new_plan_; | 147 bool needs_new_plan_; |
| 148 bool policy_managed_; | |
| 144 | 149 |
| 145 DISALLOW_COPY_AND_ASSIGN(NetworkInfoDictionary); | 150 DISALLOW_COPY_AND_ASSIGN(NetworkInfoDictionary); |
| 146 }; | 151 }; |
| 147 | 152 |
| 148 NetworkInfoDictionary::NetworkInfoDictionary() { | 153 NetworkInfoDictionary::NetworkInfoDictionary() { |
| 149 set_connecting(false); | 154 set_connecting(false); |
| 150 set_connected(false); | 155 set_connected(false); |
| 151 set_connectable(false); | 156 set_connectable(false); |
| 152 set_remembered(false); | 157 set_remembered(false); |
| 153 set_shared(false); | 158 set_shared(false); |
| 154 set_activation_state(chromeos::ACTIVATION_STATE_UNKNOWN); | 159 set_activation_state(chromeos::ACTIVATION_STATE_UNKNOWN); |
| 155 set_needs_new_plan(false); | 160 set_needs_new_plan(false); |
| 161 set_policy_managed(false); | |
| 156 } | 162 } |
| 157 | 163 |
| 158 NetworkInfoDictionary::NetworkInfoDictionary(const chromeos::Network* network) { | 164 NetworkInfoDictionary::NetworkInfoDictionary(const chromeos::Network* network) { |
| 159 set_service_path(network->service_path()); | 165 set_service_path(network->service_path()); |
| 160 set_icon(chromeos::NetworkMenuIcon::GetBitmap(network)); | 166 set_icon(chromeos::NetworkMenuIcon::GetBitmap(network)); |
| 161 set_name(network->name()); | 167 set_name(network->name()); |
| 162 set_connecting(network->connecting()); | 168 set_connecting(network->connecting()); |
| 163 set_connected(network->connected()); | 169 set_connected(network->connected()); |
| 164 set_connectable(network->connectable()); | 170 set_connectable(network->connectable()); |
| 165 set_connection_type(network->type()); | 171 set_connection_type(network->type()); |
| 166 set_remembered(false); | 172 set_remembered(false); |
| 167 set_shared(false); | 173 set_shared(false); |
| 168 set_needs_new_plan(false); | 174 set_needs_new_plan(false); |
| 175 set_policy_managed(chromeos::NetworkUIData::IsManaged(network)); | |
| 169 } | 176 } |
| 170 | 177 |
| 171 NetworkInfoDictionary::NetworkInfoDictionary( | 178 NetworkInfoDictionary::NetworkInfoDictionary( |
| 172 const chromeos::Network* network, | 179 const chromeos::Network* network, |
| 173 const chromeos::Network* remembered) { | 180 const chromeos::Network* remembered) { |
| 174 set_service_path(remembered->service_path()); | 181 set_service_path(remembered->service_path()); |
| 175 set_icon( | 182 set_icon( |
| 176 chromeos::NetworkMenuIcon::GetBitmap(network ? network : remembered)); | 183 chromeos::NetworkMenuIcon::GetBitmap(network ? network : remembered)); |
| 177 set_name(remembered->name()); | 184 set_name(remembered->name()); |
| 178 set_connecting(network ? network->connecting() : false); | 185 set_connecting(network ? network->connecting() : false); |
| 179 set_connected(network ? network->connected() : false); | 186 set_connected(network ? network->connected() : false); |
| 180 set_connectable(true); | 187 set_connectable(true); |
| 181 set_connection_type(remembered->type()); | 188 set_connection_type(remembered->type()); |
| 182 set_remembered(true); | 189 set_remembered(true); |
| 183 set_shared(remembered->profile_type() == chromeos::PROFILE_SHARED); | 190 set_shared(remembered->profile_type() == chromeos::PROFILE_SHARED); |
| 184 set_needs_new_plan(false); | 191 set_needs_new_plan(false); |
| 192 set_policy_managed( | |
| 193 network ? chromeos::NetworkUIData::IsManaged(network) : false); | |
| 185 } | 194 } |
| 186 | 195 |
| 187 DictionaryValue* NetworkInfoDictionary::BuildDictionary() { | 196 DictionaryValue* NetworkInfoDictionary::BuildDictionary() { |
| 188 std::string status; | 197 std::string status; |
| 189 | 198 |
| 190 if (remembered_) { | 199 if (remembered_) { |
| 191 if (shared_) | 200 if (shared_) |
| 192 status = l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SHARED_NETWORK); | 201 status = l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SHARED_NETWORK); |
| 193 } else { | 202 } else { |
| 194 // 802.1X networks can be connected but not have saved credentials, and | 203 // 802.1X networks can be connected but not have saved credentials, and |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 220 network_info->SetBoolean(kNetworkInfoKeyConnected, connected_); | 229 network_info->SetBoolean(kNetworkInfoKeyConnected, connected_); |
| 221 network_info->SetBoolean(kNetworkInfoKeyConnecting, connecting_); | 230 network_info->SetBoolean(kNetworkInfoKeyConnecting, connecting_); |
| 222 network_info->SetString(kNetworkInfoKeyIconURL, icon_url_); | 231 network_info->SetString(kNetworkInfoKeyIconURL, icon_url_); |
| 223 network_info->SetBoolean(kNetworkInfoKeyNeedsNewPlan, needs_new_plan_); | 232 network_info->SetBoolean(kNetworkInfoKeyNeedsNewPlan, needs_new_plan_); |
| 224 network_info->SetString(kNetworkInfoKeyNetworkName, name_); | 233 network_info->SetString(kNetworkInfoKeyNetworkName, name_); |
| 225 network_info->SetString(kNetworkInfoKeyNetworkStatus, status); | 234 network_info->SetString(kNetworkInfoKeyNetworkStatus, status); |
| 226 network_info->SetInteger(kNetworkInfoKeyNetworkType, | 235 network_info->SetInteger(kNetworkInfoKeyNetworkType, |
| 227 static_cast<int>(connection_type_)); | 236 static_cast<int>(connection_type_)); |
| 228 network_info->SetBoolean(kNetworkInfoKeyRemembered, remembered_); | 237 network_info->SetBoolean(kNetworkInfoKeyRemembered, remembered_); |
| 229 network_info->SetString(kNetworkInfoKeyServicePath, service_path_); | 238 network_info->SetString(kNetworkInfoKeyServicePath, service_path_); |
| 239 network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, policy_managed_); | |
| 230 | 240 |
| 231 return network_info.release(); | 241 return network_info.release(); |
| 232 } | 242 } |
| 233 | 243 |
| 234 } // namespace | 244 } // namespace |
| 235 | 245 |
| 236 InternetOptionsHandler::InternetOptionsHandler() { | 246 InternetOptionsHandler::InternetOptionsHandler() { |
| 237 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, | 247 registrar_.Add(this, chrome::NOTIFICATION_REQUIRE_PIN_SETTING_CHANGE_ENDED, |
| 238 content::NotificationService::AllSources()); | 248 content::NotificationService::AllSources()); |
| 239 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, | 249 registrar_.Add(this, chrome::NOTIFICATION_ENTER_PIN_ENDED, |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 l10n_util::GetStringUTF16( | 300 l10n_util::GetStringUTF16( |
| 291 IDS_OPTIONS_SETTINGS_ACTIVATE)); | 301 IDS_OPTIONS_SETTINGS_ACTIVATE)); |
| 292 localized_strings->SetString("buyplan_button", | 302 localized_strings->SetString("buyplan_button", |
| 293 l10n_util::GetStringUTF16( | 303 l10n_util::GetStringUTF16( |
| 294 IDS_OPTIONS_SETTINGS_BUY_PLAN)); | 304 IDS_OPTIONS_SETTINGS_BUY_PLAN)); |
| 295 | 305 |
| 296 localized_strings->SetString("changeProxyButton", | 306 localized_strings->SetString("changeProxyButton", |
| 297 l10n_util::GetStringUTF16( | 307 l10n_util::GetStringUTF16( |
| 298 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); | 308 IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); |
| 299 | 309 |
| 310 localized_strings->SetString("managedNetwork", | |
| 311 l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_MANAGED_NETWORK)); | |
| 312 | |
| 300 localized_strings->SetString("wifiNetworkTabLabel", | 313 localized_strings->SetString("wifiNetworkTabLabel", |
| 301 l10n_util::GetStringUTF16( | 314 l10n_util::GetStringUTF16( |
| 302 IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIFI)); | 315 IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIFI)); |
| 303 localized_strings->SetString("vpnTabLabel", | 316 localized_strings->SetString("vpnTabLabel", |
| 304 l10n_util::GetStringUTF16( | 317 l10n_util::GetStringUTF16( |
| 305 IDS_OPTIONS_SETTINGS_INTERNET_TAB_VPN)); | 318 IDS_OPTIONS_SETTINGS_INTERNET_TAB_VPN)); |
| 306 localized_strings->SetString("cellularPlanTabLabel", | 319 localized_strings->SetString("cellularPlanTabLabel", |
| 307 l10n_util::GetStringUTF16( | 320 l10n_util::GetStringUTF16( |
| 308 IDS_OPTIONS_SETTINGS_INTERNET_TAB_PLAN)); | 321 IDS_OPTIONS_SETTINGS_INTERNET_TAB_PLAN)); |
| 309 localized_strings->SetString("cellularConnTabLabel", | 322 localized_strings->SetString("cellularConnTabLabel", |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 875 network->service_path()); | 888 network->service_path()); |
| 876 } | 889 } |
| 877 | 890 |
| 878 DictionaryValue dictionary; | 891 DictionaryValue dictionary; |
| 879 std::string hardware_address; | 892 std::string hardware_address; |
| 880 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( | 893 chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( |
| 881 network->device_path(), &hardware_address, | 894 network->device_path(), &hardware_address, |
| 882 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); | 895 chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); |
| 883 if (!hardware_address.empty()) | 896 if (!hardware_address.empty()) |
| 884 dictionary.SetString("hardwareAddress", hardware_address); | 897 dictionary.SetString("hardwareAddress", hardware_address); |
| 898 | |
| 899 scoped_ptr<DictionaryValue> ipconfig_dhcp; | |
| 900 scoped_ptr<DictionaryValue> ipconfig_static; | |
| 885 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); | 901 for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| 886 it != ipconfigs.end(); ++it) { | 902 it != ipconfigs.end(); ++it) { |
| 887 const chromeos::NetworkIPConfig& ipconfig = *it; | 903 const chromeos::NetworkIPConfig& ipconfig = *it; |
| 888 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); | 904 scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); |
| 889 ipconfig_dict->SetString("address", ipconfig.address); | 905 ipconfig_dict->SetString("address", ipconfig.address); |
| 890 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); | 906 ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); |
| 891 ipconfig_dict->SetString("gateway", ipconfig.gateway); | 907 ipconfig_dict->SetString("gateway", ipconfig.gateway); |
| 892 ipconfig_dict->SetString("dns", ipconfig.name_servers); | 908 ipconfig_dict->SetString("dns", ipconfig.name_servers); |
| 893 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) | 909 if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) |
| 894 dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); | 910 ipconfig_dhcp.reset(ipconfig_dict.release()); |
| 895 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) | 911 else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) |
| 896 dictionary.Set("ipconfigStatic", ipconfig_dict.release()); | 912 ipconfig_static.reset(ipconfig_dict.release()); |
| 897 } | 913 } |
| 898 | 914 |
| 915 SetValueDictionary(&dictionary, "ipconfigDHCP", ipconfig_dhcp.release(), | |
| 916 chromeos::NetworkPropertyUIData(network, NULL)); | |
| 917 SetValueDictionary(&dictionary, "ipconfigStatic", ipconfig_static.release(), | |
| 918 chromeos::NetworkPropertyUIData(network, NULL)); | |
| 919 | |
| 899 chromeos::ConnectionType type = network->type(); | 920 chromeos::ConnectionType type = network->type(); |
| 900 dictionary.SetInteger("type", type); | 921 dictionary.SetInteger("type", type); |
| 901 dictionary.SetString("servicePath", network->service_path()); | 922 dictionary.SetString("servicePath", network->service_path()); |
| 902 dictionary.SetBoolean("connecting", network->connecting()); | 923 dictionary.SetBoolean("connecting", network->connecting()); |
| 903 dictionary.SetBoolean("connected", network->connected()); | 924 dictionary.SetBoolean("connected", network->connected()); |
| 904 dictionary.SetString("connectionState", network->GetStateString()); | 925 dictionary.SetString("connectionState", network->GetStateString()); |
| 905 | 926 |
| 906 // Only show proxy for remembered networks. | 927 // Only show proxy for remembered networks. |
| 907 chromeos::NetworkProfileType network_profile = network->profile_type(); | 928 chromeos::NetworkProfileType network_profile = network->profile_type(); |
| 908 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE); | 929 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE); |
| 909 | 930 |
| 910 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) | 931 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) |
| 911 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( | 932 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( |
| 912 switches::kEnableStaticIPConfig); | 933 switches::kEnableStaticIPConfig); |
| 913 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && | 934 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && |
| 914 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); | 935 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); |
| 915 | 936 |
| 916 if (network_profile == chromeos::PROFILE_USER) { | 937 if (network_profile == chromeos::PROFILE_USER) { |
| 917 dictionary.SetBoolean("showPreferred", true); | 938 dictionary.SetBoolean("showPreferred", true); |
| 918 dictionary.SetBoolean("preferred", network->preferred()); | 939 SetValueDictionary(&dictionary, "preferred", |
| 940 Value::CreateBooleanValue(network->preferred()), | |
| 941 chromeos::NetworkPropertyUIData( | |
| 942 network, | |
| 943 chromeos::NetworkUIData::kPropertyPreferred)); | |
| 919 } else { | 944 } else { |
| 920 dictionary.SetBoolean("showPreferred", false); | 945 dictionary.SetBoolean("showPreferred", false); |
| 921 dictionary.SetBoolean("preferred", false); | 946 SetValueDictionary(&dictionary, "preferred", |
| 947 Value::CreateBooleanValue(network->preferred()), | |
| 948 chromeos::NetworkPropertyUIData( | |
| 949 network, | |
| 950 chromeos::NetworkUIData::kPropertyPreferred)); | |
| 922 } | 951 } |
| 923 dictionary.SetBoolean("autoConnect", network->auto_connect()); | 952 SetValueDictionary(&dictionary, "autoConnect", |
| 953 Value::CreateBooleanValue(network->auto_connect()), | |
| 954 chromeos::NetworkPropertyUIData( | |
| 955 network, | |
| 956 chromeos::NetworkUIData::kPropertyAutoConnect)); | |
| 924 | 957 |
| 925 if (type == chromeos::TYPE_WIFI) { | 958 if (type == chromeos::TYPE_WIFI) { |
| 926 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); | 959 dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); |
| 927 const chromeos::WifiNetwork* wifi = | 960 const chromeos::WifiNetwork* wifi = |
| 928 cros_->FindWifiNetworkByPath(network->service_path()); | 961 cros_->FindWifiNetworkByPath(network->service_path()); |
| 929 if (!wifi) { | 962 if (!wifi) { |
| 930 LOG(WARNING) << "Cannot find network " << network->service_path(); | 963 LOG(WARNING) << "Cannot find network " << network->service_path(); |
| 931 } else { | 964 } else { |
| 932 PopulateWifiDetails(wifi, &dictionary); | 965 PopulateWifiDetails(wifi, &dictionary); |
| 933 } | 966 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1020 dictionary->SetString("prlVersion", | 1053 dictionary->SetString("prlVersion", |
| 1021 base::StringPrintf("%u", device->prl_version())); | 1054 base::StringPrintf("%u", device->prl_version())); |
| 1022 dictionary->SetString("meid", device->meid()); | 1055 dictionary->SetString("meid", device->meid()); |
| 1023 dictionary->SetString("imei", device->imei()); | 1056 dictionary->SetString("imei", device->imei()); |
| 1024 dictionary->SetString("mdn", device->mdn()); | 1057 dictionary->SetString("mdn", device->mdn()); |
| 1025 dictionary->SetString("imsi", device->imsi()); | 1058 dictionary->SetString("imsi", device->imsi()); |
| 1026 dictionary->SetString("esn", device->esn()); | 1059 dictionary->SetString("esn", device->esn()); |
| 1027 dictionary->SetString("min", device->min()); | 1060 dictionary->SetString("min", device->min()); |
| 1028 dictionary->SetBoolean("gsm", | 1061 dictionary->SetBoolean("gsm", |
| 1029 device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); | 1062 device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); |
| 1030 dictionary->SetBoolean("simCardLockEnabled", | 1063 SetValueDictionary( |
| 1031 device->sim_pin_required() == chromeos::SIM_PIN_REQUIRED); | 1064 dictionary, "simCardLockEnabled", |
| 1065 Value::CreateBooleanValue( | |
| 1066 device->sim_pin_required() == chromeos::SIM_PIN_REQUIRED), | |
| 1067 chromeos::NetworkPropertyUIData(cellular, NULL)); | |
| 1032 | 1068 |
| 1033 chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance(); | 1069 chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance(); |
| 1034 if (config->IsReady()) { | 1070 if (config->IsReady()) { |
| 1035 std::string carrier_id = cros_->GetCellularHomeCarrierId(); | 1071 std::string carrier_id = cros_->GetCellularHomeCarrierId(); |
| 1036 const chromeos::MobileConfig::Carrier* carrier = | 1072 const chromeos::MobileConfig::Carrier* carrier = |
| 1037 config->GetCarrier(carrier_id); | 1073 config->GetCarrier(carrier_id); |
| 1038 if (carrier && !carrier->top_up_url().empty()) | 1074 if (carrier && !carrier->top_up_url().empty()) |
| 1039 dictionary->SetString("carrierUrl", carrier->top_up_url()); | 1075 dictionary->SetString("carrierUrl", carrier->top_up_url()); |
| 1040 } | 1076 } |
| 1041 | 1077 |
| 1042 const chromeos::CellularApnList& apn_list = device->provider_apn_list(); | 1078 const chromeos::CellularApnList& apn_list = device->provider_apn_list(); |
| 1043 ListValue* apn_list_value = new ListValue(); | 1079 ListValue* apn_list_value = new ListValue(); |
| 1044 for (chromeos::CellularApnList::const_iterator it = apn_list.begin(); | 1080 for (chromeos::CellularApnList::const_iterator it = apn_list.begin(); |
| 1045 it != apn_list.end(); ++it) { | 1081 it != apn_list.end(); ++it) { |
| 1046 apn_list_value->Append(CreateDictionaryFromCellularApn(*it)); | 1082 apn_list_value->Append(CreateDictionaryFromCellularApn(*it)); |
| 1047 } | 1083 } |
| 1048 dictionary->Set("providerApnList", apn_list_value); | 1084 SetValueDictionary(dictionary, "providerApnList", apn_list_value, |
| 1085 chromeos::NetworkPropertyUIData(cellular, NULL)); | |
| 1049 } | 1086 } |
| 1050 | 1087 |
| 1051 SetActivationButtonVisibility(cellular, dictionary); | 1088 SetActivationButtonVisibility(cellular, dictionary); |
| 1052 } | 1089 } |
| 1053 | 1090 |
| 1054 void InternetOptionsHandler::PopulateVPNDetails( | 1091 void InternetOptionsHandler::PopulateVPNDetails( |
| 1055 const chromeos::VirtualNetwork* vpn, | 1092 const chromeos::VirtualNetwork* vpn, |
| 1056 DictionaryValue* dictionary) { | 1093 DictionaryValue* dictionary) { |
| 1057 dictionary->SetString("service_name", vpn->name()); | 1094 dictionary->SetString("service_name", vpn->name()); |
| 1058 bool remembered = (vpn->profile_type() != chromeos::PROFILE_NONE); | 1095 bool remembered = (vpn->profile_type() != chromeos::PROFILE_NONE); |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1325 dictionary->Set("wirelessList", GetWirelessList()); | 1362 dictionary->Set("wirelessList", GetWirelessList()); |
| 1326 dictionary->Set("vpnList", GetVPNList()); | 1363 dictionary->Set("vpnList", GetVPNList()); |
| 1327 dictionary->Set("rememberedList", GetRememberedList()); | 1364 dictionary->Set("rememberedList", GetRememberedList()); |
| 1328 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); | 1365 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); |
| 1329 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); | 1366 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); |
| 1330 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); | 1367 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); |
| 1331 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); | 1368 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); |
| 1332 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); | 1369 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); |
| 1333 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); | 1370 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
| 1334 } | 1371 } |
| 1372 | |
| 1373 void InternetOptionsHandler::SetValueDictionary( | |
| 1374 DictionaryValue* settings, | |
| 1375 const char* key, | |
| 1376 base::Value* value, | |
| 1377 const chromeos::NetworkPropertyUIData& ui_data) { | |
| 1378 DictionaryValue* value_dict = new DictionaryValue(); | |
| 1379 // DictionaryValue::Set() takes ownership of |value|. | |
| 1380 if (value) | |
| 1381 value_dict->Set("value", value); | |
| 1382 const base::Value* default_value = ui_data.default_value(); | |
| 1383 if (default_value) | |
| 1384 value_dict->Set("default", default_value->DeepCopy()); | |
| 1385 std::string controlled_by; | |
| 1386 switch (ui_data.controller()) { | |
|
stevenjb
2011/11/29 18:15:39
As discussed, I think this will be better with the
Mattias Nissler (ping if slow)
2011/11/29 21:29:04
Done.
| |
| 1387 case chromeos::NetworkPropertyUIData::CONTROLLER_POLICY: | |
| 1388 controlled_by = "policy"; | |
| 1389 break; | |
| 1390 case chromeos::NetworkPropertyUIData::CONTROLLER_USER: | |
| 1391 if (default_value) | |
| 1392 controlled_by = "recommended"; | |
| 1393 break; | |
| 1394 } | |
| 1395 if (!controlled_by.empty()) | |
| 1396 value_dict->SetString("controlledBy", controlled_by); | |
| 1397 settings->Set(key, value_dict); | |
| 1398 } | |
| OLD | NEW |