| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/supervised_user/supervised_user_site_list.h" | 5 #include "chrome/browser/supervised_user/supervised_user_site_list.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/json/json_file_value_serializer.h" | 10 #include "base/json/json_file_value_serializer.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 SCOPED_UMA_HISTOGRAM_TIMER("ManagedUsers.Whitelist.ReadDuration"); | 29 SCOPED_UMA_HISTOGRAM_TIMER("ManagedUsers.Whitelist.ReadDuration"); |
| 30 JSONFileValueDeserializer deserializer(path); | 30 JSONFileValueDeserializer deserializer(path); |
| 31 int error_code; | 31 int error_code; |
| 32 std::string error_msg; | 32 std::string error_msg; |
| 33 scoped_ptr<base::Value> value = | 33 scoped_ptr<base::Value> value = |
| 34 deserializer.Deserialize(&error_code, &error_msg); | 34 deserializer.Deserialize(&error_code, &error_msg); |
| 35 if (!value) { | 35 if (!value) { |
| 36 LOG(ERROR) << "Couldn't load site list " << path.value() << ": " | 36 LOG(ERROR) << "Couldn't load site list " << path.value() << ": " |
| 37 << error_msg; | 37 << error_msg; |
| 38 } | 38 } |
| 39 return value.Pass(); | 39 return value; |
| 40 } | 40 } |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 SupervisedUserSiteList::HostnameHash::HostnameHash( | 44 SupervisedUserSiteList::HostnameHash::HostnameHash( |
| 45 const std::string& hostname) { | 45 const std::string& hostname) { |
| 46 base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(hostname.c_str()), | 46 base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(hostname.c_str()), |
| 47 hostname.size(), bytes_.data()); | 47 hostname.size(), bytes_.data()); |
| 48 } | 48 } |
| 49 | 49 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 base::ListValue* patterns = nullptr; | 155 base::ListValue* patterns = nullptr; |
| 156 dict->GetList(kWhitelistKey, &patterns); | 156 dict->GetList(kWhitelistKey, &patterns); |
| 157 | 157 |
| 158 base::ListValue* hostname_hashes = nullptr; | 158 base::ListValue* hostname_hashes = nullptr; |
| 159 dict->GetList(kHostnameHashesKey, &hostname_hashes); | 159 dict->GetList(kHostnameHashesKey, &hostname_hashes); |
| 160 | 160 |
| 161 callback.Run(make_scoped_refptr(new SupervisedUserSiteList( | 161 callback.Run(make_scoped_refptr(new SupervisedUserSiteList( |
| 162 title, GURL(entry_point_url), patterns, hostname_hashes))); | 162 title, GURL(entry_point_url), patterns, hostname_hashes))); |
| 163 } | 163 } |
| OLD | NEW |