You are asking for a whole lesson in metallurgy.
In order to harden a piece of steel that steel must contain some reasonable amount of carbon. A nail, for example, has about 0.1%carbon in it. Heat it bright red, quench in water and it comes out just as soft as it was when you bought it. Probably softer.
If a piece of steel has, say 0.4% carbon then it can be heated to the appropriate red heat temperature and quenched to be rather hard. To be useful, that metal must be reheated a bit, which these days is called "tempering", anywhere from 700 to 1100F to make it tougher. That might be how a high strength bolt is made, for example.
If you want a file, or maybe a truck spring, one starts out with a high carbon steel, such as AISI 1095. This commonly available steel has almost 1% carbon by weight in it. Heat it 1440F, quench straight down into salt water & it will be hard as a file. Literally, as that is how files are made.
Too hard for a spring, so take that thing out of the quench and reheat (temper) it to maybe 800F or so. Then it will still be strong, but not so hard as to break in use as a spring.
One may take a piece of low carbon steel and put it into a box surrounded by charcoal, sometimes with other stuff added to speed up the process. Heat it red hot, anywhere from 1500F up to maybe 1750F and carbon will slowly diffuse into the surface. When you quench the thing, the surface becomes file hard but the bulk of the piece, the "core" remains soft and tough. This is done for things like pinion gears and impact wrench parts.
No, one does NOT do this to a gun barrel. Would make it too brittle. As well as distort it from the quenching process.
"Color casehardening" is done to make the thing pretty, with only 0.001 or 0.002" hard case on it. Done to make guns look pretty. Not an industrial thing in recent century or so.
Chemical? I dunno, though it might mean someone dipped the thing in a bath of molten sodium cyanide. When oil quenched gets pretty colors and a very wear resistant case. Gov't doesn't like people doing this now. In the bad old days we just did not mix the cyanide with our lunch, thankee.