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

Side by Side Diff: chromeos/network/onc/onc_translator_shill_to_onc.cc

Issue 535283002: Translate activation/romaing state, restricted pool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_7b
Patch Set: Rebase Created 6 years, 3 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
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 "chromeos/network/onc/onc_translator.h" 5 #include "chromeos/network/onc/onc_translator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 shill::kSecurityProperty, kWiFiSecurityTable, ::onc::wifi::kSecurity); 308 shill::kSecurityProperty, kWiFiSecurityTable, ::onc::wifi::kSecurity);
309 std::string ssid = shill_property_util::GetSSIDFromProperties( 309 std::string ssid = shill_property_util::GetSSIDFromProperties(
310 *shill_dictionary_, NULL /* ignore unknown encoding */); 310 *shill_dictionary_, NULL /* ignore unknown encoding */);
311 if (!ssid.empty()) 311 if (!ssid.empty())
312 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid); 312 onc_object_->SetStringWithoutPathExpansion(::onc::wifi::kSSID, ssid);
313 CopyPropertiesAccordingToSignature(); 313 CopyPropertiesAccordingToSignature();
314 } 314 }
315 315
316 void ShillToONCTranslator::TranslateCellularWithState() { 316 void ShillToONCTranslator::TranslateCellularWithState() {
317 CopyPropertiesAccordingToSignature(); 317 CopyPropertiesAccordingToSignature();
318 TranslateWithTableAndSet(shill::kActivationStateProperty,
319 kActivationStateTable,
320 ::onc::cellular::kActivationState);
321 TranslateWithTableAndSet(shill::kRoamingStateProperty,
322 kRoamingStateTable,
323 ::onc::cellular::kRoamingState);
318 const base::DictionaryValue* dictionary = NULL; 324 const base::DictionaryValue* dictionary = NULL;
319 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 325 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
320 shill::kServingOperatorProperty, &dictionary)) { 326 shill::kServingOperatorProperty, &dictionary)) {
321 TranslateAndAddNestedObject(::onc::cellular::kServingOperator, *dictionary); 327 TranslateAndAddNestedObject(::onc::cellular::kServingOperator, *dictionary);
322 } 328 }
323 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 329 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
324 shill::kCellularApnProperty, &dictionary)) { 330 shill::kCellularApnProperty, &dictionary)) {
325 TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary); 331 TranslateAndAddNestedObject(::onc::cellular::kAPN, *dictionary);
326 } 332 }
327 if (shill_dictionary_->GetDictionaryWithoutPathExpansion( 333 if (shill_dictionary_->GetDictionaryWithoutPathExpansion(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kStateProperty, 401 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kStateProperty,
396 &state)) { 402 &state)) {
397 std::string onc_state = ::onc::connection_state::kNotConnected; 403 std::string onc_state = ::onc::connection_state::kNotConnected;
398 if (NetworkState::StateIsConnected(state)) { 404 if (NetworkState::StateIsConnected(state)) {
399 onc_state = ::onc::connection_state::kConnected; 405 onc_state = ::onc::connection_state::kConnected;
400 } else if (NetworkState::StateIsConnecting(state)) { 406 } else if (NetworkState::StateIsConnecting(state)) {
401 onc_state = ::onc::connection_state::kConnecting; 407 onc_state = ::onc::connection_state::kConnecting;
402 } 408 }
403 onc_object_->SetStringWithoutPathExpansion( 409 onc_object_->SetStringWithoutPathExpansion(
404 ::onc::network_config::kConnectionState, onc_state); 410 ::onc::network_config::kConnectionState, onc_state);
411 onc_object_->SetBooleanWithoutPathExpansion(
412 ::onc::network_config::kRestricted, state == shill::kStatePortal);
405 } 413 }
406 414
407 // Use a human-readable aa:bb format for any hardware MAC address. Note: 415 // Use a human-readable aa:bb format for any hardware MAC address. Note:
408 // this property is provided by the caller but is not part of the Shill 416 // this property is provided by the caller but is not part of the Shill
409 // Service properties (it is copied from the Device properties). 417 // Service properties (it is copied from the Device properties).
410 std::string address; 418 std::string address;
411 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kAddressProperty, 419 if (shill_dictionary_->GetStringWithoutPathExpansion(shill::kAddressProperty,
412 &address)) { 420 &address)) {
413 onc_object_->SetStringWithoutPathExpansion( 421 onc_object_->SetStringWithoutPathExpansion(
414 ::onc::network_config::kMacAddress, 422 ::onc::network_config::kMacAddress,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 const base::DictionaryValue& shill_dictionary, 629 const base::DictionaryValue& shill_dictionary,
622 const OncValueSignature* onc_signature) { 630 const OncValueSignature* onc_signature) {
623 CHECK(onc_signature != NULL); 631 CHECK(onc_signature != NULL);
624 632
625 ShillToONCTranslator translator(shill_dictionary, *onc_signature); 633 ShillToONCTranslator translator(shill_dictionary, *onc_signature);
626 return translator.CreateTranslatedONCObject(); 634 return translator.CreateTranslatedONCObject();
627 } 635 }
628 636
629 } // namespace onc 637 } // namespace onc
630 } // namespace chromeos 638 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698