#include "services/shape_detection/shape_detection_sandbox_hook.h"
#include <dlfcn.h>
#include "build/branding_buildflags.h"
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
#include "services/shape_detection/shape_detection_library_holder.h"
#endif
namespace shape_detection {
bool ShapeDetectionPreSandboxHook(
sandbox::policy::SandboxLinux::Options options) {
#if BUILDFLAG(GOOGLE_CHROME_BRANDING)
const auto path = shape_detection::GetChromeShapeDetectionPath();
void* dl =
dlopen(path.value().c_str(), RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
if (!dl) {
LOG(ERROR) << "Failed to open Chrome Shape Detection shared library!";
return false;
} else {
DVLOG(1) << "Successfully opened Chrome Shape Detection shared library.";
}
#endif
auto* instance = sandbox::policy::SandboxLinux::GetInstance();
instance->EngageNamespaceSandboxIfPossible();
return true;
}
}