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

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

Issue 23451044: Add an Ethernet EAP policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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/policy_util.h" 5 #include "chromeos/network/policy_util.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chromeos/network/network_profile.h" 8 #include "chromeos/network/network_profile.h"
9 #include "chromeos/network/network_ui_data.h" 9 #include "chromeos/network/network_ui_data.h"
10 #include "chromeos/network/onc/onc_constants.h" 10 #include "chromeos/network/onc/onc_constants.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 65 }
66 // Otherwise, the value is set and modified by the UI, thus we keep that 66 // Otherwise, the value is set and modified by the UI, thus we keep that
67 // value to overwrite whatever is stored in Shill. 67 // value to overwrite whatever is stored in Shill.
68 } 68 }
69 } 69 }
70 } 70 }
71 71
72 // Returns true if |policy| matches |actual_network|, which must be part of a 72 // Returns true if |policy| matches |actual_network|, which must be part of a
73 // ONC NetworkConfiguration. This should be the only such matching function 73 // ONC NetworkConfiguration. This should be the only such matching function
74 // within Chrome. Shill does such matching in several functions for network 74 // within Chrome. Shill does such matching in several functions for network
75 // identification. For compatibility, we currently should stick to Shill's 75 // identification. For compatibility, we currently should stick to Shill's
bartfab (slow) 2013/09/17 08:45:54 Just to make sure nothing is overlooked: I presume
pneubeck (no reviews) 2013/09/17 12:48:36 This function isn't directly Shill related because
76 // matching behavior. 76 // matching behavior.
77 bool IsPolicyMatching(const base::DictionaryValue& policy, 77 bool IsPolicyMatching(const base::DictionaryValue& policy,
78 const base::DictionaryValue& actual_network) { 78 const base::DictionaryValue& actual_network) {
79 std::string policy_type; 79 std::string policy_type;
80 policy.GetStringWithoutPathExpansion(onc::network_config::kType, 80 policy.GetStringWithoutPathExpansion(onc::network_config::kType,
81 &policy_type); 81 &policy_type);
82 std::string network_type; 82 std::string actual_network_type;
83 actual_network.GetStringWithoutPathExpansion(onc::network_config::kType, 83 actual_network.GetStringWithoutPathExpansion(onc::network_config::kType,
84 &network_type); 84 &actual_network_type);
85 if (policy_type != network_type) 85 if (policy_type != actual_network_type)
86 return false; 86 return false;
87 87
88 if (network_type != onc::network_type::kWiFi) 88 if (actual_network_type == onc::network_type::kEthernet) {
89 return false; 89 const base::DictionaryValue* policy_ethernet = NULL;
bartfab (slow) 2013/09/17 08:45:54 Nit: #include "base/values.h"
pneubeck (no reviews) 2013/09/17 12:48:36 Done.
90 policy.GetDictionaryWithoutPathExpansion(onc::network_config::kEthernet,
91 &policy_ethernet);
92 const base::DictionaryValue* actual_ethernet = NULL;
93 actual_network.GetDictionaryWithoutPathExpansion(
94 onc::network_config::kEthernet, &actual_ethernet);
95 if (!policy_ethernet || !actual_ethernet)
96 return false;
90 97
91 const base::DictionaryValue* policy_wifi = NULL; 98 std::string policy_auth;
92 policy.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi, 99 policy_ethernet->GetStringWithoutPathExpansion(
93 &policy_wifi); 100 onc::ethernet::kAuthentication, &policy_auth);
94 const base::DictionaryValue* actual_wifi = NULL; 101 std::string actual_auth;
95 actual_network.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi, 102 actual_ethernet->GetStringWithoutPathExpansion(
96 &actual_wifi); 103 onc::ethernet::kAuthentication, &actual_auth);
97 if (!policy_wifi || !actual_wifi) 104 return (policy_auth == actual_auth);
bartfab (slow) 2013/09/17 08:45:54 Nit: No need for brackets here.
pneubeck (no reviews) 2013/09/17 12:48:36 Done.
98 return false; 105 } else if (actual_network_type == onc::network_type::kWiFi) {
106 const base::DictionaryValue* policy_wifi = NULL;
107 policy.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi,
108 &policy_wifi);
109 const base::DictionaryValue* actual_wifi = NULL;
110 actual_network.GetDictionaryWithoutPathExpansion(onc::network_config::kWiFi,
111 &actual_wifi);
112 if (!policy_wifi || !actual_wifi)
113 return false;
99 114
100 std::string policy_ssid; 115 std::string policy_ssid;
101 policy_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &policy_ssid); 116 policy_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &policy_ssid);
102 std::string actual_ssid; 117 std::string actual_ssid;
103 actual_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &actual_ssid); 118 actual_wifi->GetStringWithoutPathExpansion(onc::wifi::kSSID, &actual_ssid);
104 return (policy_ssid == actual_ssid); 119 return (policy_ssid == actual_ssid);
120 }
121 return false;
105 } 122 }
106 123
107 } // namespace 124 } // namespace
108 125
109 scoped_ptr<base::DictionaryValue> CreateShillConfiguration( 126 scoped_ptr<base::DictionaryValue> CreateShillConfiguration(
110 const NetworkProfile& profile, 127 const NetworkProfile& profile,
111 const std::string& guid, 128 const std::string& guid,
112 const base::DictionaryValue* policy, 129 const base::DictionaryValue* policy,
113 const base::DictionaryValue* settings) { 130 const base::DictionaryValue* settings) {
114 scoped_ptr<base::DictionaryValue> effective; 131 scoped_ptr<base::DictionaryValue> effective;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 it != policies.end(); ++it) { 209 it != policies.end(); ++it) {
193 if (IsPolicyMatching(*it->second, actual_network)) 210 if (IsPolicyMatching(*it->second, actual_network))
194 return it->second; 211 return it->second;
195 } 212 }
196 return NULL; 213 return NULL;
197 } 214 }
198 215
199 } // namespace policy_util 216 } // namespace policy_util
200 217
201 } // namespace chromeos 218 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698