The Answer...
The prisoners would only keep quiet if they cannot eliminate enough
and 100% confirmed the colour of their hat. In other words, each
would probably be having the options of 2 possible colours or 3
possible colours of their own hats.
A keeps quiet at first because obviously he doesn't know as he
couldn't see anyone's hat.
D who could see everyone's hat except his, kept quiet. This means
that he has a dilemma on the colour of his hats(couldn't 100%
confirm). This means on the 3 prisoners, the colour cannot be 1 red
and 2 black. Because by elimination, D would have guessed his is
white and he would have shouted out his hat is white first. Hence,
it is concluded that D could see a white in front of him.
Prior to D's silence(meaning that 1 red and 2 black is not possible
among A, B, and C), can it be 1 red, 1 black, 1 white? D would
remain quiet cos he is either white or black. But C could see that
if the hats in front of him are 1 red and 1 black, his would
definitely be white and he would shout his is white but he didn't.
Hence, it is concluded again that he sees a white in front of
him.
Now to B. After D and C kept quiet, he should know both of them saw
a white either on him or A because of their silence. If he saw a
red or a black on A, that means he is white, so he could shout out
the answer! But he didn't shout. So if he didn't shout that means
he didn't see a red or a black, but a white hat on A!
Thanks to the silence treatement by D,C, and B, A now knows all of
them saw a white hat. That's how he shouted his hat is
white!