Prepare #717. Cookie injection and head injection share the same logic.
Implements user interface for #717
Add missing components #717