Commit 4e48284e authored by yilkal's avatar yilkal Committed by Commit Bot

Error handling in whitelist policy wrapper.

Enable whitelist policy wrapper to graciously handle
empty or incorrect values.

Bug: 1051201
Change-Id: I1e94af89e60106b7eedbd0e65c2b1138055ba5e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2065983Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Commit-Queue: Yilkal Abe <yilkal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743106}
parent 5fbb211f
......@@ -4,6 +4,7 @@
#include "chrome/browser/chromeos/child_accounts/time_limits/app_time_limits_whitelist_policy_wrapper.h"
#include "base/logging.h"
#include "base/optional.h"
#include "chrome/browser/chromeos/child_accounts/time_limits/app_time_policy_helpers.h"
#include "chrome/browser/chromeos/child_accounts/time_limits/app_types.h"
......@@ -20,12 +21,20 @@ AppTimeLimitsWhitelistPolicyWrapper::~AppTimeLimitsWhitelistPolicyWrapper() =
std::vector<std::string>
AppTimeLimitsWhitelistPolicyWrapper::GetWhitelistURLList() const {
std::vector<std::string> return_value;
const base::Value* list = value_->FindListKey(policy::kUrlList);
DCHECK(list);
if (!list) {
VLOG(1) << "Invalid whitelist URL list provided.";
return return_value;
}
base::Value::ConstListView list_view = list->GetList();
std::vector<std::string> return_value;
for (const base::Value& value : list_view) {
if (!value.is_string()) {
VLOG(1) << "Whitelist URL is not a string.";
continue;
}
return_value.push_back(value.GetString());
}
return return_value;
......@@ -33,11 +42,15 @@ AppTimeLimitsWhitelistPolicyWrapper::GetWhitelistURLList() const {
std::vector<AppId> AppTimeLimitsWhitelistPolicyWrapper::GetWhitelistAppList()
const {
std::vector<AppId> return_value;
const base::Value* app_list = value_->FindListKey(policy::kAppList);
DCHECK(app_list);
if (!app_list) {
VLOG(1) << "Invalid whitelist application list.";
return return_value;
}
base::Value::ConstListView list_view = app_list->GetList();
std::vector<AppId> return_value;
for (const base::Value& value : list_view) {
base::Optional<AppId> app_id = policy::AppIdFromDict(value);
if (app_id)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment