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 "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 SupervisedUserSiteList::~SupervisedUserSiteList() { | 134 SupervisedUserSiteList::~SupervisedUserSiteList() { |
135 } | 135 } |
136 | 136 |
137 // static | 137 // static |
138 void SupervisedUserSiteList::ParseJson( | 138 void SupervisedUserSiteList::ParseJson( |
139 const base::FilePath& path, | 139 const base::FilePath& path, |
140 const SupervisedUserSiteList::LoadedCallback& callback, | 140 const SupervisedUserSiteList::LoadedCallback& callback, |
141 const std::string& json) { | 141 const std::string& json) { |
142 if (g_load_in_process) { | 142 if (g_load_in_process) { |
143 JSONFileValueSerializer serializer(path); | 143 JSONFileValueDeserializer deserializer(path); |
144 std::string error; | 144 std::string error; |
145 scoped_ptr<base::Value> value(serializer.Deserialize(nullptr, &error)); | 145 scoped_ptr<base::Value> value(deserializer.Deserialize(nullptr, &error)); |
146 if (!value) { | 146 if (!value) { |
147 HandleError(path, error); | 147 HandleError(path, error); |
148 return; | 148 return; |
149 } | 149 } |
150 | 150 |
151 OnJsonParseSucceeded(path, base::TimeTicks(), callback, value.Pass()); | 151 OnJsonParseSucceeded(path, base::TimeTicks(), callback, value.Pass()); |
152 return; | 152 return; |
153 } | 153 } |
154 | 154 |
155 // TODO(bauerb): Use batch mode to load multiple whitelists? | 155 // TODO(bauerb): Use batch mode to load multiple whitelists? |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 191 |
192 base::ListValue* sites = nullptr; | 192 base::ListValue* sites = nullptr; |
193 if (!dict->GetList(kSitesKey, &sites)) { | 193 if (!dict->GetList(kSitesKey, &sites)) { |
194 LOG(ERROR) << "Site list " << path.value() | 194 LOG(ERROR) << "Site list " << path.value() |
195 << " does not contain any sites"; | 195 << " does not contain any sites"; |
196 return; | 196 return; |
197 } | 197 } |
198 | 198 |
199 callback.Run(make_scoped_refptr(new SupervisedUserSiteList(*sites))); | 199 callback.Run(make_scoped_refptr(new SupervisedUserSiteList(*sites))); |
200 } | 200 } |
OLD | NEW |