section 515(10)


515(10) For the purposes of this section, the detention of an accused in custody is justified only on one or more of the following grounds: (a) where the detention is necessary to ensure his or her attendance in court in order to be dealt with according to law; (b) where the detention is necessary for the protection or safety of the public, including any victim of or witness to the offence, or any person under the age of 18 years, having regard to all the circumstances including any substantial likelihood that the accused will, if released from custody, commit a criminal offence or interfere with the administration of justice; and (c) if the detention is necessary to maintain confidence in the administration of justice, having regard to all the circumstances, including (i) the apparent strength of the prosecutions case, (ii) the gravity of the offence, (iii) the circumstances surrounding the commission of the offence, including whether a firearm was used, and (iv) the fact that the accused is liable, on conviction, for a potentially lengthy term of imprisonment or, in the case of an offence that involves, or whose subject-matter is, a firearm, a minimum punishment of imprisonment for a term of three years or more.