blob: 9896b34cd99c1a7fa8f628c29153b1cc0bb58bd2 [file] [log] [blame]
#ifndef THIRD_PARTY_HUNSPELL_SANDBOX_SANDBOX_H_
#define THIRD_PARTY_HUNSPELL_SANDBOX_SANDBOX_H_
#include <memory>
#include <string>
#include <utility>
#include "third_party/hunspell/sandbox/sandboxed_hunspell.sapi.h"
#include "third_party/sandboxed_api/sandbox2/policy.h"
namespace sandboxed_hunspell {
class LibHunspellSapiSandbox : public LibHunspellSandbox {
public:
explicit LibHunspellSapiSandbox(std::string affix_file_name,
std::string dictionary_file_name)
: affix_file_name_(std::move(affix_file_name)),
dictionary_file_name_(std::move(dictionary_file_name)) {}
private:
std::unique_ptr<sandbox2::Policy> ModifyPolicy(
sandbox2::PolicyBuilder* builder) override {
return builder->AddFile(affix_file_name_, /*is_ro=*/true)
.AddFile(dictionary_file_name_, /*is_ro=*/true)
.BuildOrDie();
}
std::string affix_file_name_;
std::string dictionary_file_name_;
};
} // namespace sandboxed_hunspell
#endif // THIRD_PARTY_HUNSPELL_SANDBOX_SANDBOX_H_