中文:a language that used by chinese people。
汉语:a language that used by Han nationality。
there are 56 nationalities in China, but Han is a majority, as a Chinese, when I talk to foreigners, I may say "I speak '中文'", but among the compatriots ,I say " I like the '汉语语法书'(chinese grammar book)"