From a prison cell where he has been charged for murder, David Aames (Tom Cruise), in a prosthetic mask, tells his life story to court psychologist, Dr. Curtis McCabe (Kurt Russell).
In flashback, David is shown to be the wealthy owner of a large publishing firm in New York City which he inherited from his father, leaving its regular duties to his father's trusted associates. As David enjoys the bachelor lifestyle, he is introduced to Sofia Serrano (PenĂŠlope Cruz) by his best friend, author Brian Shelby (Jason Lee) at a party. David and Sofia spend a night together talking and fall in love. When David's former lover, Julianna "Julie" Gianni (Cameron Diaz), hears of Sofia, she attempts to kill herself and David in a car crash. Julie dies but David survives, his face grotesquely disfigured, leading him to wear a mask to hide the injuries. With no hope to use plastic surgery to repair the damage, David cannot come to grips with the idea of wearing the mask for the rest of his life. On a night out with Sofia and Brian, David gets hopelessly drunk and Sofia and Brian leave David to wallow in the street outside.
David is awakened the next day in the street by Sofia, who apologises for deserting him the night before, and takes him home. The two continue to see each other, and David has his face surgically repaired despite being told it was impossible before. Though his life seems perfectly content, David finds oddities, such as brief visions of his distorted face, and a man (Noah Taylor) at a bar that tells him David can control the world and everyone in it, if he wanted to. One day, when he goes to Sofia's apartment, he finds Julie there instead; all of the previous mementos of Sofia now show Julie's face. Angry and confused, David suffocates Julie, and is later arrested and placed in a mental institution, finding his face has reverted to its previously disfigured state.
David completes telling his story to Curtis, who proceeds to then visit David further for more sessions to try to help him recuperate. During one interview Curtis tells David the staff reported him calling out "Ellie" in a bad dream and asks who she is. David later sees a nearby TV advertisement for "Life Extension", a company that specializes in cryonic suspension, and realises he'd actually called out "L","E". Under Curtis' and a police officer's guard, David is taken to the Life Extension offices, where the salesclerk Rebecca (Tilda Swinton) explains they freeze people just after the point of death, until a cure for their ailment is available in the future, keeping their brain active by placing them in a lucid dream state. David becomes anxious and breaks free of Curtis, realizing he is in his own lucid dream that has gone wrong, and calls for tech support.
David finds himself in the empty lobby of the offices, and the man whom he saw earlier at the bar appears, claiming to be David's tech support from Life Extension, which is now known as the Oasis Project. They ride up in an elevator to the top of an impossibly tall building, the height triggering David's severe acrophobia. The man explains that David has been in cryonic sleep for 150 years. David had opted for Life Extension's services after struggling with his breakup with Sofia and his disfigurement, and after securing the publishing company to its associates, proceeded to kill himself with a drug overdose; Life Extension preserved his body and, as David directed, put him into his lucid dream starting from the drunken night when Sofia left him, under the "vanilla sky" from a Monet painting. However, during his sleep, the dream went horribly wrong and attempted to incorporate elements from his subconscious, such as substituting Julie for Sofia and creating a father-figure in Curtis. As they arrive at the top of the building, the man offers David a choice: either to be reinserted into the corrected lucid dream, or return to the real world by taking a literal leap of faith off the roof that will wake him from his sleep. David decides to wake up, ignoring the vision of Curtis that his subconscious has brought to life to talk him out of it. David envisions Sofia and Brian to say his goodbyes. Conquering his final fear, David jumps off the building, his life flashing before his eyes, and whites out immediately before hitting the ground. A female voice commands him to "open your eyes" (a recurring theme in the movie), and the film ends with David opening his eyes.

Question: Who was arrested and put into a mental institution?
Answer: David