After witnessing Ginny kissing Dean in a private hallway, Harry realises his love for Ginny, but since Ron vocally objects to Dean dating his sister, Harry interprets this as his not wanting any of his friends to date her.
After witnessing Ginny kissing Dean in an empty corridor, Harry has an angry internal reaction, which surprises him, and, upon reflection, realises his love for Ginny. Since Ron vocally objects to Dean dating his sister, Harry interprets this as his not wanting any of his friends to date her.