When accused persons are brought into the courtroom, handcuffs should be removed as soon as they are placed into the dock unless the court officers are aware of a security concern respecting that particular accused.  If that is the case, the officers should notify Crown counsel, preferably in advance, so that he or she may make the appropriate application before the presiding judge.

R. v. Fortuin, 2015 ONCJ 116.

The presiding judge has the discretion to decide whether an accused must appear in court in any form of restraint.  A hearing is required to enable the presiding judge to properly exercise his or her discretion on the issue.

R. v. Jones, 1996 CanLII 8006 (ON SC), 107 C.C.C. (3d) 517.

There is a longstanding presumption that accused persons appearing in court should not be restrained unless the need for restraints has been justified by the Crown.

R. v. McNeill (1996), 1996 CanLII 812 (ON CA), 29 O.R. (3d) 641 (C.A); See also R. v. Wills, [2006] O.J. No. 3662 (S.C.J.) at para. 45; R. v. Zwezdaryk, [2004] O.J. No. 6137 (S.C.J.) at para. 14; R. v. Jones (1996), 1996 CanLII 8006 (ON SC), 29 O.R. (3d) 294 (Gen. Div.) at paras. 28-31. See also R. v. Cambridge Justices, Ex parte Peacock (1992), 156 J.P.R. 895 (Q.B.), at p. 902:

“They [Magistrates], not the gaoler, must decide whether a prisoner should be handcuffed in court. No prisoner should be handcuffed in court unless there are reasonable grounds for the apprehending that he will be violent or will attempt to escape. If an application is made that a prisoner should be handcuffed, the magistrates must entertain it.”

If the Crown takes the position that restraints are necessary, it bears the onus of establishing reasonable grounds for their use:

R. v. Wills, [2006] O.J. No. 3662 (S.C.J.), at para. 45.

A balance should be struck between the duty of the judge to ensure the safety of all participants to the proceeding and to prevent escape on the one hand, and the need to maintain the dignity of the prisoner in the context of the presumption of innocence on the other. In effecting this balance the views and expertise of the security personnel will no doubt be given considerable weight. The ultimate determination, however, must be made by the presiding judge and not by security staff.

See R. v. McNeill (1996), 1996 CanLII 812 (ON CA).
The legal principles that apply to the use of handcuffs, leg shackles and other forms of restraint for in-custody accused in court were usefully summarized by the Provincial Court of Newfoundland and Labrador in R. v. Kalleo, 2016 CanLII 7716 (NL PC):

(1) every accused, whether in custody or not, has the right to appear in court free of any restraint;

(2) the presiding judge, whether for a plea appearance, bail, preliminary inquiry, trial or sentencing hearing, has the discretion to decide whether an accused must appear in court in any form of restraint;

(3) police and sheriff’s officers have the responsibility to provide security within courtrooms, but within applicable legal principles. A policy of restraints on all in-custody accused cannot be used to replace a plan to provide appropriate levels of security. The authorities must base their security plan on the assumption that in-custody accused may appear in court without restraints;

(4) the police or sheriff’s officers have a particular concern about an individual in-custody accused, then they must advise the Crown, and the Crown, if he or she concludes that the officers’ concerns have merit, may apply for a hearing on the use of restraints with that particular in-custody accused;

(5) the judges should give considerable weight to the views and expertise of the R.C.M.P. and sheriff’s officers concerning particular in-custody accused, but deference to them is inappropriate. The issue of restraint in the courtroom is a matter for the judge to decide;

(6) the court, the Crown or the Defence may raise the issue of restraint of in-custody accused;

(7) once the court, the Crown or the Defence raises the issue of restraint of in-custody accused, then the judge must conduct a hearing;

(8) restraints in the courtroom should be the exception not the rule;

(9) judges must decide the issue of using restraints on in-custody accused on a case-by-case basis;

(10) the unnecessary or unreasonable use of leg shackles, handcuffs or other apparatus constitutes a civil assault;

(11) the Royal Canadian Mounted Police Act, the Royal Newfoundland and Labrador Constabulary Act, 1992 and regulations do not supersede the judge’s authority to determine the issue of restraints used on in-custody accused in court;

(12) a blanket policy of restraints on all in-custody accused is not lawful.  It may amount to a civil assault and give rise to an award of damages. The accused may also have other remedies under the Charter of Rights and Freedoms.

(13) it is illogical for police or sheriff’s officers to use leg shackles, handcuffs or other restraints in court on in-custody accused for whom the Crown is recommending release, including the young, the elderly or the frail, unless there are specific grounds to believe that each individual person will be violent or attempt escape. Such an approach brings the administration of justice into disrepute;

(14) judges have the discretion to decide if an accused sits in the criminal dock, with Defence counsel, or elsewhere in the courtroom.