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

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

Issue 8726007: Disable UI in chrome://settings/internet and details popup for policy-managed networks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make clang happy. Created 9 years 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
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/internet_options_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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
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
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
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
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
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 chromeos::NetworkPropertyUIData ipconfig_dhcp_ui_data(network, NULL);
916 SetValueDictionary(&dictionary, "ipconfigDHCP", ipconfig_dhcp.release(),
917 ipconfig_dhcp_ui_data);
918 chromeos::NetworkPropertyUIData ipconfig_static_ui_data(network, NULL);
919 SetValueDictionary(&dictionary, "ipconfigStatic", ipconfig_static.release(),
920 ipconfig_static_ui_data);
921
899 chromeos::ConnectionType type = network->type(); 922 chromeos::ConnectionType type = network->type();
900 dictionary.SetInteger("type", type); 923 dictionary.SetInteger("type", type);
901 dictionary.SetString("servicePath", network->service_path()); 924 dictionary.SetString("servicePath", network->service_path());
902 dictionary.SetBoolean("connecting", network->connecting()); 925 dictionary.SetBoolean("connecting", network->connecting());
903 dictionary.SetBoolean("connected", network->connected()); 926 dictionary.SetBoolean("connected", network->connected());
904 dictionary.SetString("connectionState", network->GetStateString()); 927 dictionary.SetString("connectionState", network->GetStateString());
905 928
906 // Only show proxy for remembered networks. 929 // Only show proxy for remembered networks.
907 chromeos::NetworkProfileType network_profile = network->profile_type(); 930 chromeos::NetworkProfileType network_profile = network->profile_type();
908 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE); 931 dictionary.SetBoolean("showProxy", network_profile != chromeos::PROFILE_NONE);
909 932
910 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled) 933 // Hide the dhcp/static radio if not ethernet or wifi (or if not enabled)
911 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch( 934 bool staticIPConfig = CommandLine::ForCurrentProcess()->HasSwitch(
912 switches::kEnableStaticIPConfig); 935 switches::kEnableStaticIPConfig);
913 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && 936 dictionary.SetBoolean("showStaticIPConfig", staticIPConfig &&
914 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); 937 (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET));
915 938
939 chromeos::NetworkPropertyUIData preferred_ui_data(
940 network, chromeos::NetworkUIData::kPropertyPreferred);
916 if (network_profile == chromeos::PROFILE_USER) { 941 if (network_profile == chromeos::PROFILE_USER) {
917 dictionary.SetBoolean("showPreferred", true); 942 dictionary.SetBoolean("showPreferred", true);
918 dictionary.SetBoolean("preferred", network->preferred()); 943 SetValueDictionary(&dictionary, "preferred",
944 Value::CreateBooleanValue(network->preferred()),
945 preferred_ui_data);
919 } else { 946 } else {
920 dictionary.SetBoolean("showPreferred", false); 947 dictionary.SetBoolean("showPreferred", false);
921 dictionary.SetBoolean("preferred", false); 948 SetValueDictionary(&dictionary, "preferred",
949 Value::CreateBooleanValue(network->preferred()),
950 preferred_ui_data);
922 } 951 }
923 dictionary.SetBoolean("autoConnect", network->auto_connect()); 952 chromeos::NetworkPropertyUIData auto_connect_ui_data(
953 network, chromeos::NetworkUIData::kPropertyAutoConnect);
954 SetValueDictionary(&dictionary, "autoConnect",
955 Value::CreateBooleanValue(network->auto_connect()),
956 auto_connect_ui_data);
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 dictionary->SetBoolean("needsPlan", cellular->needs_new_plan()); 1039 dictionary->SetBoolean("needsPlan", cellular->needs_new_plan());
1007 1040
1008 dictionary->Set("apn", CreateDictionaryFromCellularApn(cellular->apn())); 1041 dictionary->Set("apn", CreateDictionaryFromCellularApn(cellular->apn()));
1009 dictionary->Set("lastGoodApn", 1042 dictionary->Set("lastGoodApn",
1010 CreateDictionaryFromCellularApn(cellular->last_good_apn())); 1043 CreateDictionaryFromCellularApn(cellular->last_good_apn()));
1011 1044
1012 // Device settings. 1045 // Device settings.
1013 const chromeos::NetworkDevice* device = 1046 const chromeos::NetworkDevice* device =
1014 cros_->FindNetworkDeviceByPath(cellular->device_path()); 1047 cros_->FindNetworkDeviceByPath(cellular->device_path());
1015 if (device) { 1048 if (device) {
1049 chromeos::NetworkPropertyUIData cellular_propety_ui_data(cellular, NULL);
1016 dictionary->SetString("manufacturer", device->manufacturer()); 1050 dictionary->SetString("manufacturer", device->manufacturer());
1017 dictionary->SetString("modelId", device->model_id()); 1051 dictionary->SetString("modelId", device->model_id());
1018 dictionary->SetString("firmwareRevision", device->firmware_revision()); 1052 dictionary->SetString("firmwareRevision", device->firmware_revision());
1019 dictionary->SetString("hardwareRevision", device->hardware_revision()); 1053 dictionary->SetString("hardwareRevision", device->hardware_revision());
1020 dictionary->SetString("prlVersion", 1054 dictionary->SetString("prlVersion",
1021 base::StringPrintf("%u", device->prl_version())); 1055 base::StringPrintf("%u", device->prl_version()));
1022 dictionary->SetString("meid", device->meid()); 1056 dictionary->SetString("meid", device->meid());
1023 dictionary->SetString("imei", device->imei()); 1057 dictionary->SetString("imei", device->imei());
1024 dictionary->SetString("mdn", device->mdn()); 1058 dictionary->SetString("mdn", device->mdn());
1025 dictionary->SetString("imsi", device->imsi()); 1059 dictionary->SetString("imsi", device->imsi());
1026 dictionary->SetString("esn", device->esn()); 1060 dictionary->SetString("esn", device->esn());
1027 dictionary->SetString("min", device->min()); 1061 dictionary->SetString("min", device->min());
1028 dictionary->SetBoolean("gsm", 1062 dictionary->SetBoolean("gsm",
1029 device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); 1063 device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM);
1030 dictionary->SetBoolean("simCardLockEnabled", 1064 SetValueDictionary(
1031 device->sim_pin_required() == chromeos::SIM_PIN_REQUIRED); 1065 dictionary, "simCardLockEnabled",
1066 Value::CreateBooleanValue(
1067 device->sim_pin_required() == chromeos::SIM_PIN_REQUIRED),
1068 cellular_propety_ui_data);
1032 1069
1033 chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance(); 1070 chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance();
1034 if (config->IsReady()) { 1071 if (config->IsReady()) {
1035 std::string carrier_id = cros_->GetCellularHomeCarrierId(); 1072 std::string carrier_id = cros_->GetCellularHomeCarrierId();
1036 const chromeos::MobileConfig::Carrier* carrier = 1073 const chromeos::MobileConfig::Carrier* carrier =
1037 config->GetCarrier(carrier_id); 1074 config->GetCarrier(carrier_id);
1038 if (carrier && !carrier->top_up_url().empty()) 1075 if (carrier && !carrier->top_up_url().empty())
1039 dictionary->SetString("carrierUrl", carrier->top_up_url()); 1076 dictionary->SetString("carrierUrl", carrier->top_up_url());
1040 } 1077 }
1041 1078
1042 const chromeos::CellularApnList& apn_list = device->provider_apn_list(); 1079 const chromeos::CellularApnList& apn_list = device->provider_apn_list();
1043 ListValue* apn_list_value = new ListValue(); 1080 ListValue* apn_list_value = new ListValue();
1044 for (chromeos::CellularApnList::const_iterator it = apn_list.begin(); 1081 for (chromeos::CellularApnList::const_iterator it = apn_list.begin();
1045 it != apn_list.end(); ++it) { 1082 it != apn_list.end(); ++it) {
1046 apn_list_value->Append(CreateDictionaryFromCellularApn(*it)); 1083 apn_list_value->Append(CreateDictionaryFromCellularApn(*it));
1047 } 1084 }
1048 dictionary->Set("providerApnList", apn_list_value); 1085 SetValueDictionary(dictionary, "providerApnList", apn_list_value,
1086 cellular_propety_ui_data);
1049 } 1087 }
1050 1088
1051 SetActivationButtonVisibility(cellular, dictionary); 1089 SetActivationButtonVisibility(cellular, dictionary);
1052 } 1090 }
1053 1091
1054 void InternetOptionsHandler::PopulateVPNDetails( 1092 void InternetOptionsHandler::PopulateVPNDetails(
1055 const chromeos::VirtualNetwork* vpn, 1093 const chromeos::VirtualNetwork* vpn,
1056 DictionaryValue* dictionary) { 1094 DictionaryValue* dictionary) {
1057 dictionary->SetString("service_name", vpn->name()); 1095 dictionary->SetString("service_name", vpn->name());
1058 bool remembered = (vpn->profile_type() != chromeos::PROFILE_NONE); 1096 bool remembered = (vpn->profile_type() != chromeos::PROFILE_NONE);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 dictionary->Set("wirelessList", GetWirelessList()); 1363 dictionary->Set("wirelessList", GetWirelessList());
1326 dictionary->Set("vpnList", GetVPNList()); 1364 dictionary->Set("vpnList", GetVPNList());
1327 dictionary->Set("rememberedList", GetRememberedList()); 1365 dictionary->Set("rememberedList", GetRememberedList());
1328 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available()); 1366 dictionary->SetBoolean("wifiAvailable", cros_->wifi_available());
1329 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy()); 1367 dictionary->SetBoolean("wifiBusy", cros_->wifi_busy());
1330 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled()); 1368 dictionary->SetBoolean("wifiEnabled", cros_->wifi_enabled());
1331 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available()); 1369 dictionary->SetBoolean("cellularAvailable", cros_->cellular_available());
1332 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); 1370 dictionary->SetBoolean("cellularBusy", cros_->cellular_busy());
1333 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); 1371 dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled());
1334 } 1372 }
1373
1374 void InternetOptionsHandler::SetValueDictionary(
1375 DictionaryValue* settings,
1376 const char* key,
1377 base::Value* value,
1378 const chromeos::NetworkPropertyUIData& ui_data) {
1379 DictionaryValue* value_dict = new DictionaryValue();
1380 // DictionaryValue::Set() takes ownership of |value|.
1381 if (value)
1382 value_dict->Set("value", value);
1383 const base::Value* default_value = ui_data.default_value();
1384 if (default_value)
1385 value_dict->Set("default", default_value->DeepCopy());
1386 if (ui_data.managed())
1387 value_dict->SetString("controlledBy", "policy");
1388 else if (ui_data.recommended())
1389 value_dict->SetString("controlledBy", "recommended");
1390 settings->Set(key, value_dict);
1391 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/internet_options_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698