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

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

Issue 275543005: Use GUID instead of ServicePath in networkingPrivate API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 | Annotate | Revision Log
« no previous file with comments | « chromeos/network/favorite_state.cc ('k') | chromeos/network/managed_state.h » ('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 <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "base/values.h" 17 #include "base/values.h"
18 #include "chromeos/dbus/shill_manager_client.h" 18 #include "chromeos/dbus/shill_manager_client.h"
19 #include "chromeos/dbus/shill_profile_client.h" 19 #include "chromeos/dbus/shill_profile_client.h"
20 #include "chromeos/dbus/shill_service_client.h" 20 #include "chromeos/dbus/shill_service_client.h"
21 #include "chromeos/network/device_state.h" 21 #include "chromeos/network/device_state.h"
22 #include "chromeos/network/favorite_state.h"
22 #include "chromeos/network/network_configuration_handler.h" 23 #include "chromeos/network/network_configuration_handler.h"
23 #include "chromeos/network/network_event_log.h" 24 #include "chromeos/network/network_event_log.h"
24 #include "chromeos/network/network_policy_observer.h" 25 #include "chromeos/network/network_policy_observer.h"
25 #include "chromeos/network/network_profile.h" 26 #include "chromeos/network/network_profile.h"
26 #include "chromeos/network/network_profile_handler.h" 27 #include "chromeos/network/network_profile_handler.h"
27 #include "chromeos/network/network_state.h" 28 #include "chromeos/network/network_state.h"
28 #include "chromeos/network/network_state_handler.h" 29 #include "chromeos/network/network_state_handler.h"
29 #include "chromeos/network/network_ui_data.h" 30 #include "chromeos/network/network_ui_data.h"
30 #include "chromeos/network/onc/onc_merger.h" 31 #include "chromeos/network/onc/onc_merger.h"
31 #include "chromeos/network/onc/onc_signature.h" 32 #include "chromeos/network/onc/onc_signature.h"
(...skipping 11 matching lines...) Expand all
43 typedef std::map<std::string, const base::DictionaryValue*> GuidToPolicyMap; 44 typedef std::map<std::string, const base::DictionaryValue*> GuidToPolicyMap;
44 45
45 // These are error strings used for error callbacks. None of these error 46 // These are error strings used for error callbacks. None of these error
46 // messages are user-facing: they should only appear in logs. 47 // messages are user-facing: they should only appear in logs.
47 const char kInvalidUserSettings[] = "InvalidUserSettings"; 48 const char kInvalidUserSettings[] = "InvalidUserSettings";
48 const char kNetworkAlreadyConfigured[] = "NetworkAlreadyConfigured"; 49 const char kNetworkAlreadyConfigured[] = "NetworkAlreadyConfigured";
49 const char kPoliciesNotInitialized[] = "PoliciesNotInitialized"; 50 const char kPoliciesNotInitialized[] = "PoliciesNotInitialized";
50 const char kProfileNotInitialized[] = "ProflieNotInitialized"; 51 const char kProfileNotInitialized[] = "ProflieNotInitialized";
51 const char kSetOnUnconfiguredNetwork[] = "SetCalledOnUnconfiguredNetwork"; 52 const char kSetOnUnconfiguredNetwork[] = "SetCalledOnUnconfiguredNetwork";
52 const char kUnknownProfilePath[] = "UnknownProfilePath"; 53 const char kUnknownProfilePath[] = "UnknownProfilePath";
53 const char kUnknownServicePath[] = "UnknownServicePath"; 54 const char kUnknownNetwork[] = "UnknownNetwork";
54 55
55 std::string ToDebugString(::onc::ONCSource source, 56 std::string ToDebugString(::onc::ONCSource source,
56 const std::string& userhash) { 57 const std::string& userhash) {
57 return source == ::onc::ONC_SOURCE_USER_POLICY ? 58 return source == ::onc::ONC_SOURCE_USER_POLICY ?
58 ("user policy of " + userhash) : "device policy"; 59 ("user policy of " + userhash) : "device policy";
59 } 60 }
60 61
61 void InvokeErrorCallback(const std::string& service_path, 62 void InvokeErrorCallback(const std::string& service_path,
62 const network_handler::ErrorCallback& error_callback, 63 const network_handler::ErrorCallback& error_callback,
63 const std::string& error_name) { 64 const std::string& error_name) {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 *properties_copy, 231 *properties_copy,
231 &onc::kNetworkWithStateSignature)); 232 &onc::kNetworkWithStateSignature));
232 callback.Run(service_path, *onc_network); 233 callback.Run(service_path, *onc_network);
233 } 234 }
234 235
235 void ManagedNetworkConfigurationHandlerImpl::SetProperties( 236 void ManagedNetworkConfigurationHandlerImpl::SetProperties(
236 const std::string& service_path, 237 const std::string& service_path,
237 const base::DictionaryValue& user_settings, 238 const base::DictionaryValue& user_settings,
238 const base::Closure& callback, 239 const base::Closure& callback,
239 const network_handler::ErrorCallback& error_callback) const { 240 const network_handler::ErrorCallback& error_callback) const {
240 const NetworkState* state = 241 const FavoriteState* state =
241 network_state_handler_->GetNetworkState(service_path); 242 network_state_handler_->GetFavoriteStateFromServicePath(
242 243 service_path, true /* configured_only */);
243 if (!state) { 244 if (!state) {
244 InvokeErrorCallback(service_path, error_callback, kUnknownServicePath); 245 InvokeErrorCallback(service_path, error_callback, kUnknownNetwork);
245 return; 246 return;
246 } 247 }
247 248
248 std::string guid = state->guid(); 249 std::string guid = state->guid();
249 if (guid.empty()) { 250 if (guid.empty()) {
250 // TODO(pneubeck): create an initial configuration in this case. As for 251 // TODO(pneubeck): create an initial configuration in this case. As for
251 // CreateConfiguration, user settings from older ChromeOS versions have to 252 // CreateConfiguration, user settings from older ChromeOS versions have to
252 // determined here. 253 // determined here.
253 InvokeErrorCallback( 254 InvokeErrorCallback(
254 service_path, error_callback, kSetOnUnconfiguredNetwork); 255 service_path, error_callback, kSetOnUnconfiguredNetwork);
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 // Convert IPConfig dictionary to a ListValue. 637 // Convert IPConfig dictionary to a ListValue.
637 base::ListValue* ip_configs = new base::ListValue; 638 base::ListValue* ip_configs = new base::ListValue;
638 for (base::DictionaryValue::Iterator iter(device_state->ip_configs()); 639 for (base::DictionaryValue::Iterator iter(device_state->ip_configs());
639 !iter.IsAtEnd(); iter.Advance()) { 640 !iter.IsAtEnd(); iter.Advance()) {
640 ip_configs->Append(iter.value().DeepCopy()); 641 ip_configs->Append(iter.value().DeepCopy());
641 } 642 }
642 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs); 643 properties->SetWithoutPathExpansion(shill::kIPConfigsProperty, ip_configs);
643 } 644 }
644 645
645 } // namespace chromeos 646 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/favorite_state.cc ('k') | chromeos/network/managed_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698