Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 26 matching lines...) Expand all Loading... | |
| 37 #include "chromeos/network/network_device_handler.h" | 37 #include "chromeos/network/network_device_handler.h" |
| 38 #include "chromeos/network/network_event_log.h" | 38 #include "chromeos/network/network_event_log.h" |
| 39 #include "chromeos/network/network_ip_config.h" | 39 #include "chromeos/network/network_ip_config.h" |
| 40 #include "chromeos/network/network_profile.h" | 40 #include "chromeos/network/network_profile.h" |
| 41 #include "chromeos/network/network_profile_handler.h" | 41 #include "chromeos/network/network_profile_handler.h" |
| 42 #include "chromeos/network/network_state.h" | 42 #include "chromeos/network/network_state.h" |
| 43 #include "chromeos/network/network_state_handler.h" | 43 #include "chromeos/network/network_state_handler.h" |
| 44 #include "chromeos/network/network_util.h" | 44 #include "chromeos/network/network_util.h" |
| 45 #include "chromeos/network/onc/onc_signature.h" | 45 #include "chromeos/network/onc/onc_signature.h" |
| 46 #include "chromeos/network/onc/onc_translator.h" | 46 #include "chromeos/network/onc/onc_translator.h" |
| 47 #include "chromeos/network/onc/onc_utils.h" | |
| 47 #include "components/onc/onc_constants.h" | 48 #include "components/onc/onc_constants.h" |
| 48 #include "content/public/browser/user_metrics.h" | 49 #include "content/public/browser/user_metrics.h" |
| 49 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
| 50 #include "content/public/browser/web_ui.h" | 51 #include "content/public/browser/web_ui.h" |
| 51 #include "grit/ash_resources.h" | 52 #include "grit/ash_resources.h" |
| 52 #include "grit/ui_chromeos_resources.h" | 53 #include "grit/ui_chromeos_resources.h" |
| 53 #include "third_party/cros_system_api/dbus/service_constants.h" | 54 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 54 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
| 55 #include "ui/base/webui/web_ui_util.h" | 56 #include "ui/base/webui/web_ui_util.h" |
| 56 #include "ui/chromeos/network/network_icon.h" | 57 #include "ui/chromeos/network/network_icon.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 119 const char kSetPreferNetworkMessage[] = "setPreferNetwork"; | 120 const char kSetPreferNetworkMessage[] = "setPreferNetwork"; |
| 120 const char kSetServerHostname[] = "setServerHostname"; | 121 const char kSetServerHostname[] = "setServerHostname"; |
| 121 const char kSetSimCardLockMessage[] = "setSimCardLock"; | 122 const char kSetSimCardLockMessage[] = "setSimCardLock"; |
| 122 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; | 123 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; |
| 123 | 124 |
| 124 // These are strings used to communicate with JavaScript. | 125 // These are strings used to communicate with JavaScript. |
| 125 const char kTagActivate[] = "activate"; | 126 const char kTagActivate[] = "activate"; |
| 126 const char kTagActivationState[] = "activationState"; | 127 const char kTagActivationState[] = "activationState"; |
| 127 const char kTagAddConnection[] = "add"; | 128 const char kTagAddConnection[] = "add"; |
| 128 const char kTagApn[] = "apn"; | 129 const char kTagApn[] = "apn"; |
| 129 const char kTagAutoConnect[] = "autoConnect"; | |
| 130 const char kTagCarrierSelectFlag[] = "showCarrierSelect"; | 130 const char kTagCarrierSelectFlag[] = "showCarrierSelect"; |
| 131 const char kTagCarrierUrl[] = "carrierUrl"; | 131 const char kTagCarrierUrl[] = "carrierUrl"; |
| 132 const char kTagCellularAvailable[] = "cellularAvailable"; | 132 const char kTagCellularAvailable[] = "cellularAvailable"; |
| 133 const char kTagCellularEnabled[] = "cellularEnabled"; | 133 const char kTagCellularEnabled[] = "cellularEnabled"; |
| 134 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; | 134 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; |
| 135 const char kTagConfigure[] = "configure"; | 135 const char kTagConfigure[] = "configure"; |
| 136 const char kTagConnect[] = "connect"; | 136 const char kTagConnect[] = "connect"; |
| 137 const char kTagControlledBy[] = "controlledBy"; | 137 const char kTagControlledBy[] = "controlledBy"; |
| 138 const char kTagDeviceConnected[] = "deviceConnected"; | 138 const char kTagDeviceConnected[] = "deviceConnected"; |
| 139 const char kTagDisconnect[] = "disconnect"; | 139 const char kTagDisconnect[] = "disconnect"; |
| 140 const char kTagErrorState[] = "errorState"; | 140 const char kTagErrorMessage[] = "errorMessage"; |
| 141 const char kTagForget[] = "forget"; | 141 const char kTagForget[] = "forget"; |
| 142 const char kTagIdentity[] = "identity"; | |
| 143 const char kTagLanguage[] = "language"; | 142 const char kTagLanguage[] = "language"; |
| 144 const char kTagLastGoodApn[] = "lastGoodApn"; | 143 const char kTagLastGoodApn[] = "lastGoodApn"; |
| 145 const char kTagLocalizedName[] = "localizedName"; | 144 const char kTagLocalizedName[] = "localizedName"; |
| 146 const char kTagName[] = "name"; | 145 const char kTagName[] = "name"; |
| 147 const char kTagNameServersGoogle[] = "nameServersGoogle"; | 146 const char kTagNameServersGoogle[] = "nameServersGoogle"; |
| 148 const char kTagNameServerType[] = "nameServerType"; | 147 const char kTagNameServerType[] = "nameServerType"; |
| 149 const char kTagNetworkId[] = "networkId"; | 148 const char kTagNetworkId[] = "networkId"; |
| 150 const char kTagOptions[] = "options"; | 149 const char kTagOptions[] = "options"; |
| 151 const char kTagPassword[] = "password"; | 150 const char kTagPassword[] = "password"; |
| 152 const char kTagPolicy[] = "policy"; | 151 const char kTagPolicy[] = "policy"; |
| 153 const char kTagPreferred[] = "preferred"; | 152 const char kTagPreferred[] = "preferred"; |
| 154 const char kTagProviderType[] = "providerType"; | 153 const char kTagProviderType[] = "providerType"; |
| 155 const char kTagProviderApnList[] = "providerApnList"; | 154 const char kTagProviderApnList[] = "providerApnList"; |
| 156 const char kTagRecommended[] = "recommended"; | 155 const char kTagRecommended[] = "recommended"; |
| 157 const char kTagRecommendedValue[] = "recommendedValue"; | 156 const char kTagRecommendedValue[] = "recommendedValue"; |
| 158 const char kTagRemembered[] = "remembered"; | 157 const char kTagRemembered[] = "remembered"; |
| 159 const char kTagRememberedList[] = "rememberedList"; | 158 const char kTagRememberedList[] = "rememberedList"; |
| 160 const char kTagRestrictedPool[] = "restrictedPool"; | 159 const char kTagRestrictedPool[] = "restrictedPool"; |
| 161 const char kTagRoamingState[] = "roamingState"; | 160 const char kTagRoamingState[] = "roamingState"; |
| 162 const char kTagServerHostname[] = "serverHostname"; | 161 const char kTagServerHostname[] = "serverHostname"; |
| 163 const char kTagCarriers[] = "carriers"; | 162 const char kTagCarriers[] = "carriers"; |
| 164 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; | 163 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; |
| 165 const char kTagShared[] = "shared"; | 164 const char kTagShared[] = "shared"; |
| 166 const char kTagShowActivateButton[] = "showActivateButton"; | 165 const char kTagShowActivateButton[] = "showActivateButton"; |
| 167 const char kTagShowStaticIPConfig[] = "showStaticIPConfig"; | |
| 168 const char kTagShowViewAccountButton[] = "showViewAccountButton"; | 166 const char kTagShowViewAccountButton[] = "showViewAccountButton"; |
| 169 const char kTagSimCardLockEnabled[] = "simCardLockEnabled"; | 167 const char kTagSimCardLockEnabled[] = "simCardLockEnabled"; |
| 170 const char kTagSupportUrl[] = "supportUrl"; | 168 const char kTagSupportUrl[] = "supportUrl"; |
| 171 const char kTagTrue[] = "true"; | 169 const char kTagTrue[] = "true"; |
| 172 const char kTagUsername[] = "username"; | 170 const char kTagUsername[] = "username"; |
| 173 const char kTagValue[] = "value"; | 171 const char kTagValue[] = "value"; |
| 174 const char kTagVpnList[] = "vpnList"; | 172 const char kTagVpnList[] = "vpnList"; |
| 175 const char kTagWifiAvailable[] = "wifiAvailable"; | 173 const char kTagWifiAvailable[] = "wifiAvailable"; |
| 176 const char kTagWifiEnabled[] = "wifiEnabled"; | 174 const char kTagWifiEnabled[] = "wifiEnabled"; |
| 177 const char kTagWimaxAvailable[] = "wimaxAvailable"; | 175 const char kTagWimaxAvailable[] = "wimaxAvailable"; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 288 std::string name_servers; | 286 std::string name_servers; |
| 289 if (shill_properties.GetStringWithoutPathExpansion( | 287 if (shill_properties.GetStringWithoutPathExpansion( |
| 290 name_servers_key, &name_servers)) { | 288 name_servers_key, &name_servers)) { |
| 291 ip_info_dict->SetString(kIpConfigNameServers, name_servers); | 289 ip_info_dict->SetString(kIpConfigNameServers, name_servers); |
| 292 VLOG(2) << "Found " << name_servers_key << ": " << name_servers; | 290 VLOG(2) << "Found " << name_servers_key << ": " << name_servers; |
| 293 } | 291 } |
| 294 | 292 |
| 295 return ip_info_dict.release(); | 293 return ip_info_dict.release(); |
| 296 } | 294 } |
| 297 | 295 |
| 298 // Decorate dictionary |value_dict| with policy information from |ui_data|. | |
| 299 void DecorateValueDictionary(const NetworkPropertyUIData& ui_data, | |
| 300 const base::Value& value, | |
| 301 base::DictionaryValue* value_dict) { | |
| 302 const base::Value* recommended_value = ui_data.default_value(); | |
| 303 if (ui_data.IsManaged()) | |
| 304 value_dict->SetString(kTagControlledBy, kTagPolicy); | |
| 305 else if (recommended_value && recommended_value->Equals(&value)) | |
| 306 value_dict->SetString(kTagControlledBy, kTagRecommended); | |
| 307 | |
| 308 if (recommended_value) | |
| 309 value_dict->Set(kTagRecommendedValue, recommended_value->DeepCopy()); | |
| 310 } | |
| 311 | |
| 312 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does and | 296 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does and |
| 313 // store it under |key| in |settings|. Takes ownership of |value|. | 297 // store it under |key| in |settings|. Takes ownership of |value|. |
| 314 void SetValueDictionary(base::DictionaryValue* settings, | 298 void SetValueDictionary(const char* key, |
| 315 const char* key, | |
| 316 base::Value* value, | 299 base::Value* value, |
| 317 const NetworkPropertyUIData& ui_data) { | 300 const NetworkPropertyUIData& ui_data, |
| 301 base::DictionaryValue* settings) { | |
| 318 base::DictionaryValue* dict = new base::DictionaryValue(); | 302 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 319 // DictionaryValue::Set() takes ownership of |value|. | 303 // DictionaryValue::Set() takes ownership of |value|. |
| 320 dict->Set(kTagValue, value); | 304 dict->Set(kTagValue, value); |
| 321 settings->Set(key, dict); | 305 settings->Set(key, dict); |
| 322 DecorateValueDictionary(ui_data, *value, dict); | 306 |
| 307 const base::Value* recommended_value = ui_data.default_value(); | |
| 308 if (ui_data.IsManaged()) | |
| 309 dict->SetString(kTagControlledBy, kTagPolicy); | |
| 310 else if (recommended_value && recommended_value->Equals(value)) | |
| 311 dict->SetString(kTagControlledBy, kTagRecommended); | |
| 312 | |
| 313 if (recommended_value) | |
| 314 dict->Set(kTagRecommendedValue, recommended_value->DeepCopy()); | |
| 323 } | 315 } |
| 324 | 316 |
| 325 // Creates a decorated dictionary like SetValueDictionary does, but extended for | 317 const char* GetOncSourceString(::onc::ONCSource onc_source) { |
| 326 // the Autoconnect property, which respects additionally global network policy. | 318 if (onc_source == ::onc::ONC_SOURCE_DEVICE_POLICY) |
| 327 void SetAutoconnectValueDictionary(bool network_is_private, | 319 return ::onc::kAugmentationDevicePolicy; |
| 328 ::onc::ONCSource onc_source, | 320 return ::onc::kAugmentationUserPolicy; |
| 329 bool current_autoconnect, | 321 } |
| 330 const NetworkPropertyUIData& ui_data, | 322 |
| 331 base::DictionaryValue* settings) { | 323 // Creates a GetManagedProperties style dictionary and adds it to |settings|. |
| 324 // |default_value| represents either the recommended value if |recommended| | |
| 325 // is true, or the enforced value if |recommended| is false. | |
| 326 // Note(stevenjb): This is bridge code until we use GetManagedProperties to | |
| 327 // retrieve Shill properties. | |
| 328 void SetManagedValueDictionary(const char* key, | |
| 329 const base::Value* value, | |
| 330 ::onc::ONCSource onc_source, | |
| 331 bool recommended, | |
| 332 const base::Value* default_value, | |
| 333 base::DictionaryValue* settings) { | |
| 332 base::DictionaryValue* dict = new base::DictionaryValue(); | 334 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 333 base::Value* value = new base::FundamentalValue(current_autoconnect); | 335 settings->Set(key, dict); |
| 334 // DictionaryValue::Set() takes ownership of |value|. | 336 dict->Set(::onc::kAugmentationActiveSetting, value->DeepCopy()); |
| 335 dict->Set(kTagValue, value); | 337 |
| 336 settings->Set(kTagAutoConnect, dict); | 338 if (onc_source == ::onc::ONC_SOURCE_NONE) |
| 337 if (onc_source != ::onc::ONC_SOURCE_USER_POLICY && | 339 return; |
| 338 onc_source != ::onc::ONC_SOURCE_DEVICE_POLICY) { | 340 |
| 339 // Autoconnect can be controlled by the GlobalNetworkConfiguration of the | 341 if (recommended) { |
| 340 // ONC policy. | 342 // If an ONC property is 'Recommended' it can be edited by the user. |
| 341 bool only_policy_autoconnect = | 343 std::string editable = onc_source == ::onc::ONC_SOURCE_DEVICE_POLICY |
| 342 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(network_is_private); | 344 ? ::onc::kAugmentationDeviceEditable |
| 343 if (only_policy_autoconnect) { | 345 : ::onc::kAugmentationUserEditable; |
| 344 dict->SetString(kTagControlledBy, kTagPolicy); | 346 dict->Set(editable, new base::FundamentalValue(true)); |
| 345 return; | 347 } |
| 348 if (default_value) { | |
| 349 std::string policy_source = GetOncSourceString(onc_source); | |
| 350 dict->Set(policy_source, default_value->DeepCopy()); | |
| 351 if (recommended && !value->Equals(default_value)) { | |
|
pneubeck (no reviews)
2014/08/06 19:52:06
nit: to get some more debugging support, maybe add
stevenjb
2014/08/06 20:22:52
DCHECK(value) seems reasonable, I can see that mis
| |
| 352 dict->SetString(::onc::kAugmentationUserSetting, value->DeepCopy()); | |
| 353 dict->SetString(::onc::kAugmentationEffectiveSetting, | |
| 354 ::onc::kAugmentationUserSetting); | |
| 355 } else { | |
| 356 dict->SetString(::onc::kAugmentationEffectiveSetting, policy_source); | |
| 346 } | 357 } |
| 347 } | 358 } |
| 348 DecorateValueDictionary(ui_data, *value, dict); | |
| 349 } | 359 } |
| 350 | 360 |
| 351 std::string CopyStringFromDictionary(const base::DictionaryValue& source, | 361 std::string CopyStringFromDictionary(const base::DictionaryValue& source, |
| 352 const std::string& src_key, | 362 const std::string& src_key, |
| 353 const std::string& dest_key, | 363 const std::string& dest_key, |
| 354 base::DictionaryValue* dest) { | 364 base::DictionaryValue* dest) { |
| 355 std::string string_value; | 365 std::string string_value; |
| 356 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) | 366 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) |
| 357 dest->SetStringWithoutPathExpansion(dest_key, string_value); | 367 dest->SetStringWithoutPathExpansion(dest_key, string_value); |
| 358 return string_value; | 368 return string_value; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 onc::FindPolicyForActiveUser(vpn->guid(), &onc_source); | 404 onc::FindPolicyForActiveUser(vpn->guid(), &onc_source); |
| 395 | 405 |
| 396 NetworkPropertyUIData hostname_ui_data; | 406 NetworkPropertyUIData hostname_ui_data; |
| 397 hostname_ui_data.ParseOncProperty( | 407 hostname_ui_data.ParseOncProperty( |
| 398 onc_source, | 408 onc_source, |
| 399 onc, | 409 onc, |
| 400 ::onc::network_config::VpnProperty(::onc::vpn::kHost)); | 410 ::onc::network_config::VpnProperty(::onc::vpn::kHost)); |
| 401 std::string provider_host; | 411 std::string provider_host; |
| 402 provider_properties->GetStringWithoutPathExpansion( | 412 provider_properties->GetStringWithoutPathExpansion( |
| 403 shill::kHostProperty, &provider_host); | 413 shill::kHostProperty, &provider_host); |
| 404 SetValueDictionary(dictionary, kTagServerHostname, | 414 SetValueDictionary(kTagServerHostname, |
| 405 new base::StringValue(provider_host), | 415 new base::StringValue(provider_host), |
| 406 hostname_ui_data); | 416 hostname_ui_data, |
| 417 dictionary); | |
| 407 } | 418 } |
| 408 | 419 |
| 409 // Given a list of supported carrier's by the device, return the index of | 420 // Given a list of supported carrier's by the device, return the index of |
| 410 // the carrier the device is currently using. | 421 // the carrier the device is currently using. |
| 411 int FindCurrentCarrierIndex(const base::ListValue* carriers, | 422 int FindCurrentCarrierIndex(const base::ListValue* carriers, |
| 412 const DeviceState* device) { | 423 const DeviceState* device) { |
| 413 DCHECK(carriers); | 424 DCHECK(carriers); |
| 414 DCHECK(device); | 425 DCHECK(device); |
| 415 bool gsm = (device->technology_family() == shill::kTechnologyFamilyGsm); | 426 bool gsm = (device->technology_family() == shill::kTechnologyFamilyGsm); |
| 416 int index = 0; | 427 int index = 0; |
| 417 for (base::ListValue::const_iterator it = carriers->begin(); | 428 for (base::ListValue::const_iterator it = carriers->begin(); |
| 418 it != carriers->end(); ++it, ++index) { | 429 it != carriers->end(); ++it, ++index) { |
| 419 std::string value; | 430 std::string value; |
| 420 if (!(*it)->GetAsString(&value)) | 431 if (!(*it)->GetAsString(&value)) |
| 421 continue; | 432 continue; |
| 422 // For GSM devices the device name will be empty, so simply select | 433 // For GSM devices the device name will be empty, so simply select |
| 423 // the Generic UMTS carrier option if present. | 434 // the Generic UMTS carrier option if present. |
| 424 if (gsm && (value == shill::kCarrierGenericUMTS)) | 435 if (gsm && (value == shill::kCarrierGenericUMTS)) |
| 425 return index; | 436 return index; |
| 426 // For other carriers, the service name will match the carrier name. | 437 // For other carriers, the service name will match the carrier name. |
| 427 if (value == device->carrier()) | 438 if (value == device->carrier()) |
| 428 return index; | 439 return index; |
| 429 } | 440 } |
| 430 return -1; | 441 return -1; |
| 431 } | 442 } |
| 432 | 443 |
| 433 void PopulateWimaxDetails(const NetworkState* wimax, | |
| 434 const base::DictionaryValue& shill_properties, | |
| 435 base::DictionaryValue* dictionary) { | |
| 436 CopyStringFromDictionary( | |
| 437 shill_properties, shill::kEapIdentityProperty, kTagIdentity, dictionary); | |
| 438 } | |
| 439 | |
| 440 void CreateDictionaryFromCellularApn(const base::DictionaryValue* apn, | 444 void CreateDictionaryFromCellularApn(const base::DictionaryValue* apn, |
| 441 base::DictionaryValue* dictionary) { | 445 base::DictionaryValue* dictionary) { |
| 442 CopyStringFromDictionary(*apn, shill::kApnProperty, kTagApn, dictionary); | 446 CopyStringFromDictionary(*apn, shill::kApnProperty, kTagApn, dictionary); |
| 443 CopyStringFromDictionary( | 447 CopyStringFromDictionary( |
| 444 *apn, shill::kApnNetworkIdProperty, kTagNetworkId, dictionary); | 448 *apn, shill::kApnNetworkIdProperty, kTagNetworkId, dictionary); |
| 445 CopyStringFromDictionary( | 449 CopyStringFromDictionary( |
| 446 *apn, shill::kApnUsernameProperty, kTagUsername, dictionary); | 450 *apn, shill::kApnUsernameProperty, kTagUsername, dictionary); |
| 447 CopyStringFromDictionary( | 451 CopyStringFromDictionary( |
| 448 *apn, shill::kApnPasswordProperty, kTagPassword, dictionary); | 452 *apn, shill::kApnPasswordProperty, kTagPassword, dictionary); |
| 449 CopyStringFromDictionary(*apn, shill::kApnNameProperty, kTagName, dictionary); | 453 CopyStringFromDictionary(*apn, shill::kApnNameProperty, kTagName, dictionary); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 501 const DeviceState* device = | 505 const DeviceState* device = |
| 502 NetworkHandler::Get()->network_state_handler()->GetDeviceState( | 506 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
| 503 cellular->device_path()); | 507 cellular->device_path()); |
| 504 if (device) { | 508 if (device) { |
| 505 const base::DictionaryValue& device_properties = device->properties(); | 509 const base::DictionaryValue& device_properties = device->properties(); |
| 506 ::onc::ONCSource onc_source; | 510 ::onc::ONCSource onc_source; |
| 507 NetworkHandler::Get()->managed_network_configuration_handler()-> | 511 NetworkHandler::Get()->managed_network_configuration_handler()-> |
| 508 FindPolicyByGUID(LoginState::Get()->primary_user_hash(), | 512 FindPolicyByGUID(LoginState::Get()->primary_user_hash(), |
| 509 cellular->guid(), &onc_source); | 513 cellular->guid(), &onc_source); |
| 510 const NetworkPropertyUIData cellular_property_ui_data(onc_source); | 514 const NetworkPropertyUIData cellular_property_ui_data(onc_source); |
| 511 SetValueDictionary(dictionary, | 515 SetValueDictionary(kTagSimCardLockEnabled, |
| 512 kTagSimCardLockEnabled, | |
| 513 new base::FundamentalValue(device->sim_lock_enabled()), | 516 new base::FundamentalValue(device->sim_lock_enabled()), |
| 514 cellular_property_ui_data); | 517 cellular_property_ui_data, |
| 518 dictionary); | |
| 515 | 519 |
| 516 carrier_id = device->home_provider_id(); | 520 carrier_id = device->home_provider_id(); |
| 517 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); | 521 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); |
| 518 | 522 |
| 519 MobileConfig* config = MobileConfig::GetInstance(); | 523 MobileConfig* config = MobileConfig::GetInstance(); |
| 520 if (config->IsReady()) { | 524 if (config->IsReady()) { |
| 521 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); | 525 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); |
| 522 if (carrier && !carrier->top_up_url().empty()) | 526 if (carrier && !carrier->top_up_url().empty()) |
| 523 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); | 527 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); |
| 524 } | 528 } |
| 525 | 529 |
| 526 base::ListValue* apn_list_value = new base::ListValue(); | 530 base::ListValue* apn_list_value = new base::ListValue(); |
| 527 const base::ListValue* apn_list; | 531 const base::ListValue* apn_list; |
| 528 if (device_properties.GetListWithoutPathExpansion( | 532 if (device_properties.GetListWithoutPathExpansion( |
| 529 shill::kCellularApnListProperty, &apn_list)) { | 533 shill::kCellularApnListProperty, &apn_list)) { |
| 530 for (base::ListValue::const_iterator iter = apn_list->begin(); | 534 for (base::ListValue::const_iterator iter = apn_list->begin(); |
| 531 iter != apn_list->end(); | 535 iter != apn_list->end(); |
| 532 ++iter) { | 536 ++iter) { |
| 533 const base::DictionaryValue* dict; | 537 const base::DictionaryValue* dict; |
| 534 if ((*iter)->GetAsDictionary(&dict)) { | 538 if ((*iter)->GetAsDictionary(&dict)) { |
| 535 base::DictionaryValue* apn = new base::DictionaryValue; | 539 base::DictionaryValue* apn = new base::DictionaryValue; |
| 536 CreateDictionaryFromCellularApn(dict, apn); | 540 CreateDictionaryFromCellularApn(dict, apn); |
| 537 apn_list_value->Append(apn); | 541 apn_list_value->Append(apn); |
| 538 } | 542 } |
| 539 } | 543 } |
| 540 } | 544 } |
| 541 SetValueDictionary(dictionary, | 545 SetValueDictionary(kTagProviderApnList, |
| 542 kTagProviderApnList, | |
| 543 apn_list_value, | 546 apn_list_value, |
| 544 cellular_property_ui_data); | 547 cellular_property_ui_data, |
| 548 dictionary); | |
| 545 const base::ListValue* supported_carriers; | 549 const base::ListValue* supported_carriers; |
| 546 if (device_properties.GetListWithoutPathExpansion( | 550 if (device_properties.GetListWithoutPathExpansion( |
| 547 shill::kSupportedCarriersProperty, &supported_carriers)) { | 551 shill::kSupportedCarriersProperty, &supported_carriers)) { |
| 548 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); | 552 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); |
| 549 dictionary->SetInteger( | 553 dictionary->SetInteger( |
| 550 kTagCurrentCarrierIndex, | 554 kTagCurrentCarrierIndex, |
| 551 FindCurrentCarrierIndex(supported_carriers, device)); | 555 FindCurrentCarrierIndex(supported_carriers, device)); |
| 552 } else { | 556 } else { |
| 553 // In case of any error, set the current carrier tag to -1 indicating | 557 // In case of any error, set the current carrier tag to -1 indicating |
| 554 // to the JS code to fallback to a single carrier. | 558 // to the JS code to fallback to a single carrier. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 614 // TODO(stevenjb): Once we eliminate all references to Shill properties, | 618 // TODO(stevenjb): Once we eliminate all references to Shill properties, |
| 615 // we can switch to using managed_network_configuration_handler which | 619 // we can switch to using managed_network_configuration_handler which |
| 616 // includes Device properties for Cellular (and skip the call to | 620 // includes Device properties for Cellular (and skip the call to |
| 617 // onc::TranslateShillServiceToONCPart). For now we copy them over here. | 621 // onc::TranslateShillServiceToONCPart). For now we copy them over here. |
| 618 scoped_ptr<base::DictionaryValue> shill_properties_with_device( | 622 scoped_ptr<base::DictionaryValue> shill_properties_with_device( |
| 619 shill_properties.DeepCopy()); | 623 shill_properties.DeepCopy()); |
| 620 const DeviceState* device = | 624 const DeviceState* device = |
| 621 NetworkHandler::Get()->network_state_handler()->GetDeviceState( | 625 NetworkHandler::Get()->network_state_handler()->GetDeviceState( |
| 622 network->device_path()); | 626 network->device_path()); |
| 623 if (device) { | 627 if (device) { |
| 624 shill_properties_with_device->Set(shill::kDeviceProperty, | 628 shill_properties_with_device->SetWithoutPathExpansion( |
| 625 device->properties().DeepCopy()); | 629 shill::kDeviceProperty, device->properties().DeepCopy()); |
| 630 // Get the hardware MAC address from the DeviceState. | |
| 631 // (Note: this is done in ManagedNetworkConfigurationHandler but not | |
| 632 // in NetworkConfigurationHandler). | |
| 633 if (!device->mac_address().empty()) { | |
| 634 shill_properties_with_device->SetStringWithoutPathExpansion( | |
| 635 shill::kAddressProperty, device->mac_address()); | |
| 636 } | |
| 626 } | 637 } |
| 627 scoped_ptr<base::DictionaryValue> dictionary = | 638 scoped_ptr<base::DictionaryValue> dictionary = |
| 628 onc::TranslateShillServiceToONCPart( | 639 onc::TranslateShillServiceToONCPart( |
| 629 *shill_properties_with_device, &onc::kNetworkWithStateSignature); | 640 *shill_properties_with_device, &onc::kNetworkWithStateSignature); |
| 630 | 641 |
| 631 dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); | 642 dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); |
| 632 dictionary->SetString( | 643 dictionary->SetString( |
| 633 kTagErrorState, | 644 kTagErrorMessage, |
| 634 ash::network_connect::ErrorString(network->error(), network->path())); | 645 ash::network_connect::ErrorString(network->error(), network->path())); |
| 635 | 646 |
| 636 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); | 647 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); |
| 637 bool shared = !network->IsPrivate(); | 648 bool shared = !network->IsPrivate(); |
| 638 dictionary->SetBoolean(kTagShared, shared); | 649 dictionary->SetBoolean(kTagShared, shared); |
| 639 | 650 |
| 640 const std::string& type = network->type(); | 651 const std::string& type = network->type(); |
| 641 | 652 |
| 642 const NetworkState* connected_network = | 653 const NetworkState* connected_network = |
| 643 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( | 654 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( |
| 644 NetworkTypePattern::Primitive(type)); | 655 NetworkTypePattern::Primitive(type)); |
| 645 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); | 656 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); |
| 646 | 657 |
| 647 if (type == shill::kTypeWimax) | 658 if (type == shill::kTypeCellular) |
| 648 PopulateWimaxDetails(network, shill_properties, dictionary.get()); | |
| 649 else if (type == shill::kTypeCellular) | |
| 650 PopulateCellularDetails(network, shill_properties, dictionary.get()); | 659 PopulateCellularDetails(network, shill_properties, dictionary.get()); |
| 651 else if (type == shill::kTypeVPN) | 660 else if (type == shill::kTypeVPN) |
| 652 PopulateVPNDetails(network, shill_properties, dictionary.get()); | 661 PopulateVPNDetails(network, shill_properties, dictionary.get()); |
| 653 | 662 |
| 654 return dictionary.Pass(); | 663 return dictionary.Pass(); |
| 655 } | 664 } |
| 656 | 665 |
| 657 // Helper methods for SetIPConfigProperties | 666 // Helper methods for SetIPConfigProperties |
| 658 bool AppendPropertyKeyIfPresent(const std::string& key, | 667 bool AppendPropertyKeyIfPresent(const std::string& key, |
| 659 const base::DictionaryValue& old_properties, | 668 const base::DictionaryValue& old_properties, |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1265 | 1274 |
| 1266 // IP config | 1275 // IP config |
| 1267 scoped_ptr<base::DictionaryValue> ipconfig_dhcp(new base::DictionaryValue); | 1276 scoped_ptr<base::DictionaryValue> ipconfig_dhcp(new base::DictionaryValue); |
| 1268 ipconfig_dhcp->SetString(kIpConfigAddress, network->ip_address()); | 1277 ipconfig_dhcp->SetString(kIpConfigAddress, network->ip_address()); |
| 1269 ipconfig_dhcp->SetString(kIpConfigNetmask, network->GetNetmask()); | 1278 ipconfig_dhcp->SetString(kIpConfigNetmask, network->GetNetmask()); |
| 1270 ipconfig_dhcp->SetString(kIpConfigGateway, network->gateway()); | 1279 ipconfig_dhcp->SetString(kIpConfigGateway, network->gateway()); |
| 1271 std::string ipconfig_name_servers = network->GetDnsServersAsString(); | 1280 std::string ipconfig_name_servers = network->GetDnsServersAsString(); |
| 1272 ipconfig_dhcp->SetString(kIpConfigNameServers, ipconfig_name_servers); | 1281 ipconfig_dhcp->SetString(kIpConfigNameServers, ipconfig_name_servers); |
| 1273 ipconfig_dhcp->SetString(kIpConfigWebProxyAutoDiscoveryUrl, | 1282 ipconfig_dhcp->SetString(kIpConfigWebProxyAutoDiscoveryUrl, |
| 1274 network->web_proxy_auto_discovery_url().spec()); | 1283 network->web_proxy_auto_discovery_url().spec()); |
| 1275 SetValueDictionary(dictionary.get(), | 1284 SetValueDictionary(kDictionaryIpConfig, |
| 1276 kDictionaryIpConfig, | |
| 1277 ipconfig_dhcp.release(), | 1285 ipconfig_dhcp.release(), |
| 1278 property_ui_data); | 1286 property_ui_data, |
| 1287 dictionary.get()); | |
| 1279 | 1288 |
| 1280 std::string name_server_type = kNameServerTypeAutomatic; | 1289 std::string name_server_type = kNameServerTypeAutomatic; |
| 1281 int automatic_ip_config = 0; | 1290 int automatic_ip_config = 0; |
| 1282 scoped_ptr<base::DictionaryValue> static_ip_dict( | 1291 scoped_ptr<base::DictionaryValue> static_ip_dict( |
| 1283 BuildIPInfoDictionary(shill_properties, true, &automatic_ip_config)); | 1292 BuildIPInfoDictionary(shill_properties, true, &automatic_ip_config)); |
| 1284 dictionary->SetBoolean(kIpConfigAutoConfig, automatic_ip_config == 0); | 1293 dictionary->SetBoolean(kIpConfigAutoConfig, automatic_ip_config == 0); |
| 1285 DCHECK(automatic_ip_config == 3 || automatic_ip_config == 0) | 1294 DCHECK(automatic_ip_config == 3 || automatic_ip_config == 0) |
| 1286 << "UI doesn't support automatic specification of individual " | 1295 << "UI doesn't support automatic specification of individual " |
| 1287 << "static IP parameters."; | 1296 << "static IP parameters."; |
| 1288 scoped_ptr<base::DictionaryValue> saved_ip_dict( | 1297 scoped_ptr<base::DictionaryValue> saved_ip_dict( |
| 1289 BuildIPInfoDictionary(shill_properties, false, NULL)); | 1298 BuildIPInfoDictionary(shill_properties, false, NULL)); |
| 1290 dictionary->Set(kDictionarySavedIp, saved_ip_dict.release()); | 1299 dictionary->Set(kDictionarySavedIp, saved_ip_dict.release()); |
| 1291 | 1300 |
| 1292 // Determine what kind of name server setting we have by comparing the | 1301 // Determine what kind of name server setting we have by comparing the |
| 1293 // StaticIP and Google values with the ipconfig values. | 1302 // StaticIP and Google values with the ipconfig values. |
| 1294 std::string static_ip_nameservers; | 1303 std::string static_ip_nameservers; |
| 1295 static_ip_dict->GetString(kIpConfigNameServers, &static_ip_nameservers); | 1304 static_ip_dict->GetString(kIpConfigNameServers, &static_ip_nameservers); |
| 1296 if (!static_ip_nameservers.empty() && | 1305 if (!static_ip_nameservers.empty() && |
| 1297 static_ip_nameservers == ipconfig_name_servers) { | 1306 static_ip_nameservers == ipconfig_name_servers) { |
| 1298 name_server_type = kNameServerTypeUser; | 1307 name_server_type = kNameServerTypeUser; |
| 1299 } | 1308 } |
| 1300 if (ipconfig_name_servers == kGoogleNameServers) { | 1309 if (ipconfig_name_servers == kGoogleNameServers) { |
| 1301 name_server_type = kNameServerTypeGoogle; | 1310 name_server_type = kNameServerTypeGoogle; |
| 1302 } | 1311 } |
| 1303 SetValueDictionary(dictionary.get(), | 1312 SetValueDictionary(kDictionaryStaticIp, |
| 1304 kDictionaryStaticIp, | |
| 1305 static_ip_dict.release(), | 1313 static_ip_dict.release(), |
| 1306 property_ui_data); | 1314 property_ui_data, |
| 1315 dictionary.get()); | |
| 1307 | 1316 |
| 1308 dictionary->SetString(kTagNameServerType, name_server_type); | 1317 dictionary->SetString(kTagNameServerType, name_server_type); |
| 1309 dictionary->SetString(kTagNameServersGoogle, kGoogleNameServers); | 1318 dictionary->SetString(kTagNameServersGoogle, kGoogleNameServers); |
| 1310 | 1319 |
| 1311 // Enable static ip config for Ethernet or WiFi. | |
| 1312 bool staticIPConfig = network->Matches(NetworkTypePattern::Ethernet()) || | |
| 1313 network->Matches(NetworkTypePattern::WiFi()); | |
| 1314 dictionary->SetBoolean(kTagShowStaticIPConfig, staticIPConfig); | |
| 1315 | |
| 1316 int priority = 0; | 1320 int priority = 0; |
| 1317 shill_properties.GetIntegerWithoutPathExpansion( | 1321 shill_properties.GetIntegerWithoutPathExpansion( |
| 1318 shill::kPriorityProperty, &priority); | 1322 shill::kPriorityProperty, &priority); |
| 1319 bool preferred = priority > 0; | 1323 bool preferred = priority > 0; |
| 1320 SetValueDictionary(dictionary.get(), kTagPreferred, | 1324 SetValueDictionary(kTagPreferred, |
| 1321 new base::FundamentalValue(preferred), | 1325 new base::FundamentalValue(preferred), |
| 1322 property_ui_data); | 1326 property_ui_data, |
| 1327 dictionary.get()); | |
| 1323 | 1328 |
| 1324 NetworkPropertyUIData auto_connect_ui_data(onc_source); | |
| 1325 std::string onc_path_to_auto_connect; | 1329 std::string onc_path_to_auto_connect; |
| 1326 if (network->Matches(NetworkTypePattern::WiFi())) { | 1330 if (network->Matches(NetworkTypePattern::WiFi())) { |
| 1327 content::RecordAction( | 1331 content::RecordAction( |
| 1328 base::UserMetricsAction("Options_NetworkShowDetailsWifi")); | 1332 base::UserMetricsAction("Options_NetworkShowDetailsWifi")); |
| 1329 if (network->IsConnectedState()) { | 1333 if (network->IsConnectedState()) { |
| 1330 content::RecordAction( | 1334 content::RecordAction( |
| 1331 base::UserMetricsAction("Options_NetworkShowDetailsWifiConnected")); | 1335 base::UserMetricsAction("Options_NetworkShowDetailsWifiConnected")); |
| 1332 } | 1336 } |
| 1333 onc_path_to_auto_connect = | 1337 onc_path_to_auto_connect = |
| 1334 ::onc::network_config::WifiProperty(::onc::wifi::kAutoConnect); | 1338 ::onc::network_config::WifiProperty(::onc::wifi::kAutoConnect); |
| 1335 } else if (network->Matches(NetworkTypePattern::VPN())) { | 1339 } else if (network->Matches(NetworkTypePattern::VPN())) { |
| 1336 content::RecordAction( | 1340 content::RecordAction( |
| 1337 base::UserMetricsAction("Options_NetworkShowDetailsVPN")); | 1341 base::UserMetricsAction("Options_NetworkShowDetailsVPN")); |
| 1338 if (network->IsConnectedState()) { | 1342 if (network->IsConnectedState()) { |
| 1339 content::RecordAction( | 1343 content::RecordAction( |
| 1340 base::UserMetricsAction("Options_NetworkShowDetailsVPNConnected")); | 1344 base::UserMetricsAction("Options_NetworkShowDetailsVPNConnected")); |
| 1341 } | 1345 } |
| 1342 onc_path_to_auto_connect = ::onc::network_config::VpnProperty( | 1346 onc_path_to_auto_connect = ::onc::network_config::VpnProperty( |
| 1343 ::onc::vpn::kAutoConnect); | 1347 ::onc::vpn::kAutoConnect); |
| 1344 } else if (network->Matches(NetworkTypePattern::Cellular())) { | 1348 } else if (network->Matches(NetworkTypePattern::Cellular())) { |
| 1345 content::RecordAction( | 1349 content::RecordAction( |
| 1346 base::UserMetricsAction("Options_NetworkShowDetailsCellular")); | 1350 base::UserMetricsAction("Options_NetworkShowDetailsCellular")); |
| 1347 if (network->IsConnectedState()) { | 1351 if (network->IsConnectedState()) { |
| 1348 content::RecordAction(base::UserMetricsAction( | 1352 content::RecordAction(base::UserMetricsAction( |
| 1349 "Options_NetworkShowDetailsCellularConnected")); | 1353 "Options_NetworkShowDetailsCellularConnected")); |
| 1350 } | 1354 } |
| 1351 } | 1355 } |
| 1356 | |
| 1352 if (!onc_path_to_auto_connect.empty()) { | 1357 if (!onc_path_to_auto_connect.empty()) { |
| 1353 auto_connect_ui_data.ParseOncProperty( | 1358 bool auto_connect = false; |
| 1354 onc_source, onc, onc_path_to_auto_connect); | 1359 shill_properties.GetBooleanWithoutPathExpansion( |
| 1360 shill::kAutoConnectProperty, &auto_connect); | |
| 1361 | |
| 1362 scoped_ptr<base::Value> auto_connect_value( | |
| 1363 new base::FundamentalValue(auto_connect)); | |
| 1364 ::onc::ONCSource auto_connect_onc_source = onc_source; | |
| 1365 bool auto_connect_recommended = | |
| 1366 auto_connect_onc_source != ::onc::ONC_SOURCE_NONE && | |
| 1367 onc::IsRecommendedValue(onc, onc_path_to_auto_connect); | |
| 1368 // |auto_connect_default_value| will contain either a recommended value | |
| 1369 // if |auto_connect_recommended| is true, or an enforced value otherwise. | |
| 1370 const base::Value* auto_connect_default_value = NULL; | |
| 1371 onc->Get(onc_path_to_auto_connect, &auto_connect_default_value); | |
| 1372 | |
| 1373 // Autoconnect can be controlled by the GlobalNetworkConfiguration of the | |
| 1374 // ONC policy. | |
| 1375 if (auto_connect_onc_source == ::onc::ONC_SOURCE_NONE && | |
| 1376 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect( | |
| 1377 network->IsPrivate())) { | |
| 1378 auto_connect_recommended = false; | |
| 1379 auto_connect_onc_source = network->IsPrivate() | |
| 1380 ? ::onc::ONC_SOURCE_USER_POLICY | |
| 1381 : ::onc::ONC_SOURCE_DEVICE_POLICY; | |
| 1382 if (auto_connect) { | |
| 1383 LOG(WARNING) << "Policy prevents autoconnect, but value is True."; | |
| 1384 auto_connect_value.reset(new base::FundamentalValue(false)); | |
| 1385 } | |
| 1386 } | |
| 1387 SetManagedValueDictionary(shill::kAutoConnectProperty, | |
| 1388 auto_connect_value.get(), | |
| 1389 auto_connect_onc_source, | |
| 1390 auto_connect_recommended, | |
| 1391 auto_connect_default_value, | |
| 1392 dictionary.get()); | |
| 1355 } | 1393 } |
| 1356 bool auto_connect = false; | |
| 1357 shill_properties.GetBooleanWithoutPathExpansion( | |
| 1358 shill::kAutoConnectProperty, &auto_connect); | |
| 1359 SetAutoconnectValueDictionary(network->IsPrivate(), | |
| 1360 onc_source, | |
| 1361 auto_connect, | |
| 1362 auto_connect_ui_data, | |
| 1363 dictionary.get()); | |
| 1364 | 1394 |
| 1365 // Show details dialog | 1395 // Show details dialog |
| 1366 web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, *dictionary); | 1396 web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, *dictionary); |
| 1367 } | 1397 } |
| 1368 | 1398 |
| 1369 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { | 1399 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { |
| 1370 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1400 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
| 1371 } | 1401 } |
| 1372 | 1402 |
| 1373 float InternetOptionsHandler::GetScaleFactor() const { | 1403 float InternetOptionsHandler::GetScaleFactor() const { |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1554 dictionary->SetBoolean( | 1584 dictionary->SetBoolean( |
| 1555 kTagWimaxAvailable, | 1585 kTagWimaxAvailable, |
| 1556 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1586 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
| 1557 dictionary->SetBoolean( | 1587 dictionary->SetBoolean( |
| 1558 kTagWimaxEnabled, | 1588 kTagWimaxEnabled, |
| 1559 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1589 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
| 1560 } | 1590 } |
| 1561 | 1591 |
| 1562 } // namespace options | 1592 } // namespace options |
| 1563 } // namespace chromeos | 1593 } // namespace chromeos |
| OLD | NEW |