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