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 0d44f404c691c79492d3547c4c43919aa10e9841..eaedff2e9b79ace19ec39985b0e20c033472ee24 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(chromeos::NetworkUIData::IsManaged(network)); |
| } |
| NetworkInfoDictionary::NetworkInfoDictionary( |
| @@ -182,6 +189,8 @@ NetworkInfoDictionary::NetworkInfoDictionary( |
| set_remembered(true); |
| set_shared(remembered->profile_type() == chromeos::PROFILE_SHARED); |
| set_needs_new_plan(false); |
| + set_policy_managed( |
| + network ? chromeos::NetworkUIData::IsManaged(network) : false); |
| } |
| DictionaryValue* NetworkInfoDictionary::BuildDictionary() { |
| @@ -227,6 +236,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 +307,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)); |
| @@ -882,6 +895,9 @@ void InternetOptionsHandler::PopulateDictionaryDetails( |
| 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,16 @@ 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()); |
| } |
| + SetValueDictionary(&dictionary, "ipconfigDHCP", ipconfig_dhcp.release(), |
| + chromeos::NetworkPropertyUIData(network, NULL)); |
| + SetValueDictionary(&dictionary, "ipconfigStatic", ipconfig_static.release(), |
| + chromeos::NetworkPropertyUIData(network, NULL)); |
| + |
| chromeos::ConnectionType type = network->type(); |
| dictionary.SetInteger("type", type); |
| dictionary.SetString("servicePath", network->service_path()); |
| @@ -915,12 +936,24 @@ void InternetOptionsHandler::PopulateDictionaryDetails( |
| if (network_profile == chromeos::PROFILE_USER) { |
| dictionary.SetBoolean("showPreferred", true); |
| - dictionary.SetBoolean("preferred", network->preferred()); |
| + SetValueDictionary(&dictionary, "preferred", |
| + Value::CreateBooleanValue(network->preferred()), |
| + chromeos::NetworkPropertyUIData( |
| + network, |
| + chromeos::NetworkUIData::kPropertyPreferred)); |
| } else { |
| dictionary.SetBoolean("showPreferred", false); |
| - dictionary.SetBoolean("preferred", false); |
| + SetValueDictionary(&dictionary, "preferred", |
| + Value::CreateBooleanValue(network->preferred()), |
| + chromeos::NetworkPropertyUIData( |
| + network, |
| + chromeos::NetworkUIData::kPropertyPreferred)); |
| } |
| - dictionary.SetBoolean("autoConnect", network->auto_connect()); |
| + SetValueDictionary(&dictionary, "autoConnect", |
| + Value::CreateBooleanValue(network->auto_connect()), |
| + chromeos::NetworkPropertyUIData( |
| + network, |
| + chromeos::NetworkUIData::kPropertyAutoConnect)); |
| if (type == chromeos::TYPE_WIFI) { |
| dictionary.SetBoolean("deviceConnected", cros_->wifi_connected()); |
| @@ -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), |
| + chromeos::NetworkPropertyUIData(cellular, NULL)); |
| 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, |
| + chromeos::NetworkPropertyUIData(cellular, NULL)); |
| } |
| SetActivationButtonVisibility(cellular, dictionary); |
| @@ -1332,3 +1369,30 @@ 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(); |
| + // DictionaryValue::Set() takes ownership of |value|. |
| + if (value) |
| + value_dict->Set("value", value); |
| + 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()) { |
|
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.
|
| + 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); |
| +} |