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

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

Issue 20087002: Add migration from CaCert NSS nicknames to PEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittests depending on NetworkHandler and not on CertLoader. Created 7 years, 4 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/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/i18n/icu_encoding_detection.h" 7 #include "base/i18n/icu_encoding_detection.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 if (ui_data_str.empty()) 61 if (ui_data_str.empty())
62 return new chromeos::NetworkUIData(); 62 return new chromeos::NetworkUIData();
63 63
64 scoped_ptr<base::DictionaryValue> ui_data_dict( 64 scoped_ptr<base::DictionaryValue> ui_data_dict(
65 chromeos::onc::ReadDictionaryFromJson(ui_data_str)); 65 chromeos::onc::ReadDictionaryFromJson(ui_data_str));
66 if (!ui_data_dict) 66 if (!ui_data_dict)
67 return NULL; 67 return NULL;
68 return new chromeos::NetworkUIData(*ui_data_dict); 68 return new chromeos::NetworkUIData(*ui_data_dict);
69 } 69 }
70 70
71 bool IsCaCertNssSet(const base::DictionaryValue& properties) {
72 std::string ca_cert_nss;
73 if (properties.GetStringWithoutPathExpansion(flimflam::kEapCaCertNssProperty,
74 &ca_cert_nss) &&
75 !ca_cert_nss.empty()) {
76 return true;
77 }
78
79 const base::DictionaryValue* provider = NULL;
80 properties.GetDictionaryWithoutPathExpansion(flimflam::kProviderProperty,
81 &provider);
82 if (!provider)
83 return false;
84 if (provider->GetStringWithoutPathExpansion(
85 flimflam::kL2tpIpsecCaCertNssProperty, &ca_cert_nss) &&
86 !ca_cert_nss.empty()) {
87 return true;
88 }
89 if (provider->GetStringWithoutPathExpansion(
90 flimflam::kOpenVPNCaCertNSSProperty, &ca_cert_nss) &&
91 !ca_cert_nss.empty()) {
92 return true;
93 }
94
95 return false;
96 }
97
71 } // namespace 98 } // namespace
72 99
73 namespace chromeos { 100 namespace chromeos {
74 101
75 NetworkState::NetworkState(const std::string& path) 102 NetworkState::NetworkState(const std::string& path)
76 : ManagedState(MANAGED_TYPE_NETWORK, path), 103 : ManagedState(MANAGED_TYPE_NETWORK, path),
77 auto_connect_(false), 104 auto_connect_(false),
78 favorite_(false), 105 favorite_(false),
79 priority_(0), 106 priority_(0),
80 onc_source_(onc::ONC_SOURCE_NONE), 107 onc_source_(onc::ONC_SOURCE_NONE),
81 prefix_length_(0), 108 prefix_length_(0),
82 signal_strength_(0), 109 signal_strength_(0),
83 connectable_(false), 110 connectable_(false),
84 activate_over_non_cellular_networks_(false), 111 activate_over_non_cellular_networks_(false),
85 cellular_out_of_credits_(false) { 112 cellular_out_of_credits_(false),
113 has_ca_cert_nss_(false) {
86 } 114 }
87 115
88 NetworkState::~NetworkState() { 116 NetworkState::~NetworkState() {
89 } 117 }
90 118
91 bool NetworkState::PropertyChanged(const std::string& key, 119 bool NetworkState::PropertyChanged(const std::string& key,
92 const base::Value& value) { 120 const base::Value& value) {
93 // Keep care that these properties are the same as in |GetProperties|. 121 // Keep care that these properties are the same as in |GetProperties|.
94 if (ManagedStatePropertyChanged(key, value)) 122 if (ManagedStatePropertyChanged(key, value))
95 return true; 123 return true;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return false; 212 return false;
185 } 213 }
186 return true; 214 return true;
187 } 215 }
188 return false; 216 return false;
189 } 217 }
190 218
191 bool NetworkState::InitialPropertiesReceived( 219 bool NetworkState::InitialPropertiesReceived(
192 const base::DictionaryValue& properties) { 220 const base::DictionaryValue& properties) {
193 bool changed = UpdateName(properties); 221 bool changed = UpdateName(properties);
222 bool had_ca_cert_nss = has_ca_cert_nss_;
223 has_ca_cert_nss_ = IsCaCertNssSet(properties);
224 changed |= had_ca_cert_nss != has_ca_cert_nss_;
194 return changed; 225 return changed;
195 } 226 }
196 227
197 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { 228 void NetworkState::GetProperties(base::DictionaryValue* dictionary) const {
198 // Keep care that these properties are the same as in |PropertyChanged|. 229 // Keep care that these properties are the same as in |PropertyChanged|.
199 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name()); 230 dictionary->SetStringWithoutPathExpansion(flimflam::kNameProperty, name());
200 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type()); 231 dictionary->SetStringWithoutPathExpansion(flimflam::kTypeProperty, type());
201 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty, 232 dictionary->SetIntegerWithoutPathExpansion(flimflam::kSignalStrengthProperty,
202 signal_strength_); 233 signal_strength_);
203 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty, 234 dictionary->SetStringWithoutPathExpansion(flimflam::kStateProperty,
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 bool NetworkState::GetOncSource(const base::Value& ui_data_value, 435 bool NetworkState::GetOncSource(const base::Value& ui_data_value,
405 onc::ONCSource* out) { 436 onc::ONCSource* out) {
406 scoped_ptr<NetworkUIData> ui_data(CreateUIDataFromValue(ui_data_value)); 437 scoped_ptr<NetworkUIData> ui_data(CreateUIDataFromValue(ui_data_value));
407 if (!ui_data) 438 if (!ui_data)
408 return false; 439 return false;
409 *out = ui_data->onc_source(); 440 *out = ui_data->onc_source();
410 return true; 441 return true;
411 } 442 }
412 443
413 } // namespace chromeos 444 } // 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