| OLD | NEW | 
|    1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |    1 // Copyright (c) 2009 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/base/strict_transport_security_state.h" |    5 #include "net/base/strict_transport_security_state.h" | 
|    6  |    6  | 
|    7 #include "base/json_reader.h" |    7 #include "base/json/json_reader.h" | 
|    8 #include "base/json_writer.h" |    8 #include "base/json/json_writer.h" | 
|    9 #include "base/logging.h" |    9 #include "base/logging.h" | 
|   10 #include "base/scoped_ptr.h" |   10 #include "base/scoped_ptr.h" | 
|   11 #include "base/sha2.h" |   11 #include "base/sha2.h" | 
|   12 #include "base/string_tokenizer.h" |   12 #include "base/string_tokenizer.h" | 
|   13 #include "base/string_util.h" |   13 #include "base/string_util.h" | 
|   14 #include "base/values.h" |   14 #include "base/values.h" | 
|   15 #include "googleurl/src/gurl.h" |   15 #include "googleurl/src/gurl.h" | 
|   16 #include "net/base/base64.h" |   16 #include "net/base/base64.h" | 
|   17 #include "net/base/dns_util.h" |   17 #include "net/base/dns_util.h" | 
|   18  |   18  | 
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  221   DictionaryValue toplevel; |  221   DictionaryValue toplevel; | 
|  222   for (std::map<std::string, State>::const_iterator |  222   for (std::map<std::string, State>::const_iterator | 
|  223        i = enabled_hosts_.begin(); i != enabled_hosts_.end(); ++i) { |  223        i = enabled_hosts_.begin(); i != enabled_hosts_.end(); ++i) { | 
|  224     DictionaryValue* state = new DictionaryValue; |  224     DictionaryValue* state = new DictionaryValue; | 
|  225     state->SetBoolean(L"include_subdomains", i->second.include_subdomains); |  225     state->SetBoolean(L"include_subdomains", i->second.include_subdomains); | 
|  226     state->SetReal(L"expiry", i->second.expiry.ToDoubleT()); |  226     state->SetReal(L"expiry", i->second.expiry.ToDoubleT()); | 
|  227  |  227  | 
|  228     toplevel.Set(HashedDomainToExternalString(i->first), state); |  228     toplevel.Set(HashedDomainToExternalString(i->first), state); | 
|  229   } |  229   } | 
|  230  |  230  | 
|  231   JSONWriter::Write(&toplevel, true /* pretty print */, output); |  231   base::JSONWriter::Write(&toplevel, true /* pretty print */, output); | 
|  232   return true; |  232   return true; | 
|  233 } |  233 } | 
|  234  |  234  | 
|  235 bool StrictTransportSecurityState::Deserialise(const std::string& input) { |  235 bool StrictTransportSecurityState::Deserialise(const std::string& input) { | 
|  236   AutoLock lock(lock_); |  236   AutoLock lock(lock_); | 
|  237  |  237  | 
|  238   enabled_hosts_.clear(); |  238   enabled_hosts_.clear(); | 
|  239  |  239  | 
|  240   scoped_ptr<Value> value( |  240   scoped_ptr<Value> value( | 
|  241       JSONReader::Read(input, false /* do not allow trailing commas */)); |  241       base::JSONReader::Read(input, false /* do not allow trailing commas */)); | 
|  242   if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) |  242   if (!value.get() || !value->IsType(Value::TYPE_DICTIONARY)) | 
|  243     return false; |  243     return false; | 
|  244  |  244  | 
|  245   DictionaryValue* dict_value = reinterpret_cast<DictionaryValue*>(value.get()); |  245   DictionaryValue* dict_value = reinterpret_cast<DictionaryValue*>(value.get()); | 
|  246   const base::Time current_time(base::Time::Now()); |  246   const base::Time current_time(base::Time::Now()); | 
|  247  |  247  | 
|  248   for (DictionaryValue::key_iterator |  248   for (DictionaryValue::key_iterator | 
|  249        i = dict_value->begin_keys(); i != dict_value->end_keys(); ++i) { |  249        i = dict_value->begin_keys(); i != dict_value->end_keys(); ++i) { | 
|  250     DictionaryValue* state; |  250     DictionaryValue* state; | 
|  251     if (!dict_value->GetDictionary(*i, &state)) |  251     if (!dict_value->GetDictionary(*i, &state)) | 
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  309     if (new_host[i + 1] == '-' || |  309     if (new_host[i + 1] == '-' || | 
|  310         new_host[i + label_length] == '-') { |  310         new_host[i + label_length] == '-') { | 
|  311       return std::string(); |  311       return std::string(); | 
|  312     } |  312     } | 
|  313   } |  313   } | 
|  314  |  314  | 
|  315   return new_host; |  315   return new_host; | 
|  316 } |  316 } | 
|  317  |  317  | 
|  318 }  // namespace |  318 }  // namespace | 
| OLD | NEW |