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

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

Issue 845533002: Remove CACert NSS nickname to PEM migration. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 | « chromeos/network/network_state.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/network_state.h" 5 #include "chromeos/network/network_state.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chromeos/device_event_log.h" 9 #include "chromeos/device_event_log.h"
10 #include "chromeos/network/network_profile_handler.h" 10 #include "chromeos/network/network_profile_handler.h"
(...skipping 11 matching lines...) Expand all
22 std::vector<std::string>* result) { 22 std::vector<std::string>* result) {
23 for (size_t i = 0; i < string_list.GetSize(); ++i) { 23 for (size_t i = 0; i < string_list.GetSize(); ++i) {
24 std::string str; 24 std::string str;
25 if (!string_list.GetString(i, &str)) 25 if (!string_list.GetString(i, &str))
26 return false; 26 return false;
27 result->push_back(str); 27 result->push_back(str);
28 } 28 }
29 return true; 29 return true;
30 } 30 }
31 31
32 bool IsCaCertNssSet(const base::DictionaryValue& properties) {
33 std::string ca_cert_nss;
34 if (properties.GetStringWithoutPathExpansion(shill::kEapCaCertNssProperty,
35 &ca_cert_nss) &&
36 !ca_cert_nss.empty()) {
37 return true;
38 }
39
40 const base::DictionaryValue* provider = NULL;
41 properties.GetDictionaryWithoutPathExpansion(shill::kProviderProperty,
42 &provider);
43 if (!provider)
44 return false;
45 if (provider->GetStringWithoutPathExpansion(
46 shill::kL2tpIpsecCaCertNssProperty, &ca_cert_nss) &&
47 !ca_cert_nss.empty()) {
48 return true;
49 }
50 if (provider->GetStringWithoutPathExpansion(
51 shill::kOpenVPNCaCertNSSProperty, &ca_cert_nss) &&
52 !ca_cert_nss.empty()) {
53 return true;
54 }
55
56 return false;
57 }
58
59 } // namespace 32 } // namespace
60 33
61 namespace chromeos { 34 namespace chromeos {
62 35
63 NetworkState::NetworkState(const std::string& path) 36 NetworkState::NetworkState(const std::string& path)
64 : ManagedState(MANAGED_TYPE_NETWORK, path), 37 : ManagedState(MANAGED_TYPE_NETWORK, path),
65 visible_(false), 38 visible_(false),
66 connectable_(false), 39 connectable_(false),
67 prefix_length_(0), 40 prefix_length_(0),
68 signal_strength_(0), 41 signal_strength_(0),
69 cellular_out_of_credits_(false), 42 cellular_out_of_credits_(false) {
70 has_ca_cert_nss_(false) {
71 } 43 }
72 44
73 NetworkState::~NetworkState() { 45 NetworkState::~NetworkState() {
74 } 46 }
75 47
76 bool NetworkState::PropertyChanged(const std::string& key, 48 bool NetworkState::PropertyChanged(const std::string& key,
77 const base::Value& value) { 49 const base::Value& value) {
78 // Keep care that these properties are the same as in |GetProperties|. 50 // Keep care that these properties are the same as in |GetProperties|.
79 if (ManagedStatePropertyChanged(key, value)) 51 if (ManagedStatePropertyChanged(key, value))
80 return true; 52 return true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 123 }
152 return true; 124 return true;
153 } 125 }
154 return false; 126 return false;
155 } 127 }
156 128
157 bool NetworkState::InitialPropertiesReceived( 129 bool NetworkState::InitialPropertiesReceived(
158 const base::DictionaryValue& properties) { 130 const base::DictionaryValue& properties) {
159 NET_LOG(EVENT) << "InitialPropertiesReceived: " << path() << ": " << name() 131 NET_LOG(EVENT) << "InitialPropertiesReceived: " << path() << ": " << name()
160 << " State: " << connection_state_ << " Visible: " << visible_; 132 << " State: " << connection_state_ << " Visible: " << visible_;
161 bool changed = false;
162 if (!properties.HasKey(shill::kTypeProperty)) { 133 if (!properties.HasKey(shill::kTypeProperty)) {
163 NET_LOG(ERROR) << "NetworkState has no type: " 134 NET_LOG(ERROR) << "NetworkState has no type: "
164 << shill_property_util::GetNetworkIdFromProperties( 135 << shill_property_util::GetNetworkIdFromProperties(
165 properties); 136 properties);
166 return false; 137 return false;
167 } 138 }
168 // Ensure that the network has a valid name.
169 changed |= UpdateName(properties);
170
171 // Set the has_ca_cert_nss_ property.
172 bool had_ca_cert_nss = has_ca_cert_nss_;
173 has_ca_cert_nss_ = IsCaCertNssSet(properties);
174 changed |= had_ca_cert_nss != has_ca_cert_nss_;
175 139
176 // By convention, all visible WiFi and WiMAX networks have a 140 // By convention, all visible WiFi and WiMAX networks have a
177 // SignalStrength > 0. 141 // SignalStrength > 0.
178 if ((type() == shill::kTypeWifi || type() == shill::kTypeWimax) && 142 if ((type() == shill::kTypeWifi || type() == shill::kTypeWimax) &&
179 visible() && signal_strength_ <= 0) { 143 visible() && signal_strength_ <= 0) {
180 signal_strength_ = 1; 144 signal_strength_ = 1;
181 } 145 }
182 146
183 return changed; 147 // Ensure that the network has a valid name.
148 return UpdateName(properties);
184 } 149 }
185 150
186 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const { 151 void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const {
187 ManagedState::GetStateProperties(dictionary); 152 ManagedState::GetStateProperties(dictionary);
188 153
189 // Properties shared by all types. 154 // Properties shared by all types.
190 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid()); 155 dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid());
191 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty, 156 dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty,
192 security()); 157 security());
193 158
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 connection_state == shill::kStateCarrier); 319 connection_state == shill::kStateCarrier);
355 } 320 }
356 321
357 // static 322 // static
358 bool NetworkState::ErrorIsValid(const std::string& error) { 323 bool NetworkState::ErrorIsValid(const std::string& error) {
359 // Shill uses "Unknown" to indicate an unset or cleared error state. 324 // Shill uses "Unknown" to indicate an unset or cleared error state.
360 return !error.empty() && error != kErrorUnknown; 325 return !error.empty() && error != kErrorUnknown;
361 } 326 }
362 327
363 } // namespace chromeos 328 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698