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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/options/chromeos/internet_options_handler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c6339d789283f8aa38bbcd8f656d82f0287a4ce4 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,18 @@ 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());
}
+ chromeos::NetworkPropertyUIData ipconfig_dhcp_ui_data(network, NULL);
+ SetValueDictionary(&dictionary, "ipconfigDHCP", ipconfig_dhcp.release(),
+ ipconfig_dhcp_ui_data);
+ chromeos::NetworkPropertyUIData ipconfig_static_ui_data(network, NULL);
+ SetValueDictionary(&dictionary, "ipconfigStatic", ipconfig_static.release(),
+ ipconfig_static_ui_data);
+
chromeos::ConnectionType type = network->type();
dictionary.SetInteger("type", type);
dictionary.SetString("servicePath", network->service_path());
@@ -913,14 +936,24 @@ void InternetOptionsHandler::PopulateDictionaryDetails(
dictionary.SetBoolean("showStaticIPConfig", staticIPConfig &&
(type == chromeos::TYPE_WIFI || type == chromeos::TYPE_ETHERNET));
+ chromeos::NetworkPropertyUIData preferred_ui_data(
+ network, chromeos::NetworkUIData::kPropertyPreferred);
if (network_profile == chromeos::PROFILE_USER) {
dictionary.SetBoolean("showPreferred", true);
- dictionary.SetBoolean("preferred", network->preferred());
+ SetValueDictionary(&dictionary, "preferred",
+ Value::CreateBooleanValue(network->preferred()),
+ preferred_ui_data);
} else {
dictionary.SetBoolean("showPreferred", false);
- dictionary.SetBoolean("preferred", false);
+ SetValueDictionary(&dictionary, "preferred",
+ Value::CreateBooleanValue(network->preferred()),
+ preferred_ui_data);
}
- dictionary.SetBoolean("autoConnect", network->auto_connect());
+ chromeos::NetworkPropertyUIData auto_connect_ui_data(
+ network, chromeos::NetworkUIData::kPropertyAutoConnect);
+ SetValueDictionary(&dictionary, "autoConnect",
+ Value::CreateBooleanValue(network->auto_connect()),
+ auto_connect_ui_data);
if (type == chromeos::TYPE_WIFI) {
dictionary.SetBoolean("deviceConnected", cros_->wifi_connected());
@@ -1013,6 +1046,7 @@ void InternetOptionsHandler::PopulateCellularDetails(
const chromeos::NetworkDevice* device =
cros_->FindNetworkDeviceByPath(cellular->device_path());
if (device) {
+ chromeos::NetworkPropertyUIData cellular_propety_ui_data(cellular, NULL);
dictionary->SetString("manufacturer", device->manufacturer());
dictionary->SetString("modelId", device->model_id());
dictionary->SetString("firmwareRevision", device->firmware_revision());
@@ -1027,8 +1061,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),
+ cellular_propety_ui_data);
chromeos::MobileConfig* config = chromeos::MobileConfig::GetInstance();
if (config->IsReady()) {
@@ -1045,7 +1082,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,
+ cellular_propety_ui_data);
}
SetActivationButtonVisibility(cellular, dictionary);
@@ -1332,3 +1370,22 @@ 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());
+ if (ui_data.managed())
+ value_dict->SetString("controlledBy", "policy");
+ else if (ui_data.recommended())
+ value_dict->SetString("controlledBy", "recommended");
+ settings->Set(key, value_dict);
+}
« 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