Bug 942270 - Refactor context menu code. r=bnicholson