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

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: stevenjb@ comments. Created 3 years, 8 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 29 matching lines...) Expand all
80 } 81 }
81 82
82 const base::DictionaryValue* GetByGUID(const GuidToPolicyMap& policies, 83 const base::DictionaryValue* GetByGUID(const GuidToPolicyMap& policies,
83 const std::string& guid) { 84 const std::string& guid) {
84 auto it = policies.find(guid); 85 auto it = policies.find(guid);
85 if (it == policies.end()) 86 if (it == policies.end())
86 return NULL; 87 return NULL;
87 return it->second.get(); 88 return it->second.get();
88 } 89 }
89 90
91 bool IsTetherShillDictionary(const base::DictionaryValue& dict) {
92 std::string network_type;
93 return dict.GetStringWithoutPathExpansion(shill::kTypeProperty,
94 &network_type) &&
95 network_type == kTypeTether;
96 }
97
90 } // namespace 98 } // namespace
91 99
92 struct ManagedNetworkConfigurationHandlerImpl::Policies { 100 struct ManagedNetworkConfigurationHandlerImpl::Policies {
93 ~Policies(); 101 ~Policies();
94 102
95 GuidToPolicyMap per_network_config; 103 GuidToPolicyMap per_network_config;
96 base::DictionaryValue global_network_config; 104 base::DictionaryValue global_network_config;
97 }; 105 };
98 106
99 ManagedNetworkConfigurationHandlerImpl::Policies::~Policies() {} 107 ManagedNetworkConfigurationHandlerImpl::Policies::~Policies() {}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 const std::string& userhash, 144 const std::string& userhash,
137 const network_handler::DictionaryResultCallback& callback, 145 const network_handler::DictionaryResultCallback& callback,
138 const network_handler::ErrorCallback& error_callback, 146 const network_handler::ErrorCallback& error_callback,
139 const std::string& service_path, 147 const std::string& service_path,
140 std::unique_ptr<base::DictionaryValue> shill_properties) { 148 std::unique_ptr<base::DictionaryValue> shill_properties) {
141 std::string profile_path; 149 std::string profile_path;
142 shill_properties->GetStringWithoutPathExpansion(shill::kProfileProperty, 150 shill_properties->GetStringWithoutPathExpansion(shill::kProfileProperty,
143 &profile_path); 151 &profile_path);
144 const NetworkProfile* profile = 152 const NetworkProfile* profile =
145 network_profile_handler_->GetProfileForPath(profile_path); 153 network_profile_handler_->GetProfileForPath(profile_path);
146 if (!profile) 154 if (!profile && !IsTetherShillDictionary(*shill_properties)) {
155 // Tether networks are not expected to have an associated profile; only
156 // log an error if the provided properties do not correspond to a
157 // Tether network.
147 NET_LOG_ERROR("No profile for service: " + profile_path, service_path); 158 NET_LOG_ERROR("No profile for service: " + profile_path, service_path);
159 }
148 160
149 std::unique_ptr<NetworkUIData> ui_data = 161 std::unique_ptr<NetworkUIData> ui_data =
150 shill_property_util::GetUIDataFromProperties(*shill_properties); 162 shill_property_util::GetUIDataFromProperties(*shill_properties);
151 163
152 const base::DictionaryValue* user_settings = NULL; 164 const base::DictionaryValue* user_settings = nullptr;
153 165
154 if (ui_data && profile) { 166 if (ui_data && profile) {
155 user_settings = ui_data->user_settings(); 167 user_settings = ui_data->user_settings();
156 } else if (profile) { 168 } else if (profile) {
157 NET_LOG_DEBUG("Service contains empty or invalid UIData", service_path); 169 NET_LOG_DEBUG("Service contains empty or invalid UIData", service_path);
158 // TODO(pneubeck): add a conversion of user configured entries of old 170 // TODO(pneubeck): add a conversion of user configured entries of old
159 // ChromeOS versions. We will have to use a heuristic to determine which 171 // ChromeOS versions. We will have to use a heuristic to determine which
160 // properties _might_ be user configured. 172 // properties _might_ be user configured.
161 } 173 }
162 174
163 std::string guid; 175 std::string guid;
164 shill_properties->GetStringWithoutPathExpansion(shill::kGuidProperty, &guid); 176 shill_properties->GetStringWithoutPathExpansion(shill::kGuidProperty, &guid);
165 177
166 ::onc::ONCSource onc_source; 178 ::onc::ONCSource onc_source;
167 FindPolicyByGUID(userhash, guid, &onc_source); 179 FindPolicyByGUID(userhash, guid, &onc_source);
168 const NetworkState* network_state = 180 const NetworkState* network_state =
169 network_state_handler_->GetNetworkState(service_path); 181 network_state_handler_->GetNetworkState(service_path);
170 std::unique_ptr<base::DictionaryValue> active_settings( 182 std::unique_ptr<base::DictionaryValue> active_settings(
171 onc::TranslateShillServiceToONCPart(*shill_properties, onc_source, 183 onc::TranslateShillServiceToONCPart(*shill_properties, onc_source,
172 &onc::kNetworkWithStateSignature, 184 &onc::kNetworkWithStateSignature,
173 network_state)); 185 network_state));
174 186
175 const base::DictionaryValue* network_policy = NULL; 187 const base::DictionaryValue* network_policy = nullptr;
176 const base::DictionaryValue* global_policy = NULL; 188 const base::DictionaryValue* global_policy = nullptr;
177 if (profile) { 189 if (profile) {
178 const Policies* policies = GetPoliciesForProfile(*profile); 190 const Policies* policies = GetPoliciesForProfile(*profile);
179 if (!policies) { 191 if (!policies) {
180 InvokeErrorCallback( 192 InvokeErrorCallback(
181 service_path, error_callback, kPoliciesNotInitialized); 193 service_path, error_callback, kPoliciesNotInitialized);
182 return; 194 return;
183 } 195 }
184 if (!guid.empty()) 196 if (!guid.empty())
185 network_policy = GetByGUID(policies->per_network_config, guid); 197 network_policy = GetByGUID(policies->per_network_config, guid);
186 global_policy = &policies->global_network_config; 198 global_policy = &policies->global_network_config;
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 std::unique_ptr<base::DictionaryValue> network_properties, 918 std::unique_ptr<base::DictionaryValue> network_properties,
907 GetDevicePropertiesCallback send_callback, 919 GetDevicePropertiesCallback send_callback,
908 const std::string& error_name, 920 const std::string& error_name,
909 std::unique_ptr<base::DictionaryValue> error_data) { 921 std::unique_ptr<base::DictionaryValue> error_data) {
910 NET_LOG_ERROR("Error getting device properties", service_path); 922 NET_LOG_ERROR("Error getting device properties", service_path);
911 send_callback.Run(service_path, std::move(network_properties)); 923 send_callback.Run(service_path, std::move(network_properties));
912 } 924 }
913 925
914 926
915 } // namespace chromeos 927 } // 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