blob: 8a0342eb08aa7ab92537c05f3430605c5fe2f56a [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef SRC_SYS_APPMGR_ALLOWLIST_H_
#define SRC_SYS_APPMGR_ALLOWLIST_H_
#include <string>
#include <unordered_set>
#include "src/lib/fxl/macros.h"
namespace component {
// Represents a list of component URLs that are allowed to use a certain feature.
class Allowlist {
public:
// Parses the given file as an allowlist.
//
// The file should consist of Component URLs, one per line.
// No validation is done on the format of the file.
Allowlist(const std::string& file_path);
bool IsAllowed(const std::string& url) const {
return internal_set_.find(url) != internal_set_.end();
}
private:
std::unordered_set<std::string> internal_set_;
FXL_DISALLOW_COPY_AND_ASSIGN(Allowlist);
};
} // namespace component
#endif // SRC_SYS_APPMGR_ALLOWLIST_H_