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

Side by Side Diff: net/http/transport_security_persister.cc

Issue 374033002: Fixes for re-enabling more MSVC level 4 warnings: net/ edition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comment Created 6 years, 5 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 (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 "net/http/transport_security_persister.h" 5 #include "net/http/transport_security_persister.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 bool dirtied = false; 205 bool dirtied = false;
206 206
207 for (base::DictionaryValue::Iterator i(*dict_value); 207 for (base::DictionaryValue::Iterator i(*dict_value);
208 !i.IsAtEnd(); i.Advance()) { 208 !i.IsAtEnd(); i.Advance()) {
209 const base::DictionaryValue* parsed = NULL; 209 const base::DictionaryValue* parsed = NULL;
210 if (!i.value().GetAsDictionary(&parsed)) { 210 if (!i.value().GetAsDictionary(&parsed)) {
211 LOG(WARNING) << "Could not parse entry " << i.key() << "; skipping entry"; 211 LOG(WARNING) << "Could not parse entry " << i.key() << "; skipping entry";
212 continue; 212 continue;
213 } 213 }
214 214
215 std::string mode_string;
216 double expiry;
217 double dynamic_spki_hashes_expiry = 0.0;
218 TransportSecurityState::DomainState domain_state; 215 TransportSecurityState::DomainState domain_state;
219 216
220 // kIncludeSubdomains is a legacy synonym for kStsIncludeSubdomains and 217 // kIncludeSubdomains is a legacy synonym for kStsIncludeSubdomains and
221 // kPkpIncludeSubdomains. Parse at least one of these properties, 218 // kPkpIncludeSubdomains. Parse at least one of these properties,
222 // preferably the new ones. 219 // preferably the new ones.
223 bool include_subdomains = false; 220 bool include_subdomains = false;
224 bool parsed_include_subdomains = parsed->GetBoolean(kIncludeSubdomains, 221 bool parsed_include_subdomains = parsed->GetBoolean(kIncludeSubdomains,
225 &include_subdomains); 222 &include_subdomains);
226 domain_state.sts.include_subdomains = include_subdomains; 223 domain_state.sts.include_subdomains = include_subdomains;
227 domain_state.pkp.include_subdomains = include_subdomains; 224 domain_state.pkp.include_subdomains = include_subdomains;
228 if (parsed->GetBoolean(kStsIncludeSubdomains, &include_subdomains)) { 225 if (parsed->GetBoolean(kStsIncludeSubdomains, &include_subdomains)) {
229 domain_state.sts.include_subdomains = include_subdomains; 226 domain_state.sts.include_subdomains = include_subdomains;
230 parsed_include_subdomains = true; 227 parsed_include_subdomains = true;
231 } 228 }
232 if (parsed->GetBoolean(kPkpIncludeSubdomains, &include_subdomains)) { 229 if (parsed->GetBoolean(kPkpIncludeSubdomains, &include_subdomains)) {
233 domain_state.pkp.include_subdomains = include_subdomains; 230 domain_state.pkp.include_subdomains = include_subdomains;
234 parsed_include_subdomains = true; 231 parsed_include_subdomains = true;
235 } 232 }
236 233
234 std::string mode_string;
235 double expiry = 0;
237 if (!parsed_include_subdomains || 236 if (!parsed_include_subdomains ||
238 !parsed->GetString(kMode, &mode_string) || 237 !parsed->GetString(kMode, &mode_string) ||
239 !parsed->GetDouble(kExpiry, &expiry)) { 238 !parsed->GetDouble(kExpiry, &expiry)) {
240 LOG(WARNING) << "Could not parse some elements of entry " << i.key() 239 LOG(WARNING) << "Could not parse some elements of entry " << i.key()
241 << "; skipping entry"; 240 << "; skipping entry";
242 continue; 241 continue;
243 } 242 }
244 243
245 // Don't fail if this key is not present. 244 // Don't fail if this key is not present.
245 double dynamic_spki_hashes_expiry = 0;
246 parsed->GetDouble(kDynamicSPKIHashesExpiry, 246 parsed->GetDouble(kDynamicSPKIHashesExpiry,
247 &dynamic_spki_hashes_expiry); 247 &dynamic_spki_hashes_expiry);
248 248
249 const base::ListValue* pins_list = NULL; 249 const base::ListValue* pins_list = NULL;
250 if (parsed->GetList(kDynamicSPKIHashes, &pins_list)) { 250 if (parsed->GetList(kDynamicSPKIHashes, &pins_list)) {
251 SPKIHashesFromListValue(*pins_list, &domain_state.pkp.spki_hashes); 251 SPKIHashesFromListValue(*pins_list, &domain_state.pkp.spki_hashes);
252 } 252 }
253 253
254 if (mode_string == kForceHTTPS || mode_string == kStrict) { 254 if (mode_string == kForceHTTPS || mode_string == kStrict) {
255 domain_state.sts.upgrade_mode = 255 domain_state.sts.upgrade_mode =
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 bool dirty = false; 319 bool dirty = false;
320 if (!LoadEntries(state, &dirty)) { 320 if (!LoadEntries(state, &dirty)) {
321 LOG(ERROR) << "Failed to deserialize state: " << state; 321 LOG(ERROR) << "Failed to deserialize state: " << state;
322 return; 322 return;
323 } 323 }
324 if (dirty) 324 if (dirty)
325 StateIsDirty(transport_security_state_); 325 StateIsDirty(transport_security_state_);
326 } 326 }
327 327
328 } // namespace net 328 } // namespace net
OLDNEW
« no previous file with comments | « net/ftp/ftp_network_transaction_unittest.cc ('k') | net/socket/deterministic_socket_data_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698