| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/managed_network_configuration_handler.h" | 5 #include "chromeos/network/managed_network_configuration_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 shill_dictionary->SetStringWithoutPathExpansion(flimflam::kUIDataProperty, | 119 shill_dictionary->SetStringWithoutPathExpansion(flimflam::kUIDataProperty, |
| 120 ui_data_blob); | 120 ui_data_blob); |
| 121 } | 121 } |
| 122 | 122 |
| 123 // A dummy callback to ignore the result of Shill calls. | 123 // A dummy callback to ignore the result of Shill calls. |
| 124 void IgnoreString(const std::string& str) { | 124 void IgnoreString(const std::string& str) { |
| 125 } | 125 } |
| 126 | 126 |
| 127 void LogErrorWithDict(const tracked_objects::Location& from_where, | 127 void LogErrorWithDict(const tracked_objects::Location& from_where, |
| 128 const std::string& error_name, | 128 const std::string& error_name, |
| 129 const scoped_ptr<base::DictionaryValue> error_data) { | 129 scoped_ptr<base::DictionaryValue> error_data) { |
| 130 LOG(ERROR) << from_where.ToString() << ": " << error_name; | 130 LOG(ERROR) << from_where.ToString() << ": " << error_name; |
| 131 } | 131 } |
| 132 | 132 |
| 133 void LogErrorMessage(const tracked_objects::Location& from_where, | 133 void LogErrorMessage(const tracked_objects::Location& from_where, |
| 134 const std::string& error_name, | 134 const std::string& error_name, |
| 135 const std::string& error_message) { | 135 const std::string& error_message) { |
| 136 LOG(ERROR) << from_where.ToString() << ": " << error_message; | 136 LOG(ERROR) << from_where.ToString() << ": " << error_message; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // Removes all kFakeCredential values from sensitive fields (determined by | 139 // Removes all kFakeCredential values from sensitive fields (determined by |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 221 |
| 222 scoped_ptr<base::DictionaryValue> shill_dictionary( | 222 scoped_ptr<base::DictionaryValue> shill_dictionary( |
| 223 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature, | 223 onc::TranslateONCObjectToShill(&onc::kNetworkConfigurationSignature, |
| 224 *effective)); | 224 *effective)); |
| 225 | 225 |
| 226 shill_dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, | 226 shill_dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, |
| 227 profile_path); | 227 profile_path); |
| 228 | 228 |
| 229 scoped_ptr<NetworkUIData> ui_data; | 229 scoped_ptr<NetworkUIData> ui_data; |
| 230 if (policy) | 230 if (policy) |
| 231 ui_data = CreateUIDataFromONC(onc_source, *policy); | 231 ui_data = NetworkUIData::CreateUIDataFromONC(onc_source, *policy); |
| 232 else | 232 else |
| 233 ui_data.reset(new NetworkUIData()); | 233 ui_data.reset(new NetworkUIData()); |
| 234 | 234 |
| 235 if (settings) { | 235 if (settings) { |
| 236 // Shill doesn't know that sensitive data is contained in the UIData | 236 // Shill doesn't know that sensitive data is contained in the UIData |
| 237 // property and might write it into logs or other insecure places. Thus, we | 237 // property and might write it into logs or other insecure places. Thus, we |
| 238 // have to remove or mask credentials. | 238 // have to remove or mask credentials. |
| 239 // | 239 // |
| 240 // Shill's GetProperties doesn't return credentials. Masking credentials | 240 // Shill's GetProperties doesn't return credentials. Masking credentials |
| 241 // instead of just removing them, allows remembering if a credential is set | 241 // instead of just removing them, allows remembering if a credential is set |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 scoped_ptr<base::DictionaryValue> shill_dictionary( | 505 scoped_ptr<base::DictionaryValue> shill_dictionary( |
| 506 CreateShillConfiguration(state->profile_path(), guid, policy, | 506 CreateShillConfiguration(state->profile_path(), guid, policy, |
| 507 &user_settings)); | 507 &user_settings)); |
| 508 | 508 |
| 509 NetworkConfigurationHandler::Get()->SetProperties(service_path, | 509 NetworkConfigurationHandler::Get()->SetProperties(service_path, |
| 510 *shill_dictionary, | 510 *shill_dictionary, |
| 511 callback, | 511 callback, |
| 512 error_callback); | 512 error_callback); |
| 513 } | 513 } |
| 514 | 514 |
| 515 void ManagedNetworkConfigurationHandler::Connect( | |
| 516 const std::string& service_path, | |
| 517 const base::Closure& callback, | |
| 518 const network_handler::ErrorCallback& error_callback) const { | |
| 519 NetworkConfigurationHandler::Get()->Connect(service_path, | |
| 520 callback, | |
| 521 error_callback); | |
| 522 } | |
| 523 | |
| 524 void ManagedNetworkConfigurationHandler::Disconnect( | |
| 525 const std::string& service_path, | |
| 526 const base::Closure& callback, | |
| 527 const network_handler::ErrorCallback& error_callback) const { | |
| 528 NetworkConfigurationHandler::Get()->Disconnect(service_path, | |
| 529 callback, | |
| 530 error_callback); | |
| 531 } | |
| 532 | |
| 533 void ManagedNetworkConfigurationHandler::CreateConfiguration( | 515 void ManagedNetworkConfigurationHandler::CreateConfiguration( |
| 534 const base::DictionaryValue& properties, | 516 const base::DictionaryValue& properties, |
| 535 const network_handler::StringResultCallback& callback, | 517 const network_handler::StringResultCallback& callback, |
| 536 const network_handler::ErrorCallback& error_callback) const { | 518 const network_handler::ErrorCallback& error_callback) const { |
| 537 std::string profile_path = kUserProfilePath; | 519 std::string profile_path = kUserProfilePath; |
| 538 const PolicyMap* policies_by_guid = GetPoliciesForProfile(profile_path); | 520 const PolicyMap* policies_by_guid = GetPoliciesForProfile(profile_path); |
| 539 | 521 |
| 540 if (!policies_by_guid) { | 522 if (!policies_by_guid) { |
| 541 RunErrorCallback("", | 523 RunErrorCallback("", |
| 542 kPoliciesNotInitialized, | 524 kPoliciesNotInitialized, |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 device_policies_initialized_(false), | 853 device_policies_initialized_(false), |
| 872 weak_ptr_factory_(this) { | 854 weak_ptr_factory_(this) { |
| 873 } | 855 } |
| 874 | 856 |
| 875 ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() { | 857 ManagedNetworkConfigurationHandler::~ManagedNetworkConfigurationHandler() { |
| 876 STLDeleteValues(&user_policies_by_guid_); | 858 STLDeleteValues(&user_policies_by_guid_); |
| 877 STLDeleteValues(&device_policies_by_guid_); | 859 STLDeleteValues(&device_policies_by_guid_); |
| 878 } | 860 } |
| 879 | 861 |
| 880 } // namespace chromeos | 862 } // namespace chromeos |
| OLD | NEW |