Its in both!
The sensors are within the battery and the controlling logic is within the phone. Li-Ion batteries need to be charged with a special charger you can't just plug any power source to the battery.
Here's a basic writeup on what needs to be done: [http://batteryuniversity.com/learn/article/charging_lithium_ion_batteries|Charging Lithium-ion]. As you can see its a bit of work. Here's a sample circuit: [http://homemadecircuitsandschematics.blogspot.com/2012/05/make-this-li-ion-battery-charger.html|Make this Li-Ion Battery Charger Circuit]. The only problem here is you would need to dig a bit deeper to find out if this would work for a iPhone 4s battery, I'm not sure it would.