Chromium Code Reviews| Index: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc |
| diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc |
| index 1e5115d2de09fcd2749725d4bbdb165b1b808c1e..b211d2eec4d7335df4e71812852a9f4c85348b4b 100644 |
| --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc |
| +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc |
| @@ -70,6 +70,7 @@ const char kNetworkInfoKeyNetworkStatus[] = "networkStatus"; |
| const char kNetworkInfoKeyNetworkType[] = "networkType"; |
| const char kNetworkInfoKeyRemembered[] = "remembered"; |
| const char kNetworkInfoKeyServicePath[] = "servicePath"; |
| +const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; |
| // A helper class for building network information dictionaries to be sent to |
| // the webui code. |
| @@ -123,6 +124,9 @@ class NetworkInfoDictionary { |
| void set_needs_new_plan(bool needs_new_plan) { |
| needs_new_plan_ = needs_new_plan; |
| } |
| + void set_policy_managed(bool policy_managed) { |
| + policy_managed_ = policy_managed; |
| + } |
| // Builds the DictionaryValue representation from the previously set |
| // parameters. Ownership of the returned pointer is transferred to the caller. |
| @@ -141,6 +145,7 @@ class NetworkInfoDictionary { |
| bool shared_; |
| chromeos::ActivationState activation_state_; |
| bool needs_new_plan_; |
| + bool policy_managed_; |
| DISALLOW_COPY_AND_ASSIGN(NetworkInfoDictionary); |
| }; |
| @@ -153,6 +158,7 @@ NetworkInfoDictionary::NetworkInfoDictionary() { |
| set_shared(false); |
| set_activation_state(chromeos::ACTIVATION_STATE_UNKNOWN); |
| set_needs_new_plan(false); |
| + set_policy_managed(false); |
| } |
| NetworkInfoDictionary::NetworkInfoDictionary(const chromeos::Network* network) { |
| @@ -166,6 +172,7 @@ NetworkInfoDictionary::NetworkInfoDictionary(const chromeos::Network* network) { |
| set_remembered(false); |
| set_shared(false); |
| set_needs_new_plan(false); |
| + set_policy_managed(network->IsManagedByPolicy()); |
| } |
| NetworkInfoDictionary::NetworkInfoDictionary( |
| @@ -182,6 +189,7 @@ NetworkInfoDictionary::NetworkInfoDictionary( |
| set_remembered(true); |
| set_shared(remembered->profile_type() == chromeos::PROFILE_SHARED); |
| set_needs_new_plan(false); |
| + set_policy_managed(network ? network->IsManagedByPolicy() : false); |
| } |
| DictionaryValue* NetworkInfoDictionary::BuildDictionary() { |
| @@ -227,6 +235,7 @@ DictionaryValue* NetworkInfoDictionary::BuildDictionary() { |
| static_cast<int>(connection_type_)); |
| network_info->SetBoolean(kNetworkInfoKeyRemembered, remembered_); |
| network_info->SetString(kNetworkInfoKeyServicePath, service_path_); |
| + network_info->SetBoolean(kNetworkInfoKeyPolicyManaged, policy_managed_); |
| return network_info.release(); |
| } |
| @@ -297,6 +306,9 @@ void InternetOptionsHandler::GetLocalizedValues( |
| l10n_util::GetStringUTF16( |
| IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CHANGE_PROXY_BUTTON)); |
| + localized_strings->SetString("managedNetwork", |
| + l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_MANAGED_NETWORK)); |
| + |
| localized_strings->SetString("wifiNetworkTabLabel", |
| l10n_util::GetStringUTF16( |
| IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIFI)); |
| @@ -876,12 +888,16 @@ void InternetOptionsHandler::PopulateDictionaryDetails( |
| } |
| DictionaryValue dictionary; |
| + chromeos::NetworkPropertyUIData property_ui_data; |
|
stevenjb
2011/11/29 07:23:19
nit: declare this closer to where it is used?
Mattias Nissler (ping if slow)
2011/11/29 14:48:50
Done.
|
| std::string hardware_address; |
| chromeos::NetworkIPConfigVector ipconfigs = cros_->GetIPConfigs( |
| network->device_path(), &hardware_address, |
| chromeos::NetworkLibrary::FORMAT_COLON_SEPARATED_HEX); |
| if (!hardware_address.empty()) |
| dictionary.SetString("hardwareAddress", hardware_address); |
| + |
| + scoped_ptr<DictionaryValue> ipconfig_dhcp; |
| + scoped_ptr<DictionaryValue> ipconfig_static; |
| for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); |
| it != ipconfigs.end(); ++it) { |
| const chromeos::NetworkIPConfig& ipconfig = *it; |
| @@ -891,11 +907,17 @@ void InternetOptionsHandler::PopulateDictionaryDetails( |
| ipconfig_dict->SetString("gateway", ipconfig.gateway); |
| ipconfig_dict->SetString("dns", ipconfig.name_servers); |
| if (ipconfig.type == chromeos::IPCONFIG_TYPE_DHCP) |
| - dictionary.Set("ipconfigDHCP", ipconfig_dict.release()); |
| + ipconfig_dhcp.reset(ipconfig_dict.release()); |
| else if (ipconfig.type == chromeos::IPCONFIG_TYPE_IPV4) |
| - dictionary.Set("ipconfigStatic", ipconfig_dict.release()); |
| + ipconfig_static.reset(ipconfig_dict.release()); |
| } |
| + network->GetUIDataForIPConfig(&property_ui_data); |
| + SetValueDictionary(&dictionary, "ipconfigDHCP", ipconfig_dhcp.release(), |
| + property_ui_data); |
| + SetValueDictionary(&dictionary, "ipconfigStatic", ipconfig_static.release(), |
| + property_ui_data); |
| + |
| chromeos::ConnectionType type = network->type(); |
| dictionary.SetInteger("type", type); |
| dictionary.SetString("servicePath", network->service_path()); |
| @@ -913,14 +935,23 @@ void InternetOptionsHandler::PopulateDictionaryDetails( |
| dictionary.SetBoolean("showStaticIPConfig", staticIPConfig && |
| (type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET)); |
| + network->GetUIDataForPreferred(&property_ui_data); |
| if (network_profile == chromeos::PROFILE_USER) { |
| dictionary.SetBoolean("showPreferred", true); |
| - dictionary.SetBoolean("preferred", network->preferred()); |
| + SetValueDictionary(&dictionary, "preferred", |
| + Value::CreateBooleanValue(network->preferred()), |
| + property_ui_data); |
| } else { |
| dictionary.SetBoolean("showPreferred", false); |
| - dictionary.SetBoolean("preferred", false); |
| + network->GetUIDataForPreferred(&property_ui_data); |
| + SetValueDictionary(&dictionary, "preferred", |
| + Value::CreateBooleanValue(network->preferred()), |
| + property_ui_data); |
| } |
| - dictionary.SetBoolean("autoConnect", network->auto_connect()); |
| + network->GetUIDataForAutoConnect(&property_ui_data); |
|
stevenjb
2011/11/29 07:23:19
I found this re-use of a single property_ui_data c
Mattias Nissler (ping if slow)
2011/11/29 14:48:50
Done.
|
| + SetValueDictionary(&dictionary, "autoConnect", |
| + Value::CreateBooleanValue(network->auto_connect()), |
| + property_ui_data); |
| if (type == chromeos::TYPE_WIFI) { |
| dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); |
| @@ -1010,6 +1041,8 @@ void InternetOptionsHandler::PopulateCellularDetails( |
| CreateDictionaryFromCellularApn(cellular->last_good_apn())); |
| // Device settings. |
| + chromeos::NetworkPropertyUIData property_ui_data; |
| + property_ui_data.UpdateFromNetwork(cellular, NULL); |
| const chromeos::NetworkDevice* device = |
| cros_->FindNetworkDeviceByPath(cellular->device_path()); |
| if (device) { |
| @@ -1027,8 +1060,11 @@ void InternetOptionsHandler::PopulateCellularDetails( |
| dictionary->SetString("min", device->min()); |
| dictionary->SetBoolean("gsm", |
| device->technology_family() == chromeos::TECHNOLOGY_FAMILY_GSM); |
| - dictionary->SetBoolean("simCardLockEnabled", |
| - device->sim_pin_required() == chromeos::SIM_PIN_REQUIRED); |
| + SetValueDictionary( |
| + dictionary, "simCardLockEnabled", |
| + Value::CreateBooleanValue( |
| + device->sim_pin_required() == chromeos::SIM_PIN_REQUIRED), |
| + property_ui_data); |
| chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance(); |
| if (config->IsReady()) { |
| @@ -1045,7 +1081,8 @@ void InternetOptionsHandler::PopulateCellularDetails( |
| it != apn_list.end(); ++it) { |
| apn_list_value->Append(CreateDictionaryFromCellularApn(*it)); |
| } |
| - dictionary->Set("providerApnList", apn_list_value); |
| + SetValueDictionary(dictionary, "providerApnList", apn_list_value, |
| + property_ui_data); |
| } |
| SetActivationButtonVisibility(cellular, dictionary); |
| @@ -1332,3 +1369,29 @@ void InternetOptionsHandler::FillNetworkInfo(DictionaryValue* dictionary) { |
| dictionary->SetBoolean("cellularBusy", cros_->cellular_busy()); |
| dictionary->SetBoolean("cellularEnabled", cros_->cellular_enabled()); |
| } |
| + |
| +void InternetOptionsHandler::SetValueDictionary( |
| + DictionaryValue* settings, |
| + const char* key, |
| + base::Value* value, |
| + const chromeos::NetworkPropertyUIData& ui_data) { |
| + DictionaryValue* value_dict = new DictionaryValue(); |
| + if (value) |
| + value_dict->Set("value", value); |
|
stevenjb
2011/11/29 07:23:19
value_dict takes ownership of |value|, correct? I
Mattias Nissler (ping if slow)
2011/11/29 14:48:50
Yes. I guess I already got used to it :) Added a c
|
| + const base::Value* default_value = ui_data.default_value(); |
| + if (default_value) |
| + value_dict->Set("default", default_value->DeepCopy()); |
| + std::string controlled_by; |
| + switch (ui_data.controller()) { |
| + case chromeos::NetworkPropertyUIData::CONTROLLER_POLICY: |
| + controlled_by = "policy"; |
| + break; |
| + case chromeos::NetworkPropertyUIData::CONTROLLER_USER: |
| + if (default_value) |
| + controlled_by = "recommended"; |
| + break; |
| + } |
| + if (!controlled_by.empty()) |
| + value_dict->SetString("controlledBy", controlled_by); |
| + settings->Set(key, value_dict); |
| +} |