One standard way to do the integral is to let $1-\sin x=u$. Then $du=\cos x\,dx$, and we end up with the integral
$$\int -u^2\,du,$$
which is easy. Our integral turns out to be
$$-\frac{1}{3}(1-\sin x)^3+C.\tag{1}$$
Another way of doing it is to expand the square. So we want to integrate
$\cos x -2\cos x\sin x+\cos x\sin^2 x$. For the calculations of the integrals of the last two parts, $u=\sin x$ is again useful. We end up with
$$\sin x-\sin^2 x+\frac{1}{3}\sin^3 x+C.\tag{2}$$
It is easy to verify that $-\frac{1}{3}(1-\sin x)^3$ is not the same function as
$\sin x-\sin^2 x+\frac{1}{3}\sin^3 x$. However, they differ by a constant, so both (1) and (2) are valid answers to our integration problem. Another valid answer would be $x+\cos^2 x+\frac{1}{3}\sin^3 x+C$, because $x+\cos^2 x+\frac{1}{3}\sin^3 xx$ and $x-\sin^2 x+\frac{1}{3}\sin^3 x$ differ by a constant.
Remark: We could undoubtedly attack the problem using integration by parts. But it would be harder work than the simple substitution $u=1-\sin x$ that we used in the first calculation.