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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(hostname.c_str()), | 64 base::SHA1HashBytes(reinterpret_cast<const unsigned char*>(hostname.c_str()), |
65 hostname.size(), bytes_.data()); | 65 hostname.size(), bytes_.data()); |
66 } | 66 } |
67 | 67 |
68 SupervisedUserSiteList::HostnameHash::HostnameHash( | 68 SupervisedUserSiteList::HostnameHash::HostnameHash( |
69 const std::vector<uint8_t>& bytes) { | 69 const std::vector<uint8_t>& bytes) { |
70 CHECK_GE(bytes.size(), base::kSHA1Length); | 70 CHECK_GE(bytes.size(), base::kSHA1Length); |
71 std::copy(bytes.begin(), bytes.end(), bytes_.begin()); | 71 std::copy(bytes.begin(), bytes.end(), bytes_.begin()); |
72 } | 72 } |
73 | 73 |
| 74 SupervisedUserSiteList::HostnameHash::HostnameHash(const HostnameHash& other) = |
| 75 default; |
| 76 |
74 bool SupervisedUserSiteList::HostnameHash::operator==( | 77 bool SupervisedUserSiteList::HostnameHash::operator==( |
75 const HostnameHash& rhs) const { | 78 const HostnameHash& rhs) const { |
76 return bytes_ == rhs.bytes_; | 79 return bytes_ == rhs.bytes_; |
77 } | 80 } |
78 | 81 |
79 size_t SupervisedUserSiteList::HostnameHash::hash() const { | 82 size_t SupervisedUserSiteList::HostnameHash::hash() const { |
80 // This just returns the first sizeof(size_t) bytes of |bytes_|. | 83 // This just returns the first sizeof(size_t) bytes of |bytes_|. |
81 return *reinterpret_cast<const size_t*>(bytes_.data()); | 84 return *reinterpret_cast<const size_t*>(bytes_.data()); |
82 } | 85 } |
83 | 86 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 179 |
177 base::ListValue* patterns = nullptr; | 180 base::ListValue* patterns = nullptr; |
178 dict->GetList(kWhitelistKey, &patterns); | 181 dict->GetList(kWhitelistKey, &patterns); |
179 | 182 |
180 base::ListValue* hostname_hashes = nullptr; | 183 base::ListValue* hostname_hashes = nullptr; |
181 dict->GetList(kHostnameHashesKey, &hostname_hashes); | 184 dict->GetList(kHostnameHashesKey, &hostname_hashes); |
182 | 185 |
183 callback.Run(make_scoped_refptr(new SupervisedUserSiteList( | 186 callback.Run(make_scoped_refptr(new SupervisedUserSiteList( |
184 id, title, GURL(entry_point_url), patterns, hostname_hashes))); | 187 id, title, GURL(entry_point_url), patterns, hostname_hashes))); |
185 } | 188 } |
OLD | NEW |