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

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

Issue 2836083002: [CrOS Tether] Update NetworkConfigurationHandler::GetShillProperties() to work with Tether networks. (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | chromeos/network/network_configuration_handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 20 matching lines...) Expand all
31 #include "chromeos/network/network_ui_data.h" 31 #include "chromeos/network/network_ui_data.h"
32 #include "chromeos/network/network_util.h" 32 #include "chromeos/network/network_util.h"
33 #include "chromeos/network/onc/onc_merger.h" 33 #include "chromeos/network/onc/onc_merger.h"
34 #include "chromeos/network/onc/onc_signature.h" 34 #include "chromeos/network/onc/onc_signature.h"
35 #include "chromeos/network/onc/onc_translator.h" 35 #include "chromeos/network/onc/onc_translator.h"
36 #include "chromeos/network/onc/onc_utils.h" 36 #include "chromeos/network/onc/onc_utils.h"
37 #include "chromeos/network/onc/onc_validator.h" 37 #include "chromeos/network/onc/onc_validator.h"
38 #include "chromeos/network/policy_util.h" 38 #include "chromeos/network/policy_util.h"
39 #include "chromeos/network/prohibited_technologies_handler.h" 39 #include "chromeos/network/prohibited_technologies_handler.h"
40 #include "chromeos/network/shill_property_util.h" 40 #include "chromeos/network/shill_property_util.h"
41 #include "chromeos/network/tether_constants.h"
41 #include "components/onc/onc_constants.h" 42 #include "components/onc/onc_constants.h"
42 #include "third_party/cros_system_api/dbus/service_constants.h" 43 #include "third_party/cros_system_api/dbus/service_constants.h"
43 44
44 namespace chromeos { 45 namespace chromeos {
45 46
46 namespace { 47 namespace {
47 48
48 using GuidToPolicyMap = ManagedNetworkConfigurationHandler::GuidToPolicyMap; 49 using GuidToPolicyMap = ManagedNetworkConfigurationHandler::GuidToPolicyMap;
49 50
50 // These are error strings used for error callbacks. None of these error 51 // These are error strings used for error callbacks. None of these error
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const std::string& userhash, 137 const std::string& userhash,
137 const network_handler::DictionaryResultCallback& callback, 138 const network_handler::DictionaryResultCallback& callback,
138 const network_handler::ErrorCallback& error_callback, 139 const network_handler::ErrorCallback& error_callback,
139 const std::string& service_path, 140 const std::string& service_path,
140 std::unique_ptr<base::DictionaryValue> shill_properties) { 141 std::unique_ptr<base::DictionaryValue> shill_properties) {
141 std::string profile_path; 142 std::string profile_path;
142 shill_properties->GetStringWithoutPathExpansion(shill::kProfileProperty, 143 shill_properties->GetStringWithoutPathExpansion(shill::kProfileProperty,
143 &profile_path); 144 &profile_path);
144 const NetworkProfile* profile = 145 const NetworkProfile* profile =
145 network_profile_handler_->GetProfileForPath(profile_path); 146 network_profile_handler_->GetProfileForPath(profile_path);
146 if (!profile) 147 if (!profile && !onc::IsTetherShillDictionary(*shill_properties)) {
148 // Tether networks are not expected to have an associated profile; only
149 // log an error if the provided properties do not correspond to a
150 // Tether network.
147 NET_LOG_ERROR("No profile for service: " + profile_path, service_path); 151 NET_LOG_ERROR("No profile for service: " + profile_path, service_path);
152 }
148 153
149 std::unique_ptr<NetworkUIData> ui_data = 154 std::unique_ptr<NetworkUIData> ui_data =
150 shill_property_util::GetUIDataFromProperties(*shill_properties); 155 shill_property_util::GetUIDataFromProperties(*shill_properties);
151 156
152 const base::DictionaryValue* user_settings = NULL; 157 const base::DictionaryValue* user_settings = NULL;
153 158
154 if (ui_data && profile) { 159 if (ui_data && profile) {
155 user_settings = ui_data->user_settings(); 160 user_settings = ui_data->user_settings();
156 } else if (profile) { 161 } else if (profile) {
157 NET_LOG_DEBUG("Service contains empty or invalid UIData", service_path); 162 NET_LOG_DEBUG("Service contains empty or invalid UIData", service_path);
158 // TODO(pneubeck): add a conversion of user configured entries of old 163 // TODO(pneubeck): add a conversion of user configured entries of old
159 // ChromeOS versions. We will have to use a heuristic to determine which 164 // ChromeOS versions. We will have to use a heuristic to determine which
160 // properties _might_ be user configured. 165 // properties _might_ be user configured.
161 } 166 }
162 167
163 std::string guid; 168 std::string guid;
164 shill_properties->GetStringWithoutPathExpansion(shill::kGuidProperty, &guid); 169 shill_properties->GetStringWithoutPathExpansion(shill::kGuidProperty, &guid);
165 170
166 ::onc::ONCSource onc_source; 171 ::onc::ONCSource onc_source;
167 FindPolicyByGUID(userhash, guid, &onc_source); 172 FindPolicyByGUID(userhash, guid, &onc_source);
168 const NetworkState* network_state = 173 const NetworkState* network_state =
169 network_state_handler_->GetNetworkState(service_path); 174 network_state_handler_->GetNetworkState(service_path);
170 std::unique_ptr<base::DictionaryValue> active_settings( 175 std::unique_ptr<base::DictionaryValue> active_settings(
171 onc::TranslateShillServiceToONCPart(*shill_properties, onc_source, 176 onc::TranslateShillServiceToONCPart(*shill_properties, onc_source,
172 &onc::kNetworkWithStateSignature, 177 &onc::kNetworkWithStateSignature,
173 network_state)); 178 network_state));
174 179
175 const base::DictionaryValue* network_policy = NULL;
176 const base::DictionaryValue* global_policy = NULL;
177 if (profile) { 180 if (profile) {
178 const Policies* policies = GetPoliciesForProfile(*profile); 181 const Policies* policies = GetPoliciesForProfile(*profile);
179 if (!policies) { 182 if (!policies) {
180 InvokeErrorCallback( 183 InvokeErrorCallback(
181 service_path, error_callback, kPoliciesNotInitialized); 184 service_path, error_callback, kPoliciesNotInitialized);
182 return; 185 return;
183 } 186 }
184 if (!guid.empty()) 187
185 network_policy = GetByGUID(policies->per_network_config, guid); 188 const base::DictionaryValue* network_policy =
186 global_policy = &policies->global_network_config; 189 guid.empty() ? nullptr : GetByGUID(policies->per_network_config, guid);
190 const base::DictionaryValue* global_policy =
191 &policies->global_network_config;
192
193 std::unique_ptr<base::DictionaryValue> augmented_properties(
194 policy_util::CreateManagedONC(global_policy, network_policy,
195 user_settings, active_settings.get(),
196 profile));
197 callback.Run(service_path, *augmented_properties);
198 } else {
199 callback.Run(service_path, *active_settings);
187 } 200 }
188
189 std::unique_ptr<base::DictionaryValue> augmented_properties(
190 policy_util::CreateManagedONC(global_policy, network_policy,
191 user_settings, active_settings.get(),
192 profile));
stevenjb 2017/04/24 17:15:52 This always needs to be called, even if profile is
Kyle Horimoto 2017/04/24 19:49:38 Done.
193 callback.Run(service_path, *augmented_properties);
194 } 201 }
195 202
196 // GetProperties 203 // GetProperties
197 204
198 void ManagedNetworkConfigurationHandlerImpl::GetProperties( 205 void ManagedNetworkConfigurationHandlerImpl::GetProperties(
199 const std::string& userhash, 206 const std::string& userhash,
200 const std::string& service_path, 207 const std::string& service_path,
201 const network_handler::DictionaryResultCallback& callback, 208 const network_handler::DictionaryResultCallback& callback,
202 const network_handler::ErrorCallback& error_callback) { 209 const network_handler::ErrorCallback& error_callback) {
203 NET_LOG_USER("GetProperties", service_path); 210 NET_LOG_USER("GetProperties", service_path);
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 std::unique_ptr<base::DictionaryValue> network_properties, 913 std::unique_ptr<base::DictionaryValue> network_properties,
907 GetDevicePropertiesCallback send_callback, 914 GetDevicePropertiesCallback send_callback,
908 const std::string& error_name, 915 const std::string& error_name,
909 std::unique_ptr<base::DictionaryValue> error_data) { 916 std::unique_ptr<base::DictionaryValue> error_data) {
910 NET_LOG_ERROR("Error getting device properties", service_path); 917 NET_LOG_ERROR("Error getting device properties", service_path);
911 send_callback.Run(service_path, std::move(network_properties)); 918 send_callback.Run(service_path, std::move(network_properties));
912 } 919 }
913 920
914 921
915 } // namespace chromeos 922 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/network_configuration_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698