This function also contains a little bit of logic and a few user facing features:
Disabling the edit page tab on pages that have an entity content model
Disabling the viewsource tab on pages that have an entity content model
Adding a restore tab if:
The user is able to edit the page
AND The page is viewing an old revision
OR the page is partway through the restore flow
AND the revision hasn't been deleted
This is pretty complex and it seems only the edit tab being hidden is covered by an old ruby browser test (edit_tab.feature)
T282544 added a check to make sure that we don't mangle the link list on items that aren't pages with an entity content model and renamed the method.
Testing more than this is hard and probably requires refactoring some of this hook into a standalone class but this is probably worth it; right now with the hook we could step on other people toes if some of our logic turns out to be faulty.