A boundary criterion for cubulation