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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc

Issue 427903004: Support Managed NetworkState format dictionaries for controlled settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Managed Properties Dict Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const char kSetPreferNetworkMessage[] = "setPreferNetwork"; 119 const char kSetPreferNetworkMessage[] = "setPreferNetwork";
120 const char kSetServerHostname[] = "setServerHostname"; 120 const char kSetServerHostname[] = "setServerHostname";
121 const char kSetSimCardLockMessage[] = "setSimCardLock"; 121 const char kSetSimCardLockMessage[] = "setSimCardLock";
122 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; 122 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo";
123 123
124 // These are strings used to communicate with JavaScript. 124 // These are strings used to communicate with JavaScript.
125 const char kTagActivate[] = "activate"; 125 const char kTagActivate[] = "activate";
126 const char kTagActivationState[] = "activationState"; 126 const char kTagActivationState[] = "activationState";
127 const char kTagAddConnection[] = "add"; 127 const char kTagAddConnection[] = "add";
128 const char kTagApn[] = "apn"; 128 const char kTagApn[] = "apn";
129 const char kTagAutoConnect[] = "autoConnect";
130 const char kTagCarrierSelectFlag[] = "showCarrierSelect"; 129 const char kTagCarrierSelectFlag[] = "showCarrierSelect";
131 const char kTagCarrierUrl[] = "carrierUrl"; 130 const char kTagCarrierUrl[] = "carrierUrl";
132 const char kTagCellularAvailable[] = "cellularAvailable"; 131 const char kTagCellularAvailable[] = "cellularAvailable";
133 const char kTagCellularEnabled[] = "cellularEnabled"; 132 const char kTagCellularEnabled[] = "cellularEnabled";
134 const char kTagCellularSupportsScan[] = "cellularSupportsScan"; 133 const char kTagCellularSupportsScan[] = "cellularSupportsScan";
135 const char kTagConfigure[] = "configure"; 134 const char kTagConfigure[] = "configure";
136 const char kTagConnect[] = "connect"; 135 const char kTagConnect[] = "connect";
137 const char kTagControlledBy[] = "controlledBy"; 136 const char kTagControlledBy[] = "controlledBy";
138 const char kTagDeviceConnected[] = "deviceConnected"; 137 const char kTagDeviceConnected[] = "deviceConnected";
139 const char kTagDisconnect[] = "disconnect"; 138 const char kTagDisconnect[] = "disconnect";
140 const char kTagErrorState[] = "errorState"; 139 const char kTagErrorMessage[] = "errorMessage";
141 const char kTagForget[] = "forget"; 140 const char kTagForget[] = "forget";
142 const char kTagIdentity[] = "identity";
143 const char kTagLanguage[] = "language"; 141 const char kTagLanguage[] = "language";
144 const char kTagLastGoodApn[] = "lastGoodApn"; 142 const char kTagLastGoodApn[] = "lastGoodApn";
145 const char kTagLocalizedName[] = "localizedName"; 143 const char kTagLocalizedName[] = "localizedName";
146 const char kTagName[] = "name"; 144 const char kTagName[] = "name";
147 const char kTagNameServersGoogle[] = "nameServersGoogle"; 145 const char kTagNameServersGoogle[] = "nameServersGoogle";
148 const char kTagNameServerType[] = "nameServerType"; 146 const char kTagNameServerType[] = "nameServerType";
149 const char kTagNetworkId[] = "networkId"; 147 const char kTagNetworkId[] = "networkId";
150 const char kTagOptions[] = "options"; 148 const char kTagOptions[] = "options";
151 const char kTagPassword[] = "password"; 149 const char kTagPassword[] = "password";
152 const char kTagPolicy[] = "policy"; 150 const char kTagPolicy[] = "policy";
153 const char kTagPreferred[] = "preferred"; 151 const char kTagPreferred[] = "preferred";
154 const char kTagProviderType[] = "providerType"; 152 const char kTagProviderType[] = "providerType";
155 const char kTagProviderApnList[] = "providerApnList"; 153 const char kTagProviderApnList[] = "providerApnList";
156 const char kTagRecommended[] = "recommended"; 154 const char kTagRecommended[] = "recommended";
157 const char kTagRecommendedValue[] = "recommendedValue"; 155 const char kTagRecommendedValue[] = "recommendedValue";
158 const char kTagRemembered[] = "remembered"; 156 const char kTagRemembered[] = "remembered";
159 const char kTagRememberedList[] = "rememberedList"; 157 const char kTagRememberedList[] = "rememberedList";
160 const char kTagRestrictedPool[] = "restrictedPool"; 158 const char kTagRestrictedPool[] = "restrictedPool";
161 const char kTagRoamingState[] = "roamingState"; 159 const char kTagRoamingState[] = "roamingState";
162 const char kTagServerHostname[] = "serverHostname"; 160 const char kTagServerHostname[] = "serverHostname";
163 const char kTagCarriers[] = "carriers"; 161 const char kTagCarriers[] = "carriers";
164 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex"; 162 const char kTagCurrentCarrierIndex[] = "currentCarrierIndex";
165 const char kTagShared[] = "shared"; 163 const char kTagShared[] = "shared";
166 const char kTagShowActivateButton[] = "showActivateButton"; 164 const char kTagShowActivateButton[] = "showActivateButton";
167 const char kTagShowStaticIPConfig[] = "showStaticIPConfig";
168 const char kTagShowViewAccountButton[] = "showViewAccountButton"; 165 const char kTagShowViewAccountButton[] = "showViewAccountButton";
169 const char kTagSimCardLockEnabled[] = "simCardLockEnabled"; 166 const char kTagSimCardLockEnabled[] = "simCardLockEnabled";
170 const char kTagSupportUrl[] = "supportUrl"; 167 const char kTagSupportUrl[] = "supportUrl";
171 const char kTagTrue[] = "true"; 168 const char kTagTrue[] = "true";
172 const char kTagUsername[] = "username"; 169 const char kTagUsername[] = "username";
173 const char kTagValue[] = "value"; 170 const char kTagValue[] = "value";
174 const char kTagVpnList[] = "vpnList"; 171 const char kTagVpnList[] = "vpnList";
175 const char kTagWifiAvailable[] = "wifiAvailable"; 172 const char kTagWifiAvailable[] = "wifiAvailable";
176 const char kTagWifiEnabled[] = "wifiEnabled"; 173 const char kTagWifiEnabled[] = "wifiEnabled";
177 const char kTagWimaxAvailable[] = "wimaxAvailable"; 174 const char kTagWimaxAvailable[] = "wimaxAvailable";
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 std::string name_servers; 285 std::string name_servers;
289 if (shill_properties.GetStringWithoutPathExpansion( 286 if (shill_properties.GetStringWithoutPathExpansion(
290 name_servers_key, &name_servers)) { 287 name_servers_key, &name_servers)) {
291 ip_info_dict->SetString(kIpConfigNameServers, name_servers); 288 ip_info_dict->SetString(kIpConfigNameServers, name_servers);
292 VLOG(2) << "Found " << name_servers_key << ": " << name_servers; 289 VLOG(2) << "Found " << name_servers_key << ": " << name_servers;
293 } 290 }
294 291
295 return ip_info_dict.release(); 292 return ip_info_dict.release();
296 } 293 }
297 294
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 295 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does and
313 // store it under |key| in |settings|. Takes ownership of |value|. 296 // store it under |key| in |settings|. Takes ownership of |value|.
314 void SetValueDictionary(base::DictionaryValue* settings, 297 void SetValueDictionary(const char* key,
315 const char* key,
316 base::Value* value, 298 base::Value* value,
317 const NetworkPropertyUIData& ui_data) { 299 const NetworkPropertyUIData& ui_data,
300 base::DictionaryValue* settings) {
318 base::DictionaryValue* dict = new base::DictionaryValue(); 301 base::DictionaryValue* dict = new base::DictionaryValue();
319 // DictionaryValue::Set() takes ownership of |value|. 302 // DictionaryValue::Set() takes ownership of |value|.
320 dict->Set(kTagValue, value); 303 dict->Set(kTagValue, value);
321 settings->Set(key, dict); 304 settings->Set(key, dict);
322 DecorateValueDictionary(ui_data, *value, dict); 305
306 const base::Value* recommended_value = ui_data.default_value();
307 if (ui_data.IsManaged())
308 dict->SetString(kTagControlledBy, kTagPolicy);
309 else if (recommended_value && recommended_value->Equals(value))
310 dict->SetString(kTagControlledBy, kTagRecommended);
311
312 if (recommended_value)
313 dict->Set(kTagRecommendedValue, recommended_value->DeepCopy());
323 } 314 }
324 315
325 // Creates a decorated dictionary like SetValueDictionary does, but extended for 316 const char* GetOncSourceString(::onc::ONCSource onc_source) {
326 // the Autoconnect property, which respects additionally global network policy. 317 if (onc_source == ::onc::ONC_SOURCE_DEVICE_POLICY)
327 void SetAutoconnectValueDictionary(bool network_is_private, 318 return ::onc::kAugmentationDevicePolicy;
328 ::onc::ONCSource onc_source, 319 return ::onc::kAugmentationUserPolicy;
329 bool current_autoconnect, 320 }
330 const NetworkPropertyUIData& ui_data, 321
331 base::DictionaryValue* settings) { 322 // Creates a GetManagedProperties style dictionary. Takes ownership of |value|.
323 // |recommended_source| tracks the source for recommened ONC properties.
324 // Note(stevenjb): This is bridge code until we use GetManagedProperties to
325 // retrieve Shill properties.
326 void SetManagedValueDictionary(const char* key,
327 base::Value* value,
328 const NetworkPropertyUIData& ui_data,
329 ::onc::ONCSource recommended_source,
pneubeck (no reviews) 2014/08/01 16:09:08 optional suggestion: I find the name 'recommended
stevenjb 2014/08/01 17:07:35 I am trying to differentiate it from ui_data.onc_s
pneubeck (no reviews) 2014/08/01 17:18:48 If you look into NetowrkProperytUIData, the only f
330 base::DictionaryValue* settings) {
332 base::DictionaryValue* dict = new base::DictionaryValue(); 331 base::DictionaryValue* dict = new base::DictionaryValue();
333 base::Value* value = new base::FundamentalValue(current_autoconnect); 332 settings->Set(key, dict);
334 // DictionaryValue::Set() takes ownership of |value|. 333 dict->Set(::onc::kAugmentationActiveSetting, value); // owns |value|
335 dict->Set(kTagValue, value); 334
336 settings->Set(kTagAutoConnect, dict); 335 if (ui_data.onc_source() == ::onc::ONC_SOURCE_NONE) {
337 if (onc_source != ::onc::ONC_SOURCE_USER_POLICY && 336 if (!ui_data.default_value())
338 onc_source != ::onc::ONC_SOURCE_DEVICE_POLICY) { 337 return; // Unmanaged
pneubeck (no reviews) 2014/08/01 16:09:08 The comment is inaccurate. This case only means th
stevenjb 2014/08/01 17:07:35 Bah. Right. OK, I'm going to try do do this withou
339 // Autoconnect can be controlled by the GlobalNetworkConfiguration of the 338 // Recommended. Use |recommended_source| of the onc source.
340 // ONC policy. 339 dict->Set(::onc::kAugmentationUserEditable,
pneubeck (no reviews) 2014/08/01 16:09:08 optional nit: Using UserEditable will have the sam
stevenjb 2014/08/01 17:07:35 Uh... yeah.... OK? Not sure I followed all that, s
341 bool only_policy_autoconnect = 340 new base::FundamentalValue(true));
342 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(network_is_private); 341 std::string effective = GetOncSourceString(recommended_source);
343 if (only_policy_autoconnect) { 342 dict->SetString(::onc::kAugmentationEffectiveSetting, effective);
344 dict->SetString(kTagControlledBy, kTagPolicy); 343 dict->Set(effective, ui_data.default_value()->DeepCopy());
345 return; 344 return;
346 }
347 } 345 }
348 DecorateValueDictionary(ui_data, *value, dict); 346 std::string effective = GetOncSourceString(ui_data.onc_source());
347 dict->SetString(::onc::kAugmentationEffectiveSetting, effective);
348 // This is currently unused and redundant, but set for consistency with the
349 // results of GetManagedProperties.
350 dict->Set(effective, value->DeepCopy());
349 } 351 }
350 352
351 std::string CopyStringFromDictionary(const base::DictionaryValue& source, 353 std::string CopyStringFromDictionary(const base::DictionaryValue& source,
352 const std::string& src_key, 354 const std::string& src_key,
353 const std::string& dest_key, 355 const std::string& dest_key,
354 base::DictionaryValue* dest) { 356 base::DictionaryValue* dest) {
355 std::string string_value; 357 std::string string_value;
356 if (source.GetStringWithoutPathExpansion(src_key, &string_value)) 358 if (source.GetStringWithoutPathExpansion(src_key, &string_value))
357 dest->SetStringWithoutPathExpansion(dest_key, string_value); 359 dest->SetStringWithoutPathExpansion(dest_key, string_value);
358 return string_value; 360 return string_value;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 onc::FindPolicyForActiveUser(vpn->guid(), &onc_source); 396 onc::FindPolicyForActiveUser(vpn->guid(), &onc_source);
395 397
396 NetworkPropertyUIData hostname_ui_data; 398 NetworkPropertyUIData hostname_ui_data;
397 hostname_ui_data.ParseOncProperty( 399 hostname_ui_data.ParseOncProperty(
398 onc_source, 400 onc_source,
399 onc, 401 onc,
400 ::onc::network_config::VpnProperty(::onc::vpn::kHost)); 402 ::onc::network_config::VpnProperty(::onc::vpn::kHost));
401 std::string provider_host; 403 std::string provider_host;
402 provider_properties->GetStringWithoutPathExpansion( 404 provider_properties->GetStringWithoutPathExpansion(
403 shill::kHostProperty, &provider_host); 405 shill::kHostProperty, &provider_host);
404 SetValueDictionary(dictionary, kTagServerHostname, 406 SetValueDictionary(kTagServerHostname,
405 new base::StringValue(provider_host), 407 new base::StringValue(provider_host),
406 hostname_ui_data); 408 hostname_ui_data,
409 dictionary);
407 } 410 }
408 411
409 // Given a list of supported carrier's by the device, return the index of 412 // Given a list of supported carrier's by the device, return the index of
410 // the carrier the device is currently using. 413 // the carrier the device is currently using.
411 int FindCurrentCarrierIndex(const base::ListValue* carriers, 414 int FindCurrentCarrierIndex(const base::ListValue* carriers,
412 const DeviceState* device) { 415 const DeviceState* device) {
413 DCHECK(carriers); 416 DCHECK(carriers);
414 DCHECK(device); 417 DCHECK(device);
415 bool gsm = (device->technology_family() == shill::kTechnologyFamilyGsm); 418 bool gsm = (device->technology_family() == shill::kTechnologyFamilyGsm);
416 int index = 0; 419 int index = 0;
417 for (base::ListValue::const_iterator it = carriers->begin(); 420 for (base::ListValue::const_iterator it = carriers->begin();
418 it != carriers->end(); ++it, ++index) { 421 it != carriers->end(); ++it, ++index) {
419 std::string value; 422 std::string value;
420 if (!(*it)->GetAsString(&value)) 423 if (!(*it)->GetAsString(&value))
421 continue; 424 continue;
422 // For GSM devices the device name will be empty, so simply select 425 // For GSM devices the device name will be empty, so simply select
423 // the Generic UMTS carrier option if present. 426 // the Generic UMTS carrier option if present.
424 if (gsm && (value == shill::kCarrierGenericUMTS)) 427 if (gsm && (value == shill::kCarrierGenericUMTS))
425 return index; 428 return index;
426 // For other carriers, the service name will match the carrier name. 429 // For other carriers, the service name will match the carrier name.
427 if (value == device->carrier()) 430 if (value == device->carrier())
428 return index; 431 return index;
429 } 432 }
430 return -1; 433 return -1;
431 } 434 }
432 435
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, 436 void CreateDictionaryFromCellularApn(const base::DictionaryValue* apn,
441 base::DictionaryValue* dictionary) { 437 base::DictionaryValue* dictionary) {
442 CopyStringFromDictionary(*apn, shill::kApnProperty, kTagApn, dictionary); 438 CopyStringFromDictionary(*apn, shill::kApnProperty, kTagApn, dictionary);
443 CopyStringFromDictionary( 439 CopyStringFromDictionary(
444 *apn, shill::kApnNetworkIdProperty, kTagNetworkId, dictionary); 440 *apn, shill::kApnNetworkIdProperty, kTagNetworkId, dictionary);
445 CopyStringFromDictionary( 441 CopyStringFromDictionary(
446 *apn, shill::kApnUsernameProperty, kTagUsername, dictionary); 442 *apn, shill::kApnUsernameProperty, kTagUsername, dictionary);
447 CopyStringFromDictionary( 443 CopyStringFromDictionary(
448 *apn, shill::kApnPasswordProperty, kTagPassword, dictionary); 444 *apn, shill::kApnPasswordProperty, kTagPassword, dictionary);
449 CopyStringFromDictionary(*apn, shill::kApnNameProperty, kTagName, dictionary); 445 CopyStringFromDictionary(*apn, shill::kApnNameProperty, kTagName, dictionary);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 const DeviceState* device = 497 const DeviceState* device =
502 NetworkHandler::Get()->network_state_handler()->GetDeviceState( 498 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
503 cellular->device_path()); 499 cellular->device_path());
504 if (device) { 500 if (device) {
505 const base::DictionaryValue& device_properties = device->properties(); 501 const base::DictionaryValue& device_properties = device->properties();
506 ::onc::ONCSource onc_source; 502 ::onc::ONCSource onc_source;
507 NetworkHandler::Get()->managed_network_configuration_handler()-> 503 NetworkHandler::Get()->managed_network_configuration_handler()->
508 FindPolicyByGUID(LoginState::Get()->primary_user_hash(), 504 FindPolicyByGUID(LoginState::Get()->primary_user_hash(),
509 cellular->guid(), &onc_source); 505 cellular->guid(), &onc_source);
510 const NetworkPropertyUIData cellular_property_ui_data(onc_source); 506 const NetworkPropertyUIData cellular_property_ui_data(onc_source);
511 SetValueDictionary(dictionary, 507 SetValueDictionary(kTagSimCardLockEnabled,
512 kTagSimCardLockEnabled,
513 new base::FundamentalValue(device->sim_lock_enabled()), 508 new base::FundamentalValue(device->sim_lock_enabled()),
514 cellular_property_ui_data); 509 cellular_property_ui_data,
510 dictionary);
515 511
516 carrier_id = device->home_provider_id(); 512 carrier_id = device->home_provider_id();
517 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn); 513 device_properties.GetStringWithoutPathExpansion(shill::kMdnProperty, &mdn);
518 514
519 MobileConfig* config = MobileConfig::GetInstance(); 515 MobileConfig* config = MobileConfig::GetInstance();
520 if (config->IsReady()) { 516 if (config->IsReady()) {
521 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id); 517 const MobileConfig::Carrier* carrier = config->GetCarrier(carrier_id);
522 if (carrier && !carrier->top_up_url().empty()) 518 if (carrier && !carrier->top_up_url().empty())
523 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url()); 519 dictionary->SetString(kTagCarrierUrl, carrier->top_up_url());
524 } 520 }
525 521
526 base::ListValue* apn_list_value = new base::ListValue(); 522 base::ListValue* apn_list_value = new base::ListValue();
527 const base::ListValue* apn_list; 523 const base::ListValue* apn_list;
528 if (device_properties.GetListWithoutPathExpansion( 524 if (device_properties.GetListWithoutPathExpansion(
529 shill::kCellularApnListProperty, &apn_list)) { 525 shill::kCellularApnListProperty, &apn_list)) {
530 for (base::ListValue::const_iterator iter = apn_list->begin(); 526 for (base::ListValue::const_iterator iter = apn_list->begin();
531 iter != apn_list->end(); 527 iter != apn_list->end();
532 ++iter) { 528 ++iter) {
533 const base::DictionaryValue* dict; 529 const base::DictionaryValue* dict;
534 if ((*iter)->GetAsDictionary(&dict)) { 530 if ((*iter)->GetAsDictionary(&dict)) {
535 base::DictionaryValue* apn = new base::DictionaryValue; 531 base::DictionaryValue* apn = new base::DictionaryValue;
536 CreateDictionaryFromCellularApn(dict, apn); 532 CreateDictionaryFromCellularApn(dict, apn);
537 apn_list_value->Append(apn); 533 apn_list_value->Append(apn);
538 } 534 }
539 } 535 }
540 } 536 }
541 SetValueDictionary(dictionary, 537 SetValueDictionary(kTagProviderApnList,
542 kTagProviderApnList,
543 apn_list_value, 538 apn_list_value,
544 cellular_property_ui_data); 539 cellular_property_ui_data,
540 dictionary);
545 const base::ListValue* supported_carriers; 541 const base::ListValue* supported_carriers;
546 if (device_properties.GetListWithoutPathExpansion( 542 if (device_properties.GetListWithoutPathExpansion(
547 shill::kSupportedCarriersProperty, &supported_carriers)) { 543 shill::kSupportedCarriersProperty, &supported_carriers)) {
548 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy()); 544 dictionary->Set(kTagCarriers, supported_carriers->DeepCopy());
549 dictionary->SetInteger( 545 dictionary->SetInteger(
550 kTagCurrentCarrierIndex, 546 kTagCurrentCarrierIndex,
551 FindCurrentCarrierIndex(supported_carriers, device)); 547 FindCurrentCarrierIndex(supported_carriers, device));
552 } else { 548 } else {
553 // In case of any error, set the current carrier tag to -1 indicating 549 // In case of any error, set the current carrier tag to -1 indicating
554 // to the JS code to fallback to a single carrier. 550 // to the JS code to fallback to a single carrier.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 // TODO(stevenjb): Once we eliminate all references to Shill properties, 610 // TODO(stevenjb): Once we eliminate all references to Shill properties,
615 // we can switch to using managed_network_configuration_handler which 611 // we can switch to using managed_network_configuration_handler which
616 // includes Device properties for Cellular (and skip the call to 612 // includes Device properties for Cellular (and skip the call to
617 // onc::TranslateShillServiceToONCPart). For now we copy them over here. 613 // onc::TranslateShillServiceToONCPart). For now we copy them over here.
618 scoped_ptr<base::DictionaryValue> shill_properties_with_device( 614 scoped_ptr<base::DictionaryValue> shill_properties_with_device(
619 shill_properties.DeepCopy()); 615 shill_properties.DeepCopy());
620 const DeviceState* device = 616 const DeviceState* device =
621 NetworkHandler::Get()->network_state_handler()->GetDeviceState( 617 NetworkHandler::Get()->network_state_handler()->GetDeviceState(
622 network->device_path()); 618 network->device_path());
623 if (device) { 619 if (device) {
624 shill_properties_with_device->Set(shill::kDeviceProperty, 620 shill_properties_with_device->SetWithoutPathExpansion(
625 device->properties().DeepCopy()); 621 shill::kDeviceProperty, device->properties().DeepCopy());
622 // Get the hardware MAC address from the DeviceState.
623 // (Note: this is done in ManagedNetworkConfigurationHandler but not
624 // in NetworkConfigurationHandler).
625 if (!device->mac_address().empty()) {
626 shill_properties_with_device->SetStringWithoutPathExpansion(
627 shill::kAddressProperty, device->mac_address());
628 }
626 } 629 }
627 scoped_ptr<base::DictionaryValue> dictionary = 630 scoped_ptr<base::DictionaryValue> dictionary =
628 onc::TranslateShillServiceToONCPart( 631 onc::TranslateShillServiceToONCPart(
629 *shill_properties_with_device, &onc::kNetworkWithStateSignature); 632 *shill_properties_with_device, &onc::kNetworkWithStateSignature);
630 633
631 dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); 634 dictionary->SetString(kNetworkInfoKeyServicePath, network->path());
632 dictionary->SetString( 635 dictionary->SetString(
633 kTagErrorState, 636 kTagErrorMessage,
634 ash::network_connect::ErrorString(network->error(), network->path())); 637 ash::network_connect::ErrorString(network->error(), network->path()));
635 638
636 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty()); 639 dictionary->SetBoolean(kTagRemembered, !network->profile_path().empty());
637 bool shared = !network->IsPrivate(); 640 bool shared = !network->IsPrivate();
638 dictionary->SetBoolean(kTagShared, shared); 641 dictionary->SetBoolean(kTagShared, shared);
639 642
640 const std::string& type = network->type(); 643 const std::string& type = network->type();
641 644
642 const NetworkState* connected_network = 645 const NetworkState* connected_network =
643 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType( 646 NetworkHandler::Get()->network_state_handler()->ConnectedNetworkByType(
644 NetworkTypePattern::Primitive(type)); 647 NetworkTypePattern::Primitive(type));
645 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL); 648 dictionary->SetBoolean(kTagDeviceConnected, connected_network != NULL);
646 649
647 if (type == shill::kTypeWimax) 650 if (type == shill::kTypeCellular)
648 PopulateWimaxDetails(network, shill_properties, dictionary.get());
649 else if (type == shill::kTypeCellular)
650 PopulateCellularDetails(network, shill_properties, dictionary.get()); 651 PopulateCellularDetails(network, shill_properties, dictionary.get());
651 else if (type == shill::kTypeVPN) 652 else if (type == shill::kTypeVPN)
652 PopulateVPNDetails(network, shill_properties, dictionary.get()); 653 PopulateVPNDetails(network, shill_properties, dictionary.get());
653 654
654 return dictionary.Pass(); 655 return dictionary.Pass();
655 } 656 }
656 657
657 // Helper methods for SetIPConfigProperties 658 // Helper methods for SetIPConfigProperties
658 bool AppendPropertyKeyIfPresent(const std::string& key, 659 bool AppendPropertyKeyIfPresent(const std::string& key,
659 const base::DictionaryValue& old_properties, 660 const base::DictionaryValue& old_properties,
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
1265 1266
1266 // IP config 1267 // IP config
1267 scoped_ptr<base::DictionaryValue> ipconfig_dhcp(new base::DictionaryValue); 1268 scoped_ptr<base::DictionaryValue> ipconfig_dhcp(new base::DictionaryValue);
1268 ipconfig_dhcp->SetString(kIpConfigAddress, network->ip_address()); 1269 ipconfig_dhcp->SetString(kIpConfigAddress, network->ip_address());
1269 ipconfig_dhcp->SetString(kIpConfigNetmask, network->GetNetmask()); 1270 ipconfig_dhcp->SetString(kIpConfigNetmask, network->GetNetmask());
1270 ipconfig_dhcp->SetString(kIpConfigGateway, network->gateway()); 1271 ipconfig_dhcp->SetString(kIpConfigGateway, network->gateway());
1271 std::string ipconfig_name_servers = network->GetDnsServersAsString(); 1272 std::string ipconfig_name_servers = network->GetDnsServersAsString();
1272 ipconfig_dhcp->SetString(kIpConfigNameServers, ipconfig_name_servers); 1273 ipconfig_dhcp->SetString(kIpConfigNameServers, ipconfig_name_servers);
1273 ipconfig_dhcp->SetString(kIpConfigWebProxyAutoDiscoveryUrl, 1274 ipconfig_dhcp->SetString(kIpConfigWebProxyAutoDiscoveryUrl,
1274 network->web_proxy_auto_discovery_url().spec()); 1275 network->web_proxy_auto_discovery_url().spec());
1275 SetValueDictionary(dictionary.get(), 1276 SetValueDictionary(kDictionaryIpConfig,
1276 kDictionaryIpConfig,
1277 ipconfig_dhcp.release(), 1277 ipconfig_dhcp.release(),
1278 property_ui_data); 1278 property_ui_data,
1279 dictionary.get());
1279 1280
1280 std::string name_server_type = kNameServerTypeAutomatic; 1281 std::string name_server_type = kNameServerTypeAutomatic;
1281 int automatic_ip_config = 0; 1282 int automatic_ip_config = 0;
1282 scoped_ptr<base::DictionaryValue> static_ip_dict( 1283 scoped_ptr<base::DictionaryValue> static_ip_dict(
1283 BuildIPInfoDictionary(shill_properties, true, &automatic_ip_config)); 1284 BuildIPInfoDictionary(shill_properties, true, &automatic_ip_config));
1284 dictionary->SetBoolean(kIpConfigAutoConfig, automatic_ip_config == 0); 1285 dictionary->SetBoolean(kIpConfigAutoConfig, automatic_ip_config == 0);
1285 DCHECK(automatic_ip_config == 3 || automatic_ip_config == 0) 1286 DCHECK(automatic_ip_config == 3 || automatic_ip_config == 0)
1286 << "UI doesn't support automatic specification of individual " 1287 << "UI doesn't support automatic specification of individual "
1287 << "static IP parameters."; 1288 << "static IP parameters.";
1288 scoped_ptr<base::DictionaryValue> saved_ip_dict( 1289 scoped_ptr<base::DictionaryValue> saved_ip_dict(
1289 BuildIPInfoDictionary(shill_properties, false, NULL)); 1290 BuildIPInfoDictionary(shill_properties, false, NULL));
1290 dictionary->Set(kDictionarySavedIp, saved_ip_dict.release()); 1291 dictionary->Set(kDictionarySavedIp, saved_ip_dict.release());
1291 1292
1292 // Determine what kind of name server setting we have by comparing the 1293 // Determine what kind of name server setting we have by comparing the
1293 // StaticIP and Google values with the ipconfig values. 1294 // StaticIP and Google values with the ipconfig values.
1294 std::string static_ip_nameservers; 1295 std::string static_ip_nameservers;
1295 static_ip_dict->GetString(kIpConfigNameServers, &static_ip_nameservers); 1296 static_ip_dict->GetString(kIpConfigNameServers, &static_ip_nameservers);
1296 if (!static_ip_nameservers.empty() && 1297 if (!static_ip_nameservers.empty() &&
1297 static_ip_nameservers == ipconfig_name_servers) { 1298 static_ip_nameservers == ipconfig_name_servers) {
1298 name_server_type = kNameServerTypeUser; 1299 name_server_type = kNameServerTypeUser;
1299 } 1300 }
1300 if (ipconfig_name_servers == kGoogleNameServers) { 1301 if (ipconfig_name_servers == kGoogleNameServers) {
1301 name_server_type = kNameServerTypeGoogle; 1302 name_server_type = kNameServerTypeGoogle;
1302 } 1303 }
1303 SetValueDictionary(dictionary.get(), 1304 SetValueDictionary(kDictionaryStaticIp,
1304 kDictionaryStaticIp,
1305 static_ip_dict.release(), 1305 static_ip_dict.release(),
1306 property_ui_data); 1306 property_ui_data,
1307 dictionary.get());
1307 1308
1308 dictionary->SetString(kTagNameServerType, name_server_type); 1309 dictionary->SetString(kTagNameServerType, name_server_type);
1309 dictionary->SetString(kTagNameServersGoogle, kGoogleNameServers); 1310 dictionary->SetString(kTagNameServersGoogle, kGoogleNameServers);
1310 1311
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; 1312 int priority = 0;
1317 shill_properties.GetIntegerWithoutPathExpansion( 1313 shill_properties.GetIntegerWithoutPathExpansion(
1318 shill::kPriorityProperty, &priority); 1314 shill::kPriorityProperty, &priority);
1319 bool preferred = priority > 0; 1315 bool preferred = priority > 0;
1320 SetValueDictionary(dictionary.get(), kTagPreferred, 1316 SetValueDictionary(kTagPreferred,
1321 new base::FundamentalValue(preferred), 1317 new base::FundamentalValue(preferred),
1322 property_ui_data); 1318 property_ui_data,
1319 dictionary.get());
1323 1320
1324 NetworkPropertyUIData auto_connect_ui_data(onc_source); 1321 NetworkPropertyUIData auto_connect_ui_data(onc_source);
1325 std::string onc_path_to_auto_connect; 1322 std::string onc_path_to_auto_connect;
1326 if (network->Matches(NetworkTypePattern::WiFi())) { 1323 if (network->Matches(NetworkTypePattern::WiFi())) {
1327 content::RecordAction( 1324 content::RecordAction(
1328 base::UserMetricsAction("Options_NetworkShowDetailsWifi")); 1325 base::UserMetricsAction("Options_NetworkShowDetailsWifi"));
1329 if (network->IsConnectedState()) { 1326 if (network->IsConnectedState()) {
1330 content::RecordAction( 1327 content::RecordAction(
1331 base::UserMetricsAction("Options_NetworkShowDetailsWifiConnected")); 1328 base::UserMetricsAction("Options_NetworkShowDetailsWifiConnected"));
1332 } 1329 }
(...skipping 16 matching lines...) Expand all
1349 "Options_NetworkShowDetailsCellularConnected")); 1346 "Options_NetworkShowDetailsCellularConnected"));
1350 } 1347 }
1351 } 1348 }
1352 if (!onc_path_to_auto_connect.empty()) { 1349 if (!onc_path_to_auto_connect.empty()) {
1353 auto_connect_ui_data.ParseOncProperty( 1350 auto_connect_ui_data.ParseOncProperty(
1354 onc_source, onc, onc_path_to_auto_connect); 1351 onc_source, onc, onc_path_to_auto_connect);
1355 } 1352 }
1356 bool auto_connect = false; 1353 bool auto_connect = false;
1357 shill_properties.GetBooleanWithoutPathExpansion( 1354 shill_properties.GetBooleanWithoutPathExpansion(
1358 shill::kAutoConnectProperty, &auto_connect); 1355 shill::kAutoConnectProperty, &auto_connect);
1359 SetAutoconnectValueDictionary(network->IsPrivate(), 1356
1360 onc_source, 1357 // Autoconnect can be controlled by the GlobalNetworkConfiguration of the
1361 auto_connect, 1358 // ONC policy.
1362 auto_connect_ui_data, 1359 scoped_ptr<base::Value> auto_connect_value(
1363 dictionary.get()); 1360 new base::FundamentalValue(auto_connect));
1361 if (auto_connect_ui_data.onc_source() != ::onc::ONC_SOURCE_NONE &&
pneubeck (no reviews) 2014/08/01 16:09:08 This still has to be changed. Exact syntactic repl
stevenjb 2014/08/01 17:07:35 I -really- don't understand this. Let's see how th
1362 onc::PolicyAllowsOnlyPolicyNetworksToAutoconnect(network->IsPrivate())) {
1363 ::onc::ONCSource source = network->IsPrivate()
1364 ? ::onc::ONC_SOURCE_USER_POLICY : ::onc::ONC_SOURCE_DEVICE_POLICY;
1365 // This modifies auto_connect_ui_data, so that the autoconnect value
1366 // appears to be set to 'false' by policy and not editable by the user.
1367 if (auto_connect) {
1368 LOG(WARNING) << "Policy prevents autoconnect, but values is True.";
1369 auto_connect_value.reset(new base::FundamentalValue(false));
1370 }
1371 auto_connect_ui_data.SetOncSourceAndValue(source, auto_connect_value.get());
1372 }
1373 SetManagedValueDictionary(shill::kAutoConnectProperty,
1374 auto_connect_value.release(),
1375 auto_connect_ui_data,
1376 onc_source, // For recommended values.
1377 dictionary.get());
1364 1378
1365 // Show details dialog 1379 // Show details dialog
1366 web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, *dictionary); 1380 web_ui()->CallJavascriptFunction(kShowDetailedInfoFunction, *dictionary);
1367 } 1381 }
1368 1382
1369 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 1383 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
1370 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 1384 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
1371 } 1385 }
1372 1386
1373 float InternetOptionsHandler::GetScaleFactor() const { 1387 float InternetOptionsHandler::GetScaleFactor() const {
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1554 dictionary->SetBoolean( 1568 dictionary->SetBoolean(
1555 kTagWimaxAvailable, 1569 kTagWimaxAvailable,
1556 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 1570 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
1557 dictionary->SetBoolean( 1571 dictionary->SetBoolean(
1558 kTagWimaxEnabled, 1572 kTagWimaxEnabled,
1559 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 1573 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
1560 } 1574 }
1561 1575
1562 } // namespace options 1576 } // namespace options
1563 } // namespace chromeos 1577 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698