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

Side by Side Diff: chromeos/network/managed_network_configuration_handler_impl.cc

Issue 552113002: Add ONC 'Source' configuration property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_279351_internet_options_9a
Patch Set: Rebase, Feedback, add *Policy sources 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_impl.h" 5 #include "chromeos/network/managed_network_configuration_handler_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return; 120 return;
121 } 121 }
122 network_configuration_handler_->GetProperties( 122 network_configuration_handler_->GetProperties(
123 service_path, 123 service_path,
124 base::Bind( 124 base::Bind(
125 &ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback, 125 &ManagedNetworkConfigurationHandlerImpl::GetPropertiesCallback,
126 weak_ptr_factory_.GetWeakPtr(), 126 weak_ptr_factory_.GetWeakPtr(),
127 base::Bind( 127 base::Bind(
128 &ManagedNetworkConfigurationHandlerImpl::SendManagedProperties, 128 &ManagedNetworkConfigurationHandlerImpl::SendManagedProperties,
129 weak_ptr_factory_.GetWeakPtr(), 129 weak_ptr_factory_.GetWeakPtr(),
130 userhash,
130 callback, 131 callback,
131 error_callback)), 132 error_callback)),
132 error_callback); 133 error_callback);
133 } 134 }
134 135
135 void ManagedNetworkConfigurationHandlerImpl::SendManagedProperties( 136 void ManagedNetworkConfigurationHandlerImpl::SendManagedProperties(
137 const std::string& userhash,
136 const network_handler::DictionaryResultCallback& callback, 138 const network_handler::DictionaryResultCallback& callback,
137 const network_handler::ErrorCallback& error_callback, 139 const network_handler::ErrorCallback& error_callback,
138 const std::string& service_path, 140 const std::string& service_path,
139 scoped_ptr<base::DictionaryValue> shill_properties) { 141 scoped_ptr<base::DictionaryValue> shill_properties) {
140 std::string profile_path; 142 std::string profile_path;
141 shill_properties->GetStringWithoutPathExpansion(shill::kProfileProperty, 143 shill_properties->GetStringWithoutPathExpansion(shill::kProfileProperty,
142 &profile_path); 144 &profile_path);
143 const NetworkProfile* profile = 145 const NetworkProfile* profile =
144 network_profile_handler_->GetProfileForPath(profile_path); 146 network_profile_handler_->GetProfileForPath(profile_path);
145 if (!profile) 147 if (!profile)
146 NET_LOG_ERROR("No profile for service: " + profile_path, service_path); 148 NET_LOG_ERROR("No profile for service: " + profile_path, service_path);
147 149
148 scoped_ptr<NetworkUIData> ui_data = 150 scoped_ptr<NetworkUIData> ui_data =
149 shill_property_util::GetUIDataFromProperties(*shill_properties); 151 shill_property_util::GetUIDataFromProperties(*shill_properties);
150 152
151 const base::DictionaryValue* user_settings = NULL; 153 const base::DictionaryValue* user_settings = NULL;
152 154
153 if (ui_data && profile) { 155 if (ui_data && profile) {
154 user_settings = ui_data->user_settings(); 156 user_settings = ui_data->user_settings();
155 } else if (profile) { 157 } else if (profile) {
156 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path); 158 NET_LOG_ERROR("Service contains empty or invalid UIData", service_path);
157 // TODO(pneubeck): add a conversion of user configured entries of old 159 // TODO(pneubeck): add a conversion of user configured entries of old
158 // ChromeOS versions. We will have to use a heuristic to determine which 160 // ChromeOS versions. We will have to use a heuristic to determine which
159 // properties _might_ be user configured. 161 // properties _might_ be user configured.
160 } 162 }
161 163
164 std::string guid;
165 shill_properties->GetStringWithoutPathExpansion(shill::kGuidProperty, &guid);
166
167 ::onc::ONCSource onc_source;
168 FindPolicyByGUID(userhash, guid, &onc_source);
162 scoped_ptr<base::DictionaryValue> active_settings( 169 scoped_ptr<base::DictionaryValue> active_settings(
163 onc::TranslateShillServiceToONCPart( 170 onc::TranslateShillServiceToONCPart(
164 *shill_properties, 171 *shill_properties, onc_source, &onc::kNetworkWithStateSignature));
165 &onc::kNetworkWithStateSignature));
166
167 std::string guid;
168 active_settings->GetStringWithoutPathExpansion(::onc::network_config::kGUID,
169 &guid);
170 172
171 const base::DictionaryValue* network_policy = NULL; 173 const base::DictionaryValue* network_policy = NULL;
172 const base::DictionaryValue* global_policy = NULL; 174 const base::DictionaryValue* global_policy = NULL;
173 if (profile) { 175 if (profile) {
174 const Policies* policies = GetPoliciesForProfile(*profile); 176 const Policies* policies = GetPoliciesForProfile(*profile);
175 if (!policies) { 177 if (!policies) {
176 InvokeErrorCallback( 178 InvokeErrorCallback(
177 service_path, error_callback, kPoliciesNotInitialized); 179 service_path, error_callback, kPoliciesNotInitialized);
178 return; 180 return;
179 } 181 }
(...skipping 28 matching lines...) Expand all
208 error_callback)), 210 error_callback)),
209 error_callback); 211 error_callback);
210 } 212 }
211 213
212 void ManagedNetworkConfigurationHandlerImpl::SendProperties( 214 void ManagedNetworkConfigurationHandlerImpl::SendProperties(
213 const network_handler::DictionaryResultCallback& callback, 215 const network_handler::DictionaryResultCallback& callback,
214 const network_handler::ErrorCallback& error_callback, 216 const network_handler::ErrorCallback& error_callback,
215 const std::string& service_path, 217 const std::string& service_path,
216 scoped_ptr<base::DictionaryValue> shill_properties) { 218 scoped_ptr<base::DictionaryValue> shill_properties) {
217 scoped_ptr<base::DictionaryValue> onc_network( 219 scoped_ptr<base::DictionaryValue> onc_network(
218 onc::TranslateShillServiceToONCPart(*shill_properties, 220 onc::TranslateShillServiceToONCPart(
219 &onc::kNetworkWithStateSignature)); 221 *shill_properties, ::onc::ONC_SOURCE_NONE,
pneubeck (no reviews) 2014/09/10 10:49:38 See next comment. This leads to incorrect 'Source'
stevenjb 2014/09/10 17:32:15 Acknowledged.
222 &onc::kNetworkWithStateSignature));
220 callback.Run(service_path, *onc_network); 223 callback.Run(service_path, *onc_network);
221 } 224 }
222 225
223 // SetProperties 226 // SetProperties
224 227
225 void ManagedNetworkConfigurationHandlerImpl::SetProperties( 228 void ManagedNetworkConfigurationHandlerImpl::SetProperties(
226 const std::string& service_path, 229 const std::string& service_path,
227 const base::DictionaryValue& user_settings, 230 const base::DictionaryValue& user_settings,
228 const base::Closure& callback, 231 const base::Closure& callback,
229 const network_handler::ErrorCallback& error_callback) const { 232 const network_handler::ErrorCallback& error_callback) const {
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 scoped_ptr<base::DictionaryValue> network_properties, 713 scoped_ptr<base::DictionaryValue> network_properties,
711 GetDevicePropertiesCallback send_callback, 714 GetDevicePropertiesCallback send_callback,
712 const std::string& error_name, 715 const std::string& error_name,
713 scoped_ptr<base::DictionaryValue> error_data) { 716 scoped_ptr<base::DictionaryValue> error_data) {
714 NET_LOG_ERROR("Error getting device properties", service_path); 717 NET_LOG_ERROR("Error getting device properties", service_path);
715 send_callback.Run(service_path, network_properties.Pass()); 718 send_callback.Run(service_path, network_properties.Pass());
716 } 719 }
717 720
718 721
719 } // namespace chromeos 722 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698