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 25 matching lines...) Expand all Loading... |
36 #include "chromeos/network/network_connection_handler.h" | 36 #include "chromeos/network/network_connection_handler.h" |
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_translation_tables.h" |
46 #include "chromeos/network/onc/onc_translator.h" | 47 #include "chromeos/network/onc/onc_translator.h" |
47 #include "chromeos/network/onc/onc_utils.h" | 48 #include "chromeos/network/onc/onc_utils.h" |
48 #include "components/onc/onc_constants.h" | 49 #include "components/onc/onc_constants.h" |
49 #include "content/public/browser/user_metrics.h" | 50 #include "content/public/browser/user_metrics.h" |
50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
51 #include "content/public/browser/web_ui.h" | 52 #include "content/public/browser/web_ui.h" |
52 #include "grit/ash_resources.h" | 53 #include "grit/ash_resources.h" |
53 #include "grit/ui_chromeos_resources.h" | 54 #include "grit/ui_chromeos_resources.h" |
54 #include "third_party/cros_system_api/dbus/service_constants.h" | 55 #include "third_party/cros_system_api/dbus/service_constants.h" |
55 #include "ui/base/resource/resource_bundle.h" | 56 #include "ui/base/resource/resource_bundle.h" |
56 #include "ui/base/webui/web_ui_util.h" | 57 #include "ui/base/webui/web_ui_util.h" |
57 #include "ui/chromeos/network/network_icon.h" | 58 #include "ui/chromeos/network/network_icon.h" |
58 #include "ui/gfx/image/image_skia.h" | 59 #include "ui/gfx/image/image_skia.h" |
59 | 60 |
60 namespace chromeos { | 61 namespace chromeos { |
61 namespace options { | 62 namespace options { |
62 | 63 |
63 namespace { | 64 namespace { |
64 | 65 |
| 66 // The key in a Managed Value dictionary for translated values. |
| 67 // TODO(stevenjb): Consider making this part of the ONC spec. |
| 68 const char kTranslatedKey[] = "Translated"; |
| 69 |
65 // Keys for the network description dictionary passed to the web ui. Make sure | 70 // Keys for the network description dictionary passed to the web ui. Make sure |
66 // to keep the strings in sync with what the JavaScript side uses. | 71 // to keep the strings in sync with what the JavaScript side uses. |
67 const char kNetworkInfoKeyIconURL[] = "iconURL"; | 72 const char kNetworkInfoKeyIconURL[] = "iconURL"; |
68 const char kNetworkInfoKeyServicePath[] = "servicePath"; | 73 const char kNetworkInfoKeyServicePath[] = "servicePath"; |
69 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; | 74 const char kNetworkInfoKeyPolicyManaged[] = "policyManaged"; |
70 | 75 |
71 // These are keys for getting IP information from the web ui. | 76 // These are keys for getting IP information from the web ui. |
72 const char kIpConfigAddress[] = "address"; | 77 const char kIpConfigAddress[] = "address"; |
73 const char kIpConfigPrefixLength[] = "prefixLength"; | 78 const char kIpConfigPrefixLength[] = "prefixLength"; |
74 const char kIpConfigNetmask[] = "netmask"; | 79 const char kIpConfigNetmask[] = "netmask"; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 const char kTagLanguage[] = "language"; | 147 const char kTagLanguage[] = "language"; |
143 const char kTagLastGoodApn[] = "lastGoodApn"; | 148 const char kTagLastGoodApn[] = "lastGoodApn"; |
144 const char kTagLocalizedName[] = "localizedName"; | 149 const char kTagLocalizedName[] = "localizedName"; |
145 const char kTagName[] = "name"; | 150 const char kTagName[] = "name"; |
146 const char kTagNameServersGoogle[] = "nameServersGoogle"; | 151 const char kTagNameServersGoogle[] = "nameServersGoogle"; |
147 const char kTagNameServerType[] = "nameServerType"; | 152 const char kTagNameServerType[] = "nameServerType"; |
148 const char kTagNetworkId[] = "networkId"; | 153 const char kTagNetworkId[] = "networkId"; |
149 const char kTagOptions[] = "options"; | 154 const char kTagOptions[] = "options"; |
150 const char kTagPassword[] = "password"; | 155 const char kTagPassword[] = "password"; |
151 const char kTagPolicy[] = "policy"; | 156 const char kTagPolicy[] = "policy"; |
152 const char kTagPreferred[] = "preferred"; | |
153 const char kTagProviderType[] = "providerType"; | |
154 const char kTagProviderApnList[] = "providerApnList"; | 157 const char kTagProviderApnList[] = "providerApnList"; |
155 const char kTagRecommended[] = "recommended"; | 158 const char kTagRecommended[] = "recommended"; |
156 const char kTagRecommendedValue[] = "recommendedValue"; | 159 const char kTagRecommendedValue[] = "recommendedValue"; |
157 const char kTagRemembered[] = "remembered"; | 160 const char kTagRemembered[] = "remembered"; |
158 const char kTagRememberedList[] = "rememberedList"; | 161 const char kTagRememberedList[] = "rememberedList"; |
159 const char kTagRestrictedPool[] = "restrictedPool"; | 162 const char kTagRestrictedPool[] = "restrictedPool"; |
160 const char kTagRoamingState[] = "roamingState"; | 163 const char kTagRoamingState[] = "roamingState"; |
161 const char kTagServerHostname[] = "serverHostname"; | |
162 const char kTagCarriers[] = "carriers"; | 164 const char kTagCarriers[] = "carriers"; |
163 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; | 165 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; |
164 const char kTagShared[] = "shared"; | 166 const char kTagShared[] = "shared"; |
165 const char kTagShowActivateButton[] = "showActivateButton"; | 167 const char kTagShowActivateButton[] = "showActivateButton"; |
166 const char kTagShowViewAccountButton[] = "showViewAccountButton"; | 168 const char kTagShowViewAccountButton[] = "showViewAccountButton"; |
167 const char kTagSimCardLockEnabled[] = "simCardLockEnabled"; | 169 const char kTagSimCardLockEnabled[] = "simCardLockEnabled"; |
168 const char kTagSupportUrl[] = "supportUrl"; | 170 const char kTagSupportUrl[] = "supportUrl"; |
169 const char kTagTrue[] = "true"; | 171 const char kTagTrue[] = "true"; |
170 const char kTagUsername[] = "username"; | 172 const char kTagUsername[] = "username"; |
171 const char kTagValue[] = "value"; | 173 const char kTagValue[] = "value"; |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 } | 329 } |
328 | 330 |
329 const char* GetOncSettingString(::onc::ONCSource onc_source) { | 331 const char* GetOncSettingString(::onc::ONCSource onc_source) { |
330 if (onc_source == ::onc::ONC_SOURCE_DEVICE_POLICY) | 332 if (onc_source == ::onc::ONC_SOURCE_DEVICE_POLICY) |
331 return ::onc::kAugmentationSharedSetting; | 333 return ::onc::kAugmentationSharedSetting; |
332 return ::onc::kAugmentationUserSetting; | 334 return ::onc::kAugmentationUserSetting; |
333 } | 335 } |
334 | 336 |
335 // Creates a GetManagedProperties style dictionary and adds it to |settings|. | 337 // Creates a GetManagedProperties style dictionary and adds it to |settings|. |
336 // |default_value| represents either the recommended value if |recommended| | 338 // |default_value| represents either the recommended value if |recommended| |
337 // is true, or the enforced value if |recommended| is false. | 339 // is true, or the enforced value if |recommended| is false. |settings_dict_key| |
| 340 // is expected to be an ONC key with no '.' in it. |
338 // Note(stevenjb): This is bridge code until we use GetManagedProperties to | 341 // Note(stevenjb): This is bridge code until we use GetManagedProperties to |
339 // retrieve Shill properties. | 342 // retrieve Shill properties. |
340 void SetManagedValueDictionary(const char* key, | 343 void SetManagedValueDictionaryEx(const char* settings_dict_key, |
341 const base::Value* value, | 344 const base::Value& value, |
342 ::onc::ONCSource onc_source, | 345 ::onc::ONCSource onc_source, |
343 bool recommended, | 346 bool recommended, |
344 const base::Value* default_value, | 347 const base::Value* default_value, |
345 base::DictionaryValue* settings) { | 348 base::DictionaryValue* settings_dict) { |
346 base::DictionaryValue* dict = new base::DictionaryValue(); | 349 base::DictionaryValue* dict = new base::DictionaryValue(); |
347 settings->Set(key, dict); | 350 settings_dict->SetWithoutPathExpansion(settings_dict_key, dict); |
348 | 351 |
349 DCHECK(value); | 352 dict->Set(::onc::kAugmentationActiveSetting, value.DeepCopy()); |
350 dict->Set(::onc::kAugmentationActiveSetting, value->DeepCopy()); | |
351 | 353 |
352 if (onc_source == ::onc::ONC_SOURCE_NONE) | 354 if (onc_source == ::onc::ONC_SOURCE_NONE) |
353 return; | 355 return; |
354 | 356 |
355 if (recommended) { | 357 if (recommended) { |
356 // If an ONC property is 'Recommended' it can be edited by the user. | 358 // If an ONC property is 'Recommended' it can be edited by the user. |
357 std::string editable = GetOncEditableString(onc_source); | 359 std::string editable = GetOncEditableString(onc_source); |
358 dict->Set(editable, new base::FundamentalValue(true)); | 360 dict->Set(editable, new base::FundamentalValue(true)); |
359 } | 361 } |
360 if (default_value) { | 362 if (default_value) { |
361 std::string policy_source = GetOncPolicyString(onc_source); | 363 std::string policy_source = GetOncPolicyString(onc_source); |
362 dict->Set(policy_source, default_value->DeepCopy()); | 364 dict->Set(policy_source, default_value->DeepCopy()); |
363 if (recommended && !value->Equals(default_value)) { | 365 if (recommended && !value.Equals(default_value)) { |
364 std::string setting_source = GetOncSettingString(onc_source); | 366 std::string setting_source = GetOncSettingString(onc_source); |
365 dict->Set(setting_source, value->DeepCopy()); | 367 dict->Set(setting_source, value.DeepCopy()); |
366 dict->SetString(::onc::kAugmentationEffectiveSetting, setting_source); | 368 dict->SetString(::onc::kAugmentationEffectiveSetting, setting_source); |
367 } else { | 369 } else { |
368 dict->SetString(::onc::kAugmentationEffectiveSetting, policy_source); | 370 dict->SetString(::onc::kAugmentationEffectiveSetting, policy_source); |
369 } | 371 } |
370 } | 372 } |
371 } | 373 } |
372 | 374 |
| 375 // Wrapper for SetManagedValueDictionaryEx that does the policy lookup. |
| 376 // Note: We have to pass |onc_key| separately from |settings_dict_key| since |
| 377 // we might be populating a sub-dictionary in which case |onc_key| will be the |
| 378 // complete path (e.g. 'VPN.Host') and |settings_dict_key| is the dictionary key |
| 379 // (e.g. 'Host'). |
| 380 void SetManagedValueDictionary(const std::string& guid, |
| 381 const char* settings_dict_key, |
| 382 const base::Value& value, |
| 383 const std::string& onc_key, |
| 384 base::DictionaryValue* settings_dict) { |
| 385 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE; |
| 386 const base::DictionaryValue* onc = |
| 387 onc::FindPolicyForActiveUser(guid, &onc_source); |
| 388 DCHECK_EQ(onc == NULL, onc_source == ::onc::ONC_SOURCE_NONE); |
| 389 const base::Value* default_value = NULL; |
| 390 bool recommended = false; |
| 391 if (onc) { |
| 392 onc->Get(onc_key, &default_value); |
| 393 recommended = onc::IsRecommendedValue(onc, onc_key); |
| 394 } |
| 395 SetManagedValueDictionaryEx(settings_dict_key, |
| 396 value, |
| 397 onc_source, |
| 398 recommended, |
| 399 default_value, |
| 400 settings_dict); |
| 401 } |
| 402 |
| 403 // Creates a GetManagedProperties style dictionary with an Active value and |
| 404 // a Translated value, and adds it to |settings|. |
| 405 // Note(stevenjb): This is bridge code until we use GetManagedProperties to |
| 406 // retrieve Shill properties and include Translated values. |
| 407 void SetTranslatedDictionary(const char* settings_dict_key, |
| 408 const std::string& value, |
| 409 const std::string& translated_value, |
| 410 base::DictionaryValue* settings_dict) { |
| 411 base::DictionaryValue* dict = new base::DictionaryValue(); |
| 412 settings_dict->Set(settings_dict_key, dict); |
| 413 dict->SetString(::onc::kAugmentationActiveSetting, value); |
| 414 dict->SetString(kTranslatedKey, translated_value); |
| 415 } |
| 416 |
373 std::string CopyStringFromDictionary(const base::DictionaryValue& source, | 417 std::string CopyStringFromDictionary(const base::DictionaryValue& source, |
374 const std::string& src_key, | 418 const std::string& src_key, |
375 const std::string& dest_key, | 419 const std::string& dest_key, |
376 base::DictionaryValue* dest) { | 420 base::DictionaryValue* dest) { |
377 std::string string_value; | 421 std::string string_value; |
378 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) | 422 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) |
379 dest->SetStringWithoutPathExpansion(dest_key, string_value); | 423 dest->SetStringWithoutPathExpansion(dest_key, string_value); |
380 return string_value; | 424 return string_value; |
381 } | 425 } |
382 | 426 |
383 // Fills |dictionary| with the configuration details of |vpn|. |onc| is required | 427 // Fills |dictionary| with the configuration details of |vpn|. |onc| is required |
384 // for augmenting the policy-managed information. | 428 // for augmenting the policy-managed information. |
385 void PopulateVPNDetails(const NetworkState* vpn, | 429 void PopulateVPNDetails(const NetworkState* vpn, |
386 const base::DictionaryValue& shill_properties, | 430 const base::DictionaryValue& shill_properties, |
387 base::DictionaryValue* dictionary) { | 431 base::DictionaryValue* dictionary) { |
388 // Name and Remembered are set in PopulateConnectionDetails(). | 432 // Name and Remembered are set in PopulateConnectionDetails(). |
389 // Provider properties are stored in the "Provider" dictionary. | 433 // Provider properties are stored in the "Provider" dictionary. |
390 const base::DictionaryValue* provider_properties = NULL; | 434 const base::DictionaryValue* shill_provider_properties = NULL; |
391 if (!shill_properties.GetDictionaryWithoutPathExpansion( | 435 if (!shill_properties.GetDictionaryWithoutPathExpansion( |
392 shill::kProviderProperty, &provider_properties)) { | 436 shill::kProviderProperty, &shill_provider_properties)) { |
393 LOG(ERROR) << "No provider properties for VPN: " << vpn->path(); | 437 LOG(ERROR) << "No provider properties for VPN: " << vpn->path(); |
394 return; | 438 return; |
395 } | 439 } |
396 std::string provider_type; | 440 base::DictionaryValue* vpn_dictionary = new base::DictionaryValue; |
397 provider_properties->GetStringWithoutPathExpansion( | 441 dictionary->Set(::onc::network_config::kVPN, vpn_dictionary); |
398 shill::kTypeProperty, &provider_type); | |
399 dictionary->SetString(kTagProviderType, | |
400 internet_options_strings::ProviderTypeString( | |
401 provider_type, | |
402 *provider_properties)); | |
403 | 442 |
| 443 std::string shill_provider_type; |
| 444 if (!shill_provider_properties->GetStringWithoutPathExpansion( |
| 445 shill::kTypeProperty, &shill_provider_type)) { |
| 446 LOG(ERROR) << "Shill VPN has no Provider.Type: " << vpn->path(); |
| 447 return; |
| 448 } |
| 449 std::string onc_provider_type; |
| 450 onc::TranslateStringToONC( |
| 451 onc::kVPNTypeTable, shill_provider_type, &onc_provider_type); |
| 452 SetTranslatedDictionary( |
| 453 ::onc::vpn::kType, |
| 454 onc_provider_type, |
| 455 internet_options_strings::ProviderTypeString(shill_provider_type, |
| 456 *shill_provider_properties), |
| 457 vpn_dictionary); |
| 458 |
| 459 std::string provider_type_key; |
404 std::string username; | 460 std::string username; |
405 if (provider_type == shill::kProviderOpenVpn) { | 461 if (shill_provider_type == shill::kProviderOpenVpn) { |
406 provider_properties->GetStringWithoutPathExpansion( | 462 provider_type_key = ::onc::vpn::kOpenVPN; |
| 463 shill_provider_properties->GetStringWithoutPathExpansion( |
407 shill::kOpenVPNUserProperty, &username); | 464 shill::kOpenVPNUserProperty, &username); |
408 } else { | 465 } else { |
409 provider_properties->GetStringWithoutPathExpansion( | 466 provider_type_key = ::onc::vpn::kL2TP; |
| 467 shill_provider_properties->GetStringWithoutPathExpansion( |
410 shill::kL2tpIpsecUserProperty, &username); | 468 shill::kL2tpIpsecUserProperty, &username); |
411 } | 469 } |
412 dictionary->SetString(kTagUsername, username); | 470 base::DictionaryValue* provider_type_dictionary = new base::DictionaryValue; |
| 471 vpn_dictionary->Set(provider_type_key, provider_type_dictionary); |
| 472 provider_type_dictionary->SetString(::onc::vpn::kUsername, username); |
413 | 473 |
414 ::onc::ONCSource onc_source = ::onc::ONC_SOURCE_NONE; | |
415 const base::DictionaryValue* onc = | |
416 onc::FindPolicyForActiveUser(vpn->guid(), &onc_source); | |
417 | |
418 NetworkPropertyUIData hostname_ui_data; | |
419 hostname_ui_data.ParseOncProperty( | |
420 onc_source, | |
421 onc, | |
422 ::onc::network_config::VpnProperty(::onc::vpn::kHost)); | |
423 std::string provider_host; | 474 std::string provider_host; |
424 provider_properties->GetStringWithoutPathExpansion( | 475 shill_provider_properties->GetStringWithoutPathExpansion( |
425 shill::kHostProperty, &provider_host); | 476 shill::kHostProperty, &provider_host); |
426 SetValueDictionary(kTagServerHostname, | 477 SetManagedValueDictionary( |
427 new base::StringValue(provider_host), | 478 vpn->guid(), |
428 hostname_ui_data, | 479 ::onc::vpn::kHost, |
429 dictionary); | 480 base::StringValue(provider_host), |
| 481 ::onc::network_config::VpnProperty(::onc::vpn::kHost), |
| 482 vpn_dictionary); |
430 } | 483 } |
431 | 484 |
432 // Given a list of supported carrier's by the device, return the index of | 485 // Given a list of supported carrier's by the device, return the index of |
433 // the carrier the device is currently using. | 486 // the carrier the device is currently using. |
434 int FindCurrentCarrierIndex(const base::ListValue* carriers, | 487 int FindCurrentCarrierIndex(const base::ListValue* carriers, |
435 const DeviceState* device) { | 488 const DeviceState* device) { |
436 DCHECK(carriers); | 489 DCHECK(carriers); |
437 DCHECK(device); | 490 DCHECK(device); |
438 bool gsm = (device->technology_family() == shill::kTechnologyFamilyGsm); | 491 bool gsm = (device->technology_family() == shill::kTechnologyFamilyGsm); |
439 int index = 0; | 492 int index = 0; |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1325 static_ip_dict.release(), | 1378 static_ip_dict.release(), |
1326 property_ui_data, | 1379 property_ui_data, |
1327 dictionary.get()); | 1380 dictionary.get()); |
1328 | 1381 |
1329 dictionary->SetString(kTagNameServerType, name_server_type); | 1382 dictionary->SetString(kTagNameServerType, name_server_type); |
1330 dictionary->SetString(kTagNameServersGoogle, kGoogleNameServers); | 1383 dictionary->SetString(kTagNameServersGoogle, kGoogleNameServers); |
1331 | 1384 |
1332 int priority = 0; | 1385 int priority = 0; |
1333 shill_properties.GetIntegerWithoutPathExpansion( | 1386 shill_properties.GetIntegerWithoutPathExpansion( |
1334 shill::kPriorityProperty, &priority); | 1387 shill::kPriorityProperty, &priority); |
1335 bool preferred = priority > 0; | 1388 SetManagedValueDictionary(network->guid(), |
1336 SetValueDictionary(kTagPreferred, | 1389 ::onc::network_config::kPriority, |
1337 new base::FundamentalValue(preferred), | 1390 base::FundamentalValue(priority), |
1338 property_ui_data, | 1391 ::onc::network_config::kPriority, |
1339 dictionary.get()); | 1392 dictionary.get()); |
1340 | 1393 |
1341 std::string onc_path_to_auto_connect; | 1394 std::string onc_path_to_auto_connect; |
1342 if (network->Matches(NetworkTypePattern::WiFi())) { | 1395 if (network->Matches(NetworkTypePattern::WiFi())) { |
1343 content::RecordAction( | 1396 content::RecordAction( |
1344 base::UserMetricsAction("Options_NetworkShowDetailsWifi")); | 1397 base::UserMetricsAction("Options_NetworkShowDetailsWifi")); |
1345 if (network->IsConnectedState()) { | 1398 if (network->IsConnectedState()) { |
1346 content::RecordAction( | 1399 content::RecordAction( |
1347 base::UserMetricsAction("Options_NetworkShowDetailsWifiConnected")); | 1400 base::UserMetricsAction("Options_NetworkShowDetailsWifiConnected")); |
1348 } | 1401 } |
1349 onc_path_to_auto_connect = | 1402 onc_path_to_auto_connect = |
(...skipping 14 matching lines...) Expand all Loading... |
1364 content::RecordAction(base::UserMetricsAction( | 1417 content::RecordAction(base::UserMetricsAction( |
1365 "Options_NetworkShowDetailsCellularConnected")); | 1418 "Options_NetworkShowDetailsCellularConnected")); |
1366 } | 1419 } |
1367 } | 1420 } |
1368 | 1421 |
1369 if (!onc_path_to_auto_connect.empty()) { | 1422 if (!onc_path_to_auto_connect.empty()) { |
1370 bool auto_connect = false; | 1423 bool auto_connect = false; |
1371 shill_properties.GetBooleanWithoutPathExpansion( | 1424 shill_properties.GetBooleanWithoutPathExpansion( |
1372 shill::kAutoConnectProperty, &auto_connect); | 1425 shill::kAutoConnectProperty, &auto_connect); |
1373 | 1426 |
1374 scoped_ptr<base::Value> auto_connect_value( | 1427 base::FundamentalValue auto_connect_value(auto_connect); |
1375 new base::FundamentalValue(auto_connect)); | |
1376 ::onc::ONCSource auto_connect_onc_source = onc_source; | 1428 ::onc::ONCSource auto_connect_onc_source = onc_source; |
1377 | 1429 |
1378 DCHECK_EQ(onc == NULL, onc_source == ::onc::ONC_SOURCE_NONE); | 1430 DCHECK_EQ(onc == NULL, onc_source == ::onc::ONC_SOURCE_NONE); |
1379 bool auto_connect_recommended = | 1431 bool auto_connect_recommended = |
1380 auto_connect_onc_source != ::onc::ONC_SOURCE_NONE && | 1432 auto_connect_onc_source != ::onc::ONC_SOURCE_NONE && |
1381 onc::IsRecommendedValue(onc, onc_path_to_auto_connect); | 1433 onc::IsRecommendedValue(onc, onc_path_to_auto_connect); |
1382 // If a policy exists, |auto_connect_default_value| will contain either a | 1434 // If a policy exists, |auto_connect_default_value| will contain either a |
1383 // recommended value (if |auto_connect_recommended| is true) or an enforced | 1435 // recommended value (if |auto_connect_recommended| is true) or an enforced |
1384 // value (if |auto_connect_recommended| is false). | 1436 // value (if |auto_connect_recommended| is false). |
1385 const base::Value* auto_connect_default_value = NULL; | 1437 const base::Value* auto_connect_default_value = NULL; |
1386 if (onc) | 1438 if (onc) |
1387 onc->Get(onc_path_to_auto_connect, &auto_connect_default_value); | 1439 onc->Get(onc_path_to_auto_connect, &auto_connect_default_value); |
1388 | 1440 |
1389 // Autoconnect can be controlled by the GlobalNetworkConfiguration of the | 1441 // Autoconnect can be controlled by the GlobalNetworkConfiguration of the |
1390 // ONC policy. | 1442 // ONC policy. |
1391 if (auto_connect_onc_source == ::onc::ONC_SOURCE_NONE && | 1443 if (auto_connect_onc_source == ::onc::ONC_SOURCE_NONE && |
1392 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect( | 1444 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect( |
1393 network->IsPrivate())) { | 1445 network->IsPrivate())) { |
1394 auto_connect_recommended = false; | 1446 auto_connect_recommended = false; |
1395 auto_connect_onc_source = network->IsPrivate() | 1447 auto_connect_onc_source = network->IsPrivate() |
1396 ? ::onc::ONC_SOURCE_USER_POLICY | 1448 ? ::onc::ONC_SOURCE_USER_POLICY |
1397 : ::onc::ONC_SOURCE_DEVICE_POLICY; | 1449 : ::onc::ONC_SOURCE_DEVICE_POLICY; |
1398 if (auto_connect) { | 1450 if (auto_connect) { |
1399 LOG(WARNING) << "Policy prevents autoconnect, but value is True."; | 1451 LOG(WARNING) << "Policy prevents autoconnect, but value is True."; |
1400 auto_connect_value.reset(new base::FundamentalValue(false)); | 1452 auto_connect_value = base::FundamentalValue(false); |
1401 } | 1453 } |
1402 } | 1454 } |
1403 SetManagedValueDictionary(shill::kAutoConnectProperty, | 1455 SetManagedValueDictionaryEx(shill::kAutoConnectProperty, |
1404 auto_connect_value.get(), | 1456 auto_connect_value, |
1405 auto_connect_onc_source, | 1457 auto_connect_onc_source, |
1406 auto_connect_recommended, | 1458 auto_connect_recommended, |
1407 auto_connect_default_value, | 1459 auto_connect_default_value, |
1408 dictionary.get()); | 1460 dictionary.get()); |
1409 } | 1461 } |
1410 | 1462 |
1411 // Show details dialog | 1463 // Show details dialog |
1412 web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, *dictionary); | 1464 web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, *dictionary); |
1413 } | 1465 } |
1414 | 1466 |
1415 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { | 1467 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { |
1416 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); | 1468 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); |
1417 } | 1469 } |
1418 | 1470 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 dictionary->SetBoolean( | 1652 dictionary->SetBoolean( |
1601 kTagWimaxAvailable, | 1653 kTagWimaxAvailable, |
1602 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); | 1654 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); |
1603 dictionary->SetBoolean( | 1655 dictionary->SetBoolean( |
1604 kTagWimaxEnabled, | 1656 kTagWimaxEnabled, |
1605 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); | 1657 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); |
1606 } | 1658 } |
1607 | 1659 |
1608 } // namespace options | 1660 } // namespace options |
1609 } // namespace chromeos | 1661 } // namespace chromeos |
OLD | NEW |